diff --git a/jxr/src/main/org/apache/maven/jxr/CodeTransform.java b/jxr/src/main/org/apache/maven/jxr/CodeTransform.java index 8b17708f..416ef035 100644 --- a/jxr/src/main/org/apache/maven/jxr/CodeTransform.java +++ b/jxr/src/main/org/apache/maven/jxr/CodeTransform.java @@ -33,6 +33,7 @@ package org.apache.maven.jxr; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; @@ -747,6 +748,10 @@ public class CodeTransform implements Serializable out.println(getFooter()); out.flush(); } + 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); diff --git a/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java b/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java index 4efeb816..95102d6a 100644 --- a/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java +++ b/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java @@ -17,25 +17,22 @@ package org.apache.maven.jxr; * ==================================================================== */ -import org.apache.maven.jxr.pacman.PackageManager; -import org.apache.maven.jxr.pacman.PackageType; -import org.apache.maven.jxr.pacman.ClassType; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; -import java.util.TreeMap; import java.util.HashMap; import java.util.Iterator; import java.util.Map; - -import org.apache.oro.text.perl.Perl5Util; +import java.util.TreeMap; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.XMLOutput; +import org.apache.maven.jxr.pacman.ClassType; +import org.apache.maven.jxr.pacman.PackageManager; +import org.apache.maven.jxr.pacman.PackageType; +import org.apache.oro.text.perl.Perl5Util; /** * This class creates the navigational pages for jxr's cross-referenced source @@ -249,20 +246,46 @@ public class DirectoryIndexer throws Exception { String outFile = outDir + "/" + templateName + ".html"; - String templateFileName = getTemplateDir() + "/" + templateName + ".jelly"; - File templateFile = new File(templateFileName); + 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(); + File theFile = new File(outFile); + File dir = theFile.getParentFile(); + if (dir != null) + { + dir.mkdirs(); + } + + XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false); + context.runScript(templateFile, xmlOutput); + xmlOutput.flush(); } - OutputStream out = new FileOutputStream(outFile); - XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false); - context.runScript(templateFile, xmlOutput); - xmlOutput.flush(); - out.close(); - } + 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; + } + } + } /* diff --git a/jxr/xdocs/changes.xml b/jxr/xdocs/changes.xml index 09abcd3b..ec781947 100644 --- a/jxr/xdocs/changes.xml +++ b/jxr/xdocs/changes.xml @@ -26,6 +26,7 @@