From 9e3799abe1f9a311c93b02c189892c2d0ccac5b1 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 26 Jun 2018 19:21:54 +0300 Subject: [PATCH] Fix corrected --- src/main/kotlin/org/jetbrains/bio/big/BigBed.kt | 6 ++++-- src/main/kotlin/org/jetbrains/bio/big/BigWig.kt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/jetbrains/bio/big/BigBed.kt b/src/main/kotlin/org/jetbrains/bio/big/BigBed.kt index c3afeb3..a5d86d3 100644 --- a/src/main/kotlin/org/jetbrains/bio/big/BigBed.kt +++ b/src/main/kotlin/org/jetbrains/bio/big/BigBed.kt @@ -1,6 +1,7 @@ package org.jetbrains.bio.big import com.google.common.collect.ComparisonChain +import com.google.common.io.Closeables import org.jetbrains.bio.* import java.io.IOException import java.nio.ByteOrder @@ -104,8 +105,9 @@ class BigBedFile private constructor( factory.order = byteOrder return BigBedFile(src, factory, MAGIC, prefetch, cancelledChecker) - } finally { - factory.close() + } catch (e: Exception) { + Closeables.close(factory, true) + throw e } } diff --git a/src/main/kotlin/org/jetbrains/bio/big/BigWig.kt b/src/main/kotlin/org/jetbrains/bio/big/BigWig.kt index 45ef600..e236c49 100644 --- a/src/main/kotlin/org/jetbrains/bio/big/BigWig.kt +++ b/src/main/kotlin/org/jetbrains/bio/big/BigWig.kt @@ -1,5 +1,6 @@ package org.jetbrains.bio.big +import com.google.common.io.Closeables import org.jetbrains.bio.* import java.io.IOException import java.nio.ByteOrder @@ -180,8 +181,9 @@ class BigWigFile private constructor( factory.order = byteOrder return BigWigFile(src, factory, MAGIC, prefetch, cancelledChecker) - } finally { - factory.close() + } catch (e: Exception) { + Closeables.close(factory, true) + throw e } }