Skip to content

Commit d07c28f

Browse files
committed
Do not die if we try to close a port that was not opened previously.
1 parent aa07dc0 commit d07c28f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/android/org/stereolux/cordova/serial/Serial.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ private void closeSerial(final CallbackContext callbackContext) {
234234
cordova.getThreadPool().execute(new Runnable() {
235235
public void run() {
236236
try {
237-
port.close();
237+
// Make sure we don't die if we try to close an non-existing port!
238+
if (port != null)
239+
port.close();
238240
callbackContext.success();
239241
} catch (IOException e) {
240242
// deal with error

0 commit comments

Comments
 (0)