cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 10911] New: - unchecked NullPointer in search component
Date Wed, 17 Jul 2002 18:09:36 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10911>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10911

unchecked NullPointer in search component 

           Summary: unchecked NullPointer in search component
           Product: Cocoon 2
           Version: 2.0.3
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: sitemap components
        AssignedTo: cocoon-dev@xml.apache.org
        ReportedBy: piotr.maj@kernelpanic.pl


I tried to set up Cocoon2 v.2.0.3 in chrooted enviroment. Everything worked
fine, except of lucene search example. That was my fault (I didn't copy
/etc/resolv.conf to chroot jail), but I noticed that the problem is more general.

The null pointer occures when Indexer cannot resolv a domain. From the "public
List build(URL url)" in SimpleLuceneXMLIndexerImpl.java: 

---
URLConnection contentURLConnection = contentURL.openConnection();
String contentType = contentURLConnection.getContentType();
            
int index = contentType.indexOf(';');
---

if openConnection() fails (i.e. domain cannot be resolved, broken link...)
contentType.indexOf(';') throws an NullPointerException that is not catched
anyware, and the index creation fails (no page is displayed).

Solution:
---------
change above code to:


---
URLConnection contentURLConnection = contentURL.openConnection();
if ( contentURLConnection == null ) return java.util.Collections.EMPTY_LIST;

String contentType = contentURLConnection.getContentType();
if ( contentType == null ) return java.util.Collections.EMPTY_LIST;
int index = contentType.indexOf(';');
---

-- 
pozdrawiam,
-> m@j <-                           [http://silence.kernelpanic.pl/]

PS.
sorry for poor english.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message