Author: rhuijben
Date: Sun Mar  8 12:11:55 2015
New Revision: 1664984

URL: http://svn.apache.org/r1664984
Log:
* subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
  (Java::caught_java_exception_error): When a java exception is thrown, wrap it 
in the
    error and exit exception state to allow further JNI calls.

* subversion/bindings/javahl/native/OperationContext.cpp
  (OperationContext::checkCancel): If the JVM is in exception state (e.g. when 
an
     exception is thrown from a callback that doesn't support error return), 
return
     an error from the cancel callback with the wrapped exception (and exit 
exception
     state)

* 
subversion/bindings/javahl/tests/org/apache/subversion/javahl/ExceptionTests.java
  (*): Add some comments. Make throws a bit less generic
  (testNotify): New test, verifying that even an exception from the notify 
callback
    gets through.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp
    subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
    
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/ExceptionTests.java

Modified: 
subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp?rev=1664984&r1=1664983&r2=1664984&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp 
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/OperationContext.cpp Sun 
Mar  8 12:11:55 2015
@@ -358,6 +358,9 @@ OperationContext::checkCancel(void *canc
   OperationContext *that = static_cast<OperationContext *>(cancelBaton);
   if (that->isCancelledOperation())
     return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Operation cancelled"));
+  else if (JNIUtil::isJavaExceptionThrown())
+    return svn_error_create(SVN_ERR_CANCELLED, JNIUtil::wrapJavaException(),
+                            _("Operation cancelled"));
   else
     return SVN_NO_ERROR;
 }

Modified: 
subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp?rev=1664984&r1=1664983&r2=1664984&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp 
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/jniwrapper/jni_base.cpp 
Sun Mar  8 12:11:55 2015
@@ -375,7 +375,8 @@ const char* unknown_cxx_exception_messag
 
 svn_error_t* caught_java_exception_error(apr_status_t status) throw()
 {
-  return svn_error_create(status, NULL, _("Java exception"));
+  return svn_error_create(status, JNIUtil::wrapJavaException(),
+                          _("Java exception"));
 }
 
 } // namespace Java

Modified: 
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/ExceptionTests.java
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/ExceptionTests.java?rev=1664984&r1=1664983&r2=1664984&view=diff
==============================================================================
--- 
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/ExceptionTests.java
 (original)
+++ 
subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/ExceptionTests.java
 Sun Mar  8 12:11:55 2015
@@ -85,6 +85,10 @@ public class ExceptionTests extends SVNT
         }
     }
 
+    /**
+     * Specific exception class to verify if the marshalling of errors
+     * through Subversion is handled properly.
+     */
     final class TestException extends RuntimeException
     {
         private static final long serialVersionUID = 1L;
@@ -100,7 +104,7 @@ public class ExceptionTests extends SVNT
         }
     }
 
-    public void testStatusCallback() throws Throwable
+    public void testStatusCallback() throws Exception
     {
         // build the test setup
         OneTest thisTest = new OneTest();
@@ -130,7 +134,7 @@ public class ExceptionTests extends SVNT
         assertTrue(handled);
     }
 
-    public void testInfoCallback() throws Throwable
+    public void testInfoCallback() throws Exception
     {
         // build the test setup
         OneTest thisTest = new OneTest();
@@ -160,7 +164,7 @@ public class ExceptionTests extends SVNT
         assertTrue(handled);
     }
 
-    public void testListCallback() throws Throwable
+    public void testListCallback() throws Exception
     {
         // build the test setup
         OneTest thisTest = new OneTest();
@@ -190,7 +194,7 @@ public class ExceptionTests extends SVNT
         assertTrue(handled);
     }
 
-    public void testBlameCallback() throws Throwable
+    public void testBlameCallback() throws Exception
     {
         // build the test setup
         OneTest thisTest = new OneTest();
@@ -225,7 +229,7 @@ public class ExceptionTests extends SVNT
         assertTrue(handled);
     }
 
-    public void testLogMessageCallback() throws Throwable
+    public void testLogMessageCallback() throws Exception
     {
         // build the test setup
         OneTest thisTest = new OneTest();
@@ -264,7 +268,7 @@ public class ExceptionTests extends SVNT
         assertTrue(handled);
     }
 
-    public void testDiffSummaryReceiver() throws Throwable
+    public void testDiffSummaryReceiver() throws Exception
     {
         // build the test setup
         OneTest thisTest = new OneTest();
@@ -301,7 +305,42 @@ public class ExceptionTests extends SVNT
         assertTrue(handled);
     }
 
-    private boolean VerifyCause(Throwable caught, Throwable needle) throws 
TestException
+    public void testNotify() throws Exception
+    {
+        // build the test setup
+        OneTest thisTest = new OneTest();
+
+        final TestException theException = new TestException("The Exception");
+        boolean handled = false;
+        // Test status of non-existent file
+        try
+        {
+            client.notification2(new ClientNotifyCallback()
+                                 {
+                                    public void 
onNotify(ClientNotifyInformation info)
+                                    {
+                                        throw new TestException("inner",
+                                                                theException);
+                                    }
+                                });
+
+            client.remove(thisTest.getWCPathSet("/A"), false, false,
+                          null, null, null);
+        }
+        catch (ClientException e)
+        {
+            if (VerifyCause(e, theException))
+                handled = true;
+            else
+                throw e;
+        }
+        assertTrue(handled);
+    }
+
+    /**
+     * Verifies if a specific throwable instance is recorded in the exception 
chain
+     */
+    private boolean VerifyCause(Throwable caught, Throwable needle)
     {
         if (caught == needle)
             return true;


Reply via email to