Skip to content

Commit

Permalink
[pusbullet] Assing handler to local variable for proper flow analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakan Tandogan committed Jun 21, 2019
1 parent f3c7b5c commit b9cba02
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ public class PushbulletActions implements ThingActions {
@ActionInput(name = "message", label = "@text/actionSendPushbulletNoteInputMessageLabel", description = "@text/actionSendPushbulletNoteInputMessageDesc") @Nullable String message) {
logger.trace("sendPushbulletNote '{}', '{}', '{}'", recipient, title, message);

if (handler == null) {
// Use local variable so the SAT check can do proper flow analysis
PushbulletHandler localHandler = handler;

if (localHandler == null) {
logger.warn("Pushbullet service Handler is null!");
return false;
}

// Ignore the SAT warning, we check for nullness just above this line.
return handler.sendPush(recipient, title, message, "note");
return localHandler.sendPush(recipient, title, message, "note");
}

public static boolean sendPushbulletNote(@Nullable ThingActions actions, @Nullable String recipient,
Expand All @@ -76,13 +78,15 @@ public static boolean sendPushbulletNote(@Nullable ThingActions actions, @Nullab
@ActionInput(name = "message", label = "@text/actionSendPushbulletNoteInputMessageLabel", description = "@text/actionSendPushbulletNoteInputMessageDesc") @Nullable String message) {
logger.trace("sendPushbulletNote '{}', '{}'", recipient, message);

if (handler == null) {
// Use local variable so the SAT check can do proper flow analysis
PushbulletHandler localHandler = handler;

if (localHandler == null) {
logger.warn("Pushbullet service Handler is null!");
return false;
}

// Ignore the SAT warning, we check for nullness just above this line.
return handler.sendPush(recipient, message, "note");
return localHandler.sendPush(recipient, message, "note");
}

public static boolean sendPushbulletNote(@Nullable ThingActions actions, @Nullable String recipient,
Expand Down

0 comments on commit b9cba02

Please sign in to comment.