Skip to content

Commit e1f9507

Browse files
committed
Minor internal refinements (backported from master)
1 parent 9cad930 commit e1f9507

File tree

8 files changed

+49
-47
lines changed

8 files changed

+49
-47
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ else if (!this.allowRawInjectionDespiteWrapping && hasDependentBean(beanName)) {
605605
@Override
606606
protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
607607
Class<?> targetType = determineTargetType(beanName, mbd, typesToMatch);
608-
609608
// Apply SmartInstantiationAwareBeanPostProcessors to predict the
610609
// eventual type after a before-instantiation shortcut.
611610
if (targetType != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
@@ -1221,43 +1220,33 @@ protected void populateBean(String beanName, RootBeanDefinition mbd, BeanWrapper
12211220
// Give any InstantiationAwareBeanPostProcessors the opportunity to modify the
12221221
// state of the bean before properties are set. This can be used, for example,
12231222
// to support styles of field injection.
1224-
boolean continueWithPropertyPopulation = true;
1225-
12261223
if (!mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
12271224
for (BeanPostProcessor bp : getBeanPostProcessors()) {
12281225
if (bp instanceof InstantiationAwareBeanPostProcessor) {
12291226
InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
12301227
if (!ibp.postProcessAfterInstantiation(bw.getWrappedInstance(), beanName)) {
1231-
continueWithPropertyPopulation = false;
1232-
break;
1228+
return;
12331229
}
12341230
}
12351231
}
12361232
}
12371233

1238-
if (!continueWithPropertyPopulation) {
1239-
return;
1240-
}
1241-
1242-
if (mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_BY_NAME ||
1243-
mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_BY_TYPE) {
1234+
int resolvedAutowireMode = mbd.getResolvedAutowireMode();
1235+
if (resolvedAutowireMode == AUTOWIRE_BY_NAME || resolvedAutowireMode == AUTOWIRE_BY_TYPE) {
12441236
MutablePropertyValues newPvs = new MutablePropertyValues(pvs);
1245-
12461237
// Add property values based on autowire by name if applicable.
1247-
if (mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_BY_NAME) {
1238+
if (resolvedAutowireMode == AUTOWIRE_BY_NAME) {
12481239
autowireByName(beanName, mbd, bw, newPvs);
12491240
}
1250-
12511241
// Add property values based on autowire by type if applicable.
1252-
if (mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_BY_TYPE) {
1242+
if (resolvedAutowireMode == AUTOWIRE_BY_TYPE) {
12531243
autowireByType(beanName, mbd, bw, newPvs);
12541244
}
1255-
12561245
pvs = newPvs;
12571246
}
12581247

12591248
boolean hasInstAwareBpps = hasInstantiationAwareBeanPostProcessors();
1260-
boolean needsDepCheck = (mbd.getDependencyCheck() != RootBeanDefinition.DEPENDENCY_CHECK_NONE);
1249+
boolean needsDepCheck = (mbd.getDependencyCheck() != AbstractBeanDefinition.DEPENDENCY_CHECK_NONE);
12611250

12621251
if (hasInstAwareBpps || needsDepCheck) {
12631252
PropertyDescriptor[] filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);

spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -237,6 +237,7 @@ protected PropertiesHolder getMergedProperties(Locale locale) {
237237
if (mergedHolder != null) {
238238
return mergedHolder;
239239
}
240+
240241
Properties mergedProps = newProperties();
241242
long latestTimestamp = -1;
242243
String[] basenames = StringUtils.toStringArray(getBasenameSet());
@@ -253,6 +254,7 @@ protected PropertiesHolder getMergedProperties(Locale locale) {
253254
}
254255
}
255256
}
257+
256258
mergedHolder = new PropertiesHolder(mergedProps, latestTimestamp);
257259
PropertiesHolder existing = this.cachedMergedProperties.putIfAbsent(locale, mergedHolder);
258260
if (existing != null) {
@@ -279,18 +281,28 @@ protected List<String> calculateAllFilenames(String basename, Locale locale) {
279281
return filenames;
280282
}
281283
}
284+
285+
// Filenames for given Locale
282286
List<String> filenames = new ArrayList<String>(7);
283287
filenames.addAll(calculateFilenamesForLocale(basename, locale));
284-
if (isFallbackToSystemLocale() && !locale.equals(Locale.getDefault())) {
285-
List<String> fallbackFilenames = calculateFilenamesForLocale(basename, Locale.getDefault());
286-
for (String fallbackFilename : fallbackFilenames) {
287-
if (!filenames.contains(fallbackFilename)) {
288-
// Entry for fallback locale that isn't already in filenames list.
289-
filenames.add(fallbackFilename);
288+
289+
// Filenames for default Locale, if any
290+
if (isFallbackToSystemLocale()) {
291+
Locale defaultLocale = Locale.getDefault();
292+
if (!locale.equals(defaultLocale)) {
293+
List<String> fallbackFilenames = calculateFilenamesForLocale(basename, defaultLocale);
294+
for (String fallbackFilename : fallbackFilenames) {
295+
if (!filenames.contains(fallbackFilename)) {
296+
// Entry for fallback locale that isn't already in filenames list.
297+
filenames.add(fallbackFilename);
298+
}
290299
}
291300
}
292301
}
302+
303+
// Filename for default bundle file
293304
filenames.add(basename);
305+
294306
if (localeMap == null) {
295307
localeMap = new ConcurrentHashMap<Locale, List<String>>();
296308
Map<Locale, List<String>> existing = this.cachedFilenames.putIfAbsent(basename, localeMap);

spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -782,6 +782,7 @@ public void handleIt(TestEvent event) {
782782

783783
@EventListener
784784
@Async
785+
@Override
785786
public void handleAsync(AnotherTestEvent event) {
786787
assertTrue(!Thread.currentThread().getName().equals(event.content));
787788
this.eventCollector.addEvent(this, event);
@@ -808,6 +809,7 @@ public void handleIt(TestEvent event) {
808809

809810
@EventListener
810811
@Async
812+
@Override
811813
public void handleAsync(AnotherTestEvent event) {
812814
assertTrue(!Thread.currentThread().getName().equals(event.content));
813815
this.eventCollector.addEvent(this, event);
@@ -890,7 +892,6 @@ public void handleString(GenericEventPojo<String> value) {
890892
}
891893

892894

893-
894895
@EventListener
895896
@Retention(RetentionPolicy.RUNTIME)
896897
public @interface ConditionalEvent {
@@ -922,18 +923,20 @@ public void handle(TestEvent event) {
922923
super.handle(event);
923924
}
924925

925-
@Override
926926
@EventListener(condition = "#payload.startsWith('OK')")
927+
@Override
927928
public void handleString(String payload) {
928929
super.handleString(payload);
929930
}
930931

931932
@ConditionalEvent("#root.event.timestamp > #p0")
933+
@Override
932934
public void handleTimestamp(Long timestamp) {
933935
collectEvent(timestamp);
934936
}
935937

936938
@ConditionalEvent("@conditionEvaluator.valid(#p0)")
939+
@Override
937940
public void handleRatio(Double ratio) {
938941
collectEvent(ratio);
939942
}

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,11 +26,10 @@
2626
import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig;
2727
import org.springframework.web.socket.sockjs.transport.SockJsSession;
2828
import org.springframework.web.socket.sockjs.transport.TransportType;
29-
import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession;
3029
import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession;
3130

3231
/**
33-
* A TransportHandler for sending messages via Server-Sent events:
32+
* A TransportHandler for sending messages via Server-Sent Events:
3433
* <a href="https://dev.w3.org/html5/eventsource/">https://dev.w3.org/html5/eventsource/</a>.
3534
*
3635
* @author Rossen Stoyanchev
@@ -50,7 +49,7 @@ protected MediaType getContentType() {
5049

5150
@Override
5251
public boolean checkSessionType(SockJsSession session) {
53-
return session instanceof EventSourceStreamingSockJsSession;
52+
return (session instanceof EventSourceStreamingSockJsSession);
5453
}
5554

5655
@Override
@@ -66,7 +65,7 @@ protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) {
6665
}
6766

6867

69-
private class EventSourceStreamingSockJsSession extends StreamingSockJsSession {
68+
private static class EventSourceStreamingSockJsSession extends StreamingSockJsSession {
7069

7170
public EventSourceStreamingSockJsSession(String sessionId, SockJsServiceConfig config,
7271
WebSocketHandler wsHandler, Map<String, Object> attributes) {
@@ -76,7 +75,7 @@ public EventSourceStreamingSockJsSession(String sessionId, SockJsServiceConfig c
7675

7776
@Override
7877
protected byte[] getPrelude(ServerHttpRequest request) {
79-
return new byte[] { '\r', '\n' };
78+
return new byte[] {'\r', '\n'};
8079
}
8180
}
8281

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,14 +35,15 @@
3535
import org.springframework.web.socket.sockjs.transport.TransportHandler;
3636
import org.springframework.web.socket.sockjs.transport.TransportType;
3737
import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession;
38-
import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession;
3938
import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession;
4039
import org.springframework.web.util.JavaScriptUtils;
4140

4241
/**
43-
* An HTTP {@link TransportHandler} that uses a famous browser document.domain technique:
44-
* <a href="https://stackoverflow.com/questions/1481251/what-does-document-domain-document-domain-do">
45-
* https://stackoverflow.com/questions/1481251/what-does-document-domain-document-domain-do</a>
42+
* An HTTP {@link TransportHandler} that uses a famous browser
43+
* {@code document.domain technique}. See <a href=
44+
* "https://stackoverflow.com/questions/1481251/what-does-document-domain-document-domain-do">
45+
* stackoverflow.com/questions/1481251/what-does-document-domain-document-domain-do</a>
46+
* for details.
4647
*
4748
* @author Rossen Stoyanchev
4849
* @since 4.0
@@ -91,7 +92,7 @@ protected MediaType getContentType() {
9192

9293
@Override
9394
public boolean checkSessionType(SockJsSession session) {
94-
return session instanceof HtmlFileStreamingSockJsSession;
95+
return (session instanceof HtmlFileStreamingSockJsSession);
9596
}
9697

9798
@Override

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ public boolean isRunning() {
106106

107107
@Override
108108
public boolean checkSessionType(SockJsSession session) {
109-
return session instanceof WebSocketServerSockJsSession;
109+
return (session instanceof WebSocketServerSockJsSession);
110110
}
111111

112112
@Override

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626
import org.springframework.web.socket.sockjs.transport.SockJsSession;
2727
import org.springframework.web.socket.sockjs.transport.TransportHandler;
2828
import org.springframework.web.socket.sockjs.transport.TransportType;
29-
import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession;
3029
import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession;
3130

3231
/**
@@ -54,7 +53,7 @@ protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) {
5453

5554
@Override
5655
public boolean checkSessionType(SockJsSession session) {
57-
return session instanceof PollingSockJsSession;
56+
return (session instanceof PollingSockJsSession);
5857
}
5958

6059
@Override

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
2727
import org.springframework.web.socket.sockjs.transport.SockJsSession;
2828
import org.springframework.web.socket.sockjs.transport.TransportHandler;
2929
import org.springframework.web.socket.sockjs.transport.TransportType;
30-
import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession;
3130
import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession;
3231

3332
/**
@@ -60,7 +59,7 @@ protected MediaType getContentType() {
6059

6160
@Override
6261
public boolean checkSessionType(SockJsSession session) {
63-
return session instanceof XhrStreamingSockJsSession;
62+
return (session instanceof XhrStreamingSockJsSession);
6463
}
6564

6665
@Override

0 commit comments

Comments
 (0)