At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
------------------------------------------------------------
revno: 298
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Mon 2007-11-26 00:34:56 -0800
message:
Fixed segfault when throwing some exceptions.
modified:
java/ndbj.i ndbj.i-20070913223244-5938mztpztyn9sry-1
=== modified file 'java/ndbj.i'
--- a/java/ndbj.i 2007-11-25 05:15:15 +0000
+++ b/java/ndbj.i 2007-11-26 08:34:56 +0000
@@ -71,7 +71,7 @@
if ((mid == NULL) || (mid == 0)) {
jenv->DeleteGlobalRef(callback_data->obj);
jclass clazz = jenv->FindClass("java/lang/RuntimeException");
- jenv->ThrowNew(clazz,"No callback method!");
+ jenv->ThrowNew(clazz,"Invalid exception class specified");
}
jenv->CallVoidMethod(callback_data->obj,mid,(jlong)result,trans,callback_data->create_time);
@@ -86,8 +86,12 @@
void ndb_throw_exception(JNIEnv *jenv, const char * excp, const char *msg) {
jclass clazz = NULL;
const char * prefix = "com/mysql/cluster/ndbj/";
- if (strncmp(excp,"com.",4)) {
+ if (strncmp(excp,"com.",4)==0) {
clazz = jenv->FindClass(excp);
+ if (clazz==NULL)
+ clazz = jenv->FindClass("java/lang/RuntimeException");
+ jenv->ThrowNew(clazz,"Invalid exception class specified");
+ return;
} else {
char * exception = (char *)malloc(strlen(excp)+strlen(prefix)+1);
strcpy(exception,prefix);
@@ -95,6 +99,10 @@
clazz = jenv->FindClass(exception);
free(exception);
+ if (clazz==NULL)
+ clazz = jenv->FindClass("java/lang/RuntimeException");
+ jenv->ThrowNew(clazz,"Invalid exception class specified");
+ return;
}
jenv->ThrowNew(clazz,msg);
@@ -104,8 +112,12 @@
void ndb_throw_exception(JNIEnv *jenv, const char * excp, const char *msg, NdbError &
err) {
jclass clazz = NULL;
const char * prefix = "com/mysql/cluster/ndbj/";
- if (strncmp(excp,"com.",4)) {
+ if (strncmp(excp,"com.",4)==0) {
clazz = jenv->FindClass(excp);
+ if (clazz==NULL)
+ clazz = jenv->FindClass("java/lang/RuntimeException");
+ jenv->ThrowNew(clazz,"No callback method!");
+ return;
} else {
char * exception = (char *)malloc(strlen(excp)+strlen(prefix)+1);
strcpy(exception,prefix);
@@ -113,6 +125,10 @@
clazz = jenv->FindClass(exception);
free(exception);
+ if (clazz==NULL)
+ clazz = jenv->FindClass("java/lang/RuntimeException");
+ jenv->ThrowNew(clazz,"Invalid exception class specified");
+ return;
}
jlong errPtr = 0;
| Thread |
|---|
| • Rev 298: Fixed segfault when throwing some exceptions. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel | Monty Taylor | 26 Nov |