Fixed SonarQube findings ...

Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/2e676844
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/2e676844
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/2e676844

Branch: refs/heads/feature/flash-downloader
Commit: 2e6768445a730216aaafcfc8f46c57044dd2b3c1
Parents: 790b355
Author: Christofer Dutz <christofer.d...@codecentric.de>
Authored: Sun Dec 18 15:28:47 2016 +0100
Committer: Christofer Dutz <christofer.d...@codecentric.de>
Committed: Sun Dec 18 15:28:47 2016 +0100

----------------------------------------------------------------------
 .../flex/utilities/converter/BaseConverter.java | 21 +++++++++-----------
 .../utilities/converter/flex/FlexConverter.java |  8 ++++----
 2 files changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/2e676844/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git 
a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
 
b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index d3171fb..d80cf8f 100644
--- 
a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ 
b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -94,10 +94,9 @@ public abstract class BaseConverter {
 
     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 @@ public abstract class BaseConverter {
         } 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 @@ public abstract class BaseConverter {
             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 @@ public abstract class BaseConverter {
             // 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);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/2e676844/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
----------------------------------------------------------------------
diff --git 
a/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
 
b/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
index cbe7e87..35013d0 100644
--- 
a/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
+++ 
b/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
@@ -498,7 +498,7 @@ public class FlexConverter extends BaseConverter implements 
Converter {
                 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 @@ public class FlexConverter extends BaseConverter 
implements Converter {
             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);
         }
     }
 

Reply via email to