Skip to content

Commit

Permalink
don't rely on default charset
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Jan 3, 2025
1 parent 2e03f7f commit 683cce4
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.lang.ref.WeakReference;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Collections;
import java.util.Enumeration;
Expand All @@ -26,15 +26,14 @@ class ResourceInjectionTest {

private static String readLine(URL url) throws Exception {
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(url.openStream(), Charset.defaultCharset()))) {
new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
return reader.readLine().trim();
}
}

@Test
@SuppressWarnings("UnnecessaryAsync")
void resourcesInjectedToNonDelegatingClassLoader() throws Exception {

String resourceName = "test-resources/test-resource.txt";
URL[] urls = {SystemUtils.class.getProtectionDomain().getCodeSource().getLocation()};
AtomicReference<URLClassLoader> emptyLoader =
Expand Down

0 comments on commit 683cce4

Please sign in to comment.