Skip to content

Commit bbdee9f

Browse files
committed
Merge branch '3.1'
2 parents 2d2cd58 + 17c69d7 commit bbdee9f

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
import com.github.benmanes.caffeine.cache.Cache;
4848

49+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
50+
4951
/**
5052
* This is a wrapper class for BCFile that includes a cache for independent caches for datablocks
5153
* and metadatablocks
@@ -331,6 +333,8 @@ public Map<String,Loader> getDependencies() {
331333
return Collections.emptyMap();
332334
}
333335

336+
@SuppressFBWarnings(value = {"NP_LOAD_OF_KNOWN_NULL_VALUE"},
337+
justification = "Spotbugs false positive, see spotbugs issue 2836.")
334338
@Override
335339
public byte[] load(int maxSize, Map<String,byte[]> dependencies) {
336340

@@ -345,23 +349,18 @@ public byte[] load(int maxSize, Map<String,byte[]> dependencies) {
345349
}
346350
}
347351

348-
BlockReader _currBlock = getBlockReader(maxSize, reader);
349-
if (_currBlock == null) {
350-
return null;
351-
}
352+
try (BlockReader _currBlock = getBlockReader(maxSize, reader)) {
353+
if (_currBlock == null) {
354+
return null;
355+
}
352356

353-
byte[] b = null;
354-
try {
355-
b = new byte[(int) _currBlock.getRawSize()];
357+
byte[] b = new byte[(int) _currBlock.getRawSize()];
356358
_currBlock.readFully(b);
359+
return b;
357360
} catch (IOException e) {
358361
log.debug("Error full blockRead for file " + cacheId + " for block " + getBlockId(), e);
359362
throw new UncheckedIOException(e);
360-
} finally {
361-
_currBlock.close();
362363
}
363-
364-
return b;
365364
} catch (IOException e) {
366365
throw new UncheckedIOException(e);
367366
}

0 commit comments

Comments
 (0)