You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by ca...@apache.org on 2005/08/05 03:42:59 UTC
svn commit: r230383 - in /maven/maven-1/plugins/trunk/jxr:
src/main/org/apache/maven/jxr/CodeTransform.java
src/main/org/apache/maven/jxr/DirectoryIndexer.java xdocs/changes.xml
Author: carlos
Date: Thu Aug 4 18:42:55 2005
New Revision: 230383
URL: http://svn.apache.org/viewcvs?rev=230383&view=rev
Log:
Close streams properly on errors. MPJXR-20
Modified:
maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/CodeTransform.java
maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java
maven/maven-1/plugins/trunk/jxr/xdocs/changes.xml
Modified: maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/CodeTransform.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/CodeTransform.java?rev=230383&r1=230382&r2=230383&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/CodeTransform.java (original)
+++ maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/CodeTransform.java Thu Aug 4 18:42:55 2005
@@ -33,6 +33,7 @@
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;
@@ -746,6 +747,10 @@
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)
{
Modified: maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java?rev=230383&r1=230382&r2=230383&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java (original)
+++ maven/maven-1/plugins/trunk/jxr/src/main/org/apache/maven/jxr/DirectoryIndexer.java Thu Aug 4 18:42:55 2005
@@ -17,25 +17,22 @@
* ====================================================================
*/
-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 @@
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;
+ }
+ }
+ }
/*
Modified: maven/maven-1/plugins/trunk/jxr/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/jxr/xdocs/changes.xml?rev=230383&r1=230382&r2=230383&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/jxr/xdocs/changes.xml (original)
+++ maven/maven-1/plugins/trunk/jxr/xdocs/changes.xml Thu Aug 4 18:42:55 2005
@@ -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>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org