Skip to content

Commit

Permalink
Prevent killing application on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
tebemis committed Aug 23, 2015
1 parent c028ed3 commit c99b1aa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can either download the zip file from the releases on Github [here](https://
<dependency>
<groupId>ltg</groupId>
<artifactId>simple-java-mqtt-client</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
</dependency>
</dependencies>
...
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ltg</groupId>
<artifactId>simple-java-mqtt-client</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<name>Simple MQTT client for Java</name>

<properties>
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/ltg/commons/SimpleMQTTClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,16 @@ public void onSuccess(Void aVoid) {
}
@Override
public void onFailure(Throwable throwable) {
System.err.println("Impossible to CONNECT to the MQTT server, terminating");
System.exit(1);
System.err.println("Impossible to CONNECT to the MQTT server! This MQTT client is now useless, create a new one");
}
});
try {
if (!l.await(5, TimeUnit.SECONDS)) {
// Waits 3 seconds and then timeouts
System.err.println("Impossible to CONNECT to the MQTT server: TIMEOUT. Terminating");
System.exit(1);
System.err.println("Impossible to CONNECT to the MQTT server: TIMEOUT. This MQTT client is now useless, create a new one");
}
} catch (InterruptedException e) {
System.err.println("Impossible to CONNECT to the MQTT server, terminating");
System.exit(1);
System.err.println("Impossible to CONNECT to the MQTT server. This MQTT client is useless, create a new one");
}
}

Expand Down

0 comments on commit c99b1aa

Please sign in to comment.