vgritsenko 2002/08/02 19:33:35
Modified: src/java/org/apache/cocoon/components/search Tag:
cocoon_2_0_3_branch SimpleLuceneXMLIndexerImpl.java
Log:
fix bug #10911: NPE in indexer. Thanks to [EMAIL PROTECTED] (Piotr Maj)
Revision Changes Path
No revision
No revision
1.9.2.2 +18 -9
xml-cocoon2/src/java/org/apache/cocoon/components/search/SimpleLuceneXMLIndexerImpl.java
Index: SimpleLuceneXMLIndexerImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/search/SimpleLuceneXMLIndexerImpl.java,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -u -r1.9.2.1 -r1.9.2.2
--- SimpleLuceneXMLIndexerImpl.java 22 Jul 2002 22:55:43 -0000 1.9.2.1
+++ SimpleLuceneXMLIndexerImpl.java 3 Aug 2002 02:33:35 -0000 1.9.2.2
@@ -56,6 +56,7 @@
import java.net.URLConnection;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -174,18 +175,26 @@
+ ((url.getFile().indexOf("?") == -1) ? "?" : "&")
+ CONTENT_QUERY);
URLConnection contentURLConnection = contentURL.openConnection();
- String contentType = contentURLConnection.getContentType();
+ if (contentURLConnection == null) {
+ throw new ProcessingException("Can not open connection to URL "
+ + contentURL + " (null connection)");
+ }
- if (contentType != null) {
- int index = contentType.indexOf(';');
- if (index != -1) {
- contentType = contentType.substring(0, index);
+ String contentType = contentURLConnection.getContentType();
+ if (contentType == null) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Ignoring " + contentURL + " (no content
type)");
}
+
+ return Collections.EMPTY_LIST;
}
- if (contentType != null &&
- allowedContentType.contains(contentType)) {
+ int index = contentType.indexOf(';');
+ if (index != -1) {
+ contentType = contentType.substring(0, index);
+ }
+ if (allowedContentType.contains(contentType)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Indexing " + contentURL + " (" + contentType
+ ")");
}
@@ -209,7 +218,7 @@
getLogger().debug("Ignoring " + contentURL + " (" + contentType
+ ")");
}
- return java.util.Collections.EMPTY_LIST;
+ return Collections.EMPTY_LIST;
}
} catch (IOException ioe) {
throw new ProcessingException("Cannot read URL " + url, ioe);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]