diff --git a/src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java b/src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java
index d82fb6a..faeead6 100644
— a/src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java
+++ b/src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java
@@ -51,13 +51,8 @@ public class CoberturaCoverageParser { bufferedInputStream = new BufferedInputStream(fileInputStream); return parse(bufferedInputStream, cumulative, sourcePaths); } finally {

  • try { - if (bufferedInputStream != null) - bufferedInputStream.close(); - if (fileInputStream != null) - fileInputStream.close(); - } catch (IOException e) { - }
    + IOUtils.closeQuietly(bufferedInputStream);
    + IOUtils.closeQuietly(fileInputStream);
    }
    }

diff --git a/src/main/java/hudson/plugins/cobertura/IOUtils.java b/src/main/java/hudson/plugins/cobertura/IOUtils.java
new file mode 100644
index 0000000..6067365
— /dev/null
+++ b/src/main/java/hudson/plugins/cobertura/IOUtils.java
@@ -0,0 +1,21 @@
+package hudson.plugins.cobertura;
+
+import java.io.Closeable;
+
+/**
+ * General IO stream manipulation utilities.
+ */
+public class IOUtils {
+ /**
+ * Closes a Closeable unconditionally.
+ * Equivalent to Closeable.close(), except any exceptions will be ignored. This is typically used in finally blocks.
+ */
+ public static void closeQuietly(Closeable closeable) {
+ if (closeable != null) {
+ try { + closeable.close(); + } catch (Throwable t) { + }
+ }
+ }
+}
diff --git a/src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java b/src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java
index 0e6e0d0..a6c968e 100644
— a/src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java
+++ b/src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java
@@ -1,5 +1,7 @@
package hudson.plugins.cobertura.renderers;

+import static hudson.plugins.cobertura.IOUtils.closeQuietly;
+
import hudson.FilePath;
import hudson.model.BuildListener;
import hudson.plugins.cobertura.targets.CoveragePaint;
@@ -97,26 +99,12 @@ public class SourceCodePainter implements FilePath.FileCallable<Boolean>, Serial
}

} finally {

  • if (output != null) { - output.close(); - }
  • if (bos != null) { - bos.close(); - }
  • if (input != null) { - input.close(); - }
  • if (is != null) { - is.close(); - }
    -
    -
  • if (os != null) { - os.close(); - }
  • if (reader != null) { - reader.close(); - }
    + closeQuietly(output);
    + closeQuietly(bos);
    + closeQuietly(input);
    + closeQuietly(is);
    + closeQuietly(os);
    + closeQuietly(reader);
    }
    }
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to