Skip to content

Commit

Permalink
fix destruction problem of client
Browse files Browse the repository at this point in the history
  • Loading branch information
ahxiao committed May 24, 2023
1 parent 0feee06 commit 41b0de5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ static void on_receive_rpc_response(struct bcos_sdk_c_struct_response* resp)
jmethodID onRespMethodID = env->GetMethodID(cbClass, "onResponse", onRespSig.c_str());
if (onRespMethodID == NULL)
{
env->ExceptionDescribe();
env->DeleteGlobalRef(jcallback);
env->FatalError(
("No such method in the class, className: " + className + " ,method: onResponse")
.c_str());
Expand All @@ -47,6 +49,8 @@ static void on_receive_rpc_response(struct bcos_sdk_c_struct_response* resp)
jmethodID mid = env->GetMethodID(responseClass, "<init>", "()V");
if (mid == NULL)
{
env->ExceptionDescribe();
env->DeleteGlobalRef(jcallback);
env->FatalError(("No constructor in the class, className: " + className).c_str());
}

Expand All @@ -56,6 +60,8 @@ static void on_receive_rpc_response(struct bcos_sdk_c_struct_response* resp)
jfieldID errorCodeFieldID = env->GetFieldID(responseClass, "errorCode", "I");
if (errorCodeFieldID == NULL)
{
env->ExceptionDescribe();
env->DeleteGlobalRef(jcallback);
env->FatalError(
("No such field in the class, className: " + className + " ,fieldName: errorCode")
.c_str());
Expand All @@ -65,6 +71,8 @@ static void on_receive_rpc_response(struct bcos_sdk_c_struct_response* resp)
jfieldID errorMsgFieldID = env->GetFieldID(responseClass, "errorMessage", "Ljava/lang/String;");
if (errorMsgFieldID == NULL)
{
env->ExceptionDescribe();
env->DeleteGlobalRef(jcallback);
env->FatalError(
("No such field in the class, className: " + className + " ,fieldName: errorMessage")
.c_str());
Expand All @@ -74,6 +82,8 @@ static void on_receive_rpc_response(struct bcos_sdk_c_struct_response* resp)
jfieldID dataFieldID = env->GetFieldID(responseClass, "data", "[B");
if (errorMsgFieldID == NULL)
{
env->ExceptionDescribe();
env->DeleteGlobalRef(jcallback);
env->FatalError(
("No such field in the class, className: " + className + " ,fieldName: data").c_str());
}
Expand All @@ -98,6 +108,9 @@ static void on_receive_rpc_response(struct bcos_sdk_c_struct_response* resp)

// release callback global reference
env->DeleteGlobalRef(jcallback);

// detach current thread when job finished
jvm->DetachCurrentThread();
}

/*
Expand Down

0 comments on commit 41b0de5

Please sign in to comment.