The following issue has been updated: Updater: Ola Sandness (mailto:[EMAIL PROTECTED]) Date: Fri, 10 Dec 2004 4:31 AM Comment: The DirectoryIndexer with try-catch-finally block Changes: Attachment changed to DirectoryIndexer.java --------------------------------------------------------------------- For a full history of the issue, see:
http://jira.codehaus.org/browse/MPJXR-20?page=history --------------------------------------------------------------------- View the issue: http://jira.codehaus.org/browse/MPJXR-20 Here is an overview of the issue: --------------------------------------------------------------------- Key: MPJXR-20 Summary: JXR does not close streams properly, and causes build failures with Maven and Cruisecontrol Type: Bug Status: Unassigned Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: maven-jxr-plugin Versions: 1.4.1 Assignee: Reporter: Ola Sandness Created: Fri, 10 Dec 2004 4:29 AM Updated: Fri, 10 Dec 2004 4:31 AM Environment: Cruisecontrol 2.2, Maven 1.0.2, JXR 1.4.2, 1.4.1_01, Windows 2000 Server. Description: 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. --------------------------------------------------------------------- JIRA INFORMATION: 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 If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]