Buggy code:
class BlobReadChannel implements ReadChannel { private static final int DEFAULT_CHUNK_SIZE = ( 2 * 1024 ) * 1024 ; private final StorageOptions serviceOptions ; private final BlobId blob ; private final Map < StorageRpc . Option , ? > requestOptions ; private String lastEtag ; private int position ; private boolean isOpen ; private boolean endOfStream ; private int chunkSize = BlobReadChannel . DEFAULT_CHUNK_SIZE ; private final StorageRpc storageRpc ; private final StorageObject storageObject ; private int bufferPos ; private byte [ ] buffer ; BlobReadChannel ( StorageOptions serviceOptions , BlobId blob , Map < StorageRpc . Option , ? > requestOptions ) { } @ Override public RestorableState < ReadChannel > capture ( ) { } @ Override public boolean isOpen ( ) { } @ Override public void close ( ) { } private void validateOpen ( ) throws ClosedChannelException { } @ Override public void seek ( int position ) throws IOException { } @ Override public void chunkSize ( int chunkSize ) { } @ Override public int read ( ByteBuffer byteBuffer ) throws IOException { validateOpen ( ) ; if ( ( buffer ) == null ) { if ( endOfStream ) { return - 1 ; } final int toRead = Math . max ( byteBuffer . remaining ( ) , chunkSize ) ; try { Tuple < String , byte [ ] > result = RetryHelper . runWithRetries ( new Callable < Tuple < String , byte [ ] > > ( ) { @ Override public Tuple < String , byte [ ] > call ( ) { return storageRpc . read ( storageObject , requestOptions , position , toRead ) ; } } , serviceOptions . retryParams ( ) , EXCEPTION_HANDLER ) ; <START_BUG> if ( ( ( lastEtag ) != null ) && ( ! ( Objects . equals ( result . x ( ) , lastEtag ) ) ) ) { <END_BUG> StringBuilder messageBuilder = new StringBuilder ( ) ; messageBuilder . append ( "Blob<seq2seq4repair_space>" ) . append ( blob ) . append ( "<seq2seq4repair_space>was<seq2seq4repair_space>updated<seq2seq4repair_space>while<seq2seq4repair_space>reading" ) ; throw new StorageException ( 0 , messageBuilder . toString ( ) ) ; } lastEtag = result . x ( ) ; buffer = result . y ( ) ; } catch ( RetryHelper e ) { throw StorageException . translateAndThrow ( e ) ; } if ( toRead > ( buffer . length ) ) { endOfStream = true ; if ( ( buffer . length ) == 0 ) { buffer = null ; return - 1 ; } } } int toWrite = Math . min ( ( ( buffer . length ) - ( bufferPos ) ) , byteBuffer . remaining ( ) ) ; byteBuffer . put ( buffer , bufferPos , toWrite ) ; bufferPos += toWrite ; if ( ( bufferPos ) >= ( buffer . length ) ) { position += buffer . length ; buffer = null ; bufferPos = 0 ; } return toWrite ; } static class StateImpl implements RestorableState < ReadChannel > , Serializable { private static final long serialVersionUID = 3889420316004453706L ; private final StorageOptions serviceOptions ; private final BlobId blob ; private final Map < StorageRpc . Option , ? > requestOptions ; private final String lastEtag ; private final int position ; private final boolean isOpen ; private final boolean endOfStream ; private final int chunkSize ; StateImpl ( BlobReadChannel . StateImpl . Builder builder ) { } static class Builder { private final StorageOptions serviceOptions ; private final BlobId blob ; private final Map < StorageRpc . Option , ? > requestOptions ; private String lastEtag ; private int position ; private boolean isOpen ; private boolean endOfStream ; private int chunkSize ; private Builder ( StorageOptions options , BlobId blob , Map < StorageRpc . Option , ? > reqOptions ) { } BlobReadChannel . StateImpl . Builder lastEtag ( String lastEtag ) { } BlobReadChannel . StateImpl . Builder position ( int position ) { } BlobReadChannel . StateImpl . Builder isOpen ( boolean isOpen ) { } BlobReadChannel . StateImpl . Builder endOfStream ( boolean endOfStream ) { } BlobReadChannel . StateImpl . Builder chunkSize ( int chunkSize ) { } RestorableState < ReadChannel > build ( ) { } } static BlobReadChannel . StateImpl . Builder builder ( StorageOptions options , BlobId blob , Map < StorageRpc . Option , ? > reqOptions ) { } @ Override public ReadChannel restore ( ) { } @ Override public int hashCode ( ) { } @ Override public boolean equals ( Object obj ) { } @ Override public String toString ( ) { } } }

Fix:
if ( ( ( ( result . y ( ) . length ) > 0 ) && ( ( lastEtag ) != null ) ) && ( ! ( Objects . equals ( result . x ( ) , lastEtag ) ) ) ) {