Author: kostat
Date: 2007-03-25 05:05:01 -0500 (Sun, 25 Mar 2007)
New Revision: 74952

Modified:
   trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/BaseHttpServlet.cs
Log:
destroy AppDomain of first Servlet.destroy

Modified: trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/BaseHttpServlet.cs
===================================================================
--- trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/BaseHttpServlet.cs        
2007-03-25 10:01:28 UTC (rev 74951)
+++ trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.Hosting/BaseHttpServlet.cs        
2007-03-25 10:05:01 UTC (rev 74952)
@@ -49,7 +49,6 @@
                static readonly LocalDataStoreSlot _servletResponseSlot = 
Thread.GetNamedDataSlot(J2EEConsts.SERVLET_RESPONSE);
                static readonly LocalDataStoreSlot _servletSlot = 
Thread.GetNamedDataSlot(J2EEConsts.CURRENT_SERVLET);
 
-               bool _performedInit = false;
                bool _appVirDirInited = false;
                Field _derbyContextService;
                java.lang.ThreadLocal _derbyLocal;
@@ -138,8 +137,6 @@
                                InitDerby ();
                                
config.getServletContext().setAttribute(J2EEConsts.APP_DOMAIN, servletDomain);
                                config.getServletContext ().setAttribute 
(J2EEConsts.CURRENT_SERVLET, this);
-                               
-                               _performedInit = true;
                        }
                        finally 
                        {
@@ -196,12 +193,12 @@
                override public void destroy()
                {
                        base.destroy();
-                       if (!_performedInit)
+                       AppDomain servletDomain = (AppDomain) getServletContext 
().getAttribute (J2EEConsts.APP_DOMAIN);
+                       if (servletDomain == null)
                                return;
 
                        try 
                        {
-                               AppDomain servletDomain = 
(AppDomain)this.getServletContext().getAttribute(J2EEConsts.APP_DOMAIN);
                                [EMAIL PROTECTED](servletDomain);
 #if DEBUG
                                Console.WriteLine("Destroy of GhHttpServlet");
@@ -223,9 +220,19 @@
                                [EMAIL PROTECTED]();
                                CleanupDerby ();
                                if (_derbyContextService != null) {
-                                       URL u = vmw.common.TypeUtils.ToClass 
(this).getClassLoader ().getResource 
("org/apache/derby/iapi/services/context/ContextService.class");
-                                       if (u != null)
-                                               ((JarURLConnection) 
u.openConnection ()).getJarFile ().close ();
+                                       try {
+                                               URL u = 
vmw.common.TypeUtils.ToClass (this).getClassLoader ().getResource 
("org/apache/derby/iapi/services/context/ContextService.class");
+                                               if (u != null) {
+                                                       URLConnection con = 
u.openConnection ();
+                                                       if (con is 
JarURLConnection)
+                                                               
((JarURLConnection) con).getJarFile ().close ();
+                                               }
+                                       }
+                                       catch (Exception ex) {
+#if DEBUG
+                                               Console.WriteLine (ex.ToString 
());
+#endif
+                                       }
                                }
                        }
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to