Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2019-10-08 02:04:51 -0400
committerAlexander Kurtakov2019-10-08 02:45:07 -0400
commit0ffa055b493dcb31a07fca1bbea9f4651320b762 (patch)
treebaaa3c8574e36f625e97b95d998debc1e07861e7
parent33a3d106b830bd541aeef660825c7c7115fa3d64 (diff)
downloadrt.equinox.bundles-0ffa055b493dcb31a07fca1bbea9f4651320b762.tar.gz
rt.equinox.bundles-0ffa055b493dcb31a07fca1bbea9f4651320b762.tar.xz
rt.equinox.bundles-0ffa055b493dcb31a07fca1bbea9f4651320b762.zip
Use StandardCharsets.
Instead of string name "UTF-8". Change-Id: I30b01c5ca8d8edaac08271b881f7c20de86bc447 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java5
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java2
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java6
-rw-r--r--bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.registry/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java5
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java3
-rw-r--r--bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/StorageUtils.java31
8 files changed, 16 insertions, 40 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java
index 96cb26ce..1005e85e 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 Raymond Augé and others.
+ * Copyright (c) 2016, 2019 Raymond Augé and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,7 @@ package org.eclipse.equinox.http.servlet.tests.util;
import java.io.IOException;
import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
@@ -71,7 +72,7 @@ public class DispatchResultServlet extends HttpServlet {
response.getWriter().write(writer.toString());
}
catch (IllegalStateException ise) {
- response.getOutputStream().write(writer.toString().getBytes("UTF8"));
+ response.getOutputStream().write(writer.toString().getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java
index caa91e65..776e469f 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java
@@ -373,7 +373,7 @@ public class ServletRequestAdvisor extends Object {
try {
output = connection.getOutputStream();
- writer = new PrintWriter(new OutputStreamWriter(output, "UTF-8"), true);
+ writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true);
writer.append("--" + boundary);
writer.append(CRLF);
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
index a0e6ea2f..356c07a5 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
@@ -1,6 +1,7 @@
package org.eclipse.equinox.metatype.impl;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
/*******************************************************************************
@@ -19,7 +20,6 @@ import java.util.*;
public class Persistence {
private static final int PERSISTENCE_VERSION = 0;
- private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
private static final byte NULL = 0;
private static final byte OBJECT = 1;
private static final byte INDEX = 2;
@@ -67,7 +67,7 @@ public class Persistence {
int length = in.readInt();
byte[] data = new byte[length];
in.readFully(data);
- string = new String(data, UTF_8);
+ string = new String(data, StandardCharsets.UTF_8);
} else {
string = in.readUTF();
}
@@ -149,7 +149,7 @@ public class Persistence {
if (string == null)
out.writeByte(NULL);
else {
- byte[] data = string.getBytes(UTF_8);
+ byte[] data = string.getBytes(StandardCharsets.UTF_8);
if (data.length > 65535) {
out.writeByte(LONG_STRING);
diff --git a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
index 04b15fcf..90bf9525 100644
--- a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.registry;singleton:=true
-Bundle-Version: 3.8.500.qualifier
+Bundle-Version: 3.8.600.qualifier
Bundle-Localization: plugin
Export-Package: org.eclipse.core.internal.adapter;x-internal:=true,
org.eclipse.core.internal.registry;x-friends:="org.eclipse.core.runtime",
diff --git a/bundles/org.eclipse.equinox.registry/pom.xml b/bundles/org.eclipse.equinox.registry/pom.xml
index 13a3c840..e55ad2b0 100644
--- a/bundles/org.eclipse.equinox.registry/pom.xml
+++ b/bundles/org.eclipse.equinox.registry/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.registry</artifactId>
- <version>3.8.500-SNAPSHOT</version>
+ <version>3.8.600-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java
index 1b6f5467..646e26fd 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java
@@ -15,6 +15,7 @@ package org.eclipse.core.internal.registry;
import java.io.*;
import java.lang.ref.SoftReference;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
@@ -68,8 +69,6 @@ public class TableReader {
static final String ORPHANS = ".orphans"; //$NON-NLS-1$
File orphansFile;
- static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
-
//Status code
private static final byte fileError = 0;
private static final boolean DEBUG = false; //TODO need to change
@@ -659,7 +658,7 @@ public class TableReader {
int length = in.readInt();
byte[] data = new byte[length];
in.readFully(data);
- value = new String(data, UTF_8);
+ value = new String(data, StandardCharsets.UTF_8);
} else {
value = in.readUTF();
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
index 11545e15..95189139 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
@@ -14,6 +14,7 @@
package org.eclipse.core.internal.registry;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
@@ -423,7 +424,7 @@ public class TableWriter {
if (string == null)
out.writeByte(TableReader.NULL);
else {
- byte[] data = string.getBytes(TableReader.UTF_8);
+ byte[] data = string.getBytes(StandardCharsets.UTF_8);
if (data.length > 65535) {
out.writeByte(TableReader.LOBJECT);
out.writeInt(data.length);
diff --git a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/StorageUtils.java b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/StorageUtils.java
index bf50a56e..b5e707ad 100644
--- a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/StorageUtils.java
+++ b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/StorageUtils.java
@@ -16,9 +16,9 @@ package org.eclipse.equinox.internal.security.storage;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
+import java.nio.charset.StandardCharsets;
import org.eclipse.equinox.internal.security.auth.AuthPlugin;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
-import org.eclipse.osgi.util.NLS;
/**
* PLEASE READ BEFORE CHANGING THIS FILE
@@ -37,17 +37,10 @@ import org.eclipse.osgi.util.NLS;
public class StorageUtils {
/**
- * Characters encoding used by the secure storage.
- */
- final public static String CHAR_ENCODING = "UTF-8"; //$NON-NLS-1$
-
- /**
* Default name of the storage file
*/
final private static String propertiesFileName = ".eclipse/org.eclipse.equinox.security/secure_storage"; //$NON-NLS-1$
- static private boolean firstCharsetException = true;
-
/**
* Default locations:
* 1) user.home
@@ -128,16 +121,7 @@ public class StorageUtils {
static public byte[] getBytes(String string) {
if (string == null)
return null;
- try {
- return string.getBytes(CHAR_ENCODING);
- } catch (UnsupportedEncodingException e) {
- if (firstCharsetException) { // log error once per session
- String msg = NLS.bind(SecAuthMessages.unsupoprtedCharEncoding, StorageUtils.CHAR_ENCODING);
- AuthPlugin.getDefault().logMessage(msg);
- firstCharsetException = false;
- }
- return string.getBytes();
- }
+ return string.getBytes(StandardCharsets.UTF_8);
}
/**
@@ -150,16 +134,7 @@ public class StorageUtils {
static public String getString(byte[] bytes) {
if (bytes == null)
return null;
- try {
- return new String(bytes, CHAR_ENCODING);
- } catch (UnsupportedEncodingException e) {
- if (firstCharsetException) { // log error once per session
- String msg = NLS.bind(SecAuthMessages.unsupoprtedCharEncoding, StorageUtils.CHAR_ENCODING);
- AuthPlugin.getDefault().logMessage(msg);
- firstCharsetException = false;
- }
- return new String(bytes);
- }
+ return new String(bytes, StandardCharsets.UTF_8);
}
}

Back to the top