49
49
50
50
import com .github .benmanes .caffeine .cache .Cache ;
51
51
52
+ import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
53
+
52
54
/**
53
55
* This is a wrapper class for BCFile that includes a cache for independent caches for datablocks
54
56
* and metadatablocks
@@ -342,6 +344,8 @@ public Map<String,Loader> getDependencies() {
342
344
return Collections .emptyMap ();
343
345
}
344
346
347
+ @ SuppressFBWarnings (value = {"NP_LOAD_OF_KNOWN_NULL_VALUE" },
348
+ justification = "Spotbugs false positive, see spotbugs issue 2836." )
345
349
@ Override
346
350
public byte [] load (int maxSize , Map <String ,byte []> dependencies ) {
347
351
@@ -356,23 +360,18 @@ public byte[] load(int maxSize, Map<String,byte[]> dependencies) {
356
360
}
357
361
}
358
362
359
- BlockReader _currBlock = getBlockReader (maxSize , reader );
360
- if (_currBlock == null ) {
361
- return null ;
362
- }
363
+ try ( BlockReader _currBlock = getBlockReader (maxSize , reader )) {
364
+ if (_currBlock == null ) {
365
+ return null ;
366
+ }
363
367
364
- byte [] b = null ;
365
- try {
366
- b = new byte [(int ) _currBlock .getRawSize ()];
368
+ byte [] b = new byte [(int ) _currBlock .getRawSize ()];
367
369
_currBlock .readFully (b );
370
+ return b ;
368
371
} catch (IOException e ) {
369
372
log .debug ("Error full blockRead for file " + cacheId + " for block " + getBlockId (), e );
370
373
throw new UncheckedIOException (e );
371
- } finally {
372
- _currBlock .close ();
373
374
}
374
-
375
- return b ;
376
375
} catch (IOException e ) {
377
376
throw new UncheckedIOException (e );
378
377
}
0 commit comments