From 098475b510c21e0bd614a601a73e08f723afdab7 Mon Sep 17 00:00:00 2001 From: Kevin Coppock Date: Mon, 2 May 2022 15:21:03 -0500 Subject: [PATCH] Handle error cases in Android OnAttributeData --- src/controller/java/AndroidCallbacks.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index 499411fdcd18a5..37428c8ed46f3a 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -244,11 +244,14 @@ void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPat // Convert TLV to JSON Json::Value json; err = TlvToJson(readerForJson, json); + VerifyOrReturn(err == CHIP_NO_ERROR, ReportError(attributePathObj, err)); + UtfString jsonString(env, JsonToString(json).c_str()); // Create AttributeState object jclass attributeStateCls; err = JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/model/AttributeState", attributeStateCls); + VerifyOrReturnError(err == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find AttributeState class")); VerifyOrReturn(attributeStateCls != nullptr, ChipLogError(Controller, "Could not find AttributeState class")); chip::JniClass attributeStateJniCls(attributeStateCls); jmethodID attributeStateCtor = env->GetMethodID(attributeStateCls, "", "(Ljava/lang/Object;[BLjava/lang/String;)V");