Skip to content

Commit

Permalink
Use StandardCharsets instead of charset name
Browse files Browse the repository at this point in the history
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
  • Loading branch information
scop authored and Kai Hudalla committed Feb 17, 2017
1 parent 649d244 commit 7818af2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Expand Up @@ -16,6 +16,7 @@
package org.eclipse.leshan.server.demo.servlet;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
Expand Down Expand Up @@ -108,7 +109,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

String json = this.gson.toJson(registrations.toArray(new Registration[] {}));
resp.setContentType("application/json");
resp.getOutputStream().write(json.getBytes("UTF-8"));
resp.getOutputStream().write(json.getBytes(StandardCharsets.UTF_8));
resp.setStatus(HttpServletResponse.SC_OK);
return;
}
Expand All @@ -125,7 +126,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint);
if (registration != null) {
resp.setContentType("application/json");
resp.getOutputStream().write(this.gson.toJson(registration).getBytes("UTF-8"));
resp.getOutputStream().write(this.gson.toJson(registration).getBytes(StandardCharsets.UTF_8));
resp.setStatus(HttpServletResponse.SC_OK);
} else {
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
Expand Down
Expand Up @@ -16,6 +16,7 @@
package org.eclipse.leshan.server.demo.servlet;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
Expand Down Expand Up @@ -59,7 +60,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

String json = this.gson.toJson(model.getObjectModels().toArray(new ObjectModel[] {}));
resp.setContentType("application/json");
resp.getOutputStream().write(json.getBytes("UTF-8"));
resp.getOutputStream().write(json.getBytes(StandardCharsets.UTF_8));
resp.setStatus(HttpServletResponse.SC_OK);
return;
}
Expand Down
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.security.PublicKey;
import java.util.Collection;

Expand Down Expand Up @@ -118,15 +119,15 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

String json = this.gsonSer.toJson(infos);
resp.setContentType("application/json");
resp.getOutputStream().write(json.getBytes("UTF-8"));
resp.getOutputStream().write(json.getBytes(StandardCharsets.UTF_8));
resp.setStatus(HttpServletResponse.SC_OK);
return;
}

if ("server".equals(path[0])) {
String json = this.gsonSer.toJson(SecurityInfo.newRawPublicKeyInfo("leshan", serverPublicKey));
resp.setContentType("application/json");
resp.getOutputStream().write(json.getBytes("UTF-8"));
resp.getOutputStream().write(json.getBytes(StandardCharsets.UTF_8));
resp.setStatus(HttpServletResponse.SC_OK);
return;
}
Expand Down
Expand Up @@ -16,11 +16,11 @@

package org.eclipse.leshan.server.demo.utils;

import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Enumeration;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -60,7 +60,6 @@
*/
@SuppressWarnings("serial")
public abstract class EventSourceServlet extends HttpServlet {
private static final Charset UTF_8 = Charset.forName("UTF-8");
private static final byte[] CRLF = new byte[] { '\r', '\n' };
private static final byte[] EVENT_FIELD;
private static final byte[] DATA_FIELD;
Expand Down

0 comments on commit 7818af2

Please sign in to comment.