You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Carlos Sanchez (JIRA)" <ji...@codehaus.org> on 2005/08/05 03:43:57 UTC

[jira] Closed: (MPJXR-20) JXR does not close streams properly, and causes build failures with Maven and Cruisecontrol

     [ http://jira.codehaus.org/browse/MPJXR-20?page=all ]
     
Carlos Sanchez closed MPJXR-20:
-------------------------------

     Resolution: Fixed
    Fix Version: 1.4.3

> JXR does not close streams properly, and causes build failures with Maven and Cruisecontrol
> -------------------------------------------------------------------------------------------
>
>          Key: MPJXR-20
>          URL: http://jira.codehaus.org/browse/MPJXR-20
>      Project: maven-jxr-plugin
>         Type: Bug
>     Versions: 1.4.1
>  Environment: Cruisecontrol 2.2, Maven 1.0.2, JXR 1.4.2, 1.4.1_01, Windows 2000 Server.
>     Reporter: Ola Sandness
>     Assignee: Carlos Sanchez
>      Fix For: 1.4.3
>  Attachments: CodeTransform.java, DirectoryIndexer.java, DirectoryIndexer.patch
>
>
> When running my maven script (multiproject:site) from Cruisecontrol 2.2, the jxr plugin causes random build failures, even though my code is OK. I can not recreate this problem running outside Cruisecontrol. The build fails with this message:
> maven-jxr-plugin:report 
> [echo] 
> Scanning D:\builds\checkout\****\java
> BUILD FAILED
> File...... C:\Documents and Settings\edialog\.maven\cache\maven-multiproject-plugin-1.3.1\plugin.jelly
> Element... maven:reactor
> Line...... 103
> Column.... 9
> Unable to obtain goal [site] -- C:\Documents and Settings\edialog\.maven\cache\maven-jxr-plugin-1.4.2\plugin.jelly:105:31: <jxr:jxr> D:\builds\checkout\***\target\docs\xref\index.html (The process cannot access the file because it is being used by another process)
> Total time: 6 minutes 41 seconds
> Finished at: Fri Dec 03 10:54:48 CET 2004 
> I've created a workaround for this:
> In CodeTransform.java, I've added a catch statement before the finally block in the transform method:
> catch (FileNotFoundException e)
>         {
>            System.out.println("IGNORING: FileNotFoundException - file is probably in use by another process! Unable to process " + sourcefile + " => " + destfile);           
>         }
>         catch (RuntimeException e)
>         {
>             System.out.println("Unable to process " + sourcefile + " => " + destfile);
>             throw e;
>         }
> Also, I've added some cleanup code in the doJellyFile method in the DirectoryIndexer.java:
>  private void doJellyFile(String templateName, String outDir, JellyContext context)
>    throws Exception
>    {
>       String outFile = outDir + "/" + templateName + ".html";
>       OutputStream out = null;
>       try
>       {
>          // Throws FileNotFoundException
>          out = new FileOutputStream(outFile);
>          String templateFileName = getTemplateDir() + "/" + templateName + ".jelly";
>          File templateFile = new File(templateFileName);
>          File theFile = new File(outFile);
>          File dir = theFile.getParentFile();
>          if (dir != null)
>          {
>             dir.mkdirs();
>          }
>          // Throws UnsupportedEncodingException
>          XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false);
>          // Throws JellyException
>          context.runScript(templateFile, xmlOutput);
>          // Throws IOException
>          xmlOutput.flush();
>       }
>       catch (Throwable e)
>       {
>          System.out.println("IGNORING: Failed to process file [" + outFile + "]. Closing streams and moving on. Exception: " + e);
>       }
>       finally
>       {
>          try
>          {
>             if( out != null )
>             {
>                out.close();
>             }
>          }
>          catch (IOException e)
>          {
>             System.out.println("Failed to close outputstream for file [" + outFile + "], which is a bad thing!" );
>             throw e;
>          }
>       }
>    }
> This seems to do the trick for now, but I guess the xref docs could be in a state of limbo sometimes.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org