Skip to content

Commit ad8f7a4

Browse files
committed
#76 - Fix NPE stemming from bug in replaceAnnotationUsage
1 parent 3594aa8 commit ad8f7a4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/org/hibernate/models/internal/AnnotationTargetSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ default <S extends Annotation, P extends Annotation> MutableAnnotationUsage<P> r
163163
final MutableAnnotationUsage<P> containerTypeUsage = containerType.createUsage( buildingContext );
164164
// effectively overwrites any previous registrations
165165
getUsageMap().put( containerType.getAnnotationType(), containerTypeUsage );
166-
getUsageMap().put( repeatableType.getAnnotationType(), null );
166+
// remove any entry for the repeatable/singular form
167+
getUsageMap().remove( repeatableType.getAnnotationType() );
167168

168169
return containerTypeUsage;
169170
}

src/test/java/org/hibernate/models/annotations/AnnotationReplacementTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void basicReplacementChecks(Index index) {
5757
buildingContext
5858
);
5959

60-
assertThat( classDetails.hasAnnotationUsage( SecondaryTable.class ) ).isTrue();
60+
assertThat( classDetails.hasAnnotationUsage( SecondaryTable.class ) ).isFalse();
6161
assertThat( classDetails.hasAnnotationUsage( SecondaryTables.class ) ).isTrue();
6262

6363
List<MutableAnnotationUsage<SecondaryTable>> valueList = replacement.getList( "value" );
@@ -75,6 +75,9 @@ void basicReplacementChecks(Index index) {
7575

7676
final AnnotationUsage<SecondaryTables> annotationUsage1 = classDetails.getAnnotationUsage( SecondaryTables.class );
7777
assertThat( annotationUsage1.getList( "value" ) ).isSameAs( valueList );
78+
79+
// see #76
80+
classDetails.locateAnnotationUsage( SecondaryTable.class );
7881
}
7982

8083
}

0 commit comments

Comments
 (0)