You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/11/14 20:11:33 UTC

[tomcat] 01/03: Fix IDE warnings. Get build working with Java 6 through 14

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit dbfcadd65ed4057f00fca26f7d9693ce65a4af5e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Nov 14 19:26:00 2019 +0000

    Fix IDE warnings. Get build working with Java 6 through 14
    
    "-XDignore.symbol.file" is a hack but it is the only solution I found
    that worked cleanly with all Java versions.
---
 build.xml                                                    |  1 +
 .../apache/catalina/mbeans/JmxRemoteLifecycleListener.java   | 12 +++++++++++-
 res/findbugs/filter-false-positives.xml                      |  6 ++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/build.xml b/build.xml
index 4b49a52..39929c5 100644
--- a/build.xml
+++ b/build.xml
@@ -691,6 +691,7 @@
            encoding="ISO-8859-1"
            includeAntRuntime="true" >
       <compilerarg value="-Xlint:unchecked"/>
+      <compilerarg value="-XDignore.symbol.file"/>
       <classpath refid="compile.classpath" />
       <exclude name="org/apache/naming/factory/webservices/**" />
       <!-- Exclude classes that require Java 7 to compile -->
diff --git a/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java b/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
index 7d700a3..c81c4a9 100644
--- a/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
+++ b/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
@@ -324,7 +324,13 @@ public class JmxRemoteLifecycleListener implements LifecycleListener {
             Remote jmxServer = server.toStub();
             // Create the RMI registry
             try {
-                new JmxRegistry(theRmiRegistryPort, registryCsf, registrySsf, "jmxrmi", jmxServer);
+                /*
+                 * JmxRegistry is registered as a side-effect of creation.
+                 * This object is here so we can tell the IDE it is OK for it
+                 * not to be used.
+                 */
+                @SuppressWarnings("unused")
+                JmxRegistry unused = new JmxRegistry(theRmiRegistryPort, registryCsf, registrySsf, "jmxrmi", jmxServer);
             } catch (RemoteException e) {
                 log.error(sm.getString(
                         "jmxRemoteLifecycleListener.createRegistryFailed",
@@ -492,6 +498,10 @@ public class JmxRemoteLifecycleListener implements LifecycleListener {
     }
 
 
+    /*
+     * Better to use the internal API than re-invent the wheel.
+     */
+    @SuppressWarnings("restriction")
     private static class JmxRegistry extends sun.rmi.registry.RegistryImpl {
         private static final long serialVersionUID = -3772054804656428217L;
         private final String jmxName;
diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml
index f4341ed..50bca30 100644
--- a/res/findbugs/filter-false-positives.xml
+++ b/res/findbugs/filter-false-positives.xml
@@ -203,6 +203,12 @@
     <Bug code="REC" />
   </Match>
   <Match>
+    <!-- Object is used via side-effect of creation. -->
+    <Class name="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" />
+    <Method name="createServer" />
+    <Bug pattern="DLS_DEAD_LOCAL_STORE" />
+  </Match>
+  <Match>
     <Class name="org.apache.catalina.realm.JDBCRealm" />
     <Field name="containerLog" />
     <Bug code="IS" />


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