Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #515 from atmire/DS-1958

 DS-1958 Fix SolrLogger Memory Error
  • Loading branch information...
commit 54e0e644f54fe4d6304b74d3e20adc94a03c37d7 2 parents 375b8af + a54d314
@mwoodiupui mwoodiupui authored
Showing with 5 additions and 18 deletions.
  1. +5 −18 dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java
View
23 dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java
@@ -40,6 +40,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.AutoCloseInputStream;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
@@ -1300,7 +1301,6 @@ protected void buildDocument(Context context, Item item)
log.debug(" Added Grouping");
- Vector<InputStreamReader> readers = new Vector<InputStreamReader>();
try {
// now get full text of any bitstreams in the TEXT bundle
@@ -1318,17 +1318,12 @@ protected void buildDocument(Context context, Item item)
for (Bitstream myBitstream : myBitstreams)
{
try {
- InputStreamReader is = new InputStreamReader(
- myBitstream.retrieve()); // get input
- readers.add(is);
- // Add each InputStream to the Indexed Document
- String value = IOUtils.toString(is);
- doc.addField("fulltext", value);
+ doc.addField("fulltext", new AutoCloseInputStream(myBitstream.retrieve()));
if(hitHighlightingFields.contains("*") || hitHighlightingFields.contains("fulltext"))
{
- doc.addField("fulltext_hl", value);
+ doc.addField("fulltext_hl", new AutoCloseInputStream(myBitstream.retrieve()));
}
log.debug(" Added BitStream: "
@@ -1349,16 +1344,6 @@ protected void buildDocument(Context context, Item item)
{
log.error(e.getMessage(), e);
}
- finally {
- Iterator<InputStreamReader> itr = readers.iterator();
- while (itr.hasNext()) {
- InputStreamReader reader = itr.next();
- if (reader != null) {
- reader.close();
- }
- }
- log.debug("closed " + readers.size() + " readers");
- }
//Do any additional indexing, depends on the plugins
List<SolrServiceIndexPlugin> solrServiceIndexPlugins = new DSpace().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class);
@@ -1377,6 +1362,8 @@ protected void buildDocument(Context context, Item item)
}
}
+
+
/**
* Create Lucene document with all the shared fields initialized.
*
Please sign in to comment.
Something went wrong with that request. Please try again.