mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 10:11:27 +00:00
Fixed exception when closing channel that was opened with exception
This commit is contained in:
@@ -40,11 +40,19 @@ class SharedFileChannel {
|
||||
public void open(OpenMode mode) {
|
||||
doLocked(() -> {
|
||||
Thread thread = Thread.currentThread();
|
||||
if (openedBy.put(thread, thread) != null) {
|
||||
throw new IllegalStateException("SharedFileChannel already open for current thread");
|
||||
}
|
||||
if (delegate == null) {
|
||||
createChannel(mode);
|
||||
boolean failed = true;
|
||||
try {
|
||||
if (openedBy.put(thread, thread) != null) {
|
||||
throw new IllegalStateException("SharedFileChannel already open for current thread");
|
||||
}
|
||||
if (delegate == null) {
|
||||
createChannel(mode);
|
||||
}
|
||||
failed = false;
|
||||
} finally {
|
||||
if (failed) {
|
||||
openedBy.remove(thread);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user