Skip to content

Commit ee075a5

Browse files
committed
WIP
1 parent 84c950d commit ee075a5

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationExcludeFilter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.core.type.classreading.MetadataReader;
2828
import org.springframework.core.type.classreading.MetadataReaderFactory;
2929
import org.springframework.core.type.filter.TypeFilter;
30-
import org.springframework.util.Assert;
3130

3231
/**
3332
* A {@link TypeFilter} implementation that matches registered auto-configuration classes.
@@ -66,12 +65,13 @@ private boolean isAutoConfiguration(MetadataReader metadataReader) {
6665
}
6766

6867
protected List<String> getAutoConfigurations() {
69-
if (this.autoConfigurations == null) {
68+
List<String> autoConfigurations = this.autoConfigurations;
69+
if (autoConfigurations == null) {
7070
ImportCandidates importCandidates = ImportCandidates.load(AutoConfiguration.class, this.beanClassLoader);
71-
this.autoConfigurations = importCandidates.getCandidates();
71+
autoConfigurations = importCandidates.getCandidates();
72+
this.autoConfigurations = autoConfigurations;
7273
}
73-
Assert.state(this.autoConfigurations != null, "'autoConfigurations' must not be null");
74-
return this.autoConfigurations;
74+
return autoConfigurations;
7575
}
7676

7777
}

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,21 @@ boolean isAvailable() {
202202
}
203203

204204
Set<String> getBefore() {
205-
if (this.before == null) {
206-
this.before = getClassNames("AutoConfigureBefore", AutoConfigureBefore.class);
205+
Set<String> before = this.before;
206+
if (before == null) {
207+
before = getClassNames("AutoConfigureBefore", AutoConfigureBefore.class);
208+
this.before = before;
207209
}
208-
return this.before;
210+
return before;
209211
}
210212

211213
Set<String> getAfter() {
212-
if (this.after == null) {
213-
this.after = getClassNames("AutoConfigureAfter", AutoConfigureAfter.class);
214+
Set<String> after = this.after;
215+
if (after == null) {
216+
after = getClassNames("AutoConfigureAfter", AutoConfigureAfter.class);
217+
this.after = after;
214218
}
215-
return this.after;
219+
return after;
216220
}
217221

218222
private Set<String> getClassNames(String metadataKey, Class<? extends Annotation> annotation) {
@@ -244,7 +248,12 @@ private int getOrder() {
244248
}
245249
Map<String, @Nullable Object> attributes = getAnnotationMetadata()
246250
.getAnnotationAttributes(AutoConfigureOrder.class.getName());
247-
return (attributes != null) ? (Integer) attributes.get("value") : AutoConfigureOrder.DEFAULT_ORDER;
251+
if (attributes != null) {
252+
Integer value = (Integer) attributes.get("value");
253+
Assert.state(value != null, "'value' must not be null");
254+
return value;
255+
}
256+
return AutoConfigureOrder.DEFAULT_ORDER;
248257
}
249258

250259
private boolean wasProcessed() {
@@ -258,23 +267,29 @@ private Set<String> getAnnotationValue(Class<?> annotation) {
258267
if (attributes == null) {
259268
return Collections.emptySet();
260269
}
261-
Set<String> value = new LinkedHashSet<>();
262-
Collections.addAll(value, (String[]) attributes.get("value"));
263-
Collections.addAll(value, (String[]) attributes.get("name"));
264-
return value;
270+
Set<String> result = new LinkedHashSet<>();
271+
String[] value = (String[]) attributes.get("value");
272+
String[] name = (String[]) attributes.get("name");
273+
Assert.state(value != null, "'value' must not be null");
274+
Assert.state(name != null, "'name' must not be null");
275+
Collections.addAll(result, value);
276+
Collections.addAll(result, name);
277+
return result;
265278
}
266279

267280
private AnnotationMetadata getAnnotationMetadata() {
268-
if (this.annotationMetadata == null) {
281+
AnnotationMetadata annotationMetadata = this.annotationMetadata;
282+
if (annotationMetadata == null) {
269283
try {
270284
MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(this.className);
271-
this.annotationMetadata = metadataReader.getAnnotationMetadata();
285+
annotationMetadata = metadataReader.getAnnotationMetadata();
286+
this.annotationMetadata = annotationMetadata;
272287
}
273288
catch (IOException ex) {
274289
throw new IllegalStateException("Unable to read meta-data for class " + this.className, ex);
275290
}
276291
}
277-
return this.annotationMetadata;
292+
return annotationMetadata;
278293
}
279294

280295
}

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/FilteringSpringBootCondition.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ public boolean[] match(@Nullable String[] autoConfigurationClasses,
5555
@Nullable ConditionOutcome[] outcomes = getOutcomes(autoConfigurationClasses, autoConfigurationMetadata);
5656
boolean[] match = new boolean[outcomes.length];
5757
for (int i = 0; i < outcomes.length; i++) {
58-
match[i] = (outcomes[i] == null || outcomes[i].isMatch());
59-
if (!match[i] && outcomes[i] != null) {
58+
ConditionOutcome outcome = outcomes[i];
59+
match[i] = (outcome == null || outcome.isMatch());
60+
if (!match[i] && outcome != null) {
6061
String autoConfigurationClass = autoConfigurationClasses[i];
6162
Assert.state(autoConfigurationClass != null, "'autoConfigurationClass' must not be null");
62-
logOutcome(autoConfigurationClass, outcomes[i]);
63+
logOutcome(autoConfigurationClass, outcome);
6364
if (report != null) {
64-
report.recordConditionEvaluation(autoConfigurationClass, this, outcomes[i]);
65+
report.recordConditionEvaluation(autoConfigurationClass, this, outcome);
6566
}
6667
}
6768
}

0 commit comments

Comments
 (0)