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] Modify AndroidControllerExceptions errorCode type #29046

Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/controller/java/AndroidControllerExceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<init>", "(JLjava/lang/String;)V");
outEx = (jthrowable) env->NewObject(controllerExceptionCls, exceptionConstructor, static_cast<jlong>(errorCode),
jmethodID exceptionConstructor = env->GetMethodID(controllerExceptionCls, "<init>", "(ILjava/lang/String;)V");
outEx = (jthrowable) env->NewObject(controllerExceptionCls, exceptionConstructor, static_cast<jint>(errorCode),
env->NewStringUTF(message));
VerifyOrReturnError(outEx != nullptr, CHIP_JNI_ERROR_TYPE_NOT_FOUND);
return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down