@@ -73,7 +73,7 @@ public class AbfsInputStream extends FSInputStream implements CanUnbuffer,
7373 private final AbfsClient client ;
7474 private final Statistics statistics ;
7575 private final String path ;
76- private long contentLength ;
76+ private volatile long contentLength ;
7777 private final int bufferSize ; // default buffer size
7878 private final int footerReadSize ; // default buffer size to read when reading footer
7979 private final int readAheadQueueDepth ; // initialized in constructor
@@ -533,14 +533,10 @@ private boolean shouldBreakLazyOptimizedRead(final int actualLen,
533533 }
534534
535535 @ VisibleForTesting
536- synchronized long getContentLength () {
536+ long getContentLength () {
537537 return contentLength ;
538538 }
539539
540- private synchronized void setContentLength (long contentLength ) {
541- this .contentLength = contentLength ;
542- }
543-
544540 private boolean hasFileStatusInfo () {
545541 return fileStatusInformationPresent ;
546542 }
@@ -754,8 +750,8 @@ int readRemote(long position, byte[] b, int offset, int length, TracingContext t
754750
755751 private void initPropertiesFromReadResponseHeader (final AbfsHttpOperation op ) throws IOException {
756752 validateFileResourceTypeAndParseETag (op );
757- setContentLength ( parseFromRange (
758- op .getResponseHeader (HttpHeaderConfigurations .CONTENT_RANGE ))) ;
753+ contentLength = parseFromRange (
754+ op .getResponseHeader (HttpHeaderConfigurations .CONTENT_RANGE ));
759755 }
760756
761757 private long parseFromRange (final String responseHeader ) {
@@ -849,8 +845,8 @@ public synchronized int available() throws IOException {
849845 AbfsRestOperation op = client .getPathStatus (path , false , tracingContext ,
850846 null );
851847 validateFileResourceTypeAndParseETag (op .getResult ());
852- setContentLength ( Long .parseLong (
853- op .getResult ().getResponseHeader (HttpHeaderConfigurations .CONTENT_LENGTH ))) ;
848+ contentLength = Long .parseLong (
849+ op .getResult ().getResponseHeader (HttpHeaderConfigurations .CONTENT_LENGTH ));
854850 }
855851 final long remaining = getContentLength () - this .getPos ();
856852 return remaining <= Integer .MAX_VALUE
0 commit comments