File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/type/classreading Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 26
26
import org .springframework .core .type .classreading .MetadataReaderFactory ;
27
27
import org .springframework .core .type .classreading .SimpleMetadataReaderFactory ;
28
28
import org .springframework .util .ConcurrentReferenceHashMap ;
29
+ import org .springframework .util .function .ThrowingFunction ;
29
30
30
31
/**
31
32
* Caching implementation of the {@link MetadataReaderFactory} interface backed by a
@@ -70,22 +71,14 @@ public ConcurrentReferenceCachingMetadataReaderFactory(ClassLoader classLoader)
70
71
71
72
@ Override
72
73
public MetadataReader getMetadataReader (String className ) throws IOException {
73
- MetadataReader metadataReader = this .classNameCache .get (className );
74
- if (metadataReader == null ) {
75
- metadataReader = super .getMetadataReader (className );
76
- this .classNameCache .put (className , metadataReader );
77
- }
78
- return metadataReader ;
74
+ return this .classNameCache .computeIfAbsent (className ,
75
+ (ThrowingFunction <String , MetadataReader >) super ::getMetadataReader );
79
76
}
80
77
81
78
@ Override
82
79
public MetadataReader getMetadataReader (Resource resource ) throws IOException {
83
- MetadataReader metadataReader = this .resourceCache .get (resource );
84
- if (metadataReader == null ) {
85
- metadataReader = createMetadataReader (resource );
86
- this .resourceCache .put (resource , metadataReader );
87
- }
88
- return metadataReader ;
80
+ return this .resourceCache .computeIfAbsent (resource ,
81
+ (ThrowingFunction <Resource , MetadataReader >) this ::createMetadataReader );
89
82
}
90
83
91
84
/**
You can’t perform that action at this time.
0 commit comments