Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NPE #126

Merged
merged 2 commits into from
Jan 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,10 @@ private void stay() throws InterruptedException {
latch.countDown();
};

final Runnable waitForExitCommandRunnable = new Runnable() {
@Override
public void run() {
final Scanner scanner = new Scanner(System.in);
scanner.nextLine();
latch.countDown();
}
final Runnable waitForExitCommandRunnable = () -> {
final Scanner scanner = new Scanner(System.in);
scanner.nextLine();
latch.countDown();
};

final ExecutorService WORKER_THREADS = Executors.newFixedThreadPool(2);
Expand All @@ -151,19 +148,22 @@ public void run() {

WORKER_THREADS.shutdownNow();

if (!contextClient.getState().isConnectedOrReconnect()) {
removeContext();
}
else {
mqttClientExecutor.unsubscribe(contextClient, this);
if (contextClient != null) {
if (!contextClient.getState().isConnectedOrReconnect()) {
removeContext();
}
else {
mqttClientExecutor.unsubscribe(contextClient, this);
}
}


}

@Override
public String toString() {
return getClass().getSimpleName() + "{" +
"key=" + getKey() +
"key=" + ((contextClient == null)? "null" : getKey()) +
", topics=" + Arrays.toString(topics) +
", qos=" + Arrays.toString(qos) +
", outputToConsole=" + printToSTDOUT +
Expand Down