diff --git a/src/controller/java/AndroidControllerExceptions.cpp b/src/controller/java/AndroidControllerExceptions.cpp index e426759eade2e5..f126f0c8891982 100644 --- a/src/controller/java/AndroidControllerExceptions.cpp +++ b/src/controller/java/AndroidControllerExceptions.cpp @@ -33,8 +33,8 @@ CHIP_ERROR AndroidControllerExceptions::CreateAndroidControllerException(JNIEnv VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_JNI_ERROR_TYPE_NOT_FOUND); JniClass controllerExceptionJniCls(controllerExceptionCls); - jmethodID exceptionConstructor = env->GetMethodID(controllerExceptionCls, "", "(JLjava/lang/String;)V"); - outEx = (jthrowable) env->NewObject(controllerExceptionCls, exceptionConstructor, static_cast(errorCode), + jmethodID exceptionConstructor = env->GetMethodID(controllerExceptionCls, "", "(ILjava/lang/String;)V"); + outEx = (jthrowable) env->NewObject(controllerExceptionCls, exceptionConstructor, static_cast(errorCode), env->NewStringUTF(message)); VerifyOrReturnError(outEx != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND); return CHIP_NO_ERROR; diff --git a/src/controller/java/src/chip/devicecontroller/ChipDeviceControllerException.java b/src/controller/java/src/chip/devicecontroller/ChipDeviceControllerException.java index ec7cfb7b3318ea..2d2d583e146665 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceControllerException.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceControllerException.java @@ -21,11 +21,11 @@ public class ChipDeviceControllerException extends RuntimeException { private static final long serialVersionUID = 1L; - public long errorCode; + public int errorCode; public ChipDeviceControllerException() {} - public ChipDeviceControllerException(long errorCode, String message) { + public ChipDeviceControllerException(int errorCode, String message) { super(message != null ? message : String.format("Error Code %d", errorCode)); this.errorCode = errorCode; } diff --git a/src/controller/java/tests/chip/devicecontroller/GetConnectedDeviceCallbackJniTest.java b/src/controller/java/tests/chip/devicecontroller/GetConnectedDeviceCallbackJniTest.java index 56494b0efc20b7..f7f981483ba27c 100644 --- a/src/controller/java/tests/chip/devicecontroller/GetConnectedDeviceCallbackJniTest.java +++ b/src/controller/java/tests/chip/devicecontroller/GetConnectedDeviceCallbackJniTest.java @@ -48,10 +48,10 @@ public void deviceConnected() { public void connectionFailure() { var callback = new FakeGetConnectedDeviceCallback(); var jniCallback = new GetConnectedDeviceCallbackJni(callback); - callbackTestUtil.onDeviceConnectionFailure(jniCallback, 100L); + callbackTestUtil.onDeviceConnectionFailure(jniCallback, 100); assertThat(callback.error).isInstanceOf(ChipDeviceControllerException.class); - assertThat(((ChipDeviceControllerException) callback.error).errorCode).isEqualTo(100L); + assertThat(((ChipDeviceControllerException) callback.error).errorCode).isEqualTo(100); } class FakeGetConnectedDeviceCallback implements GetConnectedDeviceCallback {