You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by at...@apache.org on 2008/11/19 17:19:22 UTC

svn commit: r719003 - /portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java

Author: ate
Date: Wed Nov 19 08:19:22 2008
New Revision: 719003

URL: http://svn.apache.org/viewvc?rev=719003&view=rev
Log:
Fix for handling of portlet initialization errors which require the portlet to be taken out of service.
In old solution in PortletServlet the portlet.init() call was directly executed from the servlet.init() method which worked because the servlet itself would then go out of service.
With the new lazy initialization (waiting for the portal to come online), this no longer worked correctly as the servlet.init() would be successful even if the portlet.init() failed.  

Modified:
    portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java

Modified: portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java?rev=719003&r1=719002&r2=719003&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java (original)
+++ portals/pluto/trunk/pluto-container-api/src/main/java/org/apache/pluto/core/PortletServlet.java Wed Nov 19 08:19:22 2008
@@ -194,6 +194,9 @@
             catch (Exception ex)
             {
                 context.log(ex.getMessage(),ex);
+                // take out of service
+                portlet = null;
+                portletConfig = null;
                 return true;
             }
         }
@@ -215,7 +218,15 @@
               contextService.unregister(portletContext);
               if (portlet != null)
               {
-                  portlet.destroy();
+                  try
+                  {
+                      portlet.destroy();
+                  }
+                  catch (Exception e)
+                  {
+                      // ignore
+                  }
+                  portlet = null;
               }
             }
             super.destroy();
@@ -262,6 +273,10 @@
     private void dispatch(HttpServletRequest request,
             HttpServletResponse response) throws ServletException, IOException
     {
+        if (portlet == null)
+        {
+            throw new javax.servlet.UnavailableException("Portlet "+portletName+" unavailable");
+        }
         InternalPortletRequest portletRequest = null;
         InternalPortletResponse portletResponse = null;
         // Save portlet config into servlet request.
@@ -384,6 +399,8 @@
                 System.err.println(ex.getMessage());
                 // Don't care for Exception
             }
+            // take portlet out of service
+            portlet = null;
 
             // TODO: Handle everything as permanently for now.
             throw new javax.servlet.UnavailableException(ex.getMessage());