changeset 803:166b16bda630

remove org.eclipse.jetty.util.preventers
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 07 Sep 2016 21:21:32 -0600
parents 3428c60d7cfc
children 9f5ba30722bb
files src/org/eclipse/jetty/util/preventers/AWTLeakPreventer.java src/org/eclipse/jetty/util/preventers/AbstractLeakPreventer.java src/org/eclipse/jetty/util/preventers/AppContextLeakPreventer.java src/org/eclipse/jetty/util/preventers/DOMLeakPreventer.java src/org/eclipse/jetty/util/preventers/DriverManagerLeakPreventer.java src/org/eclipse/jetty/util/preventers/GCThreadLeakPreventer.java src/org/eclipse/jetty/util/preventers/Java2DLeakPreventer.java src/org/eclipse/jetty/util/preventers/LDAPLeakPreventer.java src/org/eclipse/jetty/util/preventers/LoginConfigurationLeakPreventer.java src/org/eclipse/jetty/util/preventers/SecurityProviderLeakPreventer.java
diffstat 10 files changed, 0 insertions(+), 505 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/util/preventers/AWTLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-import java.awt.Toolkit;
-
-/**
- * AWTLeakPreventer
- *
- * See https://issues.jboss.org/browse/AS7-3733
- * 
- * The java.awt.Toolkit class has a static field that is the default toolkit. 
- * Creating the default toolkit causes the creation of an EventQueue, which has a 
- * classloader field initialized by the thread context class loader. 
- *
- */
-public class AWTLeakPreventer extends AbstractLeakPreventer
-{
-   
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        LOG.debug("Pinning classloader for java.awt.EventQueue using "+loader);
-        Toolkit.getDefaultToolkit();
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/AbstractLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-
-package org.eclipse.jetty.util.preventers;
-
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-
-/**
- * AbstractLeakPreventer
- *
- * Abstract base class for code that seeks to avoid pinning of webapp classloaders by using the jetty classloader to
- * proactively call the code that pins them (generally pinned as static data members, or as static
- * data members that are daemon threads (which use the context classloader)).
- * 
- * Instances of subclasses of this class should be set with Server.addBean(), which will
- * ensure that they are called when the Server instance starts up, which will have the jetty
- * classloader in scope.
- *
- */
-public abstract class AbstractLeakPreventer extends AbstractLifeCycle
-{
-    protected static final Logger LOG = Log.getLogger(AbstractLeakPreventer.class);
-    
-    /* ------------------------------------------------------------ */
-    abstract public void prevent(ClassLoader loader);
-    
-    
-    /* ------------------------------------------------------------ */
-    @Override
-    protected void doStart() throws Exception
-    {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
-        try
-        {
-            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-            prevent(getClass().getClassLoader());
-            super.doStart();
-        }
-        finally
-        {
-            Thread.currentThread().setContextClassLoader(loader);
-        }
-    }
-}
--- a/src/org/eclipse/jetty/util/preventers/AppContextLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-import javax.imageio.ImageIO;
-
-/**
- * AppContextLeakPreventer
- *
- * Cause the classloader that is pinned by AppContext.getAppContext() to be 
- * a container or system classloader, not a webapp classloader.
- * 
- * Inspired by Tomcat JreMemoryLeakPrevention.
- */
-public class AppContextLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        LOG.debug("Pinning classloader for AppContext.getContext() with "+loader);
-        ImageIO.getUseCache();
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/DOMLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-
-/**
- * DOMLeakPreventer
- *
- * See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6916498
- * 
- * Prevent the RuntimeException that is a static member of AbstractDOMParser
- * from pinning a webapp classloader by causing it to be set here by a non-webapp classloader.
- * 
- * Note that according to the bug report, a heap dump may not identify the GCRoot, making 
- * it difficult to identify the cause of the leak.
- *
- */
-public class DOMLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        try 
-        {
-            factory.newDocumentBuilder();
-        } 
-        catch (Exception e) 
-        {
-            LOG.warn(e);
-        }
-
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/DriverManagerLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-
-package org.eclipse.jetty.util.preventers;
-
-import java.sql.DriverManager;
-
-
-/**
- * DriverManagerLeakPreventer
- *
- * Cause DriverManager.getCallerClassLoader() to be called, which will pin the classloader.
- * 
- * Inspired by Tomcat JreMemoryLeakPrevention.
- */
-public class DriverManagerLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        LOG.debug("Pinning DriverManager classloader with "+loader);
-        DriverManager.getDrivers();
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/GCThreadLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-import java.lang.reflect.Method;
-
-/**
- * GCThreadLeakPreventer
- *
- * Prevents a call to sun.misc.GC.requestLatency pinning a webapp classloader
- * by calling it with a non-webapp classloader. The problem appears to be that
- * when this method is called, a daemon thread is created which takes the 
- * context classloader. A known caller of this method is the RMI impl. See
- * http://stackoverflow.com/questions/6626680/does-java-garbage-collection-log-entry-full-gc-system-mean-some-class-called
- * 
- * This preventer will start the thread with the longest possible interval, although
- * subsequent calls can vary that. Recommend to only use this class if you're doing
- * RMI.
- * 
- * Inspired by Tomcat JreMemoryLeakPrevention.
- *
- */
-public class GCThreadLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        try
-        {
-            Class clazz = Class.forName("sun.misc.GC");
-            Method requestLatency = clazz.getMethod("requestLatency", new Class[] {long.class});
-            requestLatency.invoke(null, Long.valueOf(Long.MAX_VALUE-1));
-        }
-        catch (ClassNotFoundException e)
-        {
-            LOG.ignore(e);
-        }
-        catch (Exception e)
-        {
-            LOG.warn(e);
-        }
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/Java2DLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-/**
- * Java2DLeakPreventer
- *
- * Prevent pinning of webapp classloader by pre-loading sun.java2d.Disposer class
- * before webapp classloaders are created.
- * 
- * See https://issues.apache.org/bugzilla/show_bug.cgi?id=51687
- *
- */
-public class Java2DLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        try
-        {
-            Class.forName("sun.java2d.Disposer", true, loader);
-        }
-        catch (ClassNotFoundException e)
-        {
-            LOG.ignore(e);
-        }
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/LDAPLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-/**
- * LDAPLeakPreventer
- *
- * If com.sun.jndi.LdapPoolManager class is loaded and the system property
- * com.sun.jndi.ldap.connect.pool.timeout is set to a nonzero value, a daemon
- * thread is started which can pin a webapp classloader if it is the first to
- * load the LdapPoolManager.
- * 
- * Inspired by Tomcat JreMemoryLeakPrevention
- *
- */
-public class LDAPLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        try
-        {
-            Class.forName("com.sun.jndi.LdapPoolManager", true, loader);
-        }
-        catch (ClassNotFoundException e)
-        {
-            LOG.ignore(e);
-        }
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/LoginConfigurationLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-/**
- * LoginConfigurationLeakPreventer
- *
- * The javax.security.auth.login.Configuration class keeps a static reference to the 
- * thread context classloader. We prevent a webapp context classloader being used for
- * that by invoking the classloading here.
- * 
- * Inspired by Tomcat JreMemoryLeakPrevention
- */
-public class LoginConfigurationLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        try
-        {
-            Class.forName("javax.security.auth.login.Configuration", true, loader);
-        }
-        catch (ClassNotFoundException e)
-        {
-            LOG.warn(e);
-        }
-    }
-
-}
--- a/src/org/eclipse/jetty/util/preventers/SecurityProviderLeakPreventer.java	Wed Sep 07 21:15:48 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.util.preventers;
-
-import java.security.Security;
-
-/**
- * SecurityProviderLeakPreventer
- *
- * Some security providers, such as sun.security.pkcs11.SunPKCS11 start a deamon thread,
- * which will use the thread context classloader. Load them here to ensure the classloader
- * is not a webapp classloader.
- *
- * Inspired by Tomcat JreMemoryLeakPrevention
- */
-public class SecurityProviderLeakPreventer extends AbstractLeakPreventer
-{
-    /* ------------------------------------------------------------ */
-    /** 
-     * @see org.eclipse.jetty.util.preventers.AbstractLeakPreventer#prevent(java.lang.ClassLoader)
-     */
-    @Override
-    public void prevent(ClassLoader loader)
-    {
-        Security.getProviders();
-    }
-
-}