Skip to content

Commit

Permalink
HDDS-6157. More consistent synchronization in InputStreams (#2965)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai committed Jan 12, 2022
1 parent ac99b47 commit e1f9f21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -512,7 +512,7 @@ synchronized long getBlockPosition() {
}

@Override
public void unbuffer() {
public synchronized void unbuffer() {
storePosition();
releaseClient();

Expand Down
Expand Up @@ -351,14 +351,14 @@ public boolean seekToNewSource(long targetPos) throws IOException {
}

@Override
public int available() throws IOException {
public synchronized int available() throws IOException {
checkOpen();
long remaining = length - getPos();
return remaining <= Integer.MAX_VALUE ? (int) remaining : Integer.MAX_VALUE;
}

@Override
public void close() throws IOException {
public synchronized void close() throws IOException {
closed = true;
for (BlockInputStream blockStream : blockStreams) {
blockStream.close();
Expand Down Expand Up @@ -388,7 +388,7 @@ public long getRemainingOfIndex(int index) throws IOException {
}

@Override
public long skip(long n) throws IOException {
public synchronized long skip(long n) throws IOException {
if (n <= 0) {
return 0;
}
Expand All @@ -399,7 +399,7 @@ public long skip(long n) throws IOException {
}

@Override
public void unbuffer() {
public synchronized void unbuffer() {
for (BlockInputStream is : blockStreams) {
is.unbuffer();
}
Expand Down

0 comments on commit e1f9f21

Please sign in to comment.