Skip to content

Commit

Permalink
Merge pull request #17296 from gastaldi/charset
Browse files Browse the repository at this point in the history
Use StandardCharsets.UTF_8 where appropriate
  • Loading branch information
geoand authored May 18, 2021
2 parents 34de393 + 9efc639 commit 1f2cd1f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -32,7 +33,7 @@ public class PackageUtil {
protected static final String DOCKER_PREFIX = "docker-";
protected static final String BZIP2_SUFFIX = ".tar.bzip2";

private static final Charset UTF_8 = Charset.forName("UTF-8");
private static final Charset UTF_8 = StandardCharsets.UTF_8;

public static File packageFile(String path) {
return packageFile(path, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -223,7 +223,7 @@ public ResourceTemplateLocation(URL resource, Variant variant) {
@Override
public Reader read() {
try {
return new InputStreamReader(resource.openStream(), Charset.forName("utf-8"));
return new InputStreamReader(resource.openStream(), StandardCharsets.UTF_8);
} catch (IOException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
Expand Down Expand Up @@ -632,7 +632,7 @@ public void testThatTheApplicationIsReloadedOnNewResource() throws MavenInvocati
" return \"bar\";\n" +
" }\n" +
"}\n";
FileUtils.write(source, myNewResource, Charset.forName("UTF-8"));
FileUtils.write(source, myNewResource, StandardCharsets.UTF_8);

// Wait until we get "bar"
await()
Expand Down Expand Up @@ -666,7 +666,7 @@ public void testThatClassFileAreCleanedUp() throws MavenInvocationException, IOE
" return \"to be deleted\";\n" +
" }\n" +
"}";
FileUtils.write(source, classDeletionResource, Charset.forName("UTF-8"));
FileUtils.write(source, classDeletionResource, StandardCharsets.UTF_8);

runAndCheck();
// Wait until source file is compiled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testThatTheApplicationIsReloadedOnNewResource() throws MavenInvocati
" return \"bar\";\n" +
" }\n" +
"}\n";
FileUtils.write(source, myNewResource, Charset.forName("UTF-8"));
FileUtils.write(source, myNewResource, StandardCharsets.UTF_8);

// Wait until we get "bar"
await()
Expand Down

0 comments on commit 1f2cd1f

Please sign in to comment.