Test failures in dropwizard-json-logging on JDK21, sometimes
envgap__dropwizard__dropwizard-9971
01 / FAILURE SIGNATURE
As reported upstream
[ERROR] Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.290 s <<< FAILURE! -- in io.dropwizard.logging.json.LayoutIntegrationTests
Not a benchmark task.
- The project already builds and runs before the fix, so there is nothing to repair.
02 / ENVIRONMENT RECIPE
- Base commit
69311f97d17299c350a4c1eeb1a2f58e97363696- Manifest
dropwizard-parent/pom.xml- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
dropwizard/dropwizard #9971 · read the original issue
Looks like on JDK21 when surefire decides to run `io.dropwizard.logging.json.LayoutIntegrationTests` as the first test in the dropwizard-json-logging module, it fails with:
```
[ERROR] Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.290 s <<< FAILURE! -- in io.dropwizard.logging.json.LayoutIntegrationTests
[ERROR] io.dropwizard.logging.json.LayoutIntegrationTests.testLogAccessJsonToConsole -- Time elapsed: 2.698 s <<< ERROR!
com.fasterxml.jackson.core.JsonParseException:
Unrecognized token 'Mockito': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 8]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2584)
at com.fasterxml.jackson.core.JsonParser._constructReadException(JsonParser.java:2610)
at com.fasterxml.jackson.core.JsonParser._constructReadException(JsonParser.java:2618)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:825)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:3017)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:2051)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:780)
at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4960)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3281)
at io.dropwizard.logging.json.LayoutIntegrationTests.testLogAccessJsonToConsole(LayoutIntegrationTests.java:242)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
```
... it appears the captured logging output starts with:
```
Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build as described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.3
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
WARNING: A Java agent has been loaded dynamically (/home/runner/.m2/repository/net/bytebuddy/byte-buddy-agent/1.15.11/byte-buddy-agent-1.15.11.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release
```
is what's causing the failure.
Not sure what the best resolution would be, some options I can think of:
* set up surefire argsList to do the mockito agent thing as documented in [above link](https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3)
* have the test trim everything before the first `{` in the string before trying to parse the json
* ensure some other test runs before the LayoutIntegrationTests to force the log to happen before it gets captured (👎 )
* something else?04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]