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 2010/05/07 16:45:11 UTC

svn commit: r942087 - /incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java

Author: kwright
Date: Fri May  7 14:45:11 2010
New Revision: 942087

URL: http://svn.apache.org/viewvc?rev=942087&view=rev
Log:
Properly escape the document identifier for deletions.  Otherwise we get 500 errors on uris that have ampersands in them.

Modified:
    incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java

Modified: incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java?rev=942087&r1=942086&r2=942087&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java (original)
+++ incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java Fri May  7 14:45:11 2010
@@ -840,6 +840,15 @@ public class HttpPoster
     }
   }
   
+  /** XML encoding */
+  protected static String xmlEncode(String input)
+  {
+    StringBuffer sb = new StringBuffer("<![CDATA[");
+    sb.append(input);
+    sb.append("]]>");
+    return sb.toString();
+  }
+  
   /** Killable thread that does ingestions.
   * Java 1.5 stopped permitting thread interruptions to abort socket waits.  As a result, it is impossible to get threads to shutdown cleanly that are doing
   * such waits.  So, the places where this happens are segregated in their own threads so that they can be just abandoned.
@@ -1339,7 +1348,7 @@ public class HttpPoster
               OutputStream out = socket.getOutputStream();
               try
               {
-                byte[] requestBytes = ("<delete><id>"+documentURI+"</id></delete>").getBytes("UTF-8");
+                byte[] requestBytes = ("<delete><id>"+xmlEncode(documentURI)+"</id></delete>").getBytes("UTF-8");
                 long startTime = System.currentTimeMillis();
                 byte[] tmp = ("POST " + postRemoveAction + " HTTP/1.0\r\n").getBytes("ASCII");
                 out.write(tmp, 0, tmp.length);