diff --git a/solr/core/src/java/org/apache/solr/storage/SizeAwareDirectory.java b/solr/core/src/java/org/apache/solr/storage/SizeAwareDirectory.java index d9ad1f7a8f8..20608700a77 100644 --- a/solr/core/src/java/org/apache/solr/storage/SizeAwareDirectory.java +++ b/solr/core/src/java/org/apache/solr/storage/SizeAwareDirectory.java @@ -393,23 +393,22 @@ public Sizes setSizeWriter(SizeWriter sizeWriter) { @Override @SuppressWarnings("try") public void close() throws IOException { - backing.close(); - - long onDiskSize; - if (backing instanceof CompressingDirectory.SizeReportingIndexOutput) { - long finalBytesWritten = getBytesWritten(backing); - onDiskSize = finalBytesWritten; - // logical size should already be set through writeByte(s), but we need to finalize the - // on-disk size here - sizeWriter.apply(0, finalBytesWritten - lastBytesWritten, name); - } else if (backingDirectory instanceof DirectoryFactory.OnDiskSizeDirectory) { - onDiskSize = 0; - } else { - onDiskSize = getFilePointer(); - } - fileSizeMap.put(name, new Sizes(backing.getFilePointer(), onDiskSize)); - liveOutputs.remove(name); + backing.close(); + long onDiskSize; + if (backing instanceof CompressingDirectory.SizeReportingIndexOutput) { + long finalBytesWritten = getBytesWritten(backing); + onDiskSize = finalBytesWritten; + // logical size should already be set through writeByte(s), but we need to finalize the + // on-disk size here + sizeWriter.apply(0, finalBytesWritten - lastBytesWritten, name); + } else if (backingDirectory instanceof DirectoryFactory.OnDiskSizeDirectory) { + onDiskSize = 0; + } else { + onDiskSize = getFilePointer(); + } + fileSizeMap.put(name, new Sizes(backing.getFilePointer(), onDiskSize)); + liveOutputs.remove(name); } @Override