Author: amiloslavskiy
Date: Thu Oct 15 10:14:30 2020
New Revision: 1882520
URL: http://svn.apache.org/viewvc?rev=1882520&view=rev
Log:
JavaHL: Fix 'JNI call made with exception pending' error
It is incorrect to call Java method with 'CallObjectMethod' when there
is an unhandled Java exception already pending. The fix is to
temporarily move exception out of the way.
This error is easily seen when running JavaHL tests.
[in subversion/bindings/javahl]
* native/JNIUtil.cpp
Use 'StashException' helper class to temporarily move exception out
of the way in two functions which are designed to run when there is
an exception pending.
Modified:
subversion/branches/javahl-1.14-fixes/subversion/bindings/javahl/native/JNIUtil.cpp
Modified:
subversion/branches/javahl-1.14-fixes/subversion/bindings/javahl/native/JNIUtil.cpp
URL:
http://svn.apache.org/viewvc/subversion/branches/javahl-1.14-fixes/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1882520&r1=1882519&r2=1882520&view=diff
==============================================================================
---
subversion/branches/javahl-1.14-fixes/subversion/bindings/javahl/native/JNIUtil.cpp
(original)
+++
subversion/branches/javahl-1.14-fixes/subversion/bindings/javahl/native/JNIUtil.cpp
Thu Oct 15 10:14:30 2020
@@ -551,6 +551,11 @@ std::string JNIUtil::makeSVNErrorMessage
jstring *jerror_message,
jobject *jmessage_stack)
{
+ // This function may be called with a pending Java exception.
+ // It is incorrect to call Java methods (see code below) with a pending
+ // exception. Stash it away until this function exits.
+ StashException stash(getEnv());
+
if (jerror_message)
*jerror_message = NULL;
if (jmessage_stack)
@@ -761,7 +766,13 @@ namespace {
const char* known_exception_to_cstring(apr_pool_t* pool)
{
JNIEnv *env = JNIUtil::getEnv();
+
+ // This function may be called with a pending Java exception.
+ // It is incorrect to call Java methods (see code below) with a pending
+ // exception. Stash it away until this function exits.
jthrowable t = env->ExceptionOccurred();
+ StashException stashed(env);
+
jclass cls = env->GetObjectClass(t);
jstring jclass_name;