manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1432919 - in /manifoldcf/trunk: CHANGES.txt connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
Date Mon, 14 Jan 2013 13:50:53 GMT
Author: kwright
Date: Mon Jan 14 13:50:53 2013
New Revision: 1432919

URL: http://svn.apache.org/viewvc?rev=1432919&view=rev
Log:
Fix for CONNECTORS-609.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1432919&r1=1432918&r2=1432919&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Mon Jan 14 13:50:53 2013
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 1.1-dev =====================
 
+CONNECTORS-609: Solrj doesn't always set the code property of
+its http exceptions right, so we need to parse it out ourselves.
+(Ahmet Arslan, Karl Wright)
+
 CONNECTORS-608: Solr connector times out chronically on some
 documents.
 (David Morana, Karl Wright)

Modified: manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java?rev=1432919&r1=1432918&r2=1432919&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
(original)
+++ manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
Mon Jan 14 13:50:53 2013
@@ -29,6 +29,7 @@ import java.net.*;
 import java.util.*;
 import javax.net.*;
 import javax.net.ssl.*;
+import java.util.regex.*;
 
 import org.apache.log4j.*;
 
@@ -334,18 +335,39 @@ public class HttpPoster
   protected static void handleSolrException(SolrException e, String context)
     throws ManifoldCFException, ServiceInterruption
   {
+    int code = e.code();
+    if (code == 0)
+    {
+      try
+      {
+        // Solrj doesn't always set the code properly.  If it doesn't, we have to parse it
out of the exception string.  Ugh.
+        Pattern p = Pattern.compile("non ok status:([0-9]*),");
+        Matcher m = p.matcher(e.getMessage());
+        if (m.find())
+          code = Integer.parseInt(m.group(1));
+      }
+      catch (PatternSyntaxException e2)
+      {
+        throw new ManifoldCFException("Unexpected error: "+e2.getMessage());
+      }
+      catch (NumberFormatException e2)
+      {
+        throw new ManifoldCFException("Unexpected error: "+e2.getMessage());
+      }
+    }
+      
     // Use the exception text to determine the proper result.
-    if (e.code() == 500 && e.getMessage().indexOf("org.apache.tika.exception.TikaException")
!= -1)
+    if (code == 500 && e.getMessage().indexOf("org.apache.tika.exception.TikaException")
!= -1)
       // Can't process the document, so don't keep trying.
       return;
 
     // If the code is in the 400 range, the document will never be accepted, so indicate
that.
-    if (e.code() >= 400 && e.code() < 500)
+    if (code >= 400 && code < 500)
       return;
     
     // The only other kind of return code we know how to handle is 50x.
     // For these, we should retry for a while.
-    if (e.code() == 500)
+    if (code == 500)
     {
       long currentTime = System.currentTimeMillis();
       throw new ServiceInterruption("Solr exception during "+context+" ("+e.code()+"): "+e.getMessage(),



Mime
View raw message