diff options
author | Sven Gothel <[email protected]> | 2020-07-26 05:42:38 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-07-26 05:42:38 +0200 |
commit | ce4481eaf4856ab2d2e2c4a9f39093888b34617f (patch) | |
tree | 5afb24d72e91c155e1b7eda402b70bb351713206 /java | |
parent | 74d41274760a9087c7a8c57e145fe531b035baae (diff) |
Robustness: Distinguish between get<Type>Checked() and get<Type>Unchecked(): Use it accordingly, reducing duplicated code etc.
Diffstat (limited to 'java')
-rw-r--r-- | java/jni/direct_bt/DBTGattCharacteristic.cxx | 5 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTGattService.cxx | 5 |
2 files changed, 2 insertions, 8 deletions
diff --git a/java/jni/direct_bt/DBTGattCharacteristic.cxx b/java/jni/direct_bt/DBTGattCharacteristic.cxx index 6260818a..955b59ba 100644 --- a/java/jni/direct_bt/DBTGattCharacteristic.cxx +++ b/java/jni/direct_bt/DBTGattCharacteristic.cxx @@ -77,10 +77,7 @@ jobject Java_direct_1bt_tinyb_DBTGattCharacteristic_getDescriptorsImpl(JNIEnv *e std::function<jobject(JNIEnv*, jclass, jmethodID, GATTDescriptor *)> ctor_desc = [](JNIEnv *env, jclass clazz, jmethodID clazz_ctor, GATTDescriptor *descriptor)->jobject { // prepare adapter ctor - std::shared_ptr<GATTCharacteristic> characteristic = descriptor->getCharacteristic(); - if( nullptr == characteristic ) { - throw IllegalStateException("Descriptor's GATTCharacteristic destructed: "+descriptor->toString(), E_FILE_LINE); - } + std::shared_ptr<GATTCharacteristic> characteristic = descriptor->getCharacteristicChecked(); JavaGlobalObj::check(characteristic->getJavaObject(), E_FILE_LINE); jobject jcharacteristic = JavaGlobalObj::GetObject(characteristic->getJavaObject()); diff --git a/java/jni/direct_bt/DBTGattService.cxx b/java/jni/direct_bt/DBTGattService.cxx index ef25f486..03f82ee9 100644 --- a/java/jni/direct_bt/DBTGattService.cxx +++ b/java/jni/direct_bt/DBTGattService.cxx @@ -78,10 +78,7 @@ jobject Java_direct_1bt_tinyb_DBTGattService_getCharacteristicsImpl(JNIEnv *env, std::function<jobject(JNIEnv*, jclass, jmethodID, GATTCharacteristic *)> ctor_char = [](JNIEnv *env, jclass clazz, jmethodID clazz_ctor, GATTCharacteristic *characteristic)->jobject { // prepare adapter ctor - std::shared_ptr<GATTService> service = characteristic->getService(); - if( nullptr == service ) { - throw IllegalStateException("Characteristic's GATTService destructed: "+characteristic->toString(), E_FILE_LINE); - } + std::shared_ptr<GATTService> service = characteristic->getServiceChecked(); JavaGlobalObj::check(service->getJavaObject(), E_FILE_LINE); jobject jservice = JavaGlobalObj::GetObject(service->getJavaObject()); |