Close streams properly on errors. MPJXR-20
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@230383 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.4.3-SNAPSHOT" date="in SVN">
|
||||
<action dev="carlos" type="fix" issue="MPJXR-20" due-to="Ola Sandness">Close streams properly on errors</action>
|
||||
<action dev="carlos" type="fix" issue="MPJXR-26">Ignore Java 5 package-info.java files</action>
|
||||
<action dev="brett" type="fix" issue="MPJXR-11" due-to="Lukas Theussi">Fix malformed HTML when "package" or "import" used in the code/comments outside of the normal keyword use</action>
|
||||
<action dev="evenisse" type="fix" issue="MPJXR-18">Remove hardcoded encoding in templates.</action>
|
||||
|
||||
Reference in New Issue
Block a user