-
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
A @QuarkusTest with a ParameterResolver that return a java record, throws an exception #15892
Comments
Thanks for reporting this. Upstream issue: x-stream/xstream#210
Do you have something concrete in mind? @geoand WDYT? XStream 1.5 is still far away, AFAICS. |
We could try and replace xstream with java serialization and see how far that would get us. |
This would require |
Maybe it could be engaged if the class is serializable? |
Yeah, why not! I don't see why someone would want xstream serialization when the class in question declares to be java serialization compatible. |
with this code it seems to works.
The class XStreamDeepClone seems to have everything we you need, it has the classloader and the object to copy. I don t think forcing people to use the Serializable interface for all their records it's the best idea. this is a quote from Mark Reinhold:
edit: i think that the class
|
@mmaggioni-wise Thanks a lot! Btw, pull requests are more than welcome! 😉 @geoand I've been thinking we could introduce Apache Johnzon, use that primarily, but fall back to XStream in case of errors together with logging a warning, asking the user to report the respective exception. |
Yeah, we can do certainly try that - there might be a problem though... |
I did some other test, the problem with johnzon is that it require the class to have setters, a default constructor, and it doesn't work very well with collections. I tried with Gson and Jackson but they do not support records yet. It seems that in xstream something is moving. I guess that records are very new, so it will take some time to libraries to upgrade. |
After all that new info I'd say we should add java serialization support as a short term remedy and keep track of what is happening upstream. |
We should look at adding some hooks into JUnit so we no longer require this copying. |
That would definitely be the best thing to do |
Subscribed |
+💯 for the junit enhancement, but until that is available? |
Update: With #16302 now merged, Quarkus 2.0 will try plain java serialization first, falling back to XStream on error. Unless that JUnit hook or XStream 1.5 becomes available before Quarkus 2.0 is released, you will need to have your records implement |
Let's keep it open for now |
Hey folks! Just wanted to see if there has been any movement on this? I'm still experiencing this with Quarkus 3.5.0. I don't want to have my records implement |
Same issue as @edeandrea here, as I don't need my records to be serializable. Testing right now with quarkus platform 3.10.0; test running properly without |
I am testing a change which uses JBoss Marshalling's object cloner instead of XStream and serialization. I'm not 100% sure it's going to work but so far it looks good (and maybe faster as well). If it does work, then it should be able to transport records correctly, and other classes regardless of whether they are |
I am 100% sure it's better than what we have now :). I'm actually ashamed of myself for not thinking of JBoss Marshalling... |
Remove usage of xstream or serialization for cloning, and use the JBoss Marshalling cloner instead. Fixes quarkusio#15892.
Any reason that this was reverted in 3.12.*? Should this be re-open? |
The fix is already in main and should be part of 3.13 |
Remove usage of xstream or serialization for cloning, and use the JBoss Marshalling cloner instead. Fixes quarkusio#15892.
Describe the bug
During a QuarkuTest, when using a junit "ParameterResolver" that return a java record with at least one field, xstream return this error:
The problem in quarkus is at
io.quarkus.test.junit.internal.XStreamDeepClone.doClone(XStreamDeepClone.java:49)
As far as I understand, this class use xstream to just create a copy of the object (the java record) in the Quarkus ClassLoader.
If it's the only usage, i think we can use another library that support records (and maybe use json instead of XML).
what do you think?
The cause is:
To Reproduce
It's very simple.
1- Create a Java record, with at least one field
record TestRecord(String test)
2- Create a ParameterResolver that return the record
new TestRecord("my test")
3- Create a quarkus test that use that ParameterResolver
eg:
Environment:
Output of
uname -a
orver
Darwin MacBookPro.lan 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
Output of
java -version
openjdk 16 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)
Quarkus version or git rev
Quarkus 1.12.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Maven 3.6.3
Additional context
I reproduced it in a new empty project.
I can post it, if need, but it's super simple.
This occurs from java 15, for this reason
https://mail.openjdk.java.net/pipermail/amber-dev/2020-June/006241.html
https://medium.com/@atdsqdjyfkyziqkezu/java-15-breaks-deserialization-of-records-902fcc81253d
Complete stacktrace.txt
The text was updated successfully, but these errors were encountered: