vgritsenko 2002/08/02 19:33:35 Modified: src/java/org/apache/cocoon/components/search SimpleLuceneXMLIndexerImpl.java Log: fix bug #10911: NPE in indexer. Thanks to [EMAIL PROTECTED] (Piotr Maj) Revision Changes Path 1.13 +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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SimpleLuceneXMLIndexerImpl.java 31 Jul 2002 13:13:25 -0000 1.12 +++ SimpleLuceneXMLIndexerImpl.java 3 Aug 2002 02:33:35 -0000 1.13 @@ -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; @@ -170,18 +171,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 + ")"); } @@ -205,7 +214,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]