You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ko...@apache.org on 2005/12/28 21:26:52 UTC
svn commit: r359625 - in
/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow:
RewritingTestCase.java flow/FinallyFlow.java
Author: kohsuke
Date: Wed Dec 28 12:26:50 2005
New Revision: 359625
URL: http://svn.apache.org/viewcvs?rev=359625&view=rev
Log:
added a regression test case for try/catch inside a finally block.
Added:
jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/FinallyFlow.java (with props)
Modified:
jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java
Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java?rev=359625&r1=359624&r2=359625&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java (original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/RewritingTestCase.java Wed Dec 28 12:26:50 2005
@@ -7,6 +7,7 @@
import org.apache.commons.javaflow.flow.NoReferenceBugFlow;
import org.apache.commons.javaflow.flow.StackBugFlow;
import org.apache.commons.javaflow.flow.NullVariableMethodFlow;
+import org.apache.commons.javaflow.flow.FinallyFlow;
public final class RewritingTestCase extends AbstractTestCase {
@@ -19,6 +20,12 @@
public void testNullVariableMethod() throws Exception {
final Runnable r = new NullVariableMethodFlow();
+ final Continuation c = Continuation.startWith(r);
+ assertTrue(c == null);
+ }
+
+ public void testFinally() throws Exception {
+ final Runnable r = new FinallyFlow();
final Continuation c = Continuation.startWith(r);
assertTrue(c == null);
}
Added: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/FinallyFlow.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/FinallyFlow.java?rev=359625&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/FinallyFlow.java (added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/FinallyFlow.java Wed Dec 28 12:26:50 2005
@@ -0,0 +1,42 @@
+package org.apache.commons.javaflow.flow;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * We used to have a problem in handling an exception handler inside a finally block.
+ * This class tests that behavior.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public class FinallyFlow implements Runnable {
+
+ public void run() {
+ loadResource("ABC",getClass().getClassLoader());
+ }
+
+ /**
+ * The implementation of this method is mostly pointless.
+ * We just needed byte code to be generated in the right way
+ * to expose a problem in the instrumentation code.
+ *
+ * In particular, an exception handler inside a finally block.
+ * (Multiple catch blocks also seem to be related, but not exactly sure why.)
+ */
+ private void loadResource(String name, ClassLoader loader) {
+ InputStream clis = null;
+ try {
+ clis = loader.getResourceAsStream(name);
+ } catch (SecurityException sex) {
+ System.out.println("beep");
+ } catch (ClassCastException x) {
+ System.out.println("beep");
+ } finally {
+ try {
+ if (clis != null)
+ clis.close();
+ } catch (IOException ex) {
+ } // ignore it
+ }
+ }
+}
Propchange: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/flow/FinallyFlow.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org