Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,33 @@ private BCFile.Reader getBCFile(Supplier<byte[]> cachedMetadataSupplier) throws
new RateLimitedInputStream((InputStream & Seekable) inputSupplier.get(), readLimiter);
BCFile.Reader tmpReader = null;
byte[] serializedMetadata = cachedMetadataSupplier.get();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cachedMetadataSupplier.get() can throw, that should probably be moved into the try block too. Otherwise this PR LGTM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I captured that line in the try block in dd8515c

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 {
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)) {
Expand Down