This PR is to fix 2 flaky tests com.fasterxml.jackson.jakarta.rs.base.cfg.AnnotationBundleKeyTest#testWithMethodAnnotationEquals and com.fasterxml.jackson.jakarta.rs.base.cfg.AnnotationBundleKeyTest#testWithClassAnnotations in mudule base. We will take one of them as the example in the following description.
Reproduce test failures
Run the following commands to reproduce test failures:
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -pl base -Dtest=com.fasterxml.jackson.jakarta.rs.base.cfg.AnnotationBundleKeyTest#testWithClassAnnotations
Then we will get the following test failures:
AnnotationBundleKeyTest.testWithClassAnnotations:45->_checkWith:89 Internal error: should never differ: arrays first differed at element [0]; expected:<@com.fasterxml.jackson.annotation.JsonIgnoreProperties(value=[], allowGetters=false, allowSetters=false, ignoreUnknown=false)> but was:<@com.fasterxml.jackson.databind.annotation.JsonDeserialize(keyUsing=class com.fasterxml.jackson.databind.KeyDeserializer$None, as=class java.lang.Void, using=class com.fasterxml.jackson.databind.JsonDeserializer$None, contentUsing=class com.fasterxml.jackson.databind.JsonDeserializer$None, keyAs=class java.lang.Void, contentConverter=class com.fasterxml.jackson.databind.util.Converter$None, builder=class java.lang.Void, converter=class com.fasterxml.jackson.databind.util.Converter$None, contentAs=class java.lang.Void)>
Root cause and fix
In these tests, assertions are comparing 2 arrays of Annotation returned by the method getAnnotations(). However, getAnnotations() can not guarantee to return items of the array in the same order, which will lead to test failures. To fix the flakiness, we should sort the arrays in _checkWith before comparing them.
This PR is to fix 2 flaky tests
com.fasterxml.jackson.jakarta.rs.base.cfg.AnnotationBundleKeyTest#testWithMethodAnnotationEquals
andcom.fasterxml.jackson.jakarta.rs.base.cfg.AnnotationBundleKeyTest#testWithClassAnnotations
in mudulebase
. We will take one of them as the example in the following description.Reproduce test failures
Root cause and fix
In these tests, assertions are comparing 2 arrays of
Annotation
returned by the methodgetAnnotations()
. However,getAnnotations()
can not guarantee to return items of the array in the same order, which will lead to test failures. To fix the flakiness, we should sort the arrays in_checkWith
before comparing them.