Skip to content

Commit 55418b2

Browse files
committed
Merge branch '5.1.x'
2 parents 0016f58 + e5e2d2d commit 55418b2

File tree

28 files changed

+189
-201
lines changed

28 files changed

+189
-201
lines changed

spring-context/src/main/java/org/springframework/jndi/support/SimpleJndiBeanFactory.java

Lines changed: 10 additions & 13 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.
@@ -254,13 +254,12 @@ public String[] getAliases(String name) {
254254
@SuppressWarnings("unchecked")
255255
private <T> T doGetSingleton(String name, @Nullable Class<T> requiredType) throws NamingException {
256256
synchronized (this.singletonObjects) {
257-
if (this.singletonObjects.containsKey(name)) {
258-
Object jndiObject = this.singletonObjects.get(name);
259-
if (requiredType != null && !requiredType.isInstance(jndiObject)) {
260-
throw new TypeMismatchNamingException(
261-
convertJndiName(name), requiredType, (jndiObject != null ? jndiObject.getClass() : null));
257+
Object singleton = this.singletonObjects.get(name);
258+
if (singleton != null) {
259+
if (requiredType != null && !requiredType.isInstance(singleton)) {
260+
throw new TypeMismatchNamingException(convertJndiName(name), requiredType, singleton.getClass());
262261
}
263-
return (T) jndiObject;
262+
return (T) singleton;
264263
}
265264
T jndiObject = lookup(name, requiredType);
266265
this.singletonObjects.put(name, jndiObject);
@@ -274,14 +273,12 @@ private Class<?> doGetType(String name) throws NamingException {
274273
}
275274
else {
276275
synchronized (this.resourceTypes) {
277-
if (this.resourceTypes.containsKey(name)) {
278-
return this.resourceTypes.get(name);
279-
}
280-
else {
281-
Class<?> type = lookup(name, null).getClass();
276+
Class<?> type = this.resourceTypes.get(name);
277+
if (type == null) {
278+
type = lookup(name, null).getClass();
282279
this.resourceTypes.put(name, type);
283-
return type;
284280
}
281+
return type;
285282
}
286283
}
287284
}

spring-core/src/main/java/org/springframework/core/Conventions.java

Lines changed: 9 additions & 15 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.
@@ -118,13 +118,10 @@ else if (Collection.class.isAssignableFrom(parameter.getParameterType())) {
118118
}
119119
else {
120120
valueClass = parameter.getParameterType();
121-
ReactiveAdapterRegistry reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
122-
if (reactiveAdapterRegistry.hasAdapters()) {
123-
ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(valueClass);
124-
if (adapter != null && !adapter.getDescriptor().isNoValue()) {
125-
reactiveSuffix = ClassUtils.getShortName(valueClass);
126-
valueClass = parameter.nested().getNestedParameterType();
127-
}
121+
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(valueClass);
122+
if (adapter != null && !adapter.getDescriptor().isNoValue()) {
123+
reactiveSuffix = ClassUtils.getShortName(valueClass);
124+
valueClass = parameter.nested().getNestedParameterType();
128125
}
129126
}
130127

@@ -207,13 +204,10 @@ else if (Collection.class.isAssignableFrom(resolvedType)) {
207204
}
208205
else {
209206
valueClass = resolvedType;
210-
ReactiveAdapterRegistry reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
211-
if (reactiveAdapterRegistry.hasAdapters()) {
212-
ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(valueClass);
213-
if (adapter != null && !adapter.getDescriptor().isNoValue()) {
214-
reactiveSuffix = ClassUtils.getShortName(valueClass);
215-
valueClass = ResolvableType.forMethodReturnType(method).getGeneric().toClass();
216-
}
207+
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(valueClass);
208+
if (adapter != null && !adapter.getDescriptor().isNoValue()) {
209+
reactiveSuffix = ClassUtils.getShortName(valueClass);
210+
valueClass = ResolvableType.forMethodReturnType(method).getGeneric().toClass();
217211
}
218212
}
219213

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,14 @@ public class ReactiveAdapterRegistry {
5959

6060
private final boolean reactorPresent;
6161

62-
private final List<ReactiveAdapter> adapters = new ArrayList<>(32);
62+
private final List<ReactiveAdapter> adapters = new ArrayList<>();
6363

6464

6565
/**
6666
* Create a registry and auto-register default adapters.
6767
* @see #getSharedInstance()
6868
*/
6969
public ReactiveAdapterRegistry() {
70-
7170
ClassLoader classLoader = ReactiveAdapterRegistry.class.getClassLoader();
7271

7372
// Reactor
@@ -118,8 +117,8 @@ public boolean hasAdapters() {
118117

119118
/**
120119
* Register a reactive type along with functions to adapt to and from a
121-
* Reactive Streams {@link Publisher}. The functions can assume their
122-
* input is never be {@code null} nor {@link Optional}.
120+
* Reactive Streams {@link Publisher}. The function arguments assume that
121+
* their input is neither {@code null} nor {@link Optional}.
123122
*/
124123
public void registerReactiveType(ReactiveTypeDescriptor descriptor,
125124
Function<Object, Publisher<?>> toAdapter, Function<Publisher<?>, Object> fromAdapter) {
@@ -134,6 +133,7 @@ public void registerReactiveType(ReactiveTypeDescriptor descriptor,
134133

135134
/**
136135
* Get the adapter for the given reactive type.
136+
* @return the corresponding adapter, or {@code null} if none available
137137
*/
138138
@Nullable
139139
public ReactiveAdapter getAdapter(Class<?> reactiveType) {
@@ -147,20 +147,25 @@ public ReactiveAdapter getAdapter(Class<?> reactiveType) {
147147
* (may be {@code null} if a concrete source object is given)
148148
* @param source an instance of the reactive type
149149
* (i.e. to adapt from; may be {@code null} if the reactive type is specified)
150+
* @return the corresponding adapter, or {@code null} if none available
150151
*/
151152
@Nullable
152153
public ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, @Nullable Object source) {
154+
if (this.adapters.isEmpty()) {
155+
return null;
156+
}
157+
153158
Object sourceToUse = (source instanceof Optional ? ((Optional<?>) source).orElse(null) : source);
154159
Class<?> clazz = (sourceToUse != null ? sourceToUse.getClass() : reactiveType);
155160
if (clazz == null) {
156161
return null;
157162
}
158-
for(ReactiveAdapter adapter : this.adapters) {
163+
for (ReactiveAdapter adapter : this.adapters) {
159164
if (adapter.getReactiveType() == clazz) {
160165
return adapter;
161166
}
162167
}
163-
for(ReactiveAdapter adapter : this.adapters) {
168+
for (ReactiveAdapter adapter : this.adapters) {
164169
if (adapter.getReactiveType().isAssignableFrom(clazz)) {
165170
return adapter;
166171
}
@@ -170,13 +175,13 @@ public ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, @Nullable Obj
170175

171176

172177
/**
173-
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
174-
* building it once needed.
178+
* Return a shared default {@code ReactiveAdapterRegistry} instance,
179+
* lazily building it once needed.
175180
* <p><b>NOTE:</b> We highly recommend passing a long-lived, pre-configured
176181
* {@code ReactiveAdapterRegistry} instance for customization purposes.
177182
* This accessor is only meant as a fallback for code paths that want to
178183
* fall back on a default instance if one isn't provided.
179-
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
184+
* @return the shared {@code ReactiveAdapterRegistry} instance
180185
* @since 5.0.2
181186
*/
182187
public static ReactiveAdapterRegistry getSharedInstance() {

spring-core/src/main/java/org/springframework/core/codec/AbstractDecoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
*/
4141
public abstract class AbstractDecoder<T> implements Decoder<T> {
4242

43-
protected Log logger = LogFactory.getLog(getClass());
44-
4543
private final List<MimeType> decodableMimeTypes;
4644

45+
protected Log logger = LogFactory.getLog(getClass());
46+
4747

4848
protected AbstractDecoder(MimeType... supportedMimeTypes) {
4949
this.decodableMimeTypes = Arrays.asList(supportedMimeTypes);

spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
*/
3737
public abstract class AbstractEncoder<T> implements Encoder<T> {
3838

39-
protected Log logger = LogFactory.getLog(getClass());
40-
4139
private final List<MimeType> encodableMimeTypes;
4240

41+
protected Log logger = LogFactory.getLog(getClass());
42+
4343

4444
protected AbstractEncoder(MimeType... supportedMimeTypes) {
4545
this.encodableMimeTypes = Arrays.asList(supportedMimeTypes);

spring-core/src/main/java/org/springframework/core/log/CompositeLog.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,32 @@ private static Log initLogger(List<Log> loggers, Predicate<Log> predicate) {
7474

7575
@Override
7676
public boolean isFatalEnabled() {
77-
return this.fatalLogger != NO_OP_LOG;
77+
return (this.fatalLogger != NO_OP_LOG);
7878
}
7979

8080
@Override
8181
public boolean isErrorEnabled() {
82-
return this.errorLogger != NO_OP_LOG;
82+
return (this.errorLogger != NO_OP_LOG);
8383
}
8484

8585
@Override
8686
public boolean isWarnEnabled() {
87-
return this.warnLogger != NO_OP_LOG;
87+
return (this.warnLogger != NO_OP_LOG);
8888
}
8989

9090
@Override
9191
public boolean isInfoEnabled() {
92-
return this.infoLogger != NO_OP_LOG;
92+
return (this.infoLogger != NO_OP_LOG);
9393
}
9494

9595
@Override
9696
public boolean isDebugEnabled() {
97-
return this.debugLogger != NO_OP_LOG;
97+
return (this.debugLogger != NO_OP_LOG);
9898
}
9999

100100
@Override
101101
public boolean isTraceEnabled() {
102-
return this.traceLogger != NO_OP_LOG;
102+
return (this.traceLogger != NO_OP_LOG);
103103
}
104104

105105
@Override

spring-messaging/src/main/java/org/springframework/messaging/handler/HandlerMethod.java

Lines changed: 3 additions & 3 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.
@@ -58,8 +58,6 @@ public class HandlerMethod {
5858
public static final Log defaultLogger = LogFactory.getLog(HandlerMethod.class);
5959

6060

61-
protected Log logger = defaultLogger;
62-
6361
private final Object bean;
6462

6563
@Nullable
@@ -76,6 +74,8 @@ public class HandlerMethod {
7674
@Nullable
7775
private HandlerMethod resolvedFromHandlerMethod;
7876

77+
protected Log logger = defaultLogger;
78+
7979

8080
/**
8181
* Create an instance from a bean instance and a method.

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AsyncHandlerMethodReturnValueHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -43,8 +43,8 @@ public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodRetur
4343
* {@link #supportsReturnType(org.springframework.core.MethodParameter)}
4444
* is called and it returns {@code true}.
4545
* @param returnValue the value returned from the handler method
46-
* @param returnType the type of the return value.
47-
* @return true if the return value type represents an async value.
46+
* @param returnType the type of the return value
47+
* @return {@code true} if the return value type represents an async value
4848
*/
4949
boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType);
5050

@@ -58,9 +58,9 @@ public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodRetur
5858
* {@link #supportsReturnType(org.springframework.core.MethodParameter)}
5959
* is called and it returns {@code true}.
6060
* @param returnValue the value returned from the handler method
61-
* @param returnType the type of the return value.
62-
* @return the resulting ListenableFuture or {@code null} in which case no
63-
* further handling will be performed.
61+
* @param returnType the type of the return value
62+
* @return the resulting ListenableFuture, or {@code null} in which case
63+
* no further handling will be performed
6464
*/
6565
@Nullable
6666
ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType);

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/ReactiveReturnValueHandler.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.
@@ -48,7 +48,7 @@ public ReactiveReturnValueHandler(ReactiveAdapterRegistry adapterRegistry) {
4848

4949
@Override
5050
public boolean supportsReturnType(MethodParameter returnType) {
51-
return this.adapterRegistry.getAdapter(returnType.getParameterType()) != null;
51+
return (this.adapterRegistry.getAdapter(returnType.getParameterType()) != null);
5252
}
5353

5454
@Override

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

Lines changed: 3 additions & 3 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.
@@ -42,10 +42,10 @@ public abstract class AbstractMessageChannel implements MessageChannel, Intercep
4242

4343
protected Log logger = LogFactory.getLog(getClass());
4444

45-
private final List<ChannelInterceptor> interceptors = new ArrayList<>(5);
46-
4745
private String beanName;
4846

47+
private final List<ChannelInterceptor> interceptors = new ArrayList<>(5);
48+
4949

5050
public AbstractMessageChannel() {
5151
this.beanName = getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this);

spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpClient.java

Lines changed: 5 additions & 5 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.
@@ -70,8 +70,6 @@ public class ReactorNettyTcpClient<P> implements TcpOperations<P> {
7070

7171
private static final int PUBLISH_ON_BUFFER_SIZE = 16;
7272

73-
private Log logger = LogFactory.getLog(ReactorNettyTcpClient.class);
74-
7573

7674
private final TcpClient tcpClient;
7775

@@ -81,13 +79,15 @@ public class ReactorNettyTcpClient<P> implements TcpOperations<P> {
8179
private final ChannelGroup channelGroup;
8280

8381
@Nullable
84-
private LoopResources loopResources;
82+
private final LoopResources loopResources;
8583

8684
@Nullable
87-
private ConnectionProvider poolResources;
85+
private final ConnectionProvider poolResources;
8886

8987
private final Scheduler scheduler = Schedulers.newParallel("tcp-client-scheduler");
9088

89+
private Log logger = LogFactory.getLog(ReactorNettyTcpClient.class);
90+
9191
private volatile boolean stopping = false;
9292

9393

0 commit comments

Comments
 (0)