Polishing (collapsed if checks, consistent downcasts, refined javadoc)

This commit is contained in:
Juergen Hoeller
2018-03-08 18:11:57 +01:00
parent 0f7485b01d
commit 139dc1d373
50 changed files with 336 additions and 435 deletions

View File

@@ -33,8 +33,8 @@ import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils;
/**
* A {@link MessageCondition} for matching the destination of a Message against one or
* more destination patterns using a {@link PathMatcher}.
* A {@link MessageCondition} for matching the destination of a Message
* against one or more destination patterns using a {@link PathMatcher}.
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -78,10 +78,8 @@ public class DestinationPatternsMessageCondition
boolean slashSeparator = pathMatcher.combine("a", "a").equals("a/a");
Set<String> result = new LinkedHashSet<>(patterns.size());
for (String pattern : patterns) {
if (slashSeparator) {
if (StringUtils.hasLength(pattern) && !pattern.startsWith("/")) {
pattern = "/" + pattern;
}
if (slashSeparator && StringUtils.hasLength(pattern) && !pattern.startsWith("/")) {
pattern = "/" + pattern;
}
result.add(pattern);
}
@@ -152,7 +150,6 @@ public class DestinationPatternsMessageCondition
if (destination == null) {
return null;
}
if (this.patterns.isEmpty()) {
return this;
}
@@ -163,7 +160,6 @@ public class DestinationPatternsMessageCondition
matches.add(pattern);
}
}
if (matches.isEmpty()) {
return null;
}
@@ -179,9 +175,8 @@ public class DestinationPatternsMessageCondition
* If all compared patterns match equally, but one instance has more patterns,
* it is considered a closer match.
* <p>It is assumed that both instances have been obtained via
* {@link #getMatchingCondition(Message)} to ensure they
* contain only patterns that match the request and are sorted with
* the best matches on top.
* {@link #getMatchingCondition(Message)} to ensure they contain only patterns
* that match the request and are sorted with the best matches on top.
*/
@Override
public int compareTo(DestinationPatternsMessageCondition other, Message<?> message) {
@@ -189,8 +184,8 @@ public class DestinationPatternsMessageCondition
if (destination == null) {
return 0;
}
Comparator<String> patternComparator = this.pathMatcher.getPatternComparator(destination);
Comparator<String> patternComparator = this.pathMatcher.getPatternComparator(destination);
Iterator<String> iterator = this.patterns.iterator();
Iterator<String> iteratorOther = other.patterns.iterator();
while (iterator.hasNext() && iteratorOther.hasNext()) {
@@ -199,6 +194,7 @@ public class DestinationPatternsMessageCondition
return result;
}
}
if (iterator.hasNext()) {
return -1;
}

View File

@@ -1,5 +1,5 @@
/*
* 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");
* you may not use this file except in compliance with the License.
@@ -140,12 +140,10 @@ public class BufferingStompDecoder {
private void checkBufferLimits() {
Integer contentLength = this.expectedContentLength;
if (contentLength != null) {
if (contentLength > this.bufferSizeLimit) {
throw new StompConversionException(
"STOMP 'content-length' header value " + this.expectedContentLength +
" exceeds configured buffer size limit " + this.bufferSizeLimit);
}
if (contentLength != null && contentLength > this.bufferSizeLimit) {
throw new StompConversionException(
"STOMP 'content-length' header value " + this.expectedContentLength +
" exceeds configured buffer size limit " + this.bufferSizeLimit);
}
if (getBufferSize() > this.bufferSizeLimit) {
throw new StompConversionException("The configured STOMP buffer size limit of " +