From 6ff243cfc167e12284139913ddae9d274da34744 Mon Sep 17 00:00:00 2001 From: Denis Lila Date: Wed, 9 Mar 2011 13:51:48 -0500 Subject: netx findbugs based refactoring. --- netx/net/sourceforge/jnlp/JNLPFile.java | 2 +- netx/net/sourceforge/jnlp/Parser.java | 1 - netx/net/sourceforge/jnlp/cache/Resource.java | 3 --- netx/net/sourceforge/jnlp/cache/ResourceTracker.java | 2 +- netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java | 2 +- netx/net/sourceforge/jnlp/event/ApplicationEvent.java | 2 +- netx/net/sourceforge/jnlp/event/DownloadEvent.java | 4 ++-- netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java | 6 +----- netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 7 +++---- netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java | 11 +---------- .../sourceforge/jnlp/security/NotAllSignedWarningPane.java | 3 --- netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java | 2 +- .../net/sourceforge/jnlp/security/viewer/CertificatePane.java | 2 +- netx/net/sourceforge/jnlp/services/ServiceUtil.java | 2 +- netx/net/sourceforge/jnlp/tools/JarSigner.java | 3 --- netx/net/sourceforge/jnlp/util/XDesktopEntry.java | 2 -- 16 files changed, 14 insertions(+), 40 deletions(-) (limited to 'netx/net/sourceforge/jnlp') diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java index 78fc60d..5f0a955 100644 --- a/netx/net/sourceforge/jnlp/JNLPFile.java +++ b/netx/net/sourceforge/jnlp/JNLPFile.java @@ -188,7 +188,7 @@ public class JNLPFile { this.fileLocation = location; this.uniqueKey = Calendar.getInstance().getTimeInMillis() + "-" + - Math.abs(((new java.util.Random()).nextInt())) + "-" + + ((int)(Math.random()*Integer.MAX_VALUE)) + "-" + location; if (JNLPRuntime.isDebug()) diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java index d69c786..aeb03b9 100644 --- a/netx/net/sourceforge/jnlp/Parser.java +++ b/netx/net/sourceforge/jnlp/Parser.java @@ -336,7 +336,6 @@ class Parser { String part = getAttribute(node, "part", null); boolean main = "true".equals(getAttribute(node, "main", "false")); boolean lazy = "lazy".equals(getAttribute(node, "download", "eager")); - int size = Integer.parseInt(getAttribute(node, "size", "0")); if (nativeJar && main) if (strict) diff --git a/netx/net/sourceforge/jnlp/cache/Resource.java b/netx/net/sourceforge/jnlp/cache/Resource.java index 57aa338..1c4cb0f 100644 --- a/netx/net/sourceforge/jnlp/cache/Resource.java +++ b/netx/net/sourceforge/jnlp/cache/Resource.java @@ -79,9 +79,6 @@ public class Resource { /** the version downloaded from server */ Version downloadVersion; - /** connection to resource */ - URLConnection connection; - /** amount in bytes transferred */ long transferred = 0; diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java index a09f1c5..4ef0e0d 100644 --- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java +++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java @@ -94,7 +94,7 @@ public class ResourceTracker { // lock, prefetch, this.resources, each resource, listeners /** notified on initialization or download of a resource */ - private static Object lock = new Integer(0); // used to lock static structures + private static final Object lock = new Object(); // used to lock static structures // shortcuts private static final int UNINITIALIZED = Resource.UNINITIALIZED; diff --git a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java index f816824..7400b3f 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java +++ b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java @@ -71,7 +71,7 @@ public class ControlPanel extends JFrame { * @author @author Andrew Su (asu@redhat.com, andrew.su@utoronto.ca) * */ - private class SettingsPanel { + private static class SettingsPanel { final String value; final JPanel panel; diff --git a/netx/net/sourceforge/jnlp/event/ApplicationEvent.java b/netx/net/sourceforge/jnlp/event/ApplicationEvent.java index c7c5b66..19c6fc5 100644 --- a/netx/net/sourceforge/jnlp/event/ApplicationEvent.java +++ b/netx/net/sourceforge/jnlp/event/ApplicationEvent.java @@ -29,7 +29,7 @@ import net.sourceforge.jnlp.runtime.*; public class ApplicationEvent extends EventObject { /** the application instance */ - private ApplicationInstance application; + transient private ApplicationInstance application; /** * Creates a launch event for the specified application diff --git a/netx/net/sourceforge/jnlp/event/DownloadEvent.java b/netx/net/sourceforge/jnlp/event/DownloadEvent.java index 1990ab2..b8007fd 100644 --- a/netx/net/sourceforge/jnlp/event/DownloadEvent.java +++ b/netx/net/sourceforge/jnlp/event/DownloadEvent.java @@ -31,10 +31,10 @@ import net.sourceforge.jnlp.cache.*; public class DownloadEvent extends EventObject { /** the tracker */ - private ResourceTracker tracker; + transient private ResourceTracker tracker; /** the resource */ - private Resource resource; + transient private Resource resource; /** * Creates a launch event for the specified application diff --git a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java index f55c95d..993bf50 100644 --- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java +++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java @@ -43,14 +43,11 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** the JNLP file */ private JNLPFile file; - /** the applet instance */ - private AppletInstance appletInstance; - /** the applet */ private Applet applet; /** the parameters */ - private Map parameters; + private Map parameters; /** the applet container */ private Container cont; @@ -70,7 +67,6 @@ public class AppletEnvironment implements AppletContext, AppletStub { */ public AppletEnvironment(JNLPFile file, final AppletInstance appletInstance, Container cont) { this.file = file; - this.appletInstance = appletInstance; this.applet = appletInstance.getApplet(); parameters = file.getApplet().getParameters(); diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index 6bebfc6..1a41c1d 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -39,7 +39,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.TreeSet; import java.util.Vector; import java.util.jar.JarEntry; @@ -853,10 +852,10 @@ public class JNLPClassLoader extends URLClassLoader { * calls. */ protected File getNativeDir() { + final int rand = (int)((Math.random()*2 - 1) * Integer.MAX_VALUE); nativeDir = new File(System.getProperty("java.io.tmpdir") + File.separator + "netx-native-" - + (new Random().nextInt() & 0xFFFF)); - + + (rand & 0xFFFF)); File parent = nativeDir.getParentFile(); if (!parent.isDirectory() && !parent.mkdirs()) { return null; @@ -1328,7 +1327,7 @@ public class JNLPClassLoader extends URLClassLoader { * Helper class to expose protected URLClassLoader methods. */ - public class CodeBaseClassLoader extends URLClassLoader { + public static class CodeBaseClassLoader extends URLClassLoader { JNLPClassLoader parentJNLPClassLoader; diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java index 26eb799..b45dd8b 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java @@ -98,9 +98,6 @@ class JNLPSecurityManager extends AWTSecurityManager { private WeakList weakApplications = new WeakList(); - /** weak reference to most app who's windows was most recently activated */ - private WeakReference activeApplication = null; - /** Sets whether or not exit is allowed (in the context of the plugin, this is always false) */ private boolean exitAllowed = true; @@ -449,13 +446,7 @@ class JNLPSecurityManager extends AWTSecurityManager { // but when they really call, stop only the app instead of the JVM ApplicationInstance app = getApplication(stack, 0); if (app == null) { - // should check caller to make sure it is JFrame.close or - // other known System.exit call - if (activeApplication != null) - app = (ApplicationInstance) activeApplication.get(); - - if (app == null) - throw new SecurityException(R("RExitNoApp")); + throw new SecurityException(R("RExitNoApp")); } app.destroy(); diff --git a/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java b/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java index 2e3564b..b60011c 100644 --- a/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java +++ b/netx/net/sourceforge/jnlp/security/NotAllSignedWarningPane.java @@ -53,8 +53,6 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; -import net.sourceforge.jnlp.JNLPFile; - public class NotAllSignedWarningPane extends SecurityDialogPanel { public NotAllSignedWarningPane(SecurityDialog x) { @@ -66,7 +64,6 @@ public class NotAllSignedWarningPane extends SecurityDialogPanel { * Creates the actual GUI components, and adds it to this panel */ private void addComponents() { - JNLPFile file = parent.getFile(); String topLabelText = R("SNotAllSignedSummary"); String infoLabelText = R("SNotAllSignedDetail"); diff --git a/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java b/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java index e6007f4..c8354fb 100644 --- a/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java +++ b/netx/net/sourceforge/jnlp/security/SecurityDialogPanel.java @@ -100,7 +100,7 @@ public abstract class SecurityDialogPanel extends JPanel { * Creates a handler that sets a dialog's value and then disposes it when activated * */ - private class SetValueHandler implements ActionListener { + private static class SetValueHandler implements ActionListener { Integer buttonIndex; SecurityDialog dialog; diff --git a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java index db4e0cb..4f0af58 100644 --- a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java +++ b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java @@ -299,7 +299,7 @@ public class CertificatePane extends JPanel { } /** Allows storing KeyStores.Types in a JComponent */ - private class CertificateType { + private static class CertificateType { private final KeyStores.Type type; public CertificateType(KeyStores.Type type) { diff --git a/netx/net/sourceforge/jnlp/services/ServiceUtil.java b/netx/net/sourceforge/jnlp/services/ServiceUtil.java index 55c2172..69e44a9 100644 --- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java +++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java @@ -282,7 +282,7 @@ public class ServiceUtil { public Boolean run() { boolean b = SecurityDialogs.showAccessWarningDialog(tmpType, tmpApp.getJNLPFile(), tmpExtras); - return new Boolean(b); + return Boolean.valueOf(b); } }); diff --git a/netx/net/sourceforge/jnlp/tools/JarSigner.java b/netx/net/sourceforge/jnlp/tools/JarSigner.java index 14ca069..11bbbb5 100644 --- a/netx/net/sourceforge/jnlp/tools/JarSigner.java +++ b/netx/net/sourceforge/jnlp/tools/JarSigner.java @@ -425,9 +425,6 @@ public class JarSigner implements CertVerifier { details.add(detail); } - Hashtable storeHash = - new Hashtable(); - /** * signature-related files include: * . META-INF/MANIFEST.MF diff --git a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java index b13fcea..6e3a7e1 100644 --- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java +++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java @@ -72,8 +72,6 @@ public class XDesktopEntry { */ public Reader getContentsAsReader() { - String pathToJavaws = System.getProperty("java.home") + File.separator + "bin" - + File.separator + "javaws"; String cacheDir = JNLPRuntime.getConfiguration() .getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR); File cacheFile = CacheUtil.urlToPath(file.getSourceLocation(), cacheDir); -- cgit v1.2.3