Copilot commented on code in PR #1810:
URL: https://github.com/apache/commons-lang/pull/1810#discussion_r4229628552
##########
src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java:
##########
@@ -421,6 +467,15 @@ void testEquivalence() {
assertTrue(AnnotationUtils.equals(field2.getAnnotation(TestAnnotation.class),
field1.getAnnotation(TestAnnotation.class)));
}
+ @Test
+ void testEquivalenceWithoutInvokingSupplier() {
+ final ThrowingSupplierAnnotation first =
AnnotatedClass.class.getAnnotation(ThrowingSupplierAnnotation.class);
+ final ThrowingSupplierAnnotation second =
EquivalentAnnotatedClass.class.getAnnotation(ThrowingSupplierAnnotation.class);
+
+ assertNotSame(first, second);
+ assertTrue(AnnotationUtils.equals(first, second));
Review Comment:
`assertNotSame(first, second)` makes the test depend on annotation instance
identity, which is not something the Java reflection/annotation APIs guarantee
across different annotated elements. This assertion is not required to validate
the regression (synthetic methods not being invoked) and could make the test
flaky on JVMs that aggressively cache/reuse annotation proxies. Suggest
removing the identity assertion and keeping the behavioral equality assertion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]