From e55aeef9039b2f28f94ea7cf091647e86f706fac Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sat, 11 Mar 2017 23:24:33 +0100 Subject: [PATCH] Fixes beowulfe/HAP-Java#32 --- .../beowulfe/hap/characteristics/BaseCharacteristic.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/beowulfe/hap/characteristics/BaseCharacteristic.java b/src/main/java/com/beowulfe/hap/characteristics/BaseCharacteristic.java index a9064a10b..74835796d 100644 --- a/src/main/java/com/beowulfe/hap/characteristics/BaseCharacteristic.java +++ b/src/main/java/com/beowulfe/hap/characteristics/BaseCharacteristic.java @@ -68,7 +68,14 @@ public final CompletableFuture toJson(int iid) { * @return a future that will complete with the JSON builder for the object. */ protected CompletableFuture makeBuilder(int instanceId) { - return getValue().exceptionally(t -> { + CompletableFuture futureValue = getValue(); + + if (futureValue == null) { + logger.error("Could not retrieve value "+this.getClass().getName()); + return null; + } + + return futureValue.exceptionally(t -> { logger.error("Could not retrieve value "+this.getClass().getName(), t); return null; }).thenApply(value -> {