Skip to content
Permalink
Browse files
Fixed SonarQube findings ...
  • Loading branch information
chrisdutz committed Dec 18, 2016
1 parent 790b355 commit 2e6768445a730216aaafcfc8f46c57044dd2b3c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
@@ -94,10 +94,9 @@ protected void processArchive() throws ConverterException {

protected String calculateChecksum(File jarFile) throws ConverterException {
// Implement the calculation of checksums for a given jar.
final MessageDigest digest;
InputStream is = null;
try {
digest = MessageDigest.getInstance("SHA-1");
MessageDigest digest = MessageDigest.getInstance("SHA-1");

is = new FileInputStream(jarFile);
final byte[] buffer = new byte[8192];
@@ -118,15 +117,13 @@ protected String calculateChecksum(File jarFile) throws ConverterException {
} catch (FileNotFoundException e) {
throw new ConverterException("Error calculating checksum of file '" + jarFile.getPath() + "'", e);
} finally {
try {
if(is != null) {
if(is != null) {
try {
is.close();
} catch(IOException e) {
// Ignore ...
}
}
catch(IOException e) {
//noinspection ThrowFromFinallyBlock
throw new ConverterException("Unable to close input stream for MD5 calculation", e);
}
}
}

@@ -232,7 +229,7 @@ protected void copyFile(File source, File target) throws ConverterException {
final File outputDirectory = target.getParentFile();
if(!outputDirectory.exists()) {
if(!outputDirectory.mkdirs()) {
throw new RuntimeException("Could not create directory: " + outputDirectory.getAbsolutePath());
throw new ConverterException("Could not create directory: " + outputDirectory.getAbsolutePath());
}
}

@@ -465,11 +462,11 @@ protected String getFlexVersion(File rootDirectory) throws ConverterException {
// In general the version consists of the content of the version element with an appended build-number.
return (build.equals("0")) ? version + "-SNAPSHOT" : version;
} catch (ParserConfigurationException pce) {
throw new RuntimeException(pce);
throw new ConverterException("Error parsing flex-sdk-description.xml", pce);
} catch (SAXException se) {
throw new RuntimeException(se);
throw new ConverterException("Error parsing flex-sdk-description.xml", se);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
throw new ConverterException("Error parsing flex-sdk-description.xml", ioe);
}
}

@@ -498,7 +498,7 @@ public boolean accept(File pathname) {
final File targetDirectory = targetFile.getParentFile();
if (!targetDirectory.exists()) {
if (!targetDirectory.mkdirs()) {
throw new RuntimeException("Could not create directory: " + targetDirectory.getCanonicalPath());
throw new ConverterException("Could not create directory: " + targetDirectory.getCanonicalPath());
}
}

@@ -572,11 +572,11 @@ protected String getFlexBuild(File rootDirectory) throws ConverterException {
final Element root = dom.getDocumentElement();
return root.getElementsByTagName("build").item(0).getTextContent();
} catch (ParserConfigurationException pce) {
throw new RuntimeException(pce);
throw new ConverterException("Error parsing flex-sdk-description.xml", pce);
} catch (SAXException se) {
throw new RuntimeException(se);
throw new ConverterException("Error parsing flex-sdk-description.xml", se);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
throw new ConverterException("Error parsing flex-sdk-description.xml", ioe);
}
}

0 comments on commit 2e67684

Please sign in to comment.