jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1749200 - in /jmeter/trunk: src/components/org/apache/jmeter/assertions/ src/components/org/apache/jmeter/extractor/ src/components/org/apache/jmeter/visualizers/ src/components/org/apache/jmeter/visualizers/backend/graphite/ src/core/org/...
Date Sun, 19 Jun 2016 19:46:03 GMT
Author: fschumacher
Date: Sun Jun 19 19:46:02 2016
New Revision: 1749200

URL: http://svn.apache.org/viewvc?rev=1749200&view=rev
Log:
Use StandardCharsets to reduce the possibility of misspelling Charset names.

Bugzilla Id: 59722

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java
    jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
    jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXPath.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteMetricsSender.java
    jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
    jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java
    jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
    jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlDecode.java
    jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlEncode.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/JTidyHTMLParser.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/EncoderCache.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTP.java
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
    jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/HTMLAssertion.java Sun Jun 19
19:46:02 2016
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.Serializable;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.text.MessageFormat;
 
 import org.apache.commons.io.IOUtils;
@@ -101,8 +102,8 @@ public class HTMLAssertion extends Abstr
                 log.debug("xml mode: " + isXML());
             }
             tidy = new Tidy();
-            tidy.setInputEncoding("UTF8");
-            tidy.setOutputEncoding("UTF8");
+            tidy.setInputEncoding(StandardCharsets.UTF_8.name());
+            tidy.setOutputEncoding(StandardCharsets.UTF_8.name());
             tidy.setQuiet(false);
             tidy.setShowWarnings(true);
             tidy.setOnlyErrors(isErrorsOnly());

Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/XPathAssertion.java Sun Jun 19
19:46:02 2016
@@ -21,6 +21,7 @@ package org.apache.jmeter.assertions;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
 
 import javax.xml.parsers.ParserConfigurationException;
 
@@ -80,8 +81,8 @@ public class XPathAssertion extends Abst
         try {
             if (isScopeVariable()){
                 String inputString=getThreadContext().getVariables().get(getVariableName());
-                if(!StringUtils.isEmpty(inputString)) {
-                    responseData = inputString.getBytes("UTF-8");
+                if (!StringUtils.isEmpty(inputString)) {
+                    responseData = inputString.getBytes(StandardCharsets.UTF_8);
                 } 
             } else {
                 responseData = response.getResponseData();

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java Sun Jun 19
19:46:02 2016
@@ -20,7 +20,7 @@ package org.apache.jmeter.extractor;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -287,7 +287,7 @@ public class XPathExtractor extends Abst
      *
      */
     private Document parseResponse(String unicodeData)
-      throws UnsupportedEncodingException, IOException, ParserConfigurationException,SAXException,TidyException
+      throws IOException, ParserConfigurationException,SAXException,TidyException
     {
       //TODO: validate contentType for reasonable types?
 
@@ -295,7 +295,7 @@ public class XPathExtractor extends Abst
       //       Therefore we do byte -> unicode -> byte conversion
       //       to ensure UTF-8 encoding as required by XPathUtil
       // convert unicode String -> UTF-8 bytes
-      byte[] utf8data = unicodeData.getBytes("UTF-8"); // $NON-NLS-1$
+      byte[] utf8data = unicodeData.getBytes(StandardCharsets.UTF_8);
       ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
       boolean isXML = JOrphanUtils.isXML(utf8data);
       // this method assumes UTF-8 input data

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXPath.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXPath.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXPath.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXPath.java Sun Jun 19
19:46:02 2016
@@ -25,7 +25,7 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -160,7 +160,7 @@ public class RenderAsXPath implements Re
      *
      */
     private Document parseResponse(String unicodeData, XPathExtractor extractor)
-      throws UnsupportedEncodingException, IOException, ParserConfigurationException,SAXException,TidyException
+      throws IOException, ParserConfigurationException,SAXException,TidyException
     {
       //TODO: validate contentType for reasonable types?
 
@@ -168,7 +168,7 @@ public class RenderAsXPath implements Re
       //       Therefore we do byte -> unicode -> byte conversion
       //       to ensure UTF-8 encoding as required by XPathUtil
       // convert unicode String -> UTF-8 bytes
-      byte[] utf8data = unicodeData.getBytes("UTF-8"); // $NON-NLS-1$
+      byte[] utf8data = unicodeData.getBytes(StandardCharsets.UTF_8);
       ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
       boolean isXML = JOrphanUtils.isXML(utf8data);
       // this method assumes UTF-8 input data

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteMetricsSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteMetricsSender.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteMetricsSender.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteMetricsSender.java
Sun Jun 19 19:46:02 2016
@@ -18,6 +18,8 @@
 
 package org.apache.jmeter.visualizers.backend.graphite;
 
+import java.nio.charset.StandardCharsets;
+
 /**
  * @since 2.13
  */
@@ -26,7 +28,7 @@ interface GraphiteMetricsSender {
     int SOCKET_TIMEOUT = 1000;
 
 
-    String CHARSET_NAME = "UTF-8"; //$NON-NLS-1$
+    String CHARSET_NAME = StandardCharsets.UTF_8.name();
 
     final class MetricTuple {
         String name;

Modified: jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java Sun Jun 19 19:46:02
2016
@@ -31,6 +31,7 @@ import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.RandomAccessFile;
 import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -466,7 +467,7 @@ public class ResultCollector extends Abs
                 }
             }
             writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(new
FileOutputStream(filename,
-                    trimmed)), SaveService.getFileEncoding("UTF-8")), SAVING_AUTOFLUSH);
// $NON-NLS-1$
+                    trimmed)), SaveService.getFileEncoding(StandardCharsets.UTF_8.name())),
SAVING_AUTOFLUSH);
             log.debug("Opened file: "+filename);
             files.put(filename, new FileEntry(writer, saveConfig));
         } else {

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Sun Jun 19 19:46:02
2016
@@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingExcept
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -54,7 +55,7 @@ public class SampleResult implements Ser
      * The default encoding to be used if not overridden.
      * The value is ISO-8859-1.
      */
-    public static final String DEFAULT_HTTP_ENCODING = "ISO-8859-1";  // $NON-NLS-1$
+    public static final String DEFAULT_HTTP_ENCODING = StandardCharsets.ISO_8859_1.name();
 
     // Bug 33196 - encoding ISO-8859-1 is only suitable for Western countries
     // However the suggested System.getProperty("file.encoding") is Cp1252 on

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java Sun Jun 19 19:46:02 2016
@@ -25,6 +25,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -138,7 +139,7 @@ public final class CSVSaveService {
         final boolean successOnly = resultCollector.isSuccessOnlyLogging();
         try {
             dataReader = new BufferedReader(new InputStreamReader(
-                    new FileInputStream(filename), SaveService.getFileEncoding("UTF-8")));

+                    new FileInputStream(filename), SaveService.getFileEncoding(StandardCharsets.UTF_8.name())));
             dataReader.mark(400);// Enough to read the header column names
             // Get the first line, and see if it is the header
             String line = dataReader.readLine();

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/converters/ConversionHelp.java Sun Jun 19
19:46:02 2016
@@ -24,6 +24,7 @@ package org.apache.jmeter.save.converter
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -44,7 +45,7 @@ import com.thoughtworks.xstream.io.Hiera
 public class ConversionHelp {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
-    private static final String CHAR_SET = "UTF-8"; //$NON-NLS-1$
+    private static final String CHAR_SET = StandardCharsets.UTF_8.name();
 
     // Attributes for TestElement and TestElementProperty
     // Must all be unique

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/XPathUtil.java Sun Jun 19 19:46:02 2016
@@ -25,6 +25,7 @@ import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -219,8 +220,8 @@ public class XPathUtil {
      */
     public static Tidy makeTidyParser(boolean quiet, boolean showWarnings, boolean isXml,
StringWriter stringWriter) {
         Tidy tidy = new Tidy();
-        tidy.setInputEncoding("UTF8");
-        tidy.setOutputEncoding("UTF8");
+        tidy.setInputEncoding(StandardCharsets.UTF_8.name());
+        tidy.setOutputEncoding(StandardCharsets.UTF_8.name());
         tidy.setQuiet(quiet);
         tidy.setShowWarnings(showWarnings);
         tidy.setMakeClean(true);

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlDecode.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlDecode.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlDecode.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlDecode.java Sun Jun 19 19:46:02
2016
@@ -21,6 +21,7 @@ package org.apache.jmeter.functions;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
@@ -37,7 +38,7 @@ import org.apache.jmeter.util.JMeterUtil
  */
 public class UrlDecode extends AbstractFunction {
 
-    private static final String CHARSET_ENCODING = "UTF-8"; //$NON-NLS-1$
+    private static final String CHARSET_ENCODING = StandardCharsets.UTF_8.name();
     
     private static final List<String> desc = new LinkedList<>();
 

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlEncode.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlEncode.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlEncode.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/UrlEncode.java Sun Jun 19 19:46:02
2016
@@ -21,6 +21,7 @@ package org.apache.jmeter.functions;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
@@ -37,7 +38,7 @@ import org.apache.jmeter.util.JMeterUtil
  */
 public class UrlEncode extends AbstractFunction {
 
-    private static final String CHARSET_ENCODING = "UTF-8"; //$NON-NLS-1$
+    private static final String CHARSET_ENCODING = StandardCharsets.UTF_8.name();
     
     private static final List<String> desc = new LinkedList<>();
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
Sun Jun 19 19:46:02 2016
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.net.Socket;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.concurrent.TimeUnit;
 
@@ -57,7 +58,7 @@ import org.apache.oro.text.regex.Perl5Ma
 public class HttpMirrorThread implements Runnable {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
-    private static final String ISO_8859_1 = "ISO-8859-1"; //$NON-NLS-1$
+    private static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name();
     private static final byte[] CRLF = { 0x0d, 0x0a };
 
     private static final String REDIRECT = "redirect"; //$NON-NLS-1$

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/HtmlParsingUtils.java
Sun Jun 19 19:46:02 2016
@@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingExcept
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -74,7 +75,7 @@ public final class HtmlParsingUtils {
     {
         String query = null;
         try {
-            query = URLDecoder.decode(newLink.getQueryString(), "UTF-8"); // $NON-NLS-1$
+            query = URLDecoder.decode(newLink.getQueryString(), StandardCharsets.UTF_8.name());
         } catch (UnsupportedEncodingException e) {
             // UTF-8 unsupported? You must be joking!
             log.error("UTF-8 encoding not supported!");
@@ -204,8 +205,8 @@ public final class HtmlParsingUtils {
     public static Tidy getParser() {
         log.debug("Start : getParser1");
         Tidy tidy = new Tidy();
-        tidy.setInputEncoding("UTF8");
-        tidy.setOutputEncoding("UTF8");
+        tidy.setInputEncoding(StandardCharsets.UTF_8.name());
+        tidy.setOutputEncoding(StandardCharsets.UTF_8.name());
         tidy.setQuiet(true);
         tidy.setShowWarnings(false);
 
@@ -228,21 +229,19 @@ public final class HtmlParsingUtils {
     public static Node getDOM(String text) {
         log.debug("Start : getDOM1");
 
-        try {
-            Node node = getParser().parseDOM(new ByteArrayInputStream(text.getBytes("UTF-8")),
null);// $NON-NLS-1$
+        Node node = getParser()
+                .parseDOM(
+                        new ByteArrayInputStream(
+                                text.getBytes(StandardCharsets.UTF_8)), null);
 
-            if (log.isDebugEnabled()) {
-                log.debug("node : " + node);
-            }
+        if (log.isDebugEnabled()) {
+            log.debug("node : " + node);
+        }
 
-            log.debug("End : getDOM1");
+        log.debug("End : getDOM1");
+
+        return node;
 
-            return node;
-        } catch (UnsupportedEncodingException e) {
-            log.error("getDOM1 : Unsupported encoding exception - " + e);
-            log.debug("End : getDOM1");
-            throw new RuntimeException("UTF-8 encoding failed", e);
-        }
     }
 
     public static Document createEmptyDoc() {

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/JTidyHTMLParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/JTidyHTMLParser.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/JTidyHTMLParser.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/JTidyHTMLParser.java
Sun Jun 19 19:46:02 2016
@@ -21,6 +21,7 @@ package org.apache.jmeter.protocol.http.
 import java.io.ByteArrayInputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 
 import org.apache.commons.lang3.StringUtils;
@@ -211,7 +212,7 @@ class JTidyHTMLParser extends HTMLParser
         log.debug("Start : getParser");
         Tidy tidy = new Tidy();
         tidy.setInputEncoding(encoding);
-        tidy.setOutputEncoding("UTF8");
+        tidy.setOutputEncoding(StandardCharsets.UTF_8.name());
         tidy.setQuiet(true);
         tidy.setShowWarnings(false);
         if (log.isDebugEnabled()) {

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
Sun Jun 19 19:46:02 2016
@@ -27,6 +27,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLConnection;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.jmeter.protocol.http.util.HTTPArgument;
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
@@ -49,7 +50,7 @@ public class PostWriter {
 
     private static final byte[] CRLF = { 0x0d, 0x0A };
 
-    public static final String ENCODING = "ISO-8859-1"; // $NON-NLS-1$
+    public static final String ENCODING = StandardCharsets.ISO_8859_1.name();
 
     /** The form data that is going to be sent as url encoded */
     protected byte[] formDataUrlEncoded;

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
Sun Jun 19 19:46:02 2016
@@ -25,6 +25,7 @@ import java.net.URL;
 import java.net.URLDecoder;
 import java.nio.charset.Charset;
 import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -127,7 +128,7 @@ public class ConversionUtils {
      * @throws Exception when given <code>url</code> leads to a malformed URL
or URI
      */
     public static String escapeIllegalURLCharacters(String url) throws Exception{
-        String decodeUrl = URLDecoder.decode(url,"UTF-8");
+        String decodeUrl = URLDecoder.decode(url,StandardCharsets.UTF_8.name());
         URL urlString = new URL(decodeUrl);
         URI uri = new URI(urlString.getProtocol(), urlString.getUserInfo(), urlString.getHost(),
urlString.getPort(), urlString.getPath(), urlString.getQuery(), urlString.getRef());
         return uri.toString();

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/EncoderCache.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/EncoderCache.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/EncoderCache.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/EncoderCache.java
Sun Jun 19 19:46:02 2016
@@ -20,6 +20,7 @@ package org.apache.jmeter.protocol.http.
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.oro.util.Cache;
 import org.apache.oro.util.CacheLRU;
@@ -27,7 +28,7 @@ import org.apache.oro.util.CacheLRU;
 public class EncoderCache {
 
     /** The encoding which should be usd for URLs, according to HTTP specification */
-    public static final String URL_ARGUMENT_ENCODING = "UTF-8";
+    public static final String URL_ARGUMENT_ENCODING = StandardCharsets.UTF_8.name();
 
     private Cache cache;
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
Sun Jun 19 19:46:02 2016
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -517,7 +518,7 @@ public class TCLogParser implements LogP
         } else {
             if (decode) {
                 try {
-                    value = URLDecoder.decode(value,"UTF-8");
+                    value = URLDecoder.decode(value, StandardCharsets.UTF_8.name());
                 } catch (UnsupportedEncodingException e) {
                     log.warn(e.getMessage());
                 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTP.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTP.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTP.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/visualizers/RequestViewHTTP.java
Sun Jun 19 19:46:02 2016
@@ -23,6 +23,7 @@ import java.awt.Component;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -67,7 +68,7 @@ public class RequestViewHTTP implements
 
     private static final String KEY_LABEL = "view_results_table_request_tab_http"; //$NON-NLS-1$
     
-    private static final String CHARSET_DECODE = "ISO-8859-1"; //$NON-NLS-1$
+    private static final String CHARSET_DECODE = StandardCharsets.ISO_8859_1.name();
     
     private static final String PARAM_CONCATENATE = "&"; //$NON-NLS-1$
 

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
Sun Jun 19 19:46:02 2016
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.Date;
@@ -77,7 +78,7 @@ public abstract class AbstractJDBCTestEl
     private static final String OUT = "OUT"; // $NON-NLS-1$
 
     // TODO - should the encoding be configurable?
-    protected static final String ENCODING = "UTF-8"; // $NON-NLS-1$
+    protected static final String ENCODING = StandardCharsets.UTF_8.name();
 
     // key: name (lowercase) from java.sql.Types; entry: corresponding int value
     private static final Map<String, Integer> mapJdbcNameToInt;
@@ -153,7 +154,7 @@ public abstract class AbstractJDBCTestEl
      * @throws IOException when I/O error occurs
      * @throws UnsupportedOperationException if the user provided incorrect query type 
      */
-    protected byte[] execute(Connection conn) throws SQLException, UnsupportedEncodingException,
IOException, UnsupportedOperationException {
+    protected byte[] execute(Connection conn) throws SQLException, IOException, UnsupportedOperationException
{
         log.debug("executing jdbc");
         Statement stmt = null;
         

Modified: jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
(original)
+++ jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
Sun Jun 19 19:46:02 2016
@@ -18,7 +18,7 @@
 
 package org.apache.jmeter.protocol.ldap.sampler;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -1031,14 +1031,7 @@ public class LDAPExtSampler extends Abst
             return StringEscapeUtils.escapeXml10((String)value);
         }
         if (value instanceof byte[]) {
-            try
-            {
-                return StringEscapeUtils.escapeXml10(new String((byte[])value, "UTF-8"));
//$NON-NLS-1$
-            }
-            catch (UnsupportedEncodingException e)
-            {
-                log.error("this can't happen: UTF-8 character encoding not supported", e);
-            }
+            return StringEscapeUtils.escapeXml10(new String((byte[])value, StandardCharsets.UTF_8));
         }
         return StringEscapeUtils.escapeXml10(value.toString());
     }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1749200&r1=1749199&r2=1749200&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Jun 19 19:46:02 2016
@@ -158,6 +158,7 @@ Summary
     <li><bug>59657</bug>Only set font in JSyntaxTextArea, when property
<code>jsyntaxtextarea.font.family</code> is set.</li>
     <li><bug>59720</bug>Batch test file comparisons fail on Windows as
XML files are generated as EOL=LF</li>
     <li>Code cleanups. Patches by Graham Russell (graham at ham1.co.uk)</li>
+    <li><bug>59722</bug>Use StandardCharsets to reduce the possibility
of misspelling Charset names.</li>
 </ul>
 
  <!--  =================== Thanks =================== -->



Mime
View raw message