Skip to content

Commit 74804d5

Browse files
authored
Merge pull request #1140 from NativeScript/trifonov/fix-runtime-unlock
check if runtime is null before calling lock/unlock
2 parents beab400 + 41d2c52 commit 74804d5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test-app/app/src/debug/java/com/tns/NativeScriptSyncServiceSocketImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,18 @@ private void createOrOverrideFile(String fileName, byte[] content) throws IOExce
356356

357357
fileToCreate.getParentFile().mkdirs();
358358
FileOutputStream fos = new FileOutputStream(fileToCreate.getCanonicalPath());
359-
runtime.lock();
359+
if(runtime != null) {
360+
runtime.lock();
361+
}
360362
fos.write(content);
361363
fos.close();
362364

363365
} catch (Exception e) {
364366
throw new IOException(String.format("\nLiveSync: failed to write file: %s\nOriginal Exception: %s", fileName, e.toString()));
365367
} finally {
366-
runtime.unlock();
368+
if(runtime != null) {
369+
runtime.unlock();
370+
}
367371
}
368372
}
369373

0 commit comments

Comments
 (0)