]> source.dussan.org Git - vaadin-framework.git/commitdiff
Replace Charset.forName("UTF--8") with StandardCharsets.UTF_8
authorPer-Åke Minborg <minborg@speedment.com>
Fri, 28 Oct 2016 23:08:13 +0000 (16:08 -0700)
committerVaadin Code Review <review@vaadin.com>
Mon, 7 Nov 2016 06:38:07 +0000 (06:38 +0000)
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf722e

server/src/main/java/com/vaadin/server/VaadinServlet.java
server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java
server/src/test/java/com/vaadin/ui/declarative/DesignTest.java

index b3fa527360c611e23bc4fd451d2e70e55ed7a274..b932a9cc04c08f34d3f9e0f075ed2af38cf5208c 100644 (file)
@@ -32,6 +32,7 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -606,8 +607,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
         response.setContentType(contentType);
         final OutputStream out = response.getOutputStream();
         try ( // Set the response type
-            PrintWriter outWriter = new PrintWriter(
-                new BufferedWriter(new OutputStreamWriter(out, "UTF-8")))) {
+                PrintWriter outWriter = new PrintWriter(new BufferedWriter(
+                        new OutputStreamWriter(out, "UTF-8")))) {
             outWriter.print(output);
             outWriter.flush();
         }
@@ -1069,7 +1070,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
             return null;
         }
 
-        String jsonString = readFile(scssCacheFile, Charset.forName("UTF-8"));
+        String jsonString = readFile(scssCacheFile, StandardCharsets.UTF_8);
 
         JsonObject entryJson = Json.parse(jsonString);
 
@@ -1394,8 +1395,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
         String cacheEntryJsonString = cacheEntry.asJson();
 
         try {
-            writeFile(cacheEntryJsonString, cacheFile,
-                    Charset.forName("UTF-8"));
+            writeFile(cacheEntryJsonString, cacheFile, StandardCharsets.UTF_8);
         } catch (IOException e) {
             getLogger().log(Level.WARNING,
                     "Error persisting scss cache " + cacheFile, e);
index b13499983e656b6d3c0086a68de903297a3fe605..0ee61e6b8de811e0004a4b8b663f77313ae14113 100644 (file)
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 
 import org.jsoup.nodes.Attributes;
@@ -97,10 +97,10 @@ public class AbstractComponentDeclarativeTest
         Boolean[] explicitImmediate = { null, Boolean.FALSE, Boolean.TRUE,
                 Boolean.TRUE };
         boolean[] immediate = { true, false, true, true };
-        for (int i = 0; i < design.length; i++) {
+        for (String design1 : design) {
             component = (AbstractComponent) Design
                     .read(new ByteArrayInputStream(
-                            design[i].getBytes(Charset.forName("UTF-8"))));
+                            design1.getBytes(StandardCharsets.UTF_8)));
         }
     }
 
index 1c3b68e5fc462ebd4364795cf791defb9869955d..d4880a3d2e50f257b528192f9b013fb9c9d6e9df 100644 (file)
@@ -21,7 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -47,7 +47,7 @@ public class CustomLayoutTest {
         for (int i = 0; i < buffer; i++) {
             builder.append('a');
         }
-        byte[] bytes = builder.toString().getBytes(Charset.forName("UTF-8"));
+        byte[] bytes = builder.toString().getBytes(StandardCharsets.UTF_8);
         ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
         InputStreamImpl stream = new InputStreamImpl(inputStream, buffer / 2);
         new CustomLayout(stream);
index 77051b262ada5aae967bb0f1d2cfcdb2bbec4fcc..2b39cc7c514875b4caec31f9dcdb2c03643de621 100644 (file)
@@ -19,6 +19,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -39,8 +40,8 @@ import com.vaadin.ui.Label;
  */
 public class DesignTest {
 
-    private static Charset CP1251_CHARSET = Charset.forName("cp1251");
-    private static Charset UTF8_CHARSET = Charset.forName("UTF-8");
+    private static final Charset CP1251_CHARSET = Charset.forName("cp1251");
+    private static final Charset UTF8_CHARSET = StandardCharsets.UTF_8;
 
     private static String NON_ASCII_STRING = "\u043C";