diff --git a/CHANGES.txt b/CHANGES.txt index b2406151354..02dc26b467b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -86,7 +86,12 @@ Bug Fixes or the close of a core resulted in a warning: "SEVERE: SolrIndexWriter was not closed prior to finalize()" although there were no other consequences. (yonik) - + +* SOLR-1595: StreamingUpdateSolrServer used the patform default character + set when streaming updates, rather than using UTF-8 as the HTTP headers + indicated, leading to an encoding mismatch. (hossman, yonik) + +didn't specify the character set creating OutputStreamWriter Other Changes diff --git a/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java b/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java index cffdfde95ed..a93a6194d82 100644 --- a/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java +++ b/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java @@ -90,7 +90,7 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer public void writeRequest(OutputStream out) throws IOException { try { - OutputStreamWriter writer = new OutputStreamWriter( out ); + OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8"); writer.append( "" ); // can be anything... UpdateRequest req = queue.poll( 250, TimeUnit.MILLISECONDS ); while( req != null ) { diff --git a/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/src/test/org/apache/solr/client/solrj/SolrExampleTests.java index e050ec47573..ad578a252cb 100644 --- a/src/test/org/apache/solr/client/solrj/SolrExampleTests.java +++ b/src/test/org/apache/solr/client/solrj/SolrExampleTests.java @@ -175,7 +175,7 @@ abstract public class SolrExampleTests extends SolrExampleTestBase SolrInputDocument doc2 = new SolrInputDocument(); doc2.addField( "id", "id2", 1.0f ); - doc2.addField( "name", "doc2", 1.0f ); + doc2.addField( "name", "h\u1234llo", 1.0f ); doc2.addField( "price", 20 ); Collection docs = new ArrayList(); @@ -191,7 +191,7 @@ abstract public class SolrExampleTests extends SolrExampleTestBase query.addSortField( "price", SolrQuery.ORDER.asc ); QueryResponse rsp = server.query( query ); - Assert.assertEquals( 2, rsp.getResults().getNumFound() ); + assertEquals( 2, rsp.getResults().getNumFound() ); System.out.println( rsp.getResults() ); // Now do it again @@ -199,9 +199,14 @@ abstract public class SolrExampleTests extends SolrExampleTestBase server.commit(); rsp = server.query( query ); - Assert.assertEquals( 2, rsp.getResults().getNumFound() ); - System.out.println( rsp.getResults() ); - + assertEquals( 2, rsp.getResults().getNumFound() ); + // System.out.println( rsp.getResults() ); + + // query outside ascii range + query.setQuery("name:h\u1234llo"); + rsp = server.query( query ); + assertEquals( 1, rsp.getResults().getNumFound() ); + } /**