hi,

i encounter a problem with my application and the
SimpleCocoonCrawlerImpl.java

well first it seems it does the job OK, but when the
LuceneIndexerXMLIndexerIml
wanted to access the same files again for indexing they didn't have a
conentType anymore and were ignored.

looking at SimpleCocoonCrawlerImpl.java there was an open URLConnection
which
was never closed. so closing this URLConnection, did solve my problem, i.e.
the indexer gets now the same content-type as the crawler.

well, I don't know if this is a problem with my cocoon-application or
whether there are reasons why not to close an URLConnection.

anyway I just attached a patch, which also adresses an 'null' check for the
content-type.

may cocoon become a beautiful butterfly ;-)
Kristian
 

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
Index: 
xml-cocoon2/src/java/org/apache/cocoon/components/crawler/SimpleCocoonCrawlerImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/crawler/SimpleCocoonCrawlerImpl.java,v
retrieving revision 1.10
diff -u -r1.10 SimpleCocoonCrawlerImpl.java
--- 
xml-cocoon2/src/java/org/apache/cocoon/components/crawler/SimpleCocoonCrawlerImpl.java 
     4 Jun 2002 09:27:20 -0000       1.10
+++ 
+xml-cocoon2/src/java/org/apache/cocoon/components/crawler/SimpleCocoonCrawlerImpl.java
+      3 Aug 2002 09:54:51 -0000
@@ -466,20 +466,30 @@
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Getting links of URL " + sURL);
         }
-        try {
+        BufferedReader br = null;
+       try {
             sURL = url.getFile();
             URL links = new URL(url, sURL
                 + ((sURL.indexOf("?") == -1) ? "?" : "&")
                 + linkViewQuery);
             URLConnection links_url_connection = links.openConnection();
             InputStream is = links_url_connection.getInputStream();
-            BufferedReader br = new BufferedReader(new InputStreamReader(is));
+            br = new BufferedReader(new InputStreamReader(is));
 
             String contentType = links_url_connection.getContentType();
-            int index = contentType.indexOf(';');
-            if (contentType != null && index != -1) {
-                contentType = contentType.substring(0, index);
+            if (contentType == null) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Ignoring " + sURL + " (no content type)");
+                }
+               // there is a check on null in the calling method
+                return null;
             }
+
+           int index = contentType.indexOf(';');
+           if (index != -1) {
+               contentType = contentType.substring(0, index);
+           }
+           
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Content-type: " + contentType);
             }
@@ -523,7 +533,13 @@
             }
         } catch (IOException ioe) {
             getLogger().warn("Problems get links of " + url, ioe);
-        }
+        } finally {
+           if( br != null ) {
+               try {
+                   br.close();
+               } catch (IOException ignored ) {}
+           }
+       }
         return url_links;
     }
 
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to