I'm using assertj-core:3.21.0 and JDK 17
Here is an simple example that fails. This works in JDK 16 and assertj-core:3.19.0.
@AllArgsConstructor
@Data
class Test {
@JsonIgnore
private final ObjectMapper objectMapper = new ObjectMapper();
private String name;
}
Assertions.assertThat(Map.of(
1, new Test("a"),
2, new Test("b")
)).usingRecursiveComparison().ignoringFields("objectMapper").isEqualTo(Map.of(
1, new Test("a"),
2, new Test("b")
));
The error I'm getting is
java.lang.reflect.InaccessibleObjectException: Unable to make field private volatile java.lang.Object java.util.concurrent.atomic.AtomicReference.value accessible: module java.base does not "opens java.util.concurrent.atomic" to unnamed module @48140564
I found if I remove private final ObjectMapper objectMapper = new ObjectMapper();
from the class it will work, so looks like ignoringFields
did not ignore objectMapper
properly.
Any idea?