@@ -717,7 +717,7 @@ public synchronized void close() throws IOException {
717717 if (!closed ) {
718718 closed = true ;
719719 try {
720- stopVectoredIOOperations . set ( true );
720+ stopVectorOperations ( );
721721 // close or abort the stream; blocking
722722 closeStream ("close() operation" , false , true );
723723 // end the client+audit span.
@@ -993,9 +993,7 @@ public void readVectored(final List<? extends FileRange> ranges,
993993 final Consumer <ByteBuffer > release ) throws IOException {
994994 LOG .debug ("Starting vectored read on path {} for ranges {} " , pathStr , ranges );
995995 checkNotClosed ();
996- if (stopVectoredIOOperations .getAndSet (false )) {
997- LOG .debug ("Reinstating vectored read operation for path {} " , pathStr );
998- }
996+ maybeStartVectorOperations ();
999997 // fail fast on parameters which would otherwise only be checked
1000998 // in threads and/or in failures.
1001999 requireNonNull (allocate , "Null allocator" );
@@ -1039,6 +1037,24 @@ public void readVectored(final List<? extends FileRange> ranges,
10391037 " on path {} for ranges {} " , pathStr , ranges );
10401038 }
10411039
1040+ /**
1041+ * Start/restart vector operations if not active.
1042+ * In particular, after an unbuffer(), this performs any
1043+ * initialization required.
1044+ */
1045+ private void maybeStartVectorOperations () {
1046+ if (stopVectoredIOOperations .getAndSet (false )) {
1047+ LOG .debug ("Reinstating vectored read operation for path {} " , pathStr );
1048+ }
1049+ }
1050+
1051+ /**
1052+ * Stop vector operations.
1053+ */
1054+ private void stopVectorOperations () {
1055+ stopVectoredIOOperations .set (true );
1056+ }
1057+
10421058 /**
10431059 * Read the data from S3 for the bigger combined file range and update all the
10441060 * underlying ranges.
@@ -1558,7 +1574,7 @@ public static long validateReadahead(@Nullable Long readahead) {
15581574 @ Override
15591575 public synchronized void unbuffer () {
15601576 try {
1561- stopVectoredIOOperations . set ( true );
1577+ stopVectorOperations ( );
15621578 closeStream ("unbuffer()" , false , false );
15631579 } finally {
15641580 streamStatistics .unbuffered ();
0 commit comments