You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/08/09 21:11:56 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly Jelly.java
jstrachan 2002/08/09 12:11:56
Modified: jelly/src/java/org/apache/commons/jelly Jelly.java
Log:
Patch so that when Jelly is ran and seperate threads are created (such as by JellySwing) then there are no IOException exceptions thrown when Jelly scripts are called asynchronously.
Revision Changes Path
1.14 +20 -7 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java
Index: Jelly.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Jelly.java 25 Jul 2002 01:51:20 -0000 1.13
+++ Jelly.java 9 Aug 2002 19:11:56 -0000 1.14
@@ -115,7 +115,7 @@
// later we might wanna add some command line arguments
// checking stuff using commons-cli to specify the output file
// and input file via command line arguments
- Writer writer = ( args.length > 1 )
+ final Writer writer = ( args.length > 1 )
? new FileWriter( args[1] )
: new OutputStreamWriter( System.out );
@@ -126,7 +126,20 @@
JellyContext context = jelly.getJellyContext();
context.setVariable("args", args);
script.run(context, output);
- writer.close();
+
+ // now lets wait for all threads to close
+ Runtime.getRuntime().addShutdownHook(
+ new Thread() {
+ public void run() {
+ try {
+ writer.close();
+ }
+ catch (Exception e) {
+ // ignore errors
+ }
+ }
+ }
+ );
}
catch (JellyException e)
{
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>