HandlerExecutionChain.toString() includes reliable interceptor number
Issue: SPR-15525
(cherry picked from commit 92f18a4)
This commit is contained in:
parent
a12bbde87e
commit
e522fec611
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
package org.springframework.web.portlet;
|
package org.springframework.web.portlet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
@ -72,7 +71,7 @@ public class HandlerExecutionChain {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the handler object to execute.
|
* Return the handler object to execute.
|
||||||
* @return the handler object
|
* @return the handler object (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public Object getHandler() {
|
public Object getHandler() {
|
||||||
return this.handler;
|
return this.handler;
|
||||||
|
|
@ -84,7 +83,7 @@ public class HandlerExecutionChain {
|
||||||
|
|
||||||
public void addInterceptors(HandlerInterceptor... interceptors) {
|
public void addInterceptors(HandlerInterceptor... interceptors) {
|
||||||
if (!ObjectUtils.isEmpty(interceptors)) {
|
if (!ObjectUtils.isEmpty(interceptors)) {
|
||||||
initInterceptorList().addAll(Arrays.asList(interceptors));
|
CollectionUtils.mergeArrayIntoCollection(interceptors, initInterceptorList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +92,7 @@ public class HandlerExecutionChain {
|
||||||
this.interceptorList = new ArrayList<HandlerInterceptor>();
|
this.interceptorList = new ArrayList<HandlerInterceptor>();
|
||||||
if (this.interceptors != null) {
|
if (this.interceptors != null) {
|
||||||
// An interceptor array specified through the constructor
|
// An interceptor array specified through the constructor
|
||||||
this.interceptorList.addAll(Arrays.asList(this.interceptors));
|
CollectionUtils.mergeArrayIntoCollection(this.interceptors, this.interceptorList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.interceptors = null;
|
this.interceptors = null;
|
||||||
|
|
@ -117,7 +116,20 @@ public class HandlerExecutionChain {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.valueOf(this.handler);
|
Object handler = getHandler();
|
||||||
|
if (handler == null) {
|
||||||
|
return "HandlerExecutionChain with no handler";
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("HandlerExecutionChain with handler [").append(handler).append("]");
|
||||||
|
HandlerInterceptor[] interceptors = getInterceptors();
|
||||||
|
if (!ObjectUtils.isEmpty(interceptors)) {
|
||||||
|
sb.append(" and ").append(interceptors.length).append(" interceptor");
|
||||||
|
if (interceptors.length > 1) {
|
||||||
|
sb.append("s");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
package org.springframework.web.servlet;
|
package org.springframework.web.servlet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
@ -80,7 +79,7 @@ public class HandlerExecutionChain {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the handler object to execute.
|
* Return the handler object to execute.
|
||||||
* @return the handler object
|
* @return the handler object (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public Object getHandler() {
|
public Object getHandler() {
|
||||||
return this.handler;
|
return this.handler;
|
||||||
|
|
@ -92,7 +91,7 @@ public class HandlerExecutionChain {
|
||||||
|
|
||||||
public void addInterceptors(HandlerInterceptor... interceptors) {
|
public void addInterceptors(HandlerInterceptor... interceptors) {
|
||||||
if (!ObjectUtils.isEmpty(interceptors)) {
|
if (!ObjectUtils.isEmpty(interceptors)) {
|
||||||
initInterceptorList().addAll(Arrays.asList(interceptors));
|
CollectionUtils.mergeArrayIntoCollection(interceptors, initInterceptorList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +100,7 @@ public class HandlerExecutionChain {
|
||||||
this.interceptorList = new ArrayList<HandlerInterceptor>();
|
this.interceptorList = new ArrayList<HandlerInterceptor>();
|
||||||
if (this.interceptors != null) {
|
if (this.interceptors != null) {
|
||||||
// An interceptor array specified through the constructor
|
// An interceptor array specified through the constructor
|
||||||
this.interceptorList.addAll(Arrays.asList(this.interceptors));
|
CollectionUtils.mergeArrayIntoCollection(this.interceptors, this.interceptorList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.interceptors = null;
|
this.interceptors = null;
|
||||||
|
|
@ -202,14 +201,16 @@ public class HandlerExecutionChain {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (this.handler == null) {
|
Object handler = getHandler();
|
||||||
|
if (handler == null) {
|
||||||
return "HandlerExecutionChain with no handler";
|
return "HandlerExecutionChain with no handler";
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("HandlerExecutionChain with handler [").append(this.handler).append("]");
|
sb.append("HandlerExecutionChain with handler [").append(handler).append("]");
|
||||||
if (!CollectionUtils.isEmpty(this.interceptorList)) {
|
HandlerInterceptor[] interceptors = getInterceptors();
|
||||||
sb.append(" and ").append(this.interceptorList.size()).append(" interceptor");
|
if (!ObjectUtils.isEmpty(interceptors)) {
|
||||||
if (this.interceptorList.size() > 1) {
|
sb.append(" and ").append(interceptors.length).append(" interceptor");
|
||||||
|
if (interceptors.length > 1) {
|
||||||
sb.append("s");
|
sb.append("s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue