You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/03/31 22:35:17 UTC

svn commit: r1583449 [2/2] - in /lucene/dev/trunk: lucene/core/src/java/org/apache/lucene/codecs/ lucene/core/src/java/org/apache/lucene/util/ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/ lucene/spatial/src/test/org/apache/lucene/spat...

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTestBase.java Mon Mar 31 20:35:16 2014
@@ -18,6 +18,7 @@ package org.apache.solr.servlet;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 
 import org.apache.http.HttpResponse;
@@ -49,7 +50,7 @@ public abstract class CacheHeaderTestBas
     }
 
     URI uri = URI.create(httpserver.getBaseURL() + "/select?" +
-                         URLEncodedUtils.format(qparams, "UTF-8"));
+                         URLEncodedUtils.format(qparams, StandardCharsets.UTF_8));
    
     if ("GET".equals(method)) {
       m = new HttpGet(uri);
@@ -72,7 +73,7 @@ public abstract class CacheHeaderTestBas
     }
 
     URI uri = URI.create(httpserver.getBaseURL() + "/update?" + 
-                         URLEncodedUtils.format(qparams, "UTF-8"));
+                         URLEncodedUtils.format(qparams, StandardCharsets.UTF_8));
     
     if ("GET".equals(method)) {
       m=new HttpGet(uri);

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java Mon Mar 31 20:35:16 2014
@@ -18,6 +18,7 @@ package org.apache.solr.update;
  */
 
 import com.google.common.collect.Lists;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.Term;
@@ -39,6 +40,7 @@ import org.junit.Test;
 
 import java.io.File;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
@@ -326,9 +328,9 @@ public class SolrIndexSplitterTest exten
 
   private List<DocRouter.Range> getRanges(String id1, String id2) throws UnsupportedEncodingException {
     // find minHash/maxHash hash ranges
-    byte[] bytes = id1.getBytes("UTF-8");
+    byte[] bytes = id1.getBytes(StandardCharsets.UTF_8);
     int minHash = Hash.murmurhash3_x86_32(bytes, 0, bytes.length, 0);
-    bytes = id2.getBytes("UTF-8");
+    bytes = id2.getBytes(StandardCharsets.UTF_8);
     int maxHash = Hash.murmurhash3_x86_32(bytes, 0, bytes.length, 0);
 
     if (minHash > maxHash)  {

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java Mon Mar 31 20:35:16 2014
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
@@ -213,7 +214,7 @@ public class SimplePostToolTest extends 
       sb.append("Disallow: /disallow # Disallow this path\n");
       sb.append("Disallow: /nonexistingpath # Disallow this path\n");
       this.robotsCache.put("[ff01::114]", SimplePostTool.pageFetcher.
-          parseRobotsTxt(new ByteArrayInputStream(sb.toString().getBytes("UTF-8"))));
+          parseRobotsTxt(new ByteArrayInputStream(sb.toString().getBytes(StandardCharsets.UTF_8))));
     }
     
     @Override
@@ -225,11 +226,7 @@ public class SimplePostToolTest extends 
       }
       res.httpStatus = 200;
       res.contentType = "text/html";
-      try {
-        res.content = htmlMap.get(u.toString()).getBytes("UTF-8");
-      } catch (UnsupportedEncodingException e) {
-        throw new RuntimeException();
-      }
+      res.content = htmlMap.get(u.toString()).getBytes(StandardCharsets.UTF_8);
       return res;
     }
     

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java Mon Mar 31 20:35:16 2014
@@ -198,7 +198,7 @@ public class ConcurrentUpdateSolrServer 
                           byte[] content = String.format(Locale.ROOT,
                               fmt,
                               params.getBool(UpdateParams.WAIT_SEARCHER, false)
-                                  + "").getBytes("UTF-8");
+                                  + "").getBytes(StandardCharsets.UTF_8);
                           out.write(content);
                         }
                       }

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java Mon Mar 31 20:35:16 2014
@@ -336,7 +336,7 @@ public class HttpSolrServer extends Solr
                 if (vals != null) {
                   for (String v : vals) {
                     if (isMultipart) {
-                      parts.add(new FormBodyPart(p, new StringBody(v, Charset.forName("UTF-8"))));
+                      parts.add(new FormBodyPart(p, new StringBody(v, StandardCharsets.UTF_8)));
                     } else {
                       postParams.add(new BasicNameValuePair(p, v));
                     }
@@ -370,7 +370,7 @@ public class HttpSolrServer extends Solr
                 post.setEntity(entity);
               } else {
                 //not using multipart
-                post.setEntity(new UrlEncodedFormEntity(postParams, "UTF-8"));
+                post.setEntity(new UrlEncodedFormEntity(postParams, StandardCharsets.UTF_8));
               }
 
               method = post;

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java Mon Mar 31 20:35:16 2014
@@ -28,6 +28,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 /**
  * A RequestWriter is used to write requests to Solr.
@@ -38,7 +39,7 @@ import java.nio.charset.Charset;
  * @since solr 1.4
  */
 public class RequestWriter {
-  public static final Charset UTF_8 = Charset.forName("UTF-8");
+  public static final Charset UTF_8 = StandardCharsets.UTF_8;
 
   public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException {
     if (req instanceof UpdateRequest) {

Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java Mon Mar 31 20:35:16 2014
@@ -41,6 +41,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 /**
@@ -102,7 +103,7 @@ public class NoOpResponseParserTest exte
     NoOpResponseParser parser = new NoOpResponseParser();
     try (final InputStream is = getResponse()) {
       assertNotNull(is);
-      Reader in = new InputStreamReader(is, "UTF-8");
+      Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);
       NamedList<Object> response = parser.processResponse(in);
       assertNotNull(response.get("response"));
       String expectedResponse = IOUtils.toString(getResponse(), "UTF-8");

Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java Mon Mar 31 20:35:16 2014
@@ -18,6 +18,7 @@
 package org.apache.solr.client.solrj.response;
 
 import junit.framework.Assert;
+
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.client.solrj.impl.XMLResponseParser;
 import org.apache.solr.common.SolrDocumentList;
@@ -29,6 +30,7 @@ import org.junit.Test;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 /**
@@ -42,7 +44,7 @@ public class QueryResponseTest extends L
     XMLResponseParser parser = new XMLResponseParser();
     InputStream is = new SolrResourceLoader(null, null).openResource("solrj/sampleDateFacetResponse.xml");
     assertNotNull(is);
-    Reader in = new InputStreamReader(is, "UTF-8");
+    Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);
     NamedList<Object> response = parser.processResponse(in);
     in.close();
     
@@ -66,7 +68,7 @@ public class QueryResponseTest extends L
     XMLResponseParser parser = new XMLResponseParser();
     InputStream is = new SolrResourceLoader(null, null).openResource("solrj/sampleDateFacetResponse.xml");
     assertNotNull(is);
-    Reader in = new InputStreamReader(is, "UTF-8");
+    Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);
     NamedList<Object> response = parser.processResponse(in);
     in.close();
 
@@ -123,7 +125,7 @@ public class QueryResponseTest extends L
     XMLResponseParser parser = new XMLResponseParser();
     InputStream is = new SolrResourceLoader(null, null).openResource("solrj/sampleGroupResponse.xml");
     assertNotNull(is);
-    Reader in = new InputStreamReader(is, "UTF-8");
+    Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);
     NamedList<Object> response = parser.processResponse(in);
     in.close();
 
@@ -225,7 +227,7 @@ public class QueryResponseTest extends L
     XMLResponseParser parser = new XMLResponseParser();
     InputStream is = new SolrResourceLoader(null, null).openResource("solrj/sampleSimpleGroupResponse.xml");
     assertNotNull(is);
-    Reader in = new InputStreamReader(is, "UTF-8");
+    Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);
     NamedList<Object> response = parser.processResponse(in);
     in.close();
 

Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java Mon Mar 31 20:35:16 2014
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.solr.SolrTestCaseJ4;
@@ -57,7 +58,7 @@ public class ContentStreamTest extends S
     InputStream s = stream.getStream();
     FileInputStream fis = new FileInputStream(file);
     InputStreamReader isr = new InputStreamReader(
-        new FileInputStream(file), "UTF-8");
+        new FileInputStream(file), StandardCharsets.UTF_8);
     Reader r = stream.getReader();
     try {
       assertEquals(file.length(), stream.getSize().intValue());
@@ -87,7 +88,7 @@ public class ContentStreamTest extends S
     InputStream s = stream.getStream();
     FileInputStream fis = new FileInputStream(file);
     FileInputStream fis2 = new FileInputStream(file);
-    InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
+    InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
     Reader r = stream.getReader();
     try {
       assertTrue(IOUtils.contentEquals(fis2, s));

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/BaseTestHarness.java Mon Mar 31 20:35:16 2014
@@ -28,10 +28,12 @@ import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 abstract public class BaseTestHarness {
   private static final ThreadLocal<DocumentBuilder> builderTL = new ThreadLocal<>();
@@ -80,7 +82,7 @@ abstract public class BaseTestHarness {
     Document document = null;
     try {
       document = getXmlDocumentBuilder().parse(new ByteArrayInputStream
-          (xml.getBytes("UTF-8")));
+          (xml.getBytes(StandardCharsets.UTF_8)));
     } catch (UnsupportedEncodingException e1) {
       throw new RuntimeException("Totally weird UTF-8 exception", e1);
     } catch (IOException e2) {
@@ -105,7 +107,7 @@ abstract public class BaseTestHarness {
     Document document = null;
     try {
       document = getXmlDocumentBuilder().parse(new ByteArrayInputStream
-          (xml.getBytes("UTF-8")));
+          (xml.getBytes(StandardCharsets.UTF_8)));
     } catch (UnsupportedEncodingException e1) {
       throw new RuntimeException("Totally weird UTF-8 exception", e1);
     } catch (IOException e2) {

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java?rev=1583449&r1=1583448&r2=1583449&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java Mon Mar 31 20:35:16 2014
@@ -18,6 +18,7 @@ package org.apache.solr.util;
 
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
@@ -106,7 +107,7 @@ public class RestTestHarness extends Bas
   public String put(String request, String content) throws IOException {
     HttpPut httpPut = new HttpPut(getBaseURL() + request);
     httpPut.setEntity(new StringEntity(content, ContentType.create(
-        "application/json", "utf-8")));
+        "application/json", StandardCharsets.UTF_8)));
     
     return getResponse(httpPut);
   }
@@ -134,7 +135,7 @@ public class RestTestHarness extends Bas
   public String post(String request, String content) throws IOException {
     HttpPost httpPost = new HttpPost(getBaseURL() + request);
     httpPost.setEntity(new StringEntity(content, ContentType.create(
-        "application/json", "utf-8")));
+        "application/json", StandardCharsets.UTF_8)));
     
     return getResponse(httpPost);
   }
@@ -189,7 +190,7 @@ public class RestTestHarness extends Bas
     HttpEntity entity = null;
     try {
       entity = httpClient.execute(request).getEntity();
-      return EntityUtils.toString(entity, "UTF-8");
+      return EntityUtils.toString(entity, StandardCharsets.UTF_8);
     } finally {
       EntityUtils.consumeQuietly(entity);
     }