Browse Source

Optimize String argument resolution in MessageTag

Closes gh-25809

(cherry picked from commit d9da663f6d)
pull/23967/head
Juergen Hoeller 5 years ago
parent
commit
f49e0e36ff
  1. 23
      spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java

23
spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -17,9 +17,9 @@ @@ -17,9 +17,9 @@
package org.springframework.web.servlet.tags;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.jsp.JspException;
@ -255,7 +255,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware { @@ -255,7 +255,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
@Override
protected final int doStartTagInternal() throws JspException, IOException {
this.nestedArguments = new LinkedList<>();
this.nestedArguments = new ArrayList<>();
return EVAL_BODY_INCLUDE;
}
@ -358,20 +358,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware { @@ -358,20 +358,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
@Nullable
protected Object[] resolveArguments(@Nullable Object arguments) throws JspException {
if (arguments instanceof String) {
String[] stringArray =
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;
}
return StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
}
else if (arguments instanceof Object[]) {
return (Object[]) arguments;
@ -395,7 +382,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware { @@ -395,7 +382,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
* @throws IOException if writing failed
*/
protected void writeMessage(String msg) throws IOException {
this.pageContext.getOut().write(String.valueOf(msg));
this.pageContext.getOut().write(msg);
}
/**

Loading…
Cancel
Save