diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java index 36918f1fb91..91564059e2d 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java @@ -236,8 +236,9 @@ public HaplotypeCallerEngine(final HaplotypeCallerArgumentCollection hcArgs, Ass // Parse the user provided custom ploidy regions into ploidyRegions object containing SimpleCounts if (this.hcArgs.ploidyRegions != null) { - FeatureDataSource ploidyDataSource = new FeatureDataSource<>(this.hcArgs.ploidyRegions, FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, NamedFeature.class); - ploidyDataSource.forEach(r -> this.ploidyRegions.add(new SimpleCount(r))); + try (FeatureDataSource ploidyDataSource = new FeatureDataSource<>(this.hcArgs.ploidyRegions, FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, NamedFeature.class)) { + ploidyDataSource.forEach(r -> this.ploidyRegions.add(new SimpleCount(r))); + } } for (SimpleCount region : this.ploidyRegions) {