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
@@ -19,7 +19,6 @@ import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
@@ -91,9 +90,6 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
||||
// time in seconds to try to reconnect
|
||||
private static final int RECONNECT_TIME = 60;
|
||||
|
||||
// utf8 charset name
|
||||
private static final String UTF8_NAME = StandardCharsets.UTF_8.name();
|
||||
|
||||
// the value by which the volume is changed by each INCREASE or
|
||||
// DECREASE-Event
|
||||
private static final int VOLUME_CHANGE_SIZE = 5;
|
||||
@@ -520,21 +516,11 @@ public class SqueezeBoxServerHandler extends BaseBridgeHandler {
|
||||
}
|
||||
|
||||
private String decode(String raw) {
|
||||
try {
|
||||
return URLDecoder.decode(raw, UTF8_NAME);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.debug("Failed to decode '{}' ", raw, e);
|
||||
return null;
|
||||
}
|
||||
return URLDecoder.decode(raw, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private String encode(String raw) {
|
||||
try {
|
||||
return URLEncoder.encode(raw, UTF8_NAME);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.debug("Failed to encode '{}' ", raw, e);
|
||||
return null;
|
||||
}
|
||||
return URLEncoder.encode(raw, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@NonNullByDefault
|
||||
|
||||
Reference in New Issue
Block a user