diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/V2/FullDataSourceProviderV2.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/V2/FullDataSourceProviderV2.java index 813d1649e..278cf6fe0 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/V2/FullDataSourceProviderV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/V2/FullDataSourceProviderV2.java @@ -200,9 +200,10 @@ public class FullDataSourceProviderV2 implements IDebugRenderable, AutoCloseable return FullDataSourceV2.createEmpty(pos); } + FullDataSourceV2 dataSource = null; try { - FullDataSourceV2 dataSource = this.createDataSourceFromDto(dto); + dataSource = this.createDataSourceFromDto(dto); // automatically create and save adjacent data if missing if (dto.dataFormatVersion == FullDataSourceV2DTO.DATA_FORMAT.V1_NO_ADJACENT_DATA) @@ -221,6 +222,15 @@ public class FullDataSourceProviderV2 implements IDebugRenderable, AutoCloseable this.tryLogCorruptedDataError(DhSectionPos.toString(pos), e); this.repo.deleteWithKey(pos); } + catch (Exception e) + { + if (dataSource != null) + { + dataSource.close(); + } + + throw e; + } } catch (InterruptedException ignore) { } catch (IOException e)