liuliquan-marshal commented on code in PR #16865:
URL: https://github.com/apache/iceberg/pull/16865#discussion_r3474443430
##########
aliyun/src/main/java/org/apache/iceberg/aliyun/oss/OSSInputStream.java:
##########
@@ -82,89 +115,182 @@ public int read() throws IOException {
Preconditions.checkState(!closed, "Cannot read: already closed");
positionStream();
- pos += 1;
- next += 1;
- readBytes.increment();
- readOperations.increment();
+ try {
+ int bytesRead = Failsafe.with(retryPolicy).get(() -> stream.read());
+ if (bytesRead != -1) {
+ pos += 1;
+ next += 1;
+ readBytes.increment();
+ readOperations.increment();
+ }
+
+ return bytesRead;
+ } catch (FailsafeException ex) {
+ if (ex.getCause() instanceof IOException) {
+ throw (IOException) ex.getCause();
+ }
- return stream.read();
+ throw ex;
+ }
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
Preconditions.checkState(!closed, "Cannot read: already closed");
positionStream();
- int bytesRead = stream.read(b, off, len);
- pos += bytesRead;
- next += bytesRead;
- readBytes.increment(bytesRead);
- readOperations.increment();
+ try {
+ int bytesRead = Failsafe.with(retryPolicy).get(() -> stream.read(b, off,
len));
+ if (bytesRead > 0) {
+ pos += bytesRead;
+ next += bytesRead;
+ readBytes.increment(bytesRead);
+ readOperations.increment();
+ }
+
+ return bytesRead;
Review Comment:
Same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]