mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
16.29.2011 23cf07c2c64ba72f59b3257b9b91f4c8814b05ce
Fix for Issue OPENDJ-151 - Resolve a couple of potential issues raised by FindBugs.
5 files modified
116 ■■■■ changed files
opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java 33 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/LDIFBackend.java 23 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/SchemaBackend.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/TrustStoreBackend.java 49 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/common/ChangeNumberGenerator.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.admin.client.cli;
@@ -814,10 +815,11 @@
      else
        if (trustStorePathArg.isPresent())
        {
          FileInputStream fos = null;
          try
          {
            FileInputStream fos =
              new FileInputStream(trustStorePathArg.getValue());
            fos = new FileInputStream(trustStorePathArg.getValue());
            String trustStorePasswordStringValue = null;
            char[] trustStorePasswordValue = null;
            if (trustStorePasswordArg.isPresent())
@@ -845,7 +847,6 @@
            truststore = KeyStore.getInstance(KeyStore.getDefaultType());
            truststore.load(fos, trustStorePasswordValue);
            fos.close();
          }
          catch (KeyStoreException e)
          {
@@ -875,6 +876,17 @@
            // are in a best effort mode.
            LOG.log(Level.WARNING, "Error with the truststore", e);
          }
          finally
          {
            if (fos != null)
            {
              try
              {
                fos.close();
              }
              catch (Exception e) {}
            }
          }
        }
      trustManager = new ApplicationTrustManager(truststore);
    }
@@ -893,9 +905,10 @@
    char[] keyStorePasswordValue = null;
    if (keyStorePathArg.isPresent())
    {
      FileInputStream fos = null;
      try
      {
        FileInputStream fos = new FileInputStream(keyStorePathArg.getValue());
        fos = new FileInputStream(keyStorePathArg.getValue());
        if (keyStorePasswordArg.isPresent())
        {
          keyStorePasswordStringValue = keyStorePasswordArg.getValue();
@@ -911,7 +924,6 @@
        keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
        keyStore.load(fos,keyStorePasswordValue);
        fos.close();
      }
      catch (KeyStoreException e)
      {
@@ -948,6 +960,17 @@
        // in a best effort mode.
        LOG.log(Level.WARNING, "Error with the keystore", e);
      }
      finally
      {
        if (fos != null)
        {
          try {
            fos.close();
          }
          catch (Exception e) {}
        }
      }
      char[] password = null;
      if (keyStorePasswordStringValue != null)
      {
opends/src/server/org/opends/server/backends/LDIFBackend.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.backends;
@@ -637,19 +638,21 @@
        else
        {
          DN matchedDN = null;
          // BUG: parentDN can be null when entering the loop
          while (true)
          if (parentDN != null)
          {
            parentDN = parentDN.getParentDNInSuffix();
            if (parentDN == null)
            while (true)
            {
              break;
            }
              parentDN = parentDN.getParentDNInSuffix();
              if (parentDN == null)
              {
                break;
              }
            if (entryMap.containsKey(parentDN))
            {
              matchedDN = parentDN;
              break;
              if (entryMap.containsKey(parentDN))
              {
                matchedDN = parentDN;
                break;
              }
            }
          }
opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -4435,9 +4435,8 @@
   * Import an entry in a new schema by :
   *   - duplicating the schema
   *   - iterating over each element of the newSchemaEntry and comparing
   *     with the xisting schema
   *     with the existing schema
   *   - if the new schema element do not exist : add it
   *   - if the new schema.
   *
   *   FIXME : attributeTypes and objectClasses are the only elements
   *   currently taken into account.
opends/src/server/org/opends/server/backends/TrustStoreBackend.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.backends;
@@ -230,6 +231,8 @@
          String pinStr = configuration.getTrustStorePin();
          if (pinStr == null)
          {
            // This should be an Error. Otherwise, programs fails.
            // Is there a Unit Test?
            trustStorePIN = null;
          }
          else
@@ -1364,14 +1367,14 @@
         throws DirectoryException
  {
    KeyStore keyStore;
    FileInputStream inputStream = null;
    try
    {
      keyStore = KeyStore.getInstance(trustStoreType);
      FileInputStream inputStream =
      inputStream =
           new FileInputStream(getFileForPath(trustStoreFile));
      keyStore.load(inputStream, trustStorePIN);
      inputStream.close();
    }
    catch (Exception e)
    {
@@ -1385,6 +1388,17 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      if (inputStream != null)
      {
        try
        {
          inputStream.close();
        }
        catch (Exception e){}
      }
    }
    try
@@ -1424,14 +1438,14 @@
         throws DirectoryException
  {
    KeyStore trustStore;
    FileInputStream inputStream = null;
    try
    {
      trustStore = KeyStore.getInstance(trustStoreType);
      FileInputStream inputStream =
      inputStream =
           new FileInputStream(getFileForPath(trustStoreFile));
      trustStore.load(inputStream, trustStorePIN);
      inputStream.close();
    }
    catch (Exception e)
    {
@@ -1445,6 +1459,17 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      if (inputStream != null)
      {
        try
        {
          inputStream.close();
        }
        catch (Exception e){}
      }
    }
    try
@@ -1492,14 +1517,14 @@
         throws DirectoryException
  {
    KeyStore trustStore;
    FileInputStream inputStream = null;
    try
    {
      trustStore = KeyStore.getInstance(trustStoreType);
      FileInputStream inputStream =
      inputStream =
           new FileInputStream(getFileForPath(trustStoreFile));
      trustStore.load(inputStream, trustStorePIN);
      inputStream.close();
    }
    catch (Exception e)
    {
@@ -1513,7 +1538,17 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      if (inputStream != null)
      {
        try
        {
          inputStream.close();
        }
        catch (Exception e){}
      }
    }
    try
    {
opends/src/server/org/opends/server/replication/common/ChangeNumberGenerator.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.replication.common;
@@ -118,8 +119,11 @@
  {
    if (number==null)
    {
      lastTime = TimeThread.getTime();
      seqnum = 0;
      synchronized(this)
      {
        lastTime = TimeThread.getTime();
        seqnum = 0;
      }
      return;
    }