Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnnotationTypeMappings does not filter repeatable annotations #25483

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -91,7 +91,7 @@ private void addMetaAnnotationsToQueue(Deque<AnnotationTypeMapping> queue, Annot
.findRepeatedAnnotations(metaAnnotation);
if (repeatedAnnotations != null) {
for (Annotation repeatedAnnotation : repeatedAnnotations) {
if (!isMappable(source, metaAnnotation)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if that was perhaps a copy-and-paste error and if it should rather be:

if (!isMappable(source, repeatedAnnotation)) {
    continue;
}

@philwebb, what are your thoughts on the matter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philwebb, I'm assuming my above assumption is correct. (I know: a lot of assuming).

In light of that, we'll go forward with the change in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was a typo. A little concerning that no test covered it.

if (!isMappable(source, repeatedAnnotation)) {
continue;
}
addIfPossible(queue, source, repeatedAnnotation);
Expand Down
Expand Up @@ -463,6 +463,14 @@ void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() {
assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class, ReflectionUtils::invokeMethod)).isFalse();
}

@Test
void forAnnotationTypeWhenRepeatableMetaAnnotationIsFiltered() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class,
Repeating.class.getName()::equals);
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
.containsExactly(WithRepeatedMetaAnnotations.class);
}

private Method[] resolveMirrorSets(AnnotationTypeMapping mapping, Class<?> element,
Class<? extends Annotation> annotationClass) {
Annotation annotation = element.getAnnotation(annotationClass);
Expand Down