[RFC][icedtea-web][JarCertVerifier Update] Remove/update useless variables
Deepak Bhole
dbhole at redhat.com
Wed Apr 18 07:20:29 PDT 2012
* Danesh Dadachanji <ddadacha at redhat.com> [2012-04-05 16:52]:
> Hi,
>
> When going through updates for JarCertVerifier, I stumbled across
> these to variables that don't serve much purpose. The two
> ArrayLists, verifiedJars and unverifiedJars contain the jars passed
> into JarCertVerifier that are either verified or unverified.
> However, the lists' contents are never read, except for in
> allJarsSigned().
>
> To clarify, verifiedJars is never touched apart from declaration and
> adding contents so I propose we remove its unnecessary code
> altogether. Secondly, apart from initialization and adding contents,
> unverifiedJars is only read by the method mentioned above to check
> its size, let alone examine its contents. Since this is the case, an
> integer be a better fit for this variable. The attached patch does
> this.
>
> I could not find them being read anywhere outside of JarCertVerifier
> so I think these changes should be acceptable. What does everyone
> else think?
>
Looks fine to me. OK for HEAD.
Deepak
> ChangeLog:
> +2012-04-05 Danesh Dadachanji <ddadacha at redhat.com>
> +
> + Update useless variables in JarCertVerifier.
> + * netx/net/sourceforge/jnlp/tools/JarCertVerifier.java:
> + Removed verifiedJars list, renamed unverifiedJars to numUnverifiedJars
> + and changed its type to int instead of ArrayList.
> +
>
>
> Cheers,
> Danesh
> diff --git a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
> --- a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
> +++ b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
> @@ -89,11 +89,8 @@ public class JarCertVerifier implements
>
> private boolean anyJarsSigned = false;
>
> - /** all of the jar files that were verified */
> - private ArrayList<String> verifiedJars = null;
> -
> - /** all of the jar files that were not verified */
> - private ArrayList<String> unverifiedJars = null;
> + /** Number of the jar files that were not verified */
> + private int numUnverifiedJars = 0;
>
> /** the certificates used for jar verification */
> private HashMap<CertPath, Integer> certs = new HashMap<CertPath, Integer>();
> @@ -180,8 +177,7 @@ public class JarCertVerifier implements
> public void verifyJars(List<JARDesc> jars, ResourceTracker tracker)
> throws Exception {
>
> - verifiedJars = new ArrayList<String>();
> - unverifiedJars = new ArrayList<String>();
> + numUnverifiedJars = 0;
>
> for (int i = 0; i < jars.size(); i++) {
>
> @@ -201,12 +197,9 @@ public class JarCertVerifier implements
> verifyResult result = verifyJar(localFile);
>
> if (result == verifyResult.UNSIGNED) {
> - unverifiedJars.add(localFile);
> + numUnverifiedJars++;
> } else if (result == verifyResult.SIGNED_NOT_OK) {
> noSigningIssues = false;
> - verifiedJars.add(localFile);
> - } else if (result == verifyResult.SIGNED_OK) {
> - verifiedJars.add(localFile);
> }
> } catch (Exception e) {
> // We may catch exceptions from using verifyJar()
> @@ -549,7 +542,7 @@ public class JarCertVerifier implements
> * @return True if all jars are signed, false if there are one or more unsigned jars
> */
> public boolean allJarsSigned() {
> - return this.unverifiedJars.size() == 0;
> + return numUnverifiedJars == 0;
> }
>
> }
More information about the distro-pkg-dev
mailing list