Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-18858

Cobertura Unable to delete coverage.xml on windows

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • cobertura-plugin
    • Windows 2003 Server, Jenkins 1.523 Cobertura Plugin 1.9.1

      Sometimes job starting fails after successful executed with the error:

      ERROR: Failed to update svn://...
      org.tmatesoft.svn.core.SVNException: svn: E204900: Unable to delete ...\target\cobertura\report\coverage.xml
      at hudson.scm.subversion.UpdateWithCleanUpdater$TaskImpl$1.handleStatus(UpdateWithCleanUpdater.java:78)
      at org.tmatesoft.svn.core.wc.SVNStatusClient$1.receive(SVNStatusClient.java:356)
      at org.tmatesoft.svn.core.wc.SVNStatusClient$1.receive(SVNStatusClient.java:353)
      at org.tmatesoft.svn.core.wc2.SvnReceivingOperation.receive(SvnReceivingOperation.java:78)
      at org.tmatesoft.svn.core.internal.wc2.old.SvnOldGetStatus.handleStatus(SvnOldGetStatus.java:37)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.sendUnversionedStatus(SVNStatusEditor.java:361)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.getDirStatus(SVNStatusEditor.java:209)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.handleDirEntry(SVNStatusEditor.java:321)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.getDirStatus(SVNStatusEditor.java:256)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.handleDirEntry(SVNStatusEditor.java:321)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.getDirStatus(SVNStatusEditor.java:256)
      at org.tmatesoft.svn.core.internal.wc.SVNStatusEditor.closeEdit(SVNStatusEditor.java:114)
      at org.tmatesoft.svn.core.internal.wc16.SVNStatusClient16.doStatus(SVNStatusClient16.java:430)
      at org.tmatesoft.svn.core.internal.wc2.old.SvnOldGetStatus.run(SvnOldGetStatus.java:22)
      at org.tmatesoft.svn.core.internal.wc2.old.SvnOldGetStatus.run(SvnOldGetStatus.java:13)
      at org.tmatesoft.svn.core.internal.wc2.SvnOperationRunner.run(SvnOperationRunner.java:20)
      at org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1235)
      at org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:291)
      at org.tmatesoft.svn.core.wc.SVNStatusClient.doStatus(SVNStatusClient.java:360)
      at hudson.scm.subversion.UpdateWithCleanUpdater$TaskImpl.preUpdate(UpdateWithCleanUpdater.java:66)
      at hudson.scm.subversion.UpdateUpdater$TaskImpl.perform(UpdateUpdater.java:151)
      at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:153)
      at hudson.scm.SubversionSCM$CheckOutTask.perform(SubversionSCM.java:903)
      at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:884)
      at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:867)
      at hudson.FilePath.act(FilePath.java:906)
      at hudson.FilePath.act(FilePath.java:879)
      at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:843)
      at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:781)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1387)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
      at hudson.model.Run.execute(Run.java:1593)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:247)
      Caused by: svn: E204900: Unable to delete ...\target\cobertura\report\coverage.xml
      at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:109)
      ... 37 more
      Caused by: java.io.IOException: Unable to delete ...\target\cobertura\report\coverage.xml
      at hudson.Util.deleteFile(Util.java:253)
      at hudson.Util.deleteRecursive(Util.java:305)
      at hudson.Util.deleteContentsRecursive(Util.java:202)
      at hudson.Util.deleteRecursive(Util.java:296)
      at hudson.Util.deleteContentsRecursive(Util.java:202)
      at hudson.Util.deleteRecursive(Util.java:296)
      at hudson.Util.deleteContentsRecursive(Util.java:202)
      at hudson.Util.deleteRecursive(Util.java:296)
      at hudson.scm.subversion.UpdateWithCleanUpdater$TaskImpl$1.handleStatus(UpdateWithCleanUpdater.java:74)
      ... 36 more
      ERROR: Subversion update failedERROR: Failed to update svn://...

      The target\cobertura\report\coverage.xml is result of ant build step. I think that the Cobertura Plugin contains the file descriptor leaks. At the result, I need restart the Jenkins.

          [JENKINS-18858] Cobertura Unable to delete coverage.xml on windows

          Roman Erzhukov created issue -

          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);
            }
            }

          Roman Erzhukov added a comment - 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); } }

          sogabe added a comment -

          @Roman, Why don't you create pull request?

          sogabe added a comment - @Roman, Why don't you create pull request?

          I make it now.

          Roman Erzhukov added a comment - I make it now.

          Code changed in jenkins
          User: Roman Erzhukov
          Path:
          src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java
          src/main/java/hudson/plugins/cobertura/IOUtils.java
          src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java
          http://jenkins-ci.org/commit/cobertura-plugin/0493955e7caae5c990fdc10fd3dc050910695467
          Log:
          fix JENKINS-18858

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Roman Erzhukov Path: src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java src/main/java/hudson/plugins/cobertura/IOUtils.java src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java http://jenkins-ci.org/commit/cobertura-plugin/0493955e7caae5c990fdc10fd3dc050910695467 Log: fix JENKINS-18858

          Code changed in jenkins
          User: Seiji Sogabe
          Path:
          src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java
          src/main/java/hudson/plugins/cobertura/IOUtils.java
          src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java
          http://jenkins-ci.org/commit/cobertura-plugin/c0f7d7be1f553821f0ea7029fa4344654faa5fb7
          Log:
          Merge pull request #17 from romaerzhuk/master

          fix JENKINS-18858

          Compare: https://github.com/jenkinsci/cobertura-plugin/compare/e43258c5ad57...c0f7d7be1f55

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Seiji Sogabe Path: src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java src/main/java/hudson/plugins/cobertura/IOUtils.java src/main/java/hudson/plugins/cobertura/renderers/SourceCodePainter.java http://jenkins-ci.org/commit/cobertura-plugin/c0f7d7be1f553821f0ea7029fa4344654faa5fb7 Log: Merge pull request #17 from romaerzhuk/master fix JENKINS-18858 Compare: https://github.com/jenkinsci/cobertura-plugin/compare/e43258c5ad57...c0f7d7be1f55

          Rahul Parekh added a comment -

          We are running into the same issue and would appreciate if the fix can be pulled in. Thanks!

          Rahul Parekh added a comment - We are running into the same issue and would appreciate if the fix can be pulled in. Thanks!

          J L added a comment -

          This fix would help a lot. Thanks

          J L added a comment - This fix would help a lot. Thanks

          Neil Enns added a comment -

          We keep hitting this too Would love to see this fix integrated. Thanks!

          Neil Enns added a comment - We keep hitting this too Would love to see this fix integrated. Thanks!

          sogabe added a comment -

          Fixed in 1.9.2

          sogabe added a comment - Fixed in 1.9.2
          sogabe made changes -
          Assignee Original: Stephen Connolly [ stephenconnolly ] New: sogabe [ sogabe ]
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            sogabe sogabe
            romaerzhuk Roman Erzhukov
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: