Skip to content

Commit 588e41c

Browse files
committed
[modernize] Use standard charsets
unfortunately if > jdk 16 uses with current project needs, the detection can be a bit off. So this is not entirely ideal until we are on higher jdks and stop using static for searching when we already have it. For now this is better.
1 parent c29c041 commit 588e41c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/main/java/org/apache/ibatis/io/DefaultVFS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.InputStream;
2323
import java.io.InputStreamReader;
2424
import java.io.UnsupportedEncodingException;
25+
import java.nio.charset.StandardCharsets;
2526
import java.net.MalformedURLException;
2627
import java.net.URL;
2728
import java.net.URLEncoder;
@@ -269,7 +270,7 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
269270
// File name might be URL-encoded
270271
if (!file.exists()) {
271272
try {
272-
file = new File(URLEncoder.encode(jarUrl.toString(), "UTF-8"));
273+
file = new File(URLEncoder.encode(jarUrl.toString(), StandardCharsets.UTF_8.name()));
273274
} catch (UnsupportedEncodingException e) {
274275
throw new RuntimeException("Unsupported encoding? UTF-8? That's impossible.");
275276
}

src/test/java/org/apache/ibatis/io/ExternalResourcesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.FileNotFoundException;
2222
import java.io.FileWriter;
2323
import java.io.IOException;
24+
import java.nio.charset.StandardCharsets;
2425

2526
import org.junit.jupiter.api.AfterEach;
2627
import org.junit.jupiter.api.BeforeEach;

0 commit comments

Comments
 (0)