-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using asSequence.chunked(...) causes native mode to fail #13103
Comments
/cc @evanchooly |
Has anyone had a chance to look at this? :) |
It's a real pain @arturs-cc . I think there needs to be a quarkus kotlin-jackson extension that handles all of these nasties for you. |
I updated reflection-config.json: [
{
"name": "kotlin.reflect.jvm.internal.ReflectionFactoryImpl",
"allDeclaredConstructors":true
},
{
"name": "kotlin.KotlinVersion",
"allPublicMethods": true,
"allDeclaredFields":true,
"allDeclaredMethods":true,
"allDeclaredConstructors":true
},
{
"name": "kotlin.KotlinVersion[]"
},
{
"name": "kotlin.KotlinVersion$Companion"
},
{
"name": "kotlin.KotlinVersion$Companion[]"
}
] resources-config.json: {
"resources": [
{
"pattern": ".*\\.xml$"
},
{
"pattern": ".*\\.json$"
},
{
"pattern": ".*\\.properties$"
},
{"pattern":"META-INF/.*.kotlin_module$"},
{"pattern":"META-INF/services/.*"},
{"pattern":".*.kotlin_builtins"}
]
} and now started receiving the new error:
I don't know why it requires {
"name": "com.example.LambdaRequest[]",
"allPublicMethods": true,
"allDeclaredFields":true,
"allDeclaredMethods":true,
"allDeclaredConstructors":true
} It is ok as a workaround, but I think |
Probably this is a separate issue, but when I explicitly registered
This might be ok for non-nullable fields, but package com.example
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import io.quarkus.runtime.annotations.RegisterForReflection
@RegisterForReflection
data class LambdaRequest @JsonCreator constructor(
@JsonProperty(value = "nullProperty")
val nullProperty: String?,
@JsonProperty(value = "nonNullProperty")
val nonNullProperty: String
) |
Yea this is a pain too. For nullable fields, I've gotten around this by making sure there is a default set for the val. @miron4dev are you on Java 8 or 11? The solution in #3954 does not work for me in Java 8, but I'm trying it now on Java 11 and will report back.
Im using coroutines fine in production apart from the pain of this serialization issue. Vert.x coroutine support is great for IO. |
Also want to raise this one, as it's a real bummer for native and kotlin. We're seeing the same reflection-issues with native and kotlin with coroutines (and tried, as mentioned above, the different configs etc). We've thus had to abandon coroutines for the time being in all of our quarkus-based services and lambdas - as we run almost everything as native builds. Last version we tried it on was 1.9.2.Final with Java 11 and GraalVM 20.2.0. |
fwiw, i can't even recreate the failure. i get this when I run it:
|
@evanchooly how are you trying to reproduce? The error you are showing would indicate to me the lambda container crashing and thus a possible successful recreation. Happy to partner with you on this issue to get a solution. One thought by the way, now that master has support for kotlin 1.4, is to put an interface around serialization in the lambda integration (it's currently hard coded to jackson). Provide a default bean for jackson, but allow users to provide a kotlin serialization implementation. This side steps the whole problem space (Jackson and reflection) by going to a more native solution (kotlin and compile serialization code gen). |
I'm literally cutting and pasting the instructions above. I had initially bumped everything to the latest versions but when I didn't get that error I rolled back to what you've provided and still don't get the error. |
Hm ok this isn't my issue/reproducer but @arturs-cc 's. I'll take a look today to see if I can get that reproducer working. I have this issue on ~10 repos right now on a variety of graal versions, so I know its real. In the meantime - thoughts about supporting kotlin serialization? It seems to align well with quarkus / graal aot goals and eliminates this whole class of reflection issues. |
@evanchooly |
I had a similar problem with the same workaround to solve the problem: use reflect-config.json. If you think this is the same problem and you are interested in reproducing the error, I can upload my BoofCV extension. |
If not I would probably open another issue because this one is the only one I've found related to registration of a "classname[]" class name. |
Is this still an issue? |
Closing for lack of feedback |
Describe the bug
Native mode fails to run when using .
asSequence().chunked(...)
for some reason. Problem doesn't exist when using JVMFirst thing that happens is actually something that has been seen in other issues before:
Similar/Same issue has been seen here (however seemingly not related to this):
oracle/graal#2306
#8479 (comment)
#3954 (comment)
Now if we apply configuration suggested in oracle/graal#2306 we get further.
Suddenly we will need to add classes to reflection that weren't required before.
For example if we have a class
com.example.LambdaRequest
which is already registered for reflection using@RegisterForReflection
it will require to addcom.example.LambdaRequest[]
to reflection config as well. Same goes for all the fields in LambdaRequest.As well as needing their array counterparts added to reflection config it also will require
java.util.Set[]
andjava.util.List[]
to added as well.If we do all of the above we get further.
Now all of a sudden we get this:
Now if we add
java.lang.Enum
to reflection-config as well (which is quite bizarre in my opinion) we get furtherAt this point application starts up fine. But now jackson doesn't recognise the difference between nullable and non nullable fields in kotlin any more. So even if field is nullable. Adding
required = false
doesn't help, assigning default values doesn't help and nothing else seems to work either which suggests to me that the issue lies deeper.At this point it looks to me that the root issue is behind the first error.
Reproducer:
https://github.com/arturs-cc/quarkus-native-kotlin-chunked-issue
Environment (please complete the following information):
uname -a
orver
: Darwin localhost 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64java -version
: openjdk version "11.0.3" 2019-04-16OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
mvnw --version
orgradlew --version
):Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 14.0.1, vendor: N/A, runtime: /usr/local/Cellar/openjdk/14.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.6", arch: "x86_64", family: "mac"
Happy to answer any questions or provide more information!
The text was updated successfully, but these errors were encountered: