Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix memory leakage in AndroidLogDownloadFromNode Class #36742

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 14 additions & 9 deletions src/controller/java/AndroidLogDownloadFromNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,27 @@ void AndroidLogDownloadFromNode::FinishLogDownloadFromNode(CHIP_ERROR err)
// Java method signature : boolean onSuccess(int fabricIndex, long nodeId)
jniErr = JniReferences::GetInstance().FindMethod(env, mJavaCallback.ObjectRef(), "onSuccess", "(IJ)V", &onSuccessMethod);

VerifyOrReturn(jniErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find onSuccess method"));
VerifyOrExit(jniErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find onSuccess method"));

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);
VerifyOrExit(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()));
exit:
// Finish this function, this object will be deleted.
delete this;
joonhaengHeo marked this conversation as resolved.
Show resolved Hide resolved
}

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