tika-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1224863 - /tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkServer.java
Date Tue, 27 Dec 2011 02:44:28 GMT
Author: nick
Date: Tue Dec 27 02:44:28 2011
New Revision: 1224863

URL: http://svn.apache.org/viewvc?rev=1224863&view=rev
Log:
TIKA-827 Handle sending non serializable exceptions back from the ForkServer

Modified:
    tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkServer.java

Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkServer.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkServer.java?rev=1224863&r1=1224862&r2=1224863&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkServer.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkServer.java Tue Dec 27 02:44:28
2011
@@ -21,6 +21,7 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.NotSerializableException;
 import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -29,6 +30,8 @@ import java.util.zip.CheckedInputStream;
 import java.util.zip.CheckedOutputStream;
 import java.util.zip.Checksum;
 
+import org.apache.tika.exception.TikaException;
+
 class ForkServer implements Runnable, Checksum {
 
     public static final byte ERROR = -1;
@@ -137,7 +140,17 @@ class ForkServer implements Runnable, Ch
             output.write(DONE);
         } catch (InvocationTargetException e) {
             output.write(ERROR);
-            ForkObjectInputStream.sendObject(e.getCause(), output);
+            
+            // Try to send the underlying Exception itself
+            Throwable toSend = e.getCause();
+            try {
+               ForkObjectInputStream.sendObject(toSend, output);
+            } catch (NotSerializableException nse) {
+               // Need to build a serializable version of it
+               TikaException te = new TikaException( toSend.getMessage() );
+               te.setStackTrace( toSend.getStackTrace() );
+               ForkObjectInputStream.sendObject(te, output);
+            }
         }
     }
 



Mime
View raw message