This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new f03ca6b9c7 Close DFSInputStream on exception in
CachableBlockFile.getBCFile (#6377)
f03ca6b9c7 is described below
commit f03ca6b9c7ae51b00c0580976bf8b46f025f9481
Author: Dave Marion <[email protected]>
AuthorDate: Thu May 28 10:59:40 2026 -0400
Close DFSInputStream on exception in CachableBlockFile.getBCFile (#6377)
A RateLimitedInputStream is created from the supplied InputStream,
which in most cases is a DFSInputStream. However, when BCFile.Reader
throws an exception the RateLimitedInputStream is not closed leaving
the related DFSInputStream open.
---
.../file/blockfile/impl/CachableBlockFile.java | 44 +++++++++++++---------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
index f13c155641..19033e4394 100644
---
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
+++
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
@@ -186,26 +186,34 @@ public class CachableBlockFile {
RateLimitedInputStream fsIn =
new RateLimitedInputStream((InputStream & Seekable)
inputSupplier.get(), readLimiter);
BCFile.Reader tmpReader = null;
- byte[] serializedMetadata = cachedMetadataSupplier.get();
- if (serializedMetadata == null) {
- if (fileLenCache == null) {
- tmpReader = new BCFile.Reader(fsIn, lengthSupplier.get(), conf,
cryptoService);
- } else {
- long len = getCachedFileLen();
- try {
- tmpReader = new BCFile.Reader(fsIn, len, conf, cryptoService);
- } catch (Exception e) {
- log.debug("Failed to open {}, clearing file length cache and
retrying", cacheId, e);
- fileLenCache.invalidate(cacheId);
- }
-
- if (tmpReader == null) {
- len = getCachedFileLen();
- tmpReader = new BCFile.Reader(fsIn, len, conf, cryptoService);
+ try {
+ byte[] serializedMetadata = cachedMetadataSupplier.get();
+ if (serializedMetadata == null) {
+ if (fileLenCache == null) {
+ tmpReader = new BCFile.Reader(fsIn, lengthSupplier.get(), conf,
cryptoService);
+ } else {
+ long len = getCachedFileLen();
+ try {
+ tmpReader = new BCFile.Reader(fsIn, len, conf, cryptoService);
+ } catch (Exception e) {
+ log.debug("Failed to open {}, clearing file length cache and
retrying", cacheId, e);
+ fileLenCache.invalidate(cacheId);
+ }
+
+ if (tmpReader == null) {
+ len = getCachedFileLen();
+ tmpReader = new BCFile.Reader(fsIn, len, conf, cryptoService);
+ }
}
+ } else {
+ tmpReader = new BCFile.Reader(serializedMetadata, fsIn, conf,
cryptoService);
}
- } else {
- tmpReader = new BCFile.Reader(serializedMetadata, fsIn, conf,
cryptoService);
+ } catch (IOException | RuntimeException e) {
+ fsIn.close();
+ if (fileLenCache != null) {
+ fileLenCache.invalidate(cacheId);
+ }
+ throw e;
}
if (bcfr.compareAndSet(null, tmpReader)) {