Avoid UnsupportedEncodingException & use const from StandardCharsets (#11948)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
committed by
GitHub
parent
3f54327d5a
commit
167f8ebc49
@@ -15,7 +15,6 @@ package org.openhab.binding.amazonechocontrol.internal;
|
||||
import static org.openhab.binding.amazonechocontrol.internal.AmazonEchoControlBindingConstants.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
@@ -88,11 +87,11 @@ public class AccountServlet extends HttpServlet {
|
||||
this.gson = gson;
|
||||
|
||||
try {
|
||||
servletUrlWithoutRoot = "amazonechocontrol/" + URLEncoder.encode(id, "UTF8");
|
||||
servletUrlWithoutRoot = "amazonechocontrol/" + URLEncoder.encode(id, StandardCharsets.UTF_8);
|
||||
servletUrl = "/" + servletUrlWithoutRoot;
|
||||
|
||||
httpService.registerServlet(servletUrl, this, null, httpService.createDefaultHttpContext());
|
||||
} catch (UnsupportedEncodingException | NamespaceException | ServletException e) {
|
||||
} catch (NamespaceException | ServletException e) {
|
||||
throw new IllegalStateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -340,12 +339,7 @@ public class AccountServlet extends HttpServlet {
|
||||
String[] elements = param.split("=");
|
||||
if (elements.length == 2) {
|
||||
String name = elements[0];
|
||||
String value = "";
|
||||
try {
|
||||
value = URLDecoder.decode(elements[1], "UTF8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.info("Unsupported encoding", e);
|
||||
}
|
||||
String value = URLDecoder.decode(elements[1], StandardCharsets.UTF_8);
|
||||
map.put(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user