You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by sv...@apache.org on 2014/04/23 06:00:28 UTC

svn commit: r1589334 - in /subversion/branches/1.7.x: ./ STATUS subversion/bindings/javahl/native/ClientContext.cpp subversion/bindings/javahl/native/JNIUtil.cpp subversion/bindings/javahl/native/JNIUtil.h

Author: svn-role
Date: Wed Apr 23 04:00:27 2014
New Revision: 1589334

URL: http://svn.apache.org/r1589334
Log:
Merge the 1.7.x-javahl-exception-crash branch:

 * r1586439
   Fix a crash in JavaHL that was reported on the users@ list and is
   already fixed on trunk.
   Justification:
     JavaHL should not crash the JVM too often.
   Notes:
     The original report is here:
     http://mail-archives.apache.org/mod_mbox/subversion-users/201404.mbox/%3CCAAVTFFjrZEy-PT3i1xu0mOM_AC89-237CmFEZ7QYcJxNckfEtA%40mail.gmail.com%3E
   Branch:
     ^/subversion/branches/1.7.x-javahl-exception-crash
   Votes:
     +1: brane, rhuijben

Modified:
    subversion/branches/1.7.x/   (props changed)
    subversion/branches/1.7.x/STATUS
    subversion/branches/1.7.x/subversion/bindings/javahl/native/ClientContext.cpp
    subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.cpp
    subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.h

Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /subversion/branches/1.8.x-javahl-exception-crash:r1586439
  Merged /subversion/branches/1.7.x-javahl-exception-crash:r1586451-1589333

Modified: subversion/branches/1.7.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1589334&r1=1589333&r2=1589334&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Wed Apr 23 04:00:27 2014
@@ -188,17 +188,3 @@ Veto-blocked changes:
      -1: stsp (not a bug fix, changes output in a patch release)
 
 Approved changes:
-=================
-
- * r1586439
-   Fix a crash in JavaHL that was reported on the users@ list and is
-   already fixed on trunk.
-   Justification:
-     JavaHL should not crash the JVM too often.
-   Notes:
-     The original report is here:
-     http://mail-archives.apache.org/mod_mbox/subversion-users/201404.mbox/%3CCAAVTFFjrZEy-PT3i1xu0mOM_AC89-237CmFEZ7QYcJxNckfEtA%40mail.gmail.com%3E
-   Branch:
-     ^/subversion/branches/1.7.x-javahl-exception-crash
-   Votes:
-     +1: brane, rhuijben

Modified: subversion/branches/1.7.x/subversion/bindings/javahl/native/ClientContext.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/bindings/javahl/native/ClientContext.cpp?rev=1589334&r1=1589333&r2=1589334&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/bindings/javahl/native/ClientContext.cpp (original)
+++ subversion/branches/1.7.x/subversion/bindings/javahl/native/ClientContext.cpp Wed Apr 23 04:00:27 2014
@@ -422,6 +422,7 @@ ClientContext::resolve(svn_wc_conflict_r
 {
   jobject jctx = (jobject) baton;
   JNIEnv *env = JNIUtil::getEnv();
+  *result = NULL;
 
   // Create a local frame for our references
   env->PushLocalFrame(LOCAL_FRAME_SIZE);

Modified: subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1589334&r1=1589333&r2=1589334&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.cpp (original)
+++ subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.cpp Wed Apr 23 04:00:27 2014
@@ -399,7 +399,7 @@ JNIUtil::putErrorsInTrace(svn_error_t *e
   env->DeleteLocalRef(jfileName);
 }
 
-void JNIUtil::handleSVNError(svn_error_t *err)
+void JNIUtil::wrappedHandleSVNError(svn_error_t *err)
 {
   std::string msg;
   assembleErrorMessage(svn_error_purge_tracing(err), 0, APR_SUCCESS, msg);
@@ -521,7 +521,16 @@ void JNIUtil::handleSVNError(svn_error_t
 #endif
 
   env->Throw(static_cast<jthrowable>(env->PopLocalFrame(nativeException)));
+}
 
+void JNIUtil::handleSVNError(svn_error_t *err)
+{
+  try {
+    wrappedHandleSVNError(err);
+  } catch (...) {
+    svn_error_clear(err);
+    throw;
+  }
   svn_error_clear(err);
 }
 
@@ -621,28 +630,42 @@ bool JNIUtil::isJavaExceptionThrown()
 const char *
 JNIUtil::thrownExceptionToCString(SVN::Pool &in_pool)
 {
-  const char *msg;
+  const char *msg = NULL;
   JNIEnv *env = getEnv();
+  apr_pool_t *pool = in_pool.getPool();
   if (env->ExceptionCheck())
     {
       jthrowable t = env->ExceptionOccurred();
-      static jmethodID getMessage = 0;
-      if (getMessage == 0)
+      jclass cls = env->GetObjectClass(t);
+
+      jstring jclass_name;
+      {
+        jmethodID mid = env->GetMethodID(cls, "getClass", "()Ljava/lang/Class;");
+        jobject clsobj = env->CallObjectMethod(t, mid);
+        jclass basecls = env->GetObjectClass(clsobj);
+        mid = env->GetMethodID(basecls, "getName", "()Ljava/lang/String;");
+        jclass_name = (jstring) env->CallObjectMethod(clsobj, mid);
+      }
+
+      jstring jmessage;
+      {
+        jmethodID mid = env->GetMethodID(cls, "getMessage",
+                                         "()Ljava/lang/String;");
+        jmessage = (jstring) env->CallObjectMethod(t, mid);
+      }
+
+      JNIStringHolder class_name(jclass_name);
+      if (jmessage)
         {
-          jclass clazz = env->FindClass("java/lang/Throwable");
-          getMessage = env->GetMethodID(clazz, "getMessage",
-                                        "(V)Ljava/lang/String;");
-          env->DeleteLocalRef(clazz);
+          JNIStringHolder message(jmessage);
+          msg = apr_pstrcat(pool,
+                            static_cast<const char*>(class_name), ": ",
+                            static_cast<const char*>(message), NULL);
         }
-      jstring jmsg = (jstring) env->CallObjectMethod(t, getMessage);
-      JNIStringHolder tmp(jmsg);
-      msg = tmp.pstrdup(in_pool.getPool());
+      else
+        msg = class_name.pstrdup(pool);
       // ### Conditionally add t.printStackTrace() to msg?
     }
-  else
-    {
-      msg = NULL;
-    }
   return msg;
 }
 

Modified: subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.h
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.h?rev=1589334&r1=1589333&r2=1589334&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.h (original)
+++ subversion/branches/1.7.x/subversion/bindings/javahl/native/JNIUtil.h Wed Apr 23 04:00:27 2014
@@ -138,6 +138,7 @@ class JNIUtil
   enum { noLog, errorLog, exceptionLog, entryLog } LogLevel;
 
  private:
+  static void wrappedHandleSVNError(svn_error_t *err);
   static void assembleErrorMessage(svn_error_t *err, int depth,
                                    apr_status_t parent_apr_err,
                                    std::string &buffer);