Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6452571

Bad example code in javadoc for java.security.KeyStore

XMLWordPrintable

    • b95
    • sparc
    • solaris_9

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b92)
      Java HotSpot(TM) Server VM (build 1.6.0-rc-b92, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      not relevant

      A DESCRIPTION OF THE PROBLEM :
      The example code in the JavaDoc for java.security.KeyStore is erroneous. It
      doesn't use a finally block to ensure that the input stream is closed. For example:

         KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());

          // get user password and file input stream
          char[] password = getPassword();
          java.io.FileInputStream fis =
              new java.io.FileInputStream("keyStoreName");
          ks.load(fis, password);
          fis.close();

      Same problem for the example code showing a call to store.

      Since example code in JavaDoc often gets widely copied, fixing this would be good.
      Unclosed input/output streams can have seriously bad effects on enterprise applications.


      REPRODUCIBILITY :
      This bug can be reproduced always.

            xuelei Xuelei Fan
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: