Skip to content

Commit 679a66c

Browse files
authored
Merge pull request #1803 from nrgraham23/jni_error_handling
Java bindings exception handling fix
2 parents bf133c4 + 88dea4e commit 679a66c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ompi/mpi/java/c/mpi_MPI.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,23 +1128,22 @@ void ompi_java_releasePtrArray(JNIEnv *env, jlongArray array,
11281128

11291129
jboolean ompi_java_exceptionCheck(JNIEnv *env, int rc)
11301130
{
1131+
jboolean jni_exception;
1132+
11311133
if (rc < 0) {
11321134
/* handle ompi error code */
11331135
rc = ompi_errcode_get_mpi_code (rc);
11341136
/* ompi_mpi_errcode_get_class CAN NOT handle negative error codes.
11351137
* all Open MPI MPI error codes should be > 0. */
11361138
assert (rc >= 0);
11371139
}
1140+
jni_exception = (*env)->ExceptionCheck(env);
11381141

1139-
if(MPI_SUCCESS == rc)
1142+
if(MPI_SUCCESS == rc && JNI_FALSE == jni_exception)
11401143
{
11411144
return JNI_FALSE;
11421145
}
1143-
else if((*env)->ExceptionCheck(env))
1144-
{
1145-
return JNI_TRUE;
1146-
}
1147-
else
1146+
else if(MPI_SUCCESS != rc)
11481147
{
11491148
int errClass = ompi_mpi_errcode_get_class(rc);
11501149
char *message = ompi_mpi_errnum_get_string(rc);
@@ -1158,6 +1157,9 @@ jboolean ompi_java_exceptionCheck(JNIEnv *env, int rc)
11581157
(*env)->DeleteLocalRef(env, jmessage);
11591158
return JNI_TRUE;
11601159
}
1160+
else if (JNI_TRUE == jni_exception) {
1161+
return JNI_TRUE;
1162+
}
11611163
}
11621164

11631165
void* ompi_java_attrSet(JNIEnv *env, jbyteArray jval)

0 commit comments

Comments
 (0)