From 5bcf9e7854a132dc073f0609cd2e68ae3256dcdd Mon Sep 17 00:00:00 2001 From: tatsu-no-otoshigo Date: Mon, 23 Oct 2023 22:34:05 +0900 Subject: [PATCH 1/3] Improved charset retrieval to get only once. --- .../main/java/org/apache/struts2/url/StrutsUrlDecoder.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java index 3a480d87fe..a40988ae92 100644 --- a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java +++ b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java @@ -27,11 +27,14 @@ import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import java.util.Collection; public class StrutsUrlDecoder implements UrlDecoder { private static final Logger LOG = LogManager.getLogger(StrutsUrlDecoder.class); + private static final Collection AVAILAVLE_CHARSETS = Charset.availableCharsets().values(); + private String encoding = "UTF-8"; @Inject(value = StrutsConstants.STRUTS_I18N_ENCODING, required = false) @@ -107,7 +110,7 @@ private byte convertHexDigit(byte b) { } private Charset getCharset(String encoding) throws UnsupportedEncodingException { - for (Charset charset : Charset.availableCharsets().values()) { + for (Charset charset : AVAILAVLE_CHARSETS) { if (encoding.equalsIgnoreCase(charset.name())) { return charset; } From afe31cc01ed322a7d3996118b4d917433bbcec23 Mon Sep 17 00:00:00 2001 From: mygreen Date: Tue, 24 Oct 2023 19:58:12 +0900 Subject: [PATCH 2/3] Update core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java Co-authored-by: Sebastian Peters --- core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java index a40988ae92..0ad4604c96 100644 --- a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java +++ b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java @@ -33,7 +33,7 @@ public class StrutsUrlDecoder implements UrlDecoder { private static final Logger LOG = LogManager.getLogger(StrutsUrlDecoder.class); - private static final Collection AVAILAVLE_CHARSETS = Charset.availableCharsets().values(); + private static final Collection AVAILABLE_CHARSETS = Charset.availableCharsets().values(); private String encoding = "UTF-8"; From faa98d7af13df21fbcb2fd5c633867b57707edeb Mon Sep 17 00:00:00 2001 From: mygreen Date: Tue, 24 Oct 2023 19:58:19 +0900 Subject: [PATCH 3/3] Update core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java Co-authored-by: Sebastian Peters --- core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java index 0ad4604c96..656a2b85fa 100644 --- a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java +++ b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java @@ -110,7 +110,7 @@ private byte convertHexDigit(byte b) { } private Charset getCharset(String encoding) throws UnsupportedEncodingException { - for (Charset charset : AVAILAVLE_CHARSETS) { + for (Charset charset : AVAILABLE_CHARSETS) { if (encoding.equalsIgnoreCase(charset.name())) { return charset; }