Use StandardCharsets.

Instead of string name "UTF-8".

Change-Id: I30b01c5ca8d8edaac08271b881f7c20de86bc447
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
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 96cb26c..1005e85 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 @@
 
 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 @@
 			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 caa91e6..776e469 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 @@
 
 		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 a0e6ea2..356c07a 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 @@
 
 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 @@
 				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 @@
 			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 04b15fc..90bf952 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 @@
 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 13a3c84..e55ad2b 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 1b6f546..646e26f 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 @@
 
 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 @@
 	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 @@
 			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 11545e1..9518913 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 @@
 		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 bf50a56..b5e707a 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 @@
 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 @@
 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 @@
 	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 @@
 	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);
 	}
 
 }