Skip to content

Commit 8e27891

Browse files
committed
Java10: Use pre-defined charset, making catch exception not needed anymore
1 parent 9f75464 commit 8e27891

File tree

4 files changed

+14
-38
lines changed

4 files changed

+14
-38
lines changed

exist-core/src/main/java/org/exist/client/InteractiveClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ public boolean run() throws Exception {
20902090
printNotice();
20912091

20922092
// Fix "uri" property: Excalibur CLI can't parse dashes, so we need to URL encode them:
2093-
properties.setProperty(URI, URLDecoder.decode(properties.getProperty(URI), UTF_8.name()));
2093+
properties.setProperty(URI, URLDecoder.decode(properties.getProperty(URI), UTF_8));
20942094

20952095
final boolean interactive = isInteractive();
20962096

exist-core/src/main/java/org/exist/storage/serializers/XIncludeFilter.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,10 @@ protected Map<String, String> processParameters(final String args) {
608608
value = args.substring(start, end - 1);
609609
}
610610
start = end;
611-
try {
612-
param = URLDecoder.decode(param, UTF_8.name());
613-
value = URLDecoder.decode(value, UTF_8.name());
614-
LOG.debug("parameter: {} = {}", param, value);
615-
parameters.put(param, value);
616-
} catch (final UnsupportedEncodingException e) {
617-
LOG.warn(e.getMessage(), e);
618-
}
611+
param = URLDecoder.decode(param, UTF_8);
612+
value = URLDecoder.decode(value, UTF_8);
613+
LOG.debug("parameter: {} = {}", param, value);
614+
parameters.put(param, value);
619615
}
620616
return parameters;
621617
}

exist-core/src/main/java/org/exist/xmldb/XmldbURI.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,8 @@ public String getCollectionPath() {
387387
return null;
388388
}
389389

390-
try {
391-
//TODO: we might want to cache this value
392-
return URLDecoder.decode(encodedCollectionPath, UTF_8.name());
393-
} catch (final UnsupportedEncodingException e) {
394-
//Should never happen
395-
throw new IllegalArgumentException(encodedCollectionPath + " can not be properly escaped");
396-
}
390+
//TODO: we might want to cache this value
391+
return URLDecoder.decode(encodedCollectionPath, UTF_8);
397392
}
398393

399394
public XmldbURI toCollectionPathURI() {

exist-core/src/main/java/org/exist/xquery/util/URIUtils.java

+7-22
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,9 @@ public static String escapeHtmlURI(String uri){
324324
* @return The UTF-8 encoded value of the supplied uri
325325
*/
326326
public static String urlEncodeUtf8(String uri) {
327-
try {
328-
final String almostEncoded = URLEncoder.encode(uri, UTF_8.name());
329-
return almostEncoded.replaceAll("\\+","%20");
330-
} catch(final UnsupportedEncodingException e) {
331-
//wrap with a runtime Exception
332-
throw new RuntimeException(e);
333-
}
334-
}
327+
final String almostEncoded = URLEncoder.encode(uri, UTF_8);
328+
return almostEncoded.replaceAll("\\+","%20");
329+
}
335330

336331
/**
337332
* This method decodes the provided uri for human readability. The
@@ -342,13 +337,8 @@ public static String urlEncodeUtf8(String uri) {
342337
* @return The decoded value of the supplied uri
343338
*/
344339
public static String urlDecodeUtf8(String uri) {
345-
try {
346-
return URLDecoder.decode(uri, UTF_8.name());
347-
} catch(final UnsupportedEncodingException e) {
348-
//wrap with a runtime Exception
349-
throw new RuntimeException(e);
350-
}
351-
}
340+
return URLDecoder.decode(uri, UTF_8);
341+
}
352342

353343
/**
354344
* This method decodes the provided uri for human readability. The
@@ -359,13 +349,8 @@ public static String urlDecodeUtf8(String uri) {
359349
* @return The decoded value of the supplied uri
360350
*/
361351
public static String urlDecodeUtf8(XmldbURI uri) {
362-
try {
363-
return URLDecoder.decode(uri.toString(), UTF_8.name());
364-
} catch(final UnsupportedEncodingException e) {
365-
//wrap with a runtime Exception
366-
throw new RuntimeException(e);
367-
}
368-
}
352+
return URLDecoder.decode(uri.toString(), UTF_8);
353+
}
369354

370355
/**
371356
* This method splits the supplied url on the character

0 commit comments

Comments
 (0)