Skip to content

Commit 6bb2310

Browse files
committed
#1155 - Fixed thread-safety issues in AnnotationLinkRelationProvider.
We now use a ConcurrentReferenceHashMap to cache annotation lookups in AnnotationLinkRelationProvider to avoid thread-safety issues.
1 parent a2290c6 commit 6bb2310

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/springframework/hateoas/server/core/AnnotationLinkRelationProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.hateoas.server.core;
1717

18-
import java.util.HashMap;
1918
import java.util.Map;
2019

2120
import org.springframework.core.Ordered;
@@ -24,6 +23,7 @@
2423
import org.springframework.hateoas.server.LinkRelationProvider;
2524
import org.springframework.lang.Nullable;
2625
import org.springframework.util.Assert;
26+
import org.springframework.util.ConcurrentReferenceHashMap;
2727

2828
/**
2929
* {@link LinkRelationProvider} that evaluates the {@link Relation} annotation on entity types.
@@ -34,7 +34,7 @@
3434
*/
3535
public class AnnotationLinkRelationProvider implements LinkRelationProvider, Ordered {
3636

37-
private final Map<Class<?>, Relation> annotationCache = new HashMap<>();
37+
private final Map<Class<?>, Relation> annotationCache = new ConcurrentReferenceHashMap<>(128);
3838

3939
/*
4040
* (non-Javadoc)

0 commit comments

Comments
 (0)