From: <st...@us...> - 2007-07-27 10:51:18
|
Revision: 4819 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=4819&view=rev Author: steve_l Date: 2007-07-27 03:51:16 -0700 (Fri, 27 Jul 2007) Log Message: ----------- SFOS-341 org.smartfrog.test.system.functions.FunctionsSystemTest failing in cruise control: race condition? Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java 2007-07-27 09:46:38 UTC (rev 4818) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java 2007-07-27 10:51:16 UTC (rev 4819) @@ -43,6 +43,7 @@ import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.BufferedInputStream; +import java.io.OutputStreamWriter; import java.net.URL; import java.util.ListIterator; import java.util.List; @@ -908,4 +909,27 @@ return file; } + /** + * Write to a text file + * @param file file to write to + * @param text text to write + * @param encoding encoding file encoding + * @throws SmartFrogException on any failure to write the file + */ + public static void writeTextFile(File file, String text, String encoding) throws SmartFrogException { + Writer wout=null; + try { + OutputStream fout; + fout = new FileOutputStream(file); + wout = new OutputStreamWriter(fout, encoding); + wout.write(text); + wout.flush(); + wout.close(); + } catch (IOException ioe) { + close(wout); + throw SmartFrogException.forward("When trying to write to " + + file, + ioe); + } + } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java 2007-07-27 09:46:38 UTC (rev 4818) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java 2007-07-27 10:51:16 UTC (rev 4819) @@ -21,11 +21,6 @@ import org.smartfrog.sfcore.common.SmartFrogException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; import java.io.File; import java.rmi.RemoteException; @@ -58,22 +53,7 @@ String encoding = null; if (text != null) { encoding = sfResolve(ATTR_TEXT_ENCODING, (String)null, true); - Writer wout=null; - File file = getFile(); - assert file!=null; - try { - OutputStream fout; - fout = new FileOutputStream(file); - wout = new OutputStreamWriter(fout, encoding); - wout.write(text); - wout.flush(); - wout.close(); - } catch (IOException ioe) { - FileSystem.close(wout); - throw SmartFrogException.forward("When trying to write to " + - file, - ioe); - } + FileSystem.writeTextFile(getFile(), text, encoding); } //call the superclass. this may trigger deletion. super.sfStart(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |