Optimize String argument resolution in MessageTag
Closes gh-25809
This commit is contained in:
parent
c04400890f
commit
d9da663f6d
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2020 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,9 +17,9 @@
|
||||||
package org.springframework.web.servlet.tags;
|
package org.springframework.web.servlet.tags;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.jsp.JspException;
|
import javax.servlet.jsp.JspException;
|
||||||
|
@ -255,7 +255,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final int doStartTagInternal() throws JspException, IOException {
|
protected final int doStartTagInternal() throws JspException, IOException {
|
||||||
this.nestedArguments = new LinkedList<>();
|
this.nestedArguments = new ArrayList<>();
|
||||||
return EVAL_BODY_INCLUDE;
|
return EVAL_BODY_INCLUDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,20 +358,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Object[] resolveArguments(@Nullable Object arguments) throws JspException {
|
protected Object[] resolveArguments(@Nullable Object arguments) throws JspException {
|
||||||
if (arguments instanceof String) {
|
if (arguments instanceof String) {
|
||||||
String[] stringArray =
|
return StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
|
||||||
StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
|
|
||||||
if (stringArray.length == 1) {
|
|
||||||
Object argument = stringArray[0];
|
|
||||||
if (argument != null && argument.getClass().isArray()) {
|
|
||||||
return ObjectUtils.toObjectArray(argument);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new Object[] {argument};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return stringArray;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (arguments instanceof Object[]) {
|
else if (arguments instanceof Object[]) {
|
||||||
return (Object[]) arguments;
|
return (Object[]) arguments;
|
||||||
|
@ -395,7 +382,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||||
* @throws IOException if writing failed
|
* @throws IOException if writing failed
|
||||||
*/
|
*/
|
||||||
protected void writeMessage(String msg) throws IOException {
|
protected void writeMessage(String msg) throws IOException {
|
||||||
this.pageContext.getOut().write(String.valueOf(msg));
|
this.pageContext.getOut().write(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue