You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by ab...@apache.org on 2009/11/28 22:16:59 UTC

svn commit: r885148 - in /lucene/nutch/trunk: CHANGES.txt src/java/org/apache/nutch/searcher/NutchBean.java

Author: ab
Date: Sat Nov 28 21:16:42 2009
New Revision: 885148

URL: http://svn.apache.org/viewvc?rev=885148&view=rev
Log:
NUTCH-746 NutchBeanConstructor does not close NutchBean upon
contextDestroyed, causing resource leak in the container.

Modified:
    lucene/nutch/trunk/CHANGES.txt
    lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java

Modified: lucene/nutch/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/CHANGES.txt?rev=885148&r1=885147&r2=885148&view=diff
==============================================================================
--- lucene/nutch/trunk/CHANGES.txt (original)
+++ lucene/nutch/trunk/CHANGES.txt Sat Nov 28 21:16:42 2009
@@ -2,6 +2,11 @@
 
 Unreleased Changes
 
+* NUTCH-746 NutchBeanConstructor does not close NutchBean upon contextDestroyed,
+  causing resource leak in the container. (Kirby Bohling via ab)
+
+* NUTCH-772 Upgrade Nutch to use Lucene 2.9.1 (ab)
+
 * NUTCH-760 Allow field mapping from Nutch to Solr index (David Stuart, ab)
 
 * NUTCH-761 Avoid cloning CrawlDatum in CrawlDbReducer (Julien Nioche, ab)

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java?rev=885148&r1=885147&r2=885148&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java Sat Nov 28 21:16:42 2009
@@ -413,7 +413,24 @@
    */
   public static class NutchBeanConstructor implements ServletContextListener {
 
-    public void contextDestroyed(ServletContextEvent sce) { }
+    public void contextDestroyed(ServletContextEvent sce) {
+      final ServletContext context = sce.getServletContext();
+
+      LOG.info("Closing Bean");
+      try {
+        Object tmp = context.getAttribute(NutchBean.KEY);
+
+        if (tmp instanceof NutchBean) {
+          NutchBean bean = (NutchBean) tmp;
+          bean.close();
+        } else {
+          LOG.warn("No bean configured, or the wrong type?  Potential PermGen leak, or startup problem.");
+        }
+      }
+      catch (final IOException ex) {
+        LOG.error(StringUtils.stringifyException(ex));
+      }
+    }
 
     public void contextInitialized(ServletContextEvent sce) {
       final ServletContext app = sce.getServletContext();