46
46
47
47
import com .github .benmanes .caffeine .cache .Cache ;
48
48
49
+ import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
50
+
49
51
/**
50
52
* This is a wrapper class for BCFile that includes a cache for independent caches for datablocks
51
53
* and metadatablocks
@@ -331,6 +333,8 @@ public Map<String,Loader> getDependencies() {
331
333
return Collections .emptyMap ();
332
334
}
333
335
336
+ @ SuppressFBWarnings (value = {"NP_LOAD_OF_KNOWN_NULL_VALUE" },
337
+ justification = "Spotbugs false positive, see spotbugs issue 2836." )
334
338
@ Override
335
339
public byte [] load (int maxSize , Map <String ,byte []> dependencies ) {
336
340
@@ -345,23 +349,18 @@ public byte[] load(int maxSize, Map<String,byte[]> dependencies) {
345
349
}
346
350
}
347
351
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
+ }
352
356
353
- byte [] b = null ;
354
- try {
355
- b = new byte [(int ) _currBlock .getRawSize ()];
357
+ byte [] b = new byte [(int ) _currBlock .getRawSize ()];
356
358
_currBlock .readFully (b );
359
+ return b ;
357
360
} catch (IOException e ) {
358
361
log .debug ("Error full blockRead for file " + cacheId + " for block " + getBlockId (), e );
359
362
throw new UncheckedIOException (e );
360
- } finally {
361
- _currBlock .close ();
362
363
}
363
-
364
- return b ;
365
364
} catch (IOException e ) {
366
365
throw new UncheckedIOException (e );
367
366
}
0 commit comments