Skip to content

Commit 93ad7f8

Browse files
committed
Polishing
1 parent 54ba5c5 commit 93ad7f8

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,14 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi
242242

243243
// Process any @ComponentScan annotations
244244
AnnotationAttributes componentScan = AnnotationConfigUtils.attributesFor(sourceClass.getMetadata(), ComponentScan.class);
245-
if (componentScan != null) {
246-
// the config class is annotated with @ComponentScan -> perform the scan immediately
247-
if (!this.conditionEvaluator.shouldSkip(sourceClass.getMetadata(), ConfigurationPhase.REGISTER_BEAN)) {
248-
Set<BeanDefinitionHolder> scannedBeanDefinitions =
249-
this.componentScanParser.parse(componentScan, sourceClass.getMetadata().getClassName());
250-
251-
// check the set of scanned definitions for any further config classes and parse recursively if necessary
252-
for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
253-
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
254-
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
255-
}
245+
if (componentScan != null && !this.conditionEvaluator.shouldSkip(sourceClass.getMetadata(), ConfigurationPhase.REGISTER_BEAN)) {
246+
// The config class is annotated with @ComponentScan -> perform the scan immediately
247+
Set<BeanDefinitionHolder> scannedBeanDefinitions =
248+
this.componentScanParser.parse(componentScan, sourceClass.getMetadata().getClassName());
249+
// Check the set of scanned definitions for any further config classes and parse recursively if necessary
250+
for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
251+
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
252+
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
256253
}
257254
}
258255
}
@@ -292,7 +289,7 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi
292289
}
293290
}
294291

295-
// No superclass, processing is complete
292+
// No superclass -> processing is complete
296293
return null;
297294
}
298295

spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ public MessageHeaders(Map<String, Object> headers) {
107107

108108

109109
public UUID getId() {
110-
return this.get(ID, UUID.class);
110+
return get(ID, UUID.class);
111111
}
112112

113113
public Long getTimestamp() {
114-
return this.get(TIMESTAMP, Long.class);
114+
return get(TIMESTAMP, Long.class);
115115
}
116116

117117
public Object getReplyChannel() {
118-
return this.get(REPLY_CHANNEL);
118+
return get(REPLY_CHANNEL);
119119
}
120120

121121
public Object getErrorChannel() {
122-
return this.get(ERROR_CHANNEL);
122+
return get(ERROR_CHANNEL);
123123
}
124124

125125
@SuppressWarnings("unchecked")
@@ -156,7 +156,7 @@ public String toString() {
156156
}
157157

158158

159-
// Map implementation
159+
// Delegating Map implementation
160160

161161
public boolean containsKey(Object key) {
162162
return this.headers.containsKey(key);

spring-messaging/src/main/java/org/springframework/messaging/support/GenericMessage.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,21 @@ public MessageHeaders getHeaders() {
7171
}
7272

7373

74-
public boolean equals(Object obj) {
75-
if (this == obj) {
74+
public boolean equals(Object other) {
75+
if (this == other) {
7676
return true;
7777
}
78-
if (obj != null && obj instanceof GenericMessage<?>) {
79-
GenericMessage<?> other = (GenericMessage<?>) obj;
80-
return (ObjectUtils.nullSafeEquals(this.headers.getId(), other.headers.getId()) &&
81-
this.headers.equals(other.headers) && this.payload.equals(other.payload));
78+
if (!(other instanceof GenericMessage)) {
79+
return false;
8280
}
83-
return false;
81+
GenericMessage<?> otherMsg = (GenericMessage<?>) other;
82+
// Using nullSafeEquals for proper array equals comparisons
83+
return (ObjectUtils.nullSafeEquals(this.payload, otherMsg.payload) && this.headers.equals(otherMsg.headers));
8484
}
8585

8686
public int hashCode() {
87-
return (this.headers.hashCode() * 23 + ObjectUtils.nullSafeHashCode(this.payload));
87+
// Using nullSafeHashCode for proper array hashCode handling
88+
return (ObjectUtils.nullSafeHashCode(this.payload) * 23 + this.headers.hashCode());
8889
}
8990

9091
public String toString() {

0 commit comments

Comments
 (0)