99
1010package  org .elasticsearch .common .blobstore .support ;
1111
12- import  org .apache .logging .log4j .Level ;
13- import  org .apache .logging .log4j .LogManager ;
14- import  org .apache .logging .log4j .Logger ;
15- import  org .elasticsearch .common .ReferenceDocs ;
1612import  org .elasticsearch .common .Strings ;
1713import  org .elasticsearch .common .blobstore .BlobContainer ;
1814import  org .elasticsearch .common .bytes .BytesArray ;
1915import  org .elasticsearch .common .bytes .BytesReference ;
20- import  org .elasticsearch .common .logging .ChunkedLoggingStream ;
21- import  org .elasticsearch .common .unit .ByteSizeUnit ;
2216
2317import  java .io .IOException ;
2418import  java .io .InputStream ;
@@ -38,8 +32,6 @@ public static void ensureValidRegisterContent(BytesReference bytesReference) {
3832        }
3933    }
4034
41-     private  static  final  Logger  logger  = LogManager .getLogger (BlobContainerUtils .class );
42- 
4335    /** 
4436     * Many blob stores have consistent (linearizable/atomic) read semantics and in these casees it is safe to implement {@link 
4537     * BlobContainer#getRegister} by simply reading the blob using this utility. 
@@ -59,28 +51,7 @@ public static BytesReference getRegisterUsingConsistentRead(InputStream inputStr
5951            len  -= read ;
6052            pos  += read ;
6153        }
62-         final  int  nextByte  = inputStream .read ();
63-         if  (nextByte  != -1 ) {
64-             try  (
65-                 var  cls  = ChunkedLoggingStream .create (
66-                     logger ,
67-                     Level .ERROR ,
68-                     "getRegisterUsingConsistentRead including trailing data" ,
69-                     ReferenceDocs .LOGGING 
70-                 )
71-             ) {
72-                 cls .write (bytes );
73-                 cls .write (nextByte );
74-                 final  var  buffer  = new  byte [ByteSizeUnit .KB .toIntBytes (1 )];
75-                 while  (true ) {
76-                     final  var  readSize  = inputStream .read (buffer );
77-                     if  (readSize  == -1 ) {
78-                         break ;
79-                     }
80-                     cls .write (buffer , 0 , readSize );
81-                 }
82-             }
83- 
54+         if  (inputStream .read () != -1 ) {
8455            throw  new  IllegalStateException (
8556                Strings .format ("[%s] failed reading register [%s] due to unexpected trailing data" , container , key )
8657            );
0 commit comments