svn commit: r526603 - /xml/xindice/trunk/java/src/org/apache/xindice/server/rpc/messages/GetResource.java

[email protected]
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
Author: vgritsenko
Date: Sun Apr  8 14:26:04 2007
New Revision: 526603

URL: http://svn.apache.org/viewvc?view=rev&rev=526603
Log:
fix NPE in case collection is not compressed

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/server/rpc/messages/GetResource.java

Modified: xml/xindice/trunk/java/src/org/apache/xindice/server/rpc/messages/GetResource.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/server/rpc/messages/GetResource.java?view=diff&rev=526603&r1=526602&r2=526603
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/server/rpc/messages/GetResource.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/server/rpc/messages/GetResource.java Sun Apr  8 14:26:04 2007
@@ -25,6 +25,7 @@
 import org.apache.xindice.server.rpc.RPCDefaultMessage;
 import org.apache.xindice.util.SymbolSerializer;
 import org.apache.xindice.xml.TextWriter;
+import org.apache.xindice.xml.dom.CompressedDocument;
 
 import org.w3c.dom.Document;
 
@@ -78,15 +79,16 @@
             int timestamp = ((Integer) message.get("timestamp")).intValue();
             */
 
-            Document doc = (Document)obj;
-            if (/*( timestamp != -1) &&*/ (symbolSerializer != null)) {
+            // Document might be compressed (with bytes) or not. In a latter case, convert to string.
+            Document doc = (Document) obj;
+            if (/*( timestamp != -1) &&*/ symbolSerializer != null && ((CompressedDocument) doc).getDataBytes() != null) {
                 result.put(RESULT,
                            symbolSerializer.convertFromDocument(doc, timestamp));
             } else {
                 result.put(RESULT, TextWriter.toString(doc));
             }
         } else {
-            Document doc = (Document)obj;
+            Document doc = (Document) obj;
             result.put(RESULT, TextWriter.toString(doc));
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.