Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DS-1958 Fix SolrLogger Memory Error

  • Loading branch information...
commit 7f8c1b1fb31cb951486beeeb9c685da97636b3c3 1 parent 5eb55eb
@Mini-Pillai Mini-Pillai authored helix84 committed
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
@@ -13,6 +13,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;
@@ -1198,7 +1199,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
@@ -1216,17 +1216,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: "
@@ -1247,16 +1242,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);
@@ -1275,6 +1260,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.