void JNIUtil::wrappedHandleSVNError(svn_error_t *err) { std::string msg; assembleErrorMessage(svn_error_purge_tracing(err), 0, APR_SUCCESS, msg); const char *source = NULL; #ifdef SVN_DEBUG #ifndef SVN_ERR__TRACING if (err->file) { std::ostringstream buf; buf << err->file; if (err->line > 0) buf << ':' << err->line; source = buf.str().c_str(); } #endif #endif // Much of the following is stolen from throwNativeException(). As much as // we'd like to call that function, we need to do some manual stack // unrolling, so it isn't feasible. JNIEnv *env = getEnv(); // Create a local frame for our references env->PushLocalFrame(LOCAL_FRAME_SIZE); if (JNIUtil::isJavaExceptionThrown()) return; jclass clazz = env->FindClass(JAVA_PACKAGE "/ClientException"); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); if (getLogLevel() >= exceptionLog) { JNICriticalSection cs(*g_logMutex); g_logStream << "Subversion JavaHL exception thrown, message:<"; g_logStream << msg << ">"; if (source) g_logStream << " source:<" << source << ">"; if (err->apr_err != -1) g_logStream << " apr-err:<" << err->apr_err << ">"; g_logStream << std::endl; } if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); jstring jmessage = makeJString(msg.c_str()); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); jstring jsource = makeJString(source); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); jmethodID mid = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;Ljava/lang/String;I)V"); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); jobject nativeException = env->NewObject(clazz, mid, jmessage, jsource, static_cast<jint>(err->apr_err)); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); #ifdef SVN_ERR__TRACING // Add all the C error stack trace information to the Java Exception // Get the standard stack trace, and vectorize it using the Array class. static jmethodID mid_gst = 0; if (mid_gst == 0) { mid_gst = env->GetMethodID(clazz, "getStackTrace", "()[Ljava/lang/StackTraceElement;"); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); } Array stackTraceArray((jobjectArray) env->CallObjectMethod(nativeException, mid_gst)); std::vector<jobject> oldStackTrace = stackTraceArray.vector(); // Build the new stack trace elements from the chained errors. std::vector<jobject> newStackTrace; putErrorsInTrace(err, newStackTrace); // Join the new elements with the old ones for (std::vector<jobject>::const_iterator it = oldStackTrace.begin(); it < oldStackTrace.end(); ++it) { newStackTrace.push_back(*it); } jclass stClazz = env->FindClass("java/lang/StackTraceElement"); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); const jsize stSize = static_cast<jsize>(newStackTrace.size()); if (stSize != newStackTrace.size()) { env->ThrowNew(env->FindClass("java.lang.ArithmeticException"), "Overflow converting C size_t to JNI jsize"); POP_AND_RETURN_NOTHING(); } jobjectArray jStackTrace = env->NewObjectArray(stSize, stClazz, NULL); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); int i = 0; for (std::vector<jobject>::const_iterator it = newStackTrace.begin(); it < newStackTrace.end(); ++it) { env->SetObjectArrayElement(jStackTrace, i, *it); ++i; } // And put the entire trace back into the exception static jmethodID mid_sst = 0; if (mid_sst == 0) { mid_sst = env->GetMethodID(clazz, "setStackTrace", "([Ljava/lang/StackTraceElement;)V"); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); } env->CallVoidMethod(nativeException, mid_sst, jStackTrace); if (isJavaExceptionThrown()) POP_AND_RETURN_NOTHING(); #endif env->Throw(static_cast<jthrowable>(env->PopLocalFrame(nativeException))); }
static dav_error * save_value(dav_db *db, const dav_prop_name *name, const svn_string_t *const *old_value_p, const svn_string_t *value) { const char *propname; svn_error_t *serr; const dav_resource *resource = db->resource; apr_pool_t *subpool; /* get the repos-local name */ get_repos_propname(db, name, &propname); if (propname == NULL) { if (db->resource->info->repos->autoversioning) /* ignore the unknown namespace of the incoming prop. */ propname = name->name; else return dav_svn__new_error(db->p, HTTP_CONFLICT, 0, "Properties may only be defined in the " SVN_DAV_PROP_NS_SVN " and " SVN_DAV_PROP_NS_CUSTOM " namespaces."); } /* We've got three different types of properties (node, txn, and revision), and we've got two different protocol versions to deal with. Let's try to make some sense of this, shall we? HTTP v1: working baseline ('wbl') resource -> txn prop change non-working, baselined resource ('bln') -> rev prop change [*] working, non-baselined resource ('wrk') -> node prop change HTTP v2: transaction resource ('txn') -> txn prop change revision resource ('rev') -> rev prop change transaction root resource ('txr') -> node prop change [*] This is a violation of the DeltaV spec (### see issue #916). */ /* A subpool to cope with mod_dav making multiple calls, e.g. during PROPPATCH with multiple values. */ subpool = svn_pool_create(db->resource->pool); if (db->resource->baselined) { if (db->resource->working) { serr = svn_repos_fs_change_txn_prop(resource->info->root.txn, propname, value, subpool); } else { serr = svn_repos_fs_change_rev_prop4(resource->info->repos->repos, resource->info->root.rev, resource->info->repos->username, propname, old_value_p, value, TRUE, TRUE, db->authz_read_func, db->authz_read_baton, subpool); /* Prepare any hook failure message to get sent over the wire */ if (serr) { svn_error_t *purged_serr = svn_error_purge_tracing(serr); if (purged_serr->apr_err == SVN_ERR_REPOS_HOOK_FAILURE) purged_serr->message = apr_xml_quote_string (purged_serr->pool, purged_serr->message, 1); /* mod_dav doesn't handle the returned error very well, it generates its own generic error that will be returned to the client. Cache the detailed error here so that it can be returned a second time when the rollback mechanism triggers. */ resource->info->revprop_error = svn_error_dup(purged_serr); } /* Tell the logging subsystem about the revprop change. */ dav_svn__operational_log(resource->info, svn_log__change_rev_prop( resource->info->root.rev, propname, subpool)); } } else if (resource->info->restype == DAV_SVN_RESTYPE_TXN_COLLECTION) { serr = svn_repos_fs_change_txn_prop(resource->info->root.txn, propname, value, subpool); } else { serr = svn_repos_fs_change_node_prop(resource->info->root.root, get_repos_path(resource->info), propname, value, subpool); } svn_pool_destroy(subpool); if (serr != NULL) return dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, NULL, resource->pool); /* a change to the props was made; make sure our cached copy is gone */ db->props = NULL; return NULL; }
const char * svn_repos__post_commit_error_str(svn_error_t *err, apr_pool_t *pool) { svn_error_t *hook_err1, *hook_err2; const char *msg; if (! err) return _("(no error)"); err = svn_error_purge_tracing(err); /* hook_err1 is the SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED wrapped error from the post-commit script, if any, and hook_err2 should be the original error, but be defensive and handle a case where SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED doesn't wrap an error. */ hook_err1 = svn_error_find_cause(err, SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED); if (hook_err1 && hook_err1->child) hook_err2 = hook_err1->child; else hook_err2 = hook_err1; /* This implementation counts on svn_repos_fs_commit_txn() returning svn_fs_commit_txn() as the parent error with a child SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED error. If the parent error is SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED then there was no error in svn_fs_commit_txn(). The post-commit hook error message is already self describing, so it can be dropped into an error message without any additional text. */ if (hook_err1) { if (err == hook_err1) { if (hook_err2->message) msg = apr_pstrdup(pool, hook_err2->message); else msg = _("post-commit hook failed with no error message."); } else { msg = hook_err2->message ? apr_pstrdup(pool, hook_err2->message) : _("post-commit hook failed with no error message."); msg = apr_psprintf( pool, _("post commit FS processing had error:\n%s\n%s"), err->message ? err->message : _("(no error message)"), msg); } } else { msg = apr_psprintf(pool, _("post commit FS processing had error:\n%s"), err->message ? err->message : _("(no error message)")); } return msg; }