jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1824094 - in /jackrabbit/branches/2.14: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtu...
Date Tue, 13 Feb 2018 05:50:37 GMT
Author: reschke
Date: Tue Feb 13 05:50:36 2018
New Revision: 1824094

URL: http://svn.apache.org/viewvc?rev=1824094&view=rev
Log:
CR-4238: use StandardCharsets to avoid having to handle UnsupportedEncodingException (ported to 2.14)

Modified:
    jackrabbit/branches/2.14/   (props changed)
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueStore.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenProvider.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/PasswordUtility.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
    jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
    jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AbstractUserTest.java
    jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java
    jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java
    jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java
    jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java
    jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
    jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
    jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java
    jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
    jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
    jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
    jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
    jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/EncodeUtil.java

Propchange: jackrabbit/branches/2.14/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 13 05:50:36 2018
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1776907,1776911-1776912,1776914,1776918,1779166,1779460,1779614,1779632,1780208,1780220,1780406,1785225,1786325,1786330,1787043,1787381,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1793339,1796980,1797209,1797917,1798586,1799429,1799538,1799549,1799575,1800359,1800378,1800752,1802925,1802977,1807234,1807244,1808752,1808754,1809149,1809329,1809624,1810108,1811667,1812543,1812634,1812994,1814831,1817094,1817097-1817098,1817100,1817113,1817201,1817213,1817373,1817377,1818586,1819269,1819849,1820119,1820675,1821597
+/jackrabbit/trunk:1776907,1776911-1776912,1776914,1776918,1779166,1779460,1779614,1779632,1780208,1780220,1780406,1785225,1786325,1786330,1787043,1787381,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1793339,1796980,1797209,1797917,1798586,1799429,1799538,1799549,1799575,1800359,1800378,1800752,1802925,1802977,1807234,1807244,1808752,1808754,1809149,1809329,1809624,1810108,1811667,1812543,1812634,1812994,1814831,1817094,1817097-1817098,1817100,1817113,1817201,1817213,1817373,1817377,1818586,1819269,1819271,1819849,1820119,1820675,1821597

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Tue Feb 13 05:50:36 2018
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.util.ArrayList;
@@ -587,7 +588,7 @@ public class RepositoryImpl extends Abst
                 uuidFile.makeParentDirs();
                 OutputStream out = uuidFile.getOutputStream();
                 try {
-                    out.write(ROOT_NODE_ID.toString().getBytes("US-ASCII"));
+                    out.write(ROOT_NODE_ID.toString().getBytes(StandardCharsets.US_ASCII));
                     return ROOT_NODE_ID;
                 } finally {
                     IOUtils.closeQuietly(out);

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java Tue Feb 13 05:50:36 2018
@@ -22,6 +22,8 @@ import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
@@ -46,7 +48,7 @@ public class TestContentLoader {
     /**
      * The encoding of the test resources.
      */
-    private static final String ENCODING = "UTF-8";
+    private static final Charset ENCODING = StandardCharsets.UTF_8;
 
     public void loadTestContent(Session session) throws RepositoryException, IOException {
         JackrabbitWorkspace workspace =
@@ -151,7 +153,7 @@ public class TestContentLoader {
         Node resource = node.addNode("myResource", "nt:resource");
         // nt:resource not longer referenceable since JCR 2.0
         resource.addMixin("mix:referenceable");
-        resource.setProperty("jcr:encoding", ENCODING);
+        resource.setProperty("jcr:encoding", ENCODING.name());
         resource.setProperty("jcr:mimeType", "text/plain");
         resource.setProperty(
                 "jcr:data",
@@ -173,7 +175,7 @@ public class TestContentLoader {
         // NodeDefTest requires a test node with a mandatory child node
         JcrUtils.putFile(
                 node, "testFile", "text/plain",
-                new ByteArrayInputStream("Hello, World!".getBytes("UTF-8")));
+                new ByteArrayInputStream("Hello, World!".getBytes(StandardCharsets.UTF_8)));
     }
 
     /**
@@ -243,7 +245,7 @@ public class TestContentLoader {
         getOrAddNode(node, prefix + "MultiNoBin").setProperty(name, texts);
 
         Node resource = getOrAddNode(node, prefix + "MultiBin");
-        resource.setProperty("jcr:encoding", ENCODING);
+        resource.setProperty("jcr:encoding", ENCODING.name());
         resource.setProperty("jcr:mimeType", "text/plain");
         String[] values =
             new String[] { "SGVsbG8gd8O2cmxkLg==", "SGVsbG8gd8O2cmxkLg==" };
@@ -253,7 +255,7 @@ public class TestContentLoader {
         getOrAddNode(node, prefix + "NoBin").setProperty(name,  "text 1");
 
         resource = getOrAddNode(node, "invalidBin");
-        resource.setProperty("jcr:encoding", ENCODING);
+        resource.setProperty("jcr:encoding", ENCODING.name());
         resource.setProperty("jcr:mimeType", "text/plain");
         byte[] bytes = "Hello w\u00F6rld.".getBytes(ENCODING);
         resource.setProperty(name, new ByteArrayInputStream(bytes));

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java Tue Feb 13 05:50:36 2018
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -790,7 +791,7 @@ public class NodeTypeRegistry implements
         try {
             in = getClass().getClassLoader().getResourceAsStream(BUILTIN_NODETYPES_RESOURCE_PATH);
             if (in != null) {
-                Reader r = new InputStreamReader(in, "utf-8");
+                Reader r = new InputStreamReader(in, StandardCharsets.UTF_8);
                 store.loadCND(r, BUILTIN_NODETYPES_RESOURCE_PATH);
             }
         } catch (IOException ioe) {

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Tue Feb 13 05:50:36 2018
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.nodetype.virtual;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Collection;
@@ -251,12 +252,10 @@ public class VirtualNodeTypeStateProvide
     private static NodeId calculateStableId(String name) throws RepositoryException {
         try {
             MessageDigest md = MessageDigest.getInstance("MD5");
-            byte[] digest = md.digest(name.getBytes("utf-8"));
+            byte[] digest = md.digest(name.getBytes(StandardCharsets.UTF_8));
             return new NodeId(digest);
         } catch (NoSuchAlgorithmException e) {
             throw new RepositoryException(e);
-        } catch (UnsupportedEncodingException e) {
-            throw new RepositoryException(e);
         }
     }
 

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java Tue Feb 13 05:50:36 2018
@@ -21,6 +21,7 @@ import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.TimeZone;
@@ -368,7 +369,7 @@ public class BundleDumper {
                         int len = in.readInt();
                         byte[] bytes = new byte[len];
                         in.readFully(bytes);
-                        buffer.append("  value: string: ").append(new String(bytes, "UTF-8")).append("\n");
+                        buffer.append("  value: string: ").append(new String(bytes, StandardCharsets.UTF_8)).append("\n");
                     }
             }
         }
@@ -463,7 +464,7 @@ public class BundleDumper {
                     namespaces[ns] = uri;
                 }
             }
-            String local = new String(readBytes((b & 0x0f) + 1, 0x10), "UTF-8");
+            String local = new String(readBytes((b & 0x0f) + 1, 0x10), StandardCharsets.UTF_8);
             return uri + ":" + local;
         }
     }
@@ -603,7 +604,7 @@ public class BundleDumper {
 
     private String readString() throws IOException {
         if (version >= VERSION_3) {
-            return new String(readBytes(0, 0), "UTF-8");
+            return new String(readBytes(0, 0), StandardCharsets.UTF_8);
         } else {
             return in.readUTF();
         }

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java Tue Feb 13 05:50:36 2018
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.spi.commons
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.GregorianCalendar;
@@ -410,7 +411,7 @@ class BundleReader {
                     int len = in.readInt();
                     byte[] bytes = new byte[len];
                     in.readFully(bytes);
-                    String stringVal = new String(bytes, "UTF-8");
+                    String stringVal = new String(bytes, StandardCharsets.UTF_8);
 
                     // https://issues.apache.org/jira/browse/JCR-3083
                     if (PropertyType.DATE == entry.getType()) {
@@ -518,7 +519,7 @@ class BundleReader {
                 }
             }
 
-            String local = new String(readBytes((b & 0x0f) + 1, 0x10), "UTF-8");
+            String local = new String(readBytes((b & 0x0f) + 1, 0x10), StandardCharsets.UTF_8);
 
             return NameFactoryImpl.getInstance().create(uri, local);
         }
@@ -659,7 +660,7 @@ class BundleReader {
 
     private String readString() throws IOException {
         if (version >= BundleBinding.VERSION_3) {
-            return new String(readBytes(0, 0), "UTF-8");
+            return new String(readBytes(0, 0), StandardCharsets.UTF_8);
         } else {
             return in.readUTF();
         }

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java Tue Feb 13 05:50:36 2018
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.GregorianCalendar;
@@ -464,7 +465,7 @@ class BundleWriter {
             if (local.length() == 0) {
                 throw new IOException("Attempt to write an empty local name: " + name);
             }
-            byte[] bytes = local.getBytes("UTF-8");
+            byte[] bytes = local.getBytes(StandardCharsets.UTF_8);
             int len = Math.min(bytes.length - 1, 0x0f);
 
             out.writeByte(0x80 | ns << 4 | len);
@@ -707,7 +708,7 @@ class BundleWriter {
      * @throws IOException if an I/O error occurs
      */
     private void writeString(String value) throws IOException {
-        writeBytes(value.getBytes("UTF-8"), 0);
+        writeBytes(value.getBytes(StandardCharsets.UTF_8), 0);
     }
 
     /**

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java Tue Feb 13 05:50:36 2018
@@ -34,6 +34,8 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -55,7 +57,7 @@ public final class Serializer {
     /**
      * encoding used for serializing String values
      */
-    private static final String ENCODING = "UTF-8";
+    private static final Charset ENCODING = StandardCharsets.UTF_8;
 
     /**
      * Serializes the specified <code>NodeState</code> object to the given

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java Tue Feb 13 05:50:36 2018
@@ -53,6 +53,8 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
@@ -80,7 +82,7 @@ public class XMLPersistenceManager exten
     /**
      * The default encoding used in serialization
      */
-    public static final String DEFAULT_ENCODING = "UTF-8";
+    public static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;
 
     /**
      * The XML elements and attributes used in serialization
@@ -544,19 +546,11 @@ public class XMLPersistenceManager exten
             OutputStream os = nodeFile.getOutputStream();
             Writer writer = null;
             try {
-                String encoding = DEFAULT_ENCODING;
-                try {
-                    writer = new BufferedWriter(new OutputStreamWriter(os, encoding));
-                } catch (UnsupportedEncodingException e) {
-                    // should never get here!
-                    OutputStreamWriter osw = new OutputStreamWriter(os);
-                    encoding = osw.getEncoding();
-                    writer = new BufferedWriter(osw);
-                }
+                writer = new BufferedWriter(new OutputStreamWriter(os, DEFAULT_ENCODING));
 
                 String parentId = (state.getParentId() == null) ? "" : state.getParentId().toString();
                 String encodedNodeType = Text.encodeIllegalXMLCharacters(state.getNodeTypeName().toString());
-                writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
+                writer.write("<?xml version=\"1.0\" encoding=\"" + DEFAULT_ENCODING.name() + "\"?>\n");
                 writer.write("<" + NODE_ELEMENT + " "
                         + UUID_ATTRIBUTE + "=\"" + id + "\" "
                         + PARENTUUID_ATTRIBUTE + "=\"" + parentId + "\" "
@@ -618,15 +612,7 @@ public class XMLPersistenceManager exten
             // write property state to xml file
             Writer writer = null;
             try {
-                String encoding = DEFAULT_ENCODING;
-                try {
-                    writer = new BufferedWriter(new OutputStreamWriter(os, encoding));
-                } catch (UnsupportedEncodingException e) {
-                    // should never get here!
-                    OutputStreamWriter osw = new OutputStreamWriter(os);
-                    encoding = osw.getEncoding();
-                    writer = new BufferedWriter(osw);
-                }
+                writer = new BufferedWriter(new OutputStreamWriter(os, DEFAULT_ENCODING));
 
                 String typeName;
                 int type = state.getType();
@@ -637,7 +623,7 @@ public class XMLPersistenceManager exten
                     throw new ItemStateException("unexpected property-type ordinal: " + type, iae);
                 }
 
-                writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
+                writer.write("<?xml version=\"1.0\" encoding=\"" + DEFAULT_ENCODING.name() + "\"?>\n");
                 writer.write("<" + PROPERTY_ELEMENT + " "
                         + NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
                         + PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId() + "\" "
@@ -815,16 +801,9 @@ public class XMLPersistenceManager exten
             OutputStream os = refsFile.getOutputStream();
             BufferedWriter writer = null;
             try {
-                String encoding = DEFAULT_ENCODING;
-                try {
-                    writer = new BufferedWriter(new OutputStreamWriter(os, encoding));
-                } catch (UnsupportedEncodingException e) {
-                    // should never get here!
-                    OutputStreamWriter osw = new OutputStreamWriter(os);
-                    encoding = osw.getEncoding();
-                    writer = new BufferedWriter(osw);
-                }
-                writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
+                writer = new BufferedWriter(new OutputStreamWriter(os, DEFAULT_ENCODING));
+
+                writer.write("<?xml version=\"1.0\" encoding=\"" + DEFAULT_ENCODING.name() + "\"?>\n");
                 writer.write("<" + NODEREFERENCES_ELEMENT + " "
                         + TARGETID_ATTRIBUTE + "=\"" + refs.getTargetId() + "\">\n");
                 // write references (i.e. the id's of the REFERENCE properties)

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueStore.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueStore.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueStore.java Tue Feb 13 05:50:36 2018
@@ -25,6 +25,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Set;
 import java.util.HashSet;
 
@@ -45,7 +47,7 @@ class IndexingQueueStore {
     /**
      * Encoding of the indexing queue store.
      */
-    private static final String ENCODING = "UTF-8";
+    private static final Charset ENCODING = StandardCharsets.UTF_8;
 
     /**
      * Operation identifier for an added node.

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenProvider.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenProvider.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/token/TokenProvider.java Tue Feb 13 05:50:36 2018
@@ -175,9 +175,6 @@ public class TokenProvider extends Prote
             } catch (NoSuchAlgorithmException e) {
                 // error while generating login token
                 log.error(error, e);
-            } catch (UnsupportedEncodingException e) {
-                // error while generating login token
-                log.error(error, e);
             } catch (AccessDeniedException e) {
                 log.warn(error, e);
             }

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/PasswordUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/PasswordUtility.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/PasswordUtility.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/PasswordUtility.java Tue Feb 13 05:50:36 2018
@@ -17,7 +17,8 @@
 
 package org.apache.jackrabbit.core.security.user;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
@@ -35,7 +36,7 @@ public class PasswordUtility {
 
     private static final char DELIMITER = '-';
     private static final int NO_ITERATIONS = 1;    
-    private static final String ENCODING = "UTF-8";
+    private static final Charset ENCODING = StandardCharsets.UTF_8;
 
     public static final String DEFAULT_ALGORITHM = "SHA-256";
     public static final int DEFAULT_SALT_SIZE = 8;
@@ -53,9 +54,8 @@ public class PasswordUtility {
      * @param password The password to be hashed.
      * @return The password hash.
      * @throws NoSuchAlgorithmException If {@link #DEFAULT_ALGORITHM} is not supported.
-     * @throws UnsupportedEncodingException If utf-8 is not supported.
      */
-    public static String buildPasswordHash(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+    public static String buildPasswordHash(String password) throws NoSuchAlgorithmException {
         return buildPasswordHash(password, DEFAULT_ALGORITHM, DEFAULT_SALT_SIZE, DEFAULT_ITERATIONS);
     }
 
@@ -71,10 +71,9 @@ public class PasswordUtility {
      * integer is lower than 1 the {@link #DEFAULT_ITERATIONS default} value is used.
      * @return  The password hash.
      * @throws NoSuchAlgorithmException If the specified algorithm is not supported.
-     * @throws UnsupportedEncodingException If utf-8 is not supported.
      */
     public static String buildPasswordHash(String password, String algorithm,
-                                           int saltSize, int iterations) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+                                           int saltSize, int iterations) throws NoSuchAlgorithmException {
         if (password == null) {
             throw new IllegalArgumentException("Password may not be null.");
         }
@@ -127,8 +126,6 @@ public class PasswordUtility {
             } // hashedPassword is plaintext -> return false
         } catch (NoSuchAlgorithmException e) {
             log.warn(e.getMessage());
-        } catch (UnsupportedEncodingException e) {
-            log.warn(e.getMessage());
         }
         return false;
     }
@@ -164,7 +161,7 @@ public class PasswordUtility {
 
     //------------------------------------------------------------< private >---
 
-    private static String generateHash(String pwd, String algorithm, String salt, int iterations) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+    private static String generateHash(String pwd, String algorithm, String salt, int iterations) throws NoSuchAlgorithmException {
         StringBuilder passwordHash = new StringBuilder();
         passwordHash.append('{').append(algorithm).append('}');
         if (salt != null && salt.length() > 0) {
@@ -196,7 +193,7 @@ public class PasswordUtility {
         return res.toString();
     }
 
-    private static String generateDigest(String data, String algorithm, int iterations) throws UnsupportedEncodingException, NoSuchAlgorithmException {
+    private static String generateDigest(String data, String algorithm, int iterations) throws NoSuchAlgorithmException {
         byte[] bytes = data.getBytes(ENCODING);
         MessageDigest md = MessageDigest.getInstance(algorithm);
 

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java Tue Feb 13 05:50:36 2018
@@ -52,6 +52,7 @@ import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.security.NoSuchAlgorithmException;
 import java.security.Principal;
 import java.util.HashSet;
@@ -773,8 +774,6 @@ public class UserManagerImpl extends Pro
                 pwHash = PasswordUtility.buildPasswordHash(password, algorithm, PasswordUtility.DEFAULT_SALT_SIZE, iterations);
             } catch (NoSuchAlgorithmException e) {
                 throw new RepositoryException(e);
-            } catch (UnsupportedEncodingException e) {
-                throw new RepositoryException(e);
             }
         } else {
             pwHash = password;
@@ -1052,15 +1051,10 @@ public class UserManagerImpl extends Pro
      *
      * @param id The user/group id that needs to be converted to a valid NodeId.
      * @return a new <code>NodeId</code>.
-     * @throws RepositoryException If an error occurs.
      */
-    private NodeId buildNodeId(String id) throws RepositoryException {
-        try {
-            UUID uuid = UUID.nameUUIDFromBytes(id.toLowerCase().getBytes("UTF-8"));
-            return new NodeId(uuid);
-        } catch (UnsupportedEncodingException e) {
-            throw new RepositoryException("Unexpected error while build ID hash", e);
-        }
+    private NodeId buildNodeId(String id) {
+        UUID uuid = UUID.nameUUIDFromBytes(id.toLowerCase().getBytes(StandardCharsets.UTF_8));
+        return new NodeId(uuid);
     }
 
     /**

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java Tue Feb 13 05:50:36 2018
@@ -45,6 +45,7 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 
 /**
  * <code>BufferedStringValue</code> represents an appendable
@@ -122,7 +123,7 @@ class BufferedStringValue implements Tex
         if (base64) {
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             Base64.decode(value, out);
-            value = new String(out.toByteArray(), "UTF-8");
+            value = new String(out.toByteArray(), StandardCharsets.UTF_8);
         }
         return value;
     }
@@ -161,7 +162,7 @@ class BufferedStringValue implements Tex
 
     private Reader openReader() throws IOException {
         return new InputStreamReader(
-                new BufferedInputStream(new FileInputStream(tmpFile)), "UTF-8");
+                new BufferedInputStream(new FileInputStream(tmpFile)), StandardCharsets.UTF_8);
     }
 
     /**
@@ -199,7 +200,7 @@ class BufferedStringValue implements Tex
                 TransientFileFactory fileFactory = TransientFileFactory.getInstance();
                 tmpFile = fileFactory.createTransientFile("txt", null, null);
                 BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(tmpFile));
-                writer = new OutputStreamWriter(fout, "UTF-8");
+                writer = new OutputStreamWriter(fout, StandardCharsets.UTF_8);
                 writer.write(buffer.toString());
                 writer.write(chars, start, len);
                 // reset the in-memory buffer

Modified: jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AbstractUserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AbstractUserTest.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AbstractUserTest.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AbstractUserTest.java Tue Feb 13 05:50:36 2018
@@ -31,6 +31,7 @@ import javax.jcr.SimpleCredentials;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.security.auth.Subject;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.security.NoSuchAlgorithmException;
 import java.security.Principal;
 import java.util.Collections;
@@ -103,12 +104,10 @@ public abstract class AbstractUserTest e
             try {
                 StringBuilder password = new StringBuilder();
                 password.append("{").append(SecurityConstants.DEFAULT_DIGEST).append("}");
-                password.append(Text.digest(SecurityConstants.DEFAULT_DIGEST, uid.getBytes("UTF-8")));
+                password.append(Text.digest(SecurityConstants.DEFAULT_DIGEST, uid.getBytes(StandardCharsets.UTF_8)));
                 return password.toString();
             } catch (NoSuchAlgorithmException e) {
                 throw new IllegalArgumentException(e.toString());
-            } catch (UnsupportedEncodingException e) {
-                throw new IllegalArgumentException(e.toString());
             }
         } else {
             return uid;

Modified: jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java Tue Feb 13 05:50:36 2018
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import java.nio.charset.StandardCharsets;
 import java.security.SecureRandom;
 
 import javax.crypto.Mac;
@@ -98,7 +99,7 @@ public abstract class AbstractDataStore
 
             Mac mac = Mac.getInstance(ALGORITHM);
             mac.init(new SecretKeySpec(getReferenceKey(), ALGORITHM));
-            byte[] hash = mac.doFinal(id.getBytes("UTF-8"));
+            byte[] hash = mac.doFinal(id.getBytes(StandardCharsets.UTF_8));
 
             return id + ':' + encodeHexString(hash);
         } catch (Exception e) {

Modified: jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java Tue Feb 13 05:50:36 2018
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.ref.WeakReference;
+import java.nio.charset.StandardCharsets;
 import java.security.DigestOutputStream;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -681,11 +682,7 @@ public abstract class CachingDataStore e
 
     @Override
     protected byte[] getOrCreateReferenceKey() throws DataStoreException {
-        try {
-            return secret.getBytes("UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new DataStoreException(e);
-        }
+        return secret.getBytes(StandardCharsets.UTF_8);
     }
 
     public Set<String> getPendingUploads() {

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java Tue Feb 13 05:50:36 2018
@@ -22,6 +22,7 @@ import java.io.OutputStreamWriter;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -98,13 +99,8 @@ public class ToXmlContentHandler extends
      * @param stream XML output stream
      */
     public ToXmlContentHandler(OutputStream stream) {
-        try {
-            this.writer = new OutputStreamWriter(stream, "UTF-8");
-            this.declaration = "version=\"1.0\" encoding=\"UTF-8\"";
-        } catch (UnsupportedEncodingException e) {
-            // should never happen
-            throw new IllegalStateException("UTF-8 is not supported!");
-        }
+        this.writer = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
+        this.declaration = "version=\"1.0\" encoding=\"UTF-8\"";
     }
 
     /**

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java Tue Feb 13 05:50:36 2018
@@ -26,6 +26,7 @@ import java.io.Reader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.io.BufferedWriter;
+import java.nio.charset.StandardCharsets;
 
 /**
  * <code>Base64</code> provides Base64 encoding/decoding of strings and streams.
@@ -239,7 +240,7 @@ public class Base64 {
     public static String encode(String data) {
         try {
             StringWriter buffer = new StringWriter();
-            byte[] b = data.getBytes("UTF-8");
+            byte[] b = data.getBytes(StandardCharsets.UTF_8);
             encode(b, 0, b.length, buffer);
             return buffer.toString();
         } catch (IOException e) { // should never happen
@@ -261,7 +262,7 @@ public class Base64 {
         try {
             ByteArrayOutputStream buffer = new ByteArrayOutputStream();
             decode(data, buffer);
-            return new String(buffer.toByteArray(), "UTF-8");
+            return new String(buffer.toByteArray(), StandardCharsets.UTF_8);
         } catch (IllegalArgumentException e) {
             return data;
         } catch (IOException e) { // should never happen

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java Tue Feb 13 05:50:36 2018
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.util;
 
 import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
@@ -350,24 +351,20 @@ public class Text {
      * @throws NullPointerException if <code>string</code> is <code>null</code>.
      */
     public static String escape(String string, char escape, boolean isPath) {
-        try {
-            BitSet validChars = isPath ? URISaveEx : URISave;
-            byte[] bytes = string.getBytes("utf-8");
-            StringBuilder out = new StringBuilder(bytes.length);
-            for (byte aByte : bytes) {
-                int c = aByte & 0xff;
-                if (validChars.get(c) && c != escape) {
-                    out.append((char) c);
-                } else {
-                    out.append(escape);
-                    out.append(hexTable[(c >> 4) & 0x0f]);
-                    out.append(hexTable[(c) & 0x0f]);
-                }
+        BitSet validChars = isPath ? URISaveEx : URISave;
+        byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
+        StringBuilder out = new StringBuilder(bytes.length);
+        for (byte aByte : bytes) {
+            int c = aByte & 0xff;
+            if (validChars.get(c) && c != escape) {
+                out.append((char) c);
+            } else {
+                out.append(escape);
+                out.append(hexTable[(c >> 4) & 0x0f]);
+                out.append(hexTable[(c) & 0x0f]);
             }
-            return out.toString();
-        } catch (UnsupportedEncodingException e) {
-            throw new InternalError(e.toString());
         }
+        return out.toString();
     }
 
     /**
@@ -413,31 +410,26 @@ public class Text {
      *                                        escape character
      */
     public static String unescape(String string, char escape)  {
-        try {
-            byte[] utf8 = string.getBytes("utf-8");
+        byte[] utf8 = string.getBytes(StandardCharsets.UTF_8);
 
-            // Check whether escape occurs at invalid position
-            if ((utf8.length >= 1 && utf8[utf8.length - 1] == escape) ||
-                (utf8.length >= 2 && utf8[utf8.length - 2] == escape)) {
-                throw new IllegalArgumentException("Premature end of escape sequence at end of input");
-            }
+        // Check whether escape occurs at invalid position
+        if ((utf8.length >= 1 && utf8[utf8.length - 1] == escape) ||
+            (utf8.length >= 2 && utf8[utf8.length - 2] == escape)) {
+            throw new IllegalArgumentException("Premature end of escape sequence at end of input");
+        }
 
-            ByteArrayOutputStream out = new ByteArrayOutputStream(utf8.length);
-            for (int k = 0; k < utf8.length; k++) {
-                byte b = utf8[k];
-                if (b == escape) {
-                    out.write((decodeDigit(utf8[++k]) << 4) + decodeDigit(utf8[++k]));
-                }
-                else {
-                    out.write(b);
-                }
+        ByteArrayOutputStream out = new ByteArrayOutputStream(utf8.length);
+        for (int k = 0; k < utf8.length; k++) {
+            byte b = utf8[k];
+            if (b == escape) {
+                out.write((decodeDigit(utf8[++k]) << 4) + decodeDigit(utf8[++k]));
+            }
+            else {
+                out.write(b);
             }
-
-            return new String(out.toByteArray(), "utf-8");
-        }
-        catch (UnsupportedEncodingException e) {
-            throw new InternalError(e.toString());
         }
+
+        return new String(out.toByteArray(), StandardCharsets.UTF_8);
     }
 
     /**

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java Tue Feb 13 05:50:36 2018
@@ -52,6 +52,7 @@ import java.io.FilterInputStream;
 import java.io.OutputStream;
 import java.io.BufferedOutputStream;
 import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -738,7 +739,7 @@ public class ValueHelper {
         } else {
             String textVal = value.getString();
             if (enforceBase64) {
-                byte bytes[] = textVal.getBytes("UTF-8");
+                byte bytes[] = textVal.getBytes(StandardCharsets.UTF_8);
                 Base64.encode(bytes, 0, bytes.length, writer);
             }
             else {

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/AbstractValue.java Tue Feb 13 05:50:36 2018
@@ -23,6 +23,7 @@ import java.io.FilterInputStream;
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 
 import javax.jcr.Binary;
@@ -97,31 +98,27 @@ abstract class AbstractValue implements
      * by {@link #getString()}. Subclasses 
      */
     public Binary getBinary() throws RepositoryException {
-        try {
-            final byte[] value = getString().getBytes("UTF-8");
-            return new Binary() {
-                public int read(byte[] b, long position) {
-                    if (position >= value.length) {
-                        return -1;
-                    } else {
-                        int p = (int) position;
-                        int n = Math.min(b.length, value.length - p);
-                        System.arraycopy(value, p, b, 0, n);
-                        return n;
-                    }
-                }
-                public InputStream getStream() {
-                    return new ByteArrayInputStream(value);
-                }
-                public long getSize() {
-                    return value.length;
+        final byte[] value = getString().getBytes(StandardCharsets.UTF_8);
+        return new Binary() {
+            public int read(byte[] b, long position) {
+                if (position >= value.length) {
+                    return -1;
+                } else {
+                    int p = (int) position;
+                    int n = Math.min(b.length, value.length - p);
+                    System.arraycopy(value, p, b, 0, n);
+                    return n;
                 }
-                public void dispose() {
-                }
-            };
-        } catch (UnsupportedEncodingException e) {
-            throw new RepositoryException("UTF-8 is not supported", e);
-        }
+            }
+            public InputStream getStream() {
+                return new ByteArrayInputStream(value);
+            }
+            public long getSize() {
+                return value.length;
+            }
+            public void dispose() {
+            }
+        };
     }
 
     /**

Modified: jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/BinaryValue.java Tue Feb 13 05:50:36 2018
@@ -22,6 +22,7 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 
 import javax.jcr.Binary;
@@ -72,7 +73,7 @@ class BinaryValue implements Value, Seri
         try {
             InputStream stream = value.getStream();
             try {
-                Reader reader = new InputStreamReader(stream, "UTF-8");
+                Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
                 StringBuilder builder = new StringBuilder();
                 char[] buffer = new char[1024];
                 int n = reader.read(buffer);

Modified: jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java Tue Feb 13 05:50:36 2018
@@ -30,6 +30,7 @@ import java.util.Calendar;
 import java.util.TimeZone;
 import java.math.BigDecimal;
 import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -345,7 +346,7 @@ public abstract class AbstractQValue imp
             try {
                 InputStream stream = getStream();
                 try {
-                    Reader reader = new InputStreamReader(stream, "UTF-8");
+                    Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
                     Writer writer = new StringWriter();
                     char[] buffer = new char[1024];
                     int n = reader.read(buffer);

Modified: jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java Tue Feb 13 05:50:36 2018
@@ -17,10 +17,10 @@
 package org.apache.jackrabbit.spi.commons.value;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 
 import javax.jcr.Binary;
@@ -105,31 +105,27 @@ public final class QValueValue implement
         if (getType() == PropertyType.NAME || getType() == PropertyType.PATH) {
             // qualified name/path value needs to be resolved,
             // delegate conversion to getString() method
-            try {
-                final byte[] value = getString().getBytes("UTF-8");
-                return new Binary() {
-                    public int read(byte[] b, long position) {
-                        if (position >= value.length) {
-                            return -1;
-                        } else {
-                            int p = (int) position;
-                            int n = Math.min(b.length, value.length - p);
-                            System.arraycopy(value, p, b, 0, n);
-                            return n;
-                        }
+            final byte[] value = getString().getBytes(StandardCharsets.UTF_8);
+            return new Binary() {
+                public int read(byte[] b, long position) {
+                    if (position >= value.length) {
+                        return -1;
+                    } else {
+                        int p = (int) position;
+                        int n = Math.min(b.length, value.length - p);
+                        System.arraycopy(value, p, b, 0, n);
+                        return n;
                     }
-                    public InputStream getStream() {
-                        return new ByteArrayInputStream(value);
-                    }
-                    public long getSize() {
-                        return value.length;
-                    }
-                    public void dispose() {
-                    }
-                };
-            } catch (UnsupportedEncodingException ex) {
-                throw new RepositoryException("UTF-8 is not supported", ex);
-            }
+                }
+                public InputStream getStream() {
+                    return new ByteArrayInputStream(value);
+                }
+                public long getSize() {
+                    return value.length;
+                }
+                public void dispose() {
+                }
+            };
         } else {
             return qvalue.getBinary();
         }
@@ -163,11 +159,7 @@ public final class QValueValue implement
         if (stream == null) {
             if (getType() == PropertyType.NAME || getType() == PropertyType.PATH) {
                 // qualified name/path value needs to be resolved
-                try {
-                    stream = new ByteArrayInputStream(getString().getBytes("UTF-8"));
-                } catch (UnsupportedEncodingException ex) {
-                    throw new RepositoryException("UTF-8 is not supported", ex);
-                }
+                stream = new ByteArrayInputStream(getString().getBytes(StandardCharsets.UTF_8));
             } else {
                 stream = qvalue.getStream();
             }

Modified: jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java Tue Feb 13 05:50:36 2018
@@ -42,6 +42,7 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 
 /**
@@ -141,7 +142,7 @@ public class WebdavResponseImpl implemen
                 // JCR-2636: Need to use an explicit OutputStreamWriter
                 // instead of relying on the built-in UTF-8 serialization
                 // to avoid problems with surrogate pairs on Sun JRE 1.5.
-                Writer writer = new OutputStreamWriter(out, "UTF-8");
+                Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
                 DomUtil.transformDocument(doc, writer);
                 writer.flush();
 

Modified: jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/EncodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/EncodeUtil.java?rev=1824094&r1=1824093&r2=1824094&view=diff
==============================================================================
--- jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/EncodeUtil.java (original)
+++ jackrabbit/branches/2.14/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/util/EncodeUtil.java Tue Feb 13 05:50:36 2018
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.BitSet;
 
 /**
@@ -126,24 +127,20 @@ public final class EncodeUtil {
      * @throws NullPointerException if <code>string</code> is <code>null</code>.
      */
     private static String escape(String string, char escape, boolean isPath) {
-        try {
-            BitSet validChars = isPath ? URISaveEx : URISave;
-            byte[] bytes = string.getBytes("utf-8");
-            StringBuffer out = new StringBuffer(bytes.length);
-            for (byte aByte : bytes) {
-                int c = aByte & 0xff;
-                if (validChars.get(c) && c != escape) {
-                    out.append((char) c);
-                } else {
-                    out.append(escape);
-                    out.append(hexTable[(c >> 4) & 0x0f]);
-                    out.append(hexTable[(c) & 0x0f]);
-                }
+        BitSet validChars = isPath ? URISaveEx : URISave;
+        byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
+        StringBuffer out = new StringBuffer(bytes.length);
+        for (byte aByte : bytes) {
+            int c = aByte & 0xff;
+            if (validChars.get(c) && c != escape) {
+                out.append((char) c);
+            } else {
+                out.append(escape);
+                out.append(hexTable[(c >> 4) & 0x0f]);
+                out.append(hexTable[(c) & 0x0f]);
             }
-            return out.toString();
-        } catch (UnsupportedEncodingException e) {
-            throw new InternalError(e.toString());
         }
+        return out.toString();
     }
 
     /**
@@ -178,31 +175,26 @@ public final class EncodeUtil {
      *                                        escape character
      */
     private static String unescape(String string, char escape)  {
-        try {
-            byte[] utf8 = string.getBytes("utf-8");
+        byte[] utf8 = string.getBytes(StandardCharsets.UTF_8);
 
-            // Check whether escape occurs at invalid position
-            if ((utf8.length >= 1 && utf8[utf8.length - 1] == escape) ||
-                (utf8.length >= 2 && utf8[utf8.length - 2] == escape)) {
-                throw new IllegalArgumentException("Premature end of escape sequence at end of input");
-            }
+        // Check whether escape occurs at invalid position
+        if ((utf8.length >= 1 && utf8[utf8.length - 1] == escape) ||
+            (utf8.length >= 2 && utf8[utf8.length - 2] == escape)) {
+            throw new IllegalArgumentException("Premature end of escape sequence at end of input");
+        }
 
-            ByteArrayOutputStream out = new ByteArrayOutputStream(utf8.length);
-            for (int k = 0; k < utf8.length; k++) {
-                byte b = utf8[k];
-                if (b == escape) {
-                    out.write((decodeDigit(utf8[++k]) << 4) + decodeDigit(utf8[++k]));
-                }
-                else {
-                    out.write(b);
-                }
+        ByteArrayOutputStream out = new ByteArrayOutputStream(utf8.length);
+        for (int k = 0; k < utf8.length; k++) {
+            byte b = utf8[k];
+            if (b == escape) {
+                out.write((decodeDigit(utf8[++k]) << 4) + decodeDigit(utf8[++k]));
+            }
+            else {
+                out.write(b);
             }
-
-            return new String(out.toByteArray(), "utf-8");
-        }
-        catch (UnsupportedEncodingException e) {
-            throw new InternalError(e.toString());
         }
+
+        return new String(out.toByteArray(), StandardCharsets.UTF_8);
     }
     
     private static byte decodeDigit(byte b) {



Mime
View raw message