diff --git a/core/src/main/java/tachyon/hadoop/HdfsFileInputStream.java b/core/src/main/java/tachyon/hadoop/HdfsFileInputStream.java index 5d1650500d75..9c2445516199 100644 --- a/core/src/main/java/tachyon/hadoop/HdfsFileInputStream.java +++ b/core/src/main/java/tachyon/hadoop/HdfsFileInputStream.java @@ -163,7 +163,8 @@ public int read(byte[] b, int off, int len) throws IOException { * number of bytes read. This does not change the current offset of a file, and is thread-safe. */ @Override - public int read(long position, byte[] buffer, int offset, int length) throws IOException { + public synchronized int read(long position, byte[] buffer, int offset, int length) + throws IOException { int ret = -1; long oldPos = getPos(); if ((position < 0) || (position >= mTachyonFile.length())) { @@ -174,6 +175,7 @@ public int read(long position, byte[] buffer, int offset, int length) throws IOE try { seek(position); ret = mTachyonFileInputStream.read(buffer, offset, length); + mCurrentPosition += ret; return ret; } finally { seek(oldPos); @@ -184,6 +186,7 @@ public int read(long position, byte[] buffer, int offset, int length) throws IOE try { mHdfsInputStream.seek(position); ret = mHdfsInputStream.read(buffer, offset, length); + mCurrentPosition += ret; return ret; } finally { mHdfsInputStream.seek(oldPos);