From bbac85c35aba3155add140ffbcb607f9780d722b Mon Sep 17 00:00:00 2001 From: Mikhail Khludnev Date: Sat, 21 May 2016 23:11:41 +0300 Subject: [PATCH] SOLR-9147: using BAOS from commons io 2.5 in EmbeddedSolrServer to avoid array resize. --- lucene/ivy-versions.properties | 2 +- solr/CHANGES.txt | 2 ++ solr/common-build.xml | 1 - solr/core/ivy.xml | 1 + .../solr/client/solrj/embedded/EmbeddedSolrServer.java | 6 +++--- .../java/org/apache/solr/response/BinaryResponseWriter.java | 5 ++--- solr/licenses/commons-io-2.4.jar.sha1 | 1 - solr/licenses/commons-io-2.5.jar.sha1 | 1 + 8 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 solr/licenses/commons-io-2.4.jar.sha1 create mode 100644 solr/licenses/commons-io-2.5.jar.sha1 diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties index e8959da6f2f..ac9e416ab06 100644 --- a/lucene/ivy-versions.properties +++ b/lucene/ivy-versions.properties @@ -64,7 +64,7 @@ com.sun.jersey.version = 1.9 /commons-configuration/commons-configuration = 1.6 /commons-digester/commons-digester = 2.1 /commons-fileupload/commons-fileupload = 1.3.1 -/commons-io/commons-io = 2.4 +/commons-io/commons-io = 2.5 /commons-lang/commons-lang = 2.6 /commons-logging/commons-logging = 1.1.3 /de.l3s.boilerpipe/boilerpipe = 1.1.0 diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index e38d19b8fb0..f947ebc9e6f 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -282,6 +282,8 @@ Other Changes * SOLR-9131: Fix "start solr" text in cluster.vm Velocity template (janhoy) +* SOLR-9147: Upgrade commons-io to 2.5, avoid expensive array resizing in EmbeddedSolrServer (Mikhail Khludnev) + ================== 6.0.1 ================== (No Changes) diff --git a/solr/common-build.xml b/solr/common-build.xml index b13d7372a13..39e15612379 100644 --- a/solr/common-build.xml +++ b/solr/common-build.xml @@ -510,7 +510,6 @@ - diff --git a/solr/core/ivy.xml b/solr/core/ivy.xml index 5f8706f0e43..a43706ab658 100644 --- a/solr/core/ivy.xml +++ b/solr/core/ivy.xml @@ -31,6 +31,7 @@ + diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java index 4aa8b211cdf..fc283f42ef6 100644 --- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java +++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java @@ -16,13 +16,13 @@ */ package org.apache.solr.client.solrj.embedded; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; import com.google.common.base.Strings; + +import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -223,7 +223,7 @@ public class EmbeddedSolrServer extends SolrClient { }.setWritableDocFields(resolver). marshal(rsp.getValues(), out); - InputStream in = new ByteArrayInputStream(out.toByteArray()); + InputStream in = out.toInputStream(); return (NamedList) new JavaBinCodec(resolver).unmarshal(in); } catch (Exception ex) { throw new RuntimeException(ex); diff --git a/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java b/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java index 885bf78a021..3802ffd15a4 100644 --- a/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java @@ -16,8 +16,6 @@ */ package org.apache.solr.response; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -27,6 +25,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.lucene.index.IndexableField; import org.apache.solr.client.solrj.impl.BinaryResponseParser; import org.apache.solr.common.SolrDocument; @@ -165,7 +164,7 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter { ByteArrayOutputStream out = new ByteArrayOutputStream(); new JavaBinCodec(resolver).setWritableDocFields(resolver).marshal(rsp.getValues(), out); - InputStream in = new ByteArrayInputStream(out.toByteArray()); + InputStream in = out.toInputStream(); return (NamedList) new JavaBinCodec(resolver).unmarshal(in); } catch (Exception ex) { diff --git a/solr/licenses/commons-io-2.4.jar.sha1 b/solr/licenses/commons-io-2.4.jar.sha1 deleted file mode 100644 index 688318c938c..00000000000 --- a/solr/licenses/commons-io-2.4.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -b1b6ea3b7e4aa4f492509a4952029cd8e48019ad diff --git a/solr/licenses/commons-io-2.5.jar.sha1 b/solr/licenses/commons-io-2.5.jar.sha1 new file mode 100644 index 00000000000..b7f1d93e897 --- /dev/null +++ b/solr/licenses/commons-io-2.5.jar.sha1 @@ -0,0 +1 @@ +2852e6e05fbb95076fc091f6d1780f1f8fe35e0f \ No newline at end of file