Java guarantees that finally will always be called. The code should be
fine as-is. Just to make sure I was interpreting the docs right, I
tried this code:
public class TestClass {
public static void main(String[] args) throws Exception {
try {
System.out.println("Hello-- I try.");
throw new Exception("I am an exception");
} catch (Exception e) {
System.out.println("Hello-- I catch.");
throw new Exception("I am another exception", e);
} finally {
System.out.println("Hello-- I am finally going to do
something.");
}
}
}
Sure enough, all three print statements are outputted (along with a nice
stack trace when the exception bubbles to the top).
-Chris
-----Original Message-----
From: Glen Mazza [mailto:[EMAIL PROTECTED]
Sent: Monday, August 20, 2007 8:03 AM
To: [email protected]
Subject: Re: svn commit: r567631 - in
/incubator/cxf/trunk/tools:common/src/main/java/org/apache/cxf/tools/com
mon/toolspec/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/ja
vato/ws/src/main/java/org/apache/cxf/tools/java2ws/wsdlto/core/src/main/
java/or...
Am Montag, den 20.08.2007, 09:55 +0000 schrieb [EMAIL PROTECTED]:
> Author: mmao
> Date: Mon Aug 20 02:55:57 2007
> New Revision: 567631
>
> URL: http://svn.apache.org/viewvc?rev=567631&view=rev
> Log:
> CXF-912
> Restore the system standard out/err, before tools exit
>
> Modified:
>
incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools
/wsdlto/WSDLToJavaContainer.java
> URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/m
ain/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=567631
&r1=567630&r2=567631&view=diff
>
========================================================================
======
> ---
incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools
/wsdlto/WSDLToJavaContainer.java (original)
> +++
incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools
/wsdlto/WSDLToJavaContainer.java Mon Aug 20 02:55:57 2007
> @@ -240,6 +240,8 @@
> throw ex;
> } catch (Exception ex) {
> throw new ToolException(ex);
> + } finally {
> + tearDown();
> }
> }
>
There seems to be something wrong with this one. If you're going to
throw new ToolException(ex) the tearDown() in the finally block will
*not* be called, correct? Perhaps the tearDown() should be moved into
the code before the catch() block.
Glen