From dec780dc7785d0ff74fe6aef2272334910a9d94c Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 22 Dec 2023 09:00:25 -0800 Subject: [PATCH] Address review comments --- src/app/CASESessionManager.h | 3 +++ src/controller/java/AndroidCallbacks.cpp | 2 +- .../java/AndroidConnectionFailureExceptions.cpp | 9 ++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/CASESessionManager.h b/src/app/CASESessionManager.h index bc6235bb35279f..92fb7a9ba783c7 100644 --- a/src/app/CASESessionManager.h +++ b/src/app/CASESessionManager.h @@ -129,6 +129,9 @@ class CASESessionManager : public OperationalSessionReleaseDelegate, public Sess * The `attemptCount` parameter can be used to automatically retry multiple times if session setup is * not successful. * + * This function allows passing 'nullptr' for the error handler to compile, which is useful in scenarios where error + * handling is not needed. + * * @param peerId The node ID to find or establish a session with. * @param onConnection A callback to be called upon successful connection establishment. * @param attemptCount The number of retry attempts if session setup fails (default is 1). diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index e5c1334df4292b..b19e50b24e06f6 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -138,7 +138,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context, jthrowable exception; CHIP_ERROR err = AndroidConnectionFailureExceptions::GetInstance().CreateAndroidConnectionFailureException( - env, ErrorStr(failureInfo.error), failureInfo.error.AsInteger(), failureInfo.sessionStage, exception); + env, failureInfo.error.Format(), failureInfo.error.AsInteger(), failureInfo.sessionStage, exception); VerifyOrReturn( err == CHIP_NO_ERROR, ChipLogError(Controller, diff --git a/src/controller/java/AndroidConnectionFailureExceptions.cpp b/src/controller/java/AndroidConnectionFailureExceptions.cpp index 362e081d22d3f5..1e4bcd4a452ac1 100644 --- a/src/controller/java/AndroidConnectionFailureExceptions.cpp +++ b/src/controller/java/AndroidConnectionFailureExceptions.cpp @@ -30,14 +30,13 @@ CHIP_ERROR AndroidConnectionFailureExceptions::CreateAndroidConnectionFailureExc jthrowable & outEx) { jclass controllerExceptionCls; - CHIP_ERROR err = - JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ConnectionFailureException", controllerExceptionCls); + CHIP_ERROR err = JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ConnectionFailureException", + controllerExceptionCls); VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_JNI_ERROR_TYPE_NOT_FOUND); - JniClass controllerExceptionJniCls(controllerExceptionCls); jmethodID exceptionConstructor = env->GetMethodID(controllerExceptionCls, "", "(JILjava/lang/String;)V"); - outEx = (jthrowable) env->NewObject(controllerExceptionCls, exceptionConstructor, static_cast(errorCode), - static_cast(state), env->NewStringUTF(message)); + outEx = static_cast(env->NewObject(controllerExceptionCls, exceptionConstructor, static_cast(errorCode), + static_cast(state), env->NewStringUTF(message))); VerifyOrReturnError(outEx != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); return CHIP_NO_ERROR; }