summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer-Åke Minborg <minborg@speedment.com>2016-10-28 16:08:13 -0700
committerVaadin Code Review <review@vaadin.com>2016-11-07 06:38:07 +0000
commitd2e69d55b70e5a1c8396daeb329a0f981017b6de (patch)
treeee29fdf59f5150e4b6f8e104e7557c400a82363e
parentd75191c0e3c601ca87ce7d1d9e09329bce3a8ef2 (diff)
downloadvaadin-framework-d2e69d55b70e5a1c8396daeb329a0f981017b6de.tar.gz
vaadin-framework-d2e69d55b70e5a1c8396daeb329a0f981017b6de.zip
Replace Charset.forName("UTF--8") with StandardCharsets.UTF_8
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf722e
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinServlet.java10
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java6
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java4
-rw-r--r--server/src/test/java/com/vaadin/ui/declarative/DesignTest.java5
4 files changed, 13 insertions, 12 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java
index b3fa527360..b932a9cc04 100644
--- a/server/src/main/java/com/vaadin/server/VaadinServlet.java
+++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java
@@ -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);
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
index b13499983e..0ee61e6b8d 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
@@ -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)));
}
}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java
index 1c3b68e5fc..d4880a3d2e 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java
@@ -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);
diff --git a/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java b/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java
index 77051b262a..2b39cc7c51 100644
--- a/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java
+++ b/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java
@@ -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";