From 6eac6affcfd1653ee0f8a0c4ef43df2dd15cb446 Mon Sep 17 00:00:00 2001 From: David Sulpy Date: Mon, 14 Sep 2015 17:45:04 -0500 Subject: [PATCH] added some protection against potential error cases if grokerSubdomain isn't properly set --- .../initial-state-event-streamer.groovy | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smartapps/initialstate-events/initial-state-event-streamer.src/initial-state-event-streamer.groovy b/smartapps/initialstate-events/initial-state-event-streamer.src/initial-state-event-streamer.groovy index a0e7a9e2532..c480a1132e3 100644 --- a/smartapps/initialstate-events/initial-state-event-streamer.src/initial-state-event-streamer.groovy +++ b/smartapps/initialstate-events/initial-state-event-streamer.src/initial-state-event-streamer.groovy @@ -248,6 +248,9 @@ def updated() { if (atomicState.eventBuffer == null) { atomicState.eventBuffer = [] } + if (atomicState.grokerSubdomain == null || atomicState.grokerSubdomain == "") { + atomicState.grokerSubdomain = "groker" + } subscribeToEvents() @@ -260,6 +263,11 @@ def uninstalled() { def tryCreateBucket() { + // can't ship events if there is no grokerSubdomain + if (atomicState.grokerSubdomain == null || atomicState.grokerSubdomain == "") { + return + } + // if the bucket has already been created, no need to continue if (atomicState.isBucketCreated) { return @@ -346,6 +354,10 @@ def eventHandler(name, value) { // a helper function for shipping the atomicState.eventBuffer to Initial State def tryShipEvents() { + // can't ship events if there is no grokerSubdomain + if (atomicState.grokerSubdomain == null || atomicState.grokerSubdomain == "") { + return + } // can't ship if access key and bucket key are null, so finish trying if (atomicState.accessKey == null || atomicState.bucketKey == null) { return