tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1559565 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/Globals.java java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java java/org/apache/catalina/loader/WebappClassLoader.java
Date Sun, 19 Jan 2014 19:28:35 GMT
Author: markt
Date: Sun Jan 19 19:28:34 2014
New Revision: 1559565

URL: http://svn.apache.org/r1559565
Log:
Move JVM vendor detection to a global constant.
Fix detection of Sun/Oracle JVM that only worked for older Sun branded JVMs.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/Globals.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1559561

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/Globals.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/Globals.java?rev=1559565&r1=1559564&r2=1559565&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/Globals.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/Globals.java Sun Jan 19 19:28:34 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.catalina;
 
+import java.util.Locale;
+
 /**
  * Global constants that are applicable to multiple packages within Catalina.
  *
@@ -327,4 +329,31 @@ public final class Globals {
      */
     public static final String JASPER_XML_BLOCK_EXTERNAL_INIT_PARAM =
             "org.apache.jasper.XML_BLOCK_EXTERNAL";
+
+    static {
+        /**
+         * There are a few places where Tomcat either accesses JVM internals
+         * (e.g. the memory leak protection) or where feature support varies
+         * between JVMs (e.g. SPNEGO). These flags exist to enable Tomcat to
+         * adjust its behaviour based on the vendor of the JVM. In an ideal
+         * world this code would not exist.
+         */
+        String vendor = System.getProperty("java.vendor", "");
+        vendor = vendor.toLowerCase(Locale.ENGLISH);
+
+        if (vendor.startsWith("oracle") || vendor.startsWith("sun")) {
+            IS_ORACLE_JVM = true;
+            IS_IBM_JVM = false;
+        } else if (vendor.contains("ibm")) {
+            IS_ORACLE_JVM = false;
+            IS_IBM_JVM = true;
+        } else {
+            IS_ORACLE_JVM = false;
+            IS_IBM_JVM = false;
+        }
+    }
+
+    public static final boolean IS_ORACLE_JVM;
+
+    public static final boolean IS_IBM_JVM;
 }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1559565&r1=1559564&r2=1559565&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
Sun Jan 19 19:28:34 2014
@@ -30,6 +30,7 @@ import javax.imageio.ImageIO;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.catalina.Globals;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
@@ -323,8 +324,7 @@ public class JreMemoryLeakPreventionList
                                 new Class[] {long.class});
                         method.invoke(null, Long.valueOf(Long.MAX_VALUE - 1));
                     } catch (ClassNotFoundException e) {
-                        if (System.getProperty("java.vendor").startsWith(
-                                "Sun")) {
+                        if (Globals.IS_ORACLE_JVM) {
                             log.error(sm.getString(
                                     "jreLeakListener.gcDaemonFail"), e);
                         } else {
@@ -456,8 +456,7 @@ public class JreMemoryLeakPreventionList
                     try {
                         Class.forName("com.sun.jndi.ldap.LdapPoolManager");
                     } catch (ClassNotFoundException e) {
-                        if (System.getProperty("java.vendor").startsWith(
-                                "Sun")) {
+                        if (Globals.IS_ORACLE_JVM) {
                             log.error(sm.getString(
                                     "jreLeakListener.ldapPoolManagerFail"), e);
                         } else {

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=1559565&r1=1559564&r2=1559565&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Sun Jan 19
19:28:34 2014
@@ -2812,14 +2812,14 @@ public class WebappClassLoader
                     "webappClassLoader.clearReferencesResourceBundlesFail",
                     contextName), e);
         } catch (NoSuchFieldException e) {
-            if (System.getProperty("java.vendor").startsWith("Sun")) {
+            if (Globals.IS_ORACLE_JVM) {
                 log.error(sm.getString(
-                "webappClassLoader.clearReferencesResourceBundlesFail",
-                contextName), e);
+                        "webappClassLoader.clearReferencesResourceBundlesFail",
+                        getContextName()), e);
             } else {
                 log.debug(sm.getString(
-                "webappClassLoader.clearReferencesResourceBundlesFail",
-                contextName), e);
+                        "webappClassLoader.clearReferencesResourceBundlesFail",
+                        getContextName()), e);
             }
         } catch (IllegalArgumentException e) {
             log.error(sm.getString(



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message