You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where TestEvent will be one of the many events in the application. The outer object holds meta information and the event property holds event specific data including the event class name.
To deserialize that I use a custom Codec where I just let jackson take care of deserializing the Mongo Document (by using the JsonTypeInfo feature)
classEventCodec(
privatevaldocumentCodec:Codec<Document> = MongoClientSettings.getDefaultCodecRegistry().get(Document::class.java)
) : Codec<Event> {
// .. rest of the class omitted ...overridefundecode(reader:BsonReader?, decoderContext:DecoderContext?): Event {
val document = documentCodec.decode(reader, decoderContext)
return objectMapper.readValue(document.toJson())
}
}
The event class is annoated with JsonTypeInfo and every event inherits this class
@JsonTypeInfo(use =JsonTypeInfo.Id.CLASS, include =JsonTypeInfo.As.PROPERTY, property ="@class")
abstractclassEvent
This works well in production and on first test runs, but when re-running the continuous tests (with gradle quarkusTest and pressing r after all tests ran) it fails with a jackson deserialization error saying that TestEvent is not a subtype of Event
java.util.concurrent.CompletionException: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'org.acme.event_sourcing.TestEvent' as a subtype of `org.acme.event_sourcing.Event`: Not a subtype
at [Source: (String)"{"@class": "org.acme.event_sourcing.TestEvent", "someProperty": "foo"}"; line: 1, column: 12]
Expected behavior
Re-running continuous tests should not fail with a InvalidTypeIdException
Actual behavior
Tests failing with InvalidTypeIdException.
The weird thing is: If I make the test fail on purpose by throwing a random exception in the test code, and then removing that exception, all tests are passing again.
Until re-run 😅
run continuous tests (I use gradle): ./gradlew quarkusTest
all tests are passing
re-run tests by typing r in the console
related tests failing
Output of uname -a or ver
Linux rookian-XPS-13-9300 5.13.0-20-generic #20-Ubuntu SMP Fri Oct 15 14:21:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing)
GraalVM version (if different from Java)
21.3.0 with java 17 (but same issue with java 11)
Quarkus version or git rev
2.3.0-Final
Build tool (ie. output of mvnw --version or gradlew --version)
gradle 7.2
Additional information
kotlin version used: 1.5.21
Just my first idea (but I'm not really familiar with the framework code so don't take it to serious): Could that be a test runner related issue? As far as I know quarkus runs things in different threads and class loaders - maybe jackson does not support that in some way?
The text was updated successfully, but these errors were encountered:
Describe the bug
I am playing around with Kotlin and Event Sourcing and for that I save different Events in a MongoDB collection.
The event document looks something like this
where
TestEvent
will be one of the many events in the application. The outer object holds meta information and the event property holds event specific data including the event class name.To deserialize that I use a custom Codec where I just let jackson take care of deserializing the Mongo Document (by using the
JsonTypeInfo
feature)The event class is annoated with
JsonTypeInfo
and every event inherits this classThis works well in production and on first test runs, but when re-running the continuous tests (with
gradle quarkusTest
and pressing r after all tests ran) it fails with a jackson deserialization error saying thatTestEvent
is not a subtype ofEvent
Expected behavior
Re-running continuous tests should not fail with a
InvalidTypeIdException
Actual behavior
Tests failing with
InvalidTypeIdException
.The weird thing is: If I make the test fail on purpose by throwing a random exception in the test code, and then removing that exception, all tests are passing again.
Until re-run 😅
How to Reproduce?
I created a small reproducer here: https://github.com/pschmidt88/quarkus-reproduce-jackson-subtype-error
./gradlew quarkusTest
r
in the consoleOutput of
uname -a
orver
Linux rookian-XPS-13-9300 5.13.0-20-generic #20-Ubuntu SMP Fri Oct 15 14:21:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing)
GraalVM version (if different from Java)
21.3.0 with java 17 (but same issue with java 11)
Quarkus version or git rev
2.3.0-Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)gradle 7.2
Additional information
kotlin version used: 1.5.21
Just my first idea (but I'm not really familiar with the framework code so don't take it to serious): Could that be a test runner related issue? As far as I know quarkus runs things in different threads and class loaders - maybe jackson does not support that in some way?
The text was updated successfully, but these errors were encountered: