mirror of
https://github.com/apache/struts.git
synced 2026-08-31 19:35:40 +00:00
Merge pull request #773 from mygreen/improve-urldecoder-peformance
Improved the StrutsUrlDecoder so that charset retrieval is performed only once.
This commit is contained in:
@@ -27,11 +27,14 @@ import org.apache.struts2.StrutsConstants;
|
||||
|
||||
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<Charset> AVAILABLE_CHARSETS = Charset.availableCharsets().values();
|
||||
|
||||
private String encoding = "UTF-8";
|
||||
|
||||
@Inject(value = StrutsConstants.STRUTS_I18N_ENCODING, required = false)
|
||||
@@ -107,7 +110,7 @@ public class StrutsUrlDecoder implements UrlDecoder {
|
||||
}
|
||||
|
||||
private Charset getCharset(String encoding) throws UnsupportedEncodingException {
|
||||
for (Charset charset : Charset.availableCharsets().values()) {
|
||||
for (Charset charset : AVAILABLE_CHARSETS) {
|
||||
if (encoding.equalsIgnoreCase(charset.name())) {
|
||||
return charset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user