Program: 74138
Project: 74138
Buggy source:
/** 
 * Sign a jar file.
 * @param jarFileName  The name of the jar file to be signed.
 * @param signedJarFileName  The name of the signed jar file to be created.
 * @param keystoreFileName The name of the keystore file.  To create a keystore file, run<pre> cd $PTII make ptKeystore make jnlp_list <pre>
 * @param alias The alias of the certificate.  This is the string used when the key is created.
 * @param storePassword  The password of the key store.
 * @param keyPassword  The password of the key store.
 * @exception Exception  If there is a problem open or closing files, or a problem signingthe jar file.
 */
public static void sign(String jarFileName,String signedJarFileName,String keystoreFileName,String alias,char[] storePassword,char[] keyPassword) throws Exception {
  FileInputStream fileIn=null;
  OutputStream outStream=null;
  try {
    fileIn=new FileInputStream(keystoreFileName);
    KeyStore keyStore=KeyStore.getInstance("String_Node_Str");
    keyStore.load(fileIn,storePassword);
    Certificate[] chain=keyStore.getCertificateChain(alias);
    if (chain == null) {
      throw new Exception("String_Node_Str" + alias + "String_Node_Str"+ keystoreFileName+ "String_Node_Str");
    }
    X509Certificate certChain[]=new X509Certificate[0];
    if (chain != null) {
      certChain=new X509Certificate[chain.length];
      CertificateFactory cf=CertificateFactory.getInstance("String_Node_Str");
      for (int count=0; count < chain.length; count++) {
        ByteArrayInputStream certIn=new ByteArrayInputStream(chain[0].getEncoded());
        X509Certificate cert=(X509Certificate)cf.generateCertificate(certIn);
        certChain[count]=cert;
      }
    }
    Key key=keyStore.getKey(alias,keyPassword);
    if (key == null) {
      throw new Exception("String_Node_Str" + alias + "String_Node_Str"+ keystoreFileName+ "String_Node_Str");
    }
    KeyFactory keyFactory=KeyFactory.getInstance(key.getAlgorithm());
    KeySpec keySpec=keyFactory.getKeySpec(key,DSAPrivateKeySpec.class);
    PrivateKey privateKey=keyFactory.generatePrivate(keySpec);
    JarSigner jarSigner=new JarSigner("String_Node_Str",privateKey,certChain);
    JarFile jarFile=null;
    try {
      jarFile=new JarFile(jarFileName);
      outStream=new FileOutputStream(signedJarFileName);
      jarSigner._signJarFile(jarFile,outStream);
    }
  finally {
      if (jarFile != null) {
        jarFile.close();
      }
    }
  }
  finally {
    if (fileIn != null) {
      try {
        fileIn.close();
      }
 catch (      IOException ex) {
        if (outStream != null) {
          outStream.close();
        }
        throw ex;
      }
    }
    if (outStream != null) {
      outStream.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sign a jar file.
 * @param jarFileName  The name of the jar file to be signed.
 * @param signedJarFileName  The name of the signed jar file to be created.
 * @param keystoreFileName The name of the keystore file.  To create a keystore file, run<pre> cd $PTII make ptKeystore make jnlp_list <pre>
 * @param alias The alias of the certificate.  This is the string used when the key is created.
 * @param storePassword  The password of the key store.
 * @param keyPassword  The password of the key store.
 * @exception Exception  If there is a problem open or closing files, or a problem signingthe jar file.
 */
public static void sign(String jarFileName,String signedJarFileName,String keystoreFileName,String alias,char[] storePassword,char[] keyPassword) throws Exception {
  FileInputStream fileIn=null;
  OutputStream outStream=null;
  try {
    fileIn=new FileInputStream(keystoreFileName);
    KeyStore keyStore=KeyStore.getInstance("String_Node_Str");
    keyStore.load(fileIn,storePassword);
    Certificate[] chain=keyStore.getCertificateChain(alias);
    if (chain == null) {
      throw new Exception("String_Node_Str" + alias + "String_Node_Str"+ keystoreFileName+ "String_Node_Str");
    }
    X509Certificate certChain[]=new X509Certificate[0];
    certChain=new X509Certificate[chain.length];
    CertificateFactory cf=CertificateFactory.getInstance("String_Node_Str");
    for (int count=0; count < chain.length; count++) {
      ByteArrayInputStream certIn=new ByteArrayInputStream(chain[0].getEncoded());
      X509Certificate cert=(X509Certificate)cf.generateCertificate(certIn);
      certChain[count]=cert;
    }
    Key key=keyStore.getKey(alias,keyPassword);
    if (key == null) {
      throw new Exception("String_Node_Str" + alias + "String_Node_Str"+ keystoreFileName+ "String_Node_Str");
    }
    KeyFactory keyFactory=KeyFactory.getInstance(key.getAlgorithm());
    KeySpec keySpec=keyFactory.getKeySpec(key,DSAPrivateKeySpec.class);
    PrivateKey privateKey=keyFactory.generatePrivate(keySpec);
    JarSigner jarSigner=new JarSigner("String_Node_Str",privateKey,certChain);
    JarFile jarFile=null;
    try {
      jarFile=new JarFile(jarFileName);
      outStream=new FileOutputStream(signedJarFileName);
      jarSigner._signJarFile(jarFile,outStream);
    }
  finally {
      if (jarFile != null) {
        jarFile.close();
      }
    }
  }
  finally {
    if (fileIn != null) {
      try {
        fileIn.close();
      }
 catch (      IOException ex) {
        if (outStream != null) {
          outStream.close();
        }
        throw ex;
      }
    }
    if (outStream != null) {
      outStream.close();
    }
  }
}