Skip to content

regression in 20.0 on LambdaFetchingSupport , Kotlin data class, Spring boot #3121

Closed

Description

@ntf

I am trying to upgrade the library from 18.0 to 20.0 today and found below regression.

Describe the bug
The LadmbdaFetchingSupport has a regression that causeS this error:

java.lang.ClassCastException: part.to.namespace.Xxx incompatible with part.to.namespace.Xxx
	at graphql.schema.PropertyFetchingImpl.getPropertyValue(PropertyFetchingImpl.java:76) ~[graphql-java-20.0.jar:na]
	at graphql.schema.PropertyDataFetcherHelper.getPropertyValue(PropertyDataFetcherHelper.java:22) ~[graphql-java-20.0.jar:na]
	at graphql.schema.PropertyDataFetcher.getImpl(PropertyDataFetcher.java:131) ~[graphql-java-20.0.jar:na]

To Reproduce
Environment: Java 17, Kotlin 1.8.0,
last known good library version: 19.3

// This works
object.getClass().getDeclaredMethods()[0].invoke(object)
// This doesn't work
LambdaFetchingSupport.createGetter(object.getClass(), "id").get().apply(object)

I wasn't able to re-produce the error with the exact same class in Junit environement.
Two different things maybe related when I check the object.getClass()

In Junit, the class loader is ClassLoaders$AppClassLoader
In application , it is RestartClassLoader from Spring.

// This work
ProtectionDomain  (file:/C:/dev/asterisk/app/build/classes/kotlin/main/ <no signer certificates>)
 jdk.internal.loader.ClassLoaders$AppClassLoader@2089d901
 <no principals>
 java.security.Permissions@fe1776a3 (
 ("java.io.FilePermission" "C:\dev\asterisk\app\build\classes\kotlin\main\-" "read")
 ("java.lang.RuntimePermission" "exitVM")
)
// This doesn't work
ProtectionDomain  (file:/C:/dev/asterisk/app/build/classes/kotlin/main/ <no signer certificates>)
 org.springframework.boot.devtools.restart.classloader.RestartClassLoader@d8afcbba
 <no principals>
 java.security.Permissions@f41df67b (
 ("java.net.SocketPermission" "localhost:0" "listen,resolve")
 ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.beans.*")
 ("java.lang.RuntimePermission" "accessClassInPackage.com.apple.*")
 ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.java.swing.plaf.*")
 ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.beans")
 ("java.util.PropertyPermission" "java.specification.version" "read")
 ("java.util.PropertyPermission" "java.vm.vendor" "read")
 ("java.util.PropertyPermission" "path.separator" "read")
 ("java.util.PropertyPermission" "os.version" "read")
 ("java.util.PropertyPermission" "java.vendor.url" "read")
 ("java.util.PropertyPermission" "java.vm.name" "read")
 ("java.util.PropertyPermission" "java.vm.specification.version" "read")
 ("java.util.PropertyPermission" "os.name" "read")
 ("java.util.PropertyPermission" "java.version" "read")
 ("java.util.PropertyPermission" "os.arch" "read")
 ("java.util.PropertyPermission" "java.specification.vendor" "read")
 ("java.util.PropertyPermission" "java.vm.specification.name" "read")
 ("java.util.PropertyPermission" "file.separator" "read")
 ("java.util.PropertyPermission" "line.separator" "read")
 ("java.util.PropertyPermission" "java.vm.specification.vendor" "read")
 ("java.util.PropertyPermission" "java.specification.name" "read")
 ("java.util.PropertyPermission" "java.vendor" "read")
 ("java.util.PropertyPermission" "java.vm.version" "read")
 ("java.util.PropertyPermission" "java.class.version" "read")
 ("java.io.FilePermission" "C:\dev\asterisk\app\build\classes\kotlin\main\-" "read")
 ("java.io.FilePermission" "C:\dev\asterisk\app\build\classes\kotlin\main\-#plus" "read")
)

Activity

  1. bclozel commented on Mar 16, 2023

    @bclozel

    I believe this can be closed as a duplicate of spring-projects/spring-graphql#629 - we're still investigating on the Spring side, as it's likely linked to the devtools restart classloader support.

  2. ntf commented on Mar 17, 2023

    @ntf
    Author

    Got it, I didn't use spring-graphql but agree that it maybe related to the class loader

  3. bbakerman commented on Mar 18, 2023

    @bbakerman
    Member

    This is related to classloaders.

    This issue #3086 has all the details including the work to use graphql.schema.PropertyDataFetcherHelper#setUseLambdaFactory which statically turns it off for the JVM (static boolean). for now until we can get a fix out.

    I am going to close this as a duplicate since this is the same issue. That is when multiple class loaders are in place the LambdaMetadataFactory cant call it.

    (Java 9 has a fix but we cant get onto this quite yet - This is the fix for now #3095 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions