master
Rossen Stoyanchev 7 years ago
parent e2febbdd8c
commit cca78e42f1
  1. 4
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java
  2. 7
      spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java

@ -420,6 +420,7 @@ public abstract class AbstractMethodMessageHandler<T>
* <p>If there are no matching prefixes, return {@code null}. * <p>If there are no matching prefixes, return {@code null}.
* <p>If there are no destination prefixes, return the destination as is. * <p>If there are no destination prefixes, return the destination as is.
*/ */
@SuppressWarnings("ForLoopReplaceableByForEach")
@Nullable @Nullable
protected String getLookupDestination(@Nullable String destination) { protected String getLookupDestination(@Nullable String destination) {
if (destination == null) { if (destination == null) {
@ -428,8 +429,7 @@ public abstract class AbstractMethodMessageHandler<T>
if (CollectionUtils.isEmpty(this.destinationPrefixes)) { if (CollectionUtils.isEmpty(this.destinationPrefixes)) {
return destination; return destination;
} }
// Avoid unnecessary iterator allocation for (int i = 0; i < this.destinationPrefixes.size(); i++) {
for (int i = 0, size = this.destinationPrefixes.size(); i < size; i++) {
String prefix = this.destinationPrefixes.get(i); String prefix = this.destinationPrefixes.get(i);
if (destination.startsWith(prefix)) { if (destination.startsWith(prefix)) {
return destination.substring(prefix.length()); return destination.substring(prefix.length());

@ -1,5 +1,6 @@
/* /*
* Copyright 2002-2017 the original author or authors. /*
* Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -81,10 +82,10 @@ public class HandlerMethodReturnValueHandlerComposite implements AsyncHandlerMet
return getReturnValueHandler(returnType) != null; return getReturnValueHandler(returnType) != null;
} }
@SuppressWarnings("ForLoopReplaceableByForEach")
@Nullable @Nullable
private HandlerMethodReturnValueHandler getReturnValueHandler(MethodParameter returnType) { private HandlerMethodReturnValueHandler getReturnValueHandler(MethodParameter returnType) {
// Avoid allocating an iterator for (int i = 0; i < this.returnValueHandlers.size(); i++) {
for (int i = 0, size = this.returnValueHandlers.size(); i < size; i++) {
HandlerMethodReturnValueHandler handler = this.returnValueHandlers.get(i); HandlerMethodReturnValueHandler handler = this.returnValueHandlers.get(i);
if (handler.supportsReturnType(returnType)) { if (handler.supportsReturnType(returnType)) {
return handler; return handler;

Loading…
Cancel
Save