You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2017/05/12 07:34:53 UTC

svn commit: r1794938 - /manifoldcf/branches/CONNECTORS-1425/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java

Author: kwright
Date: Fri May 12 07:34:53 2017
New Revision: 1794938

URL: http://svn.apache.org/viewvc?rev=1794938&view=rev
Log:
Fix session management bug

Modified:
    manifoldcf/branches/CONNECTORS-1425/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java

Modified: manifoldcf/branches/CONNECTORS-1425/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1425/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java?rev=1794938&r1=1794937&r2=1794938&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1425/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java (original)
+++ manifoldcf/branches/CONNECTORS-1425/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java Fri May 12 07:34:53 2017
@@ -144,6 +144,8 @@ public class TikaExtractor extends org.a
     throws ManifoldCFException
   {
     expireSession();
+    tikaHostname = null;
+    tikaPortString = null;
 
     super.disconnect();
   }
@@ -231,8 +233,6 @@ public class TikaExtractor extends org.a
   protected void expireSession()
     throws ManifoldCFException
   {
-    tikaHostname = null;
-    tikaPortString = null;
     tikaPort = -1;
     httpClient = null;
     tikaHost = null;
@@ -588,7 +588,12 @@ public class TikaExtractor extends org.a
             // Make a copy of the original stream as it needs to be sent two
             // times to Tika
             // one for the metadata and one for the content
-            IOUtils.copy(document.getBinaryStream(), ds.getOutputStream());
+            final OutputStream os = ds.getOutputStream();
+            try {
+              IOUtils.copyLarge(document.getBinaryStream(), os);
+            } finally {
+              os.close();
+            }
 
             // Metadata
             HttpPut httpPut = new HttpPut(metaURI);
@@ -599,7 +604,9 @@ public class TikaExtractor extends org.a
             HttpEntity entity = new InputStreamEntity(ds.getInputStream());
             httpPut.setEntity(entity);
             try {
+              System.out.println("About to PUT");
               response = this.httpClient.execute(tikaHost, httpPut);
+              System.out.println("PUT successful");
             } catch (IOException e) {
               // Retry 3 times, 10000 ms between retries, and abort if doesn't work
               final long currentTime = System.currentTimeMillis();
@@ -663,7 +670,12 @@ public class TikaExtractor extends org.a
               tikaServerIs = response.getEntity().getContent();
               try {
                 responseDs = new FileDestinationStorage();
-                IOUtils.copyLarge(tikaServerIs, responseDs.getOutputStream(), 0L, sp.writeLimit);
+                final OutputStream os2 = responseDs.getOutputStream();
+                try {
+                  IOUtils.copyLarge(tikaServerIs, os2, 0L, sp.writeLimit);
+                } finally {
+                  os2.close();
+                }
                 length = new Long(responseDs.getBinaryLength());
               } finally {
                 tikaServerIs.close();