Skip to content

Commit

Permalink
Fix memory leakage in android diag Class
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Dec 6, 2024
1 parent c2739ca commit 50b05db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/java-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ jobs:
--factoryreset \
'
- name: Run Pairing Onnetwork and get diagnostic log Test
# TODO: test below is disabled because it seems flaky (crashes on pool not being empty on app exit)
# See: https://github.com/project-chip/connectedhomeip/issues/36734
if: false
run: |
scripts/run_in_python_env.sh out/venv \
'./scripts/tests/run_java_test.py \
Expand Down
20 changes: 12 additions & 8 deletions src/controller/java/AndroidLogDownloadFromNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,22 @@ void AndroidLogDownloadFromNode::FinishLogDownloadFromNode(CHIP_ERROR err)

env->CallVoidMethod(mJavaCallback.ObjectRef(), onSuccessMethod, static_cast<jint>(mController->GetFabricIndex()),
static_cast<jlong>(mRemoteNodeId));
return;
}
else
{
ChipLogError(Controller, "Log Download Failed : %" CHIP_ERROR_FORMAT, err.Format());

ChipLogError(Controller, "Log Download Failed : %" CHIP_ERROR_FORMAT, err.Format());
jmethodID onErrorMethod;
// Java method signature : void onError(int fabricIndex, long nodeId, long errorCode)
jniErr = JniReferences::GetInstance().FindMethod(env, mJavaCallback.ObjectRef(), "onError", "(IJJ)V", &onErrorMethod);
VerifyOrReturn(jniErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find onError method"));

jmethodID onErrorMethod;
// Java method signature : void onError(int fabricIndex, long nodeId, long errorCode)
jniErr = JniReferences::GetInstance().FindMethod(env, mJavaCallback.ObjectRef(), "onError", "(IJJ)V", &onErrorMethod);
VerifyOrReturn(jniErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find onError method"));
env->CallVoidMethod(mJavaCallback.ObjectRef(), onErrorMethod, static_cast<jint>(mController->GetFabricIndex()),
static_cast<jlong>(mRemoteNodeId), static_cast<jlong>(err.AsInteger()));
}

env->CallVoidMethod(mJavaCallback.ObjectRef(), onErrorMethod, static_cast<jint>(mController->GetFabricIndex()),
static_cast<jlong>(mRemoteNodeId), static_cast<jlong>(err.AsInteger()));
// Finish this function, this object will be deleted.
delete this;
}

void AndroidLogDownloadFromNode::OnBdxTransferCallback(void * context, FabricIndex fabricIndex, NodeId remoteNodeId,
Expand Down

0 comments on commit 50b05db

Please sign in to comment.