Browse Source

Polishing

pull/1676/head
Juergen Hoeller 7 years ago
parent
commit
d00e1c5e4f
  1. 9
      spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java
  2. 5
      spring-context/src/main/java/org/springframework/validation/DataBinder.java
  3. 3
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java

9
spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java

@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory; @@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.jmx.MBeanServerNotFoundException;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@ -69,8 +70,7 @@ public abstract class JmxUtils { @@ -69,8 +70,7 @@ public abstract class JmxUtils {
* {@code MBeanServer} can be found. Logs a warning if more than one
* {@code MBeanServer} found, returning the first one from the list.
* @return the {@code MBeanServer} if found
* @throws org.springframework.jmx.MBeanServerNotFoundException
* if no {@code MBeanServer} could be found
* @throws MBeanServerNotFoundException if no {@code MBeanServer} could be found
* @see javax.management.MBeanServerFactory#findMBeanServer
*/
public static MBeanServer locateMBeanServer() throws MBeanServerNotFoundException {
@ -85,8 +85,7 @@ public abstract class JmxUtils { @@ -85,8 +85,7 @@ public abstract class JmxUtils {
* If this parameter is {@code null}, all registered MBeanServers are considered.
* If the empty String is given, the platform MBeanServer will be returned.
* @return the {@code MBeanServer} if found
* @throws org.springframework.jmx.MBeanServerNotFoundException
* if no {@code MBeanServer} could be found
* @throws MBeanServerNotFoundException if no {@code MBeanServer} could be found
* @see javax.management.MBeanServerFactory#findMBeanServer(String)
*/
public static MBeanServer locateMBeanServer(@Nullable String agentId) throws MBeanServerNotFoundException {
@ -95,7 +94,7 @@ public abstract class JmxUtils { @@ -95,7 +94,7 @@ public abstract class JmxUtils {
// null means any registered server, but "" specifically means the platform server
if (!"".equals(agentId)) {
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(agentId);
if (servers != null && !servers.isEmpty()) {
if (!CollectionUtils.isEmpty(servers)) {
// Check to see if an MBeanServer is registered.
if (servers.size() > 1 && logger.isWarnEnabled()) {
logger.warn("Found more than one MBeanServer instance" +

5
spring-context/src/main/java/org/springframework/validation/DataBinder.java

@ -535,9 +535,10 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter { @@ -535,9 +535,10 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
}
private void assertValidators(Validator... validators) {
Object target = getTarget();
for (Validator validator : validators) {
if (validator != null && (getTarget() != null && !validator.supports(getTarget().getClass()))) {
throw new IllegalStateException("Invalid target for Validator [" + validator + "]: " + getTarget());
if (validator != null && (target != null && !validator.supports(target.getClass()))) {
throw new IllegalStateException("Invalid target for Validator [" + validator + "]: " + target);
}
}
}

3
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java

@ -54,6 +54,7 @@ import org.springframework.http.HttpStatus; @@ -54,6 +54,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.concurrent.SettableListenableFuture;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.socket.CloseStatus;
@ -276,7 +277,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport { @@ -276,7 +277,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport {
try {
ClientRequest request = new ClientRequest().setMethod(method).setPath(url.getPath());
request.getRequestHeaders().add(HttpString.tryFromString(HttpHeaders.HOST), url.getHost());
if (body != null && !body.isEmpty()) {
if (StringUtils.hasLength(body)) {
HttpString headerName = HttpString.tryFromString(HttpHeaders.CONTENT_LENGTH);
request.getRequestHeaders().add(headerName, body.length());
}

Loading…
Cancel
Save