@@ -1093,16 +1093,22 @@ private int readMultiRegions(
1093
1093
// nothing to read, skip
1094
1094
continue ;
1095
1095
}
1096
- final CacheFileRegion fileRegion = get (cacheKey , length , region ).chunk ;
1097
- final long regionStart = getRegionStart (region );
1098
- fileRegion .populateAndRead (
1099
- mapSubRangeToRegion (rangeToWrite , region ),
1100
- subRangeToRead ,
1101
- readerWithOffset (reader , fileRegion , Math .toIntExact (rangeToRead .start () - regionStart )),
1102
- writerWithOffset (writer , fileRegion , Math .toIntExact (rangeToWrite .start () - regionStart )),
1103
- ioExecutor ,
1104
- listeners .acquire (i -> bytesRead .updateAndGet (j -> Math .addExact (i , j )))
1105
- );
1096
+ ActionListener <Integer > listener = listeners .acquire (i -> bytesRead .updateAndGet (j -> Math .addExact (i , j )));
1097
+ try {
1098
+ final CacheFileRegion fileRegion = get (cacheKey , length , region ).chunk ;
1099
+ final long regionStart = getRegionStart (region );
1100
+ fileRegion .populateAndRead (
1101
+ mapSubRangeToRegion (rangeToWrite , region ),
1102
+ subRangeToRead ,
1103
+ readerWithOffset (reader , fileRegion , Math .toIntExact (rangeToRead .start () - regionStart )),
1104
+ writerWithOffset (writer , fileRegion , Math .toIntExact (rangeToWrite .start () - regionStart )),
1105
+ ioExecutor ,
1106
+ listener
1107
+ );
1108
+ } catch (Exception e ) {
1109
+ assert e instanceof AlreadyClosedException : e ;
1110
+ listener .onFailure (e );
1111
+ }
1106
1112
}
1107
1113
}
1108
1114
readsComplete .get ();
0 commit comments