Skip to content

Commit

Permalink
fix: 添加CosFsInputStream的available方法的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyang733 committed Mar 12, 2021
1 parent 3430c92 commit e5b7ffa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/apache/hadoop/fs/CosFsInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ public int read(byte[] b, int off, int len) throws IOException {
return bytesRead == 0 ? -1 : bytesRead;
}

@Override
public int available() throws IOException {
if(this.closed) {
throw new IOException(FSExceptionMessages.STREAM_IS_CLOSED);
}

long remaining = this.fileSize - this.position;
if(remaining > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}

return (int) remaining;
}

@Override
public void close() throws IOException {
if (this.closed) {
Expand Down

0 comments on commit e5b7ffa

Please sign in to comment.