Skip to content

Commit f49e0e3

Browse files
committed
Optimize String argument resolution in MessageTag
Closes gh-25809 (cherry picked from commit d9da663)
1 parent 3371c23 commit f49e0e3

File tree

1 file changed

+5
-18
lines changed
  • spring-webmvc/src/main/java/org/springframework/web/servlet/tags

1 file changed

+5
-18
lines changed

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

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,9 +17,9 @@
1717
package org.springframework.web.servlet.tags;
1818

1919
import java.io.IOException;
20+
import java.util.ArrayList;
2021
import java.util.Collection;
2122
import java.util.Collections;
22-
import java.util.LinkedList;
2323
import java.util.List;
2424

2525
import javax.servlet.jsp.JspException;
@@ -255,7 +255,7 @@ public void setJavaScriptEscape(boolean javaScriptEscape) throws JspException {
255255

256256
@Override
257257
protected final int doStartTagInternal() throws JspException, IOException {
258-
this.nestedArguments = new LinkedList<>();
258+
this.nestedArguments = new ArrayList<>();
259259
return EVAL_BODY_INCLUDE;
260260
}
261261

@@ -358,20 +358,7 @@ private Object[] appendArguments(@Nullable Object[] sourceArguments, Object[] ad
358358
@Nullable
359359
protected Object[] resolveArguments(@Nullable Object arguments) throws JspException {
360360
if (arguments instanceof String) {
361-
String[] stringArray =
362-
StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
363-
if (stringArray.length == 1) {
364-
Object argument = stringArray[0];
365-
if (argument != null && argument.getClass().isArray()) {
366-
return ObjectUtils.toObjectArray(argument);
367-
}
368-
else {
369-
return new Object[] {argument};
370-
}
371-
}
372-
else {
373-
return stringArray;
374-
}
361+
return StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
375362
}
376363
else if (arguments instanceof Object[]) {
377364
return (Object[]) arguments;
@@ -395,7 +382,7 @@ else if (arguments != null) {
395382
* @throws IOException if writing failed
396383
*/
397384
protected void writeMessage(String msg) throws IOException {
398-
this.pageContext.getOut().write(String.valueOf(msg));
385+
this.pageContext.getOut().write(msg);
399386
}
400387

401388
/**

0 commit comments

Comments
 (0)