You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tz...@apache.org on 2020/11/23 02:08:06 UTC
[flink-statefun] 02/03: [FLINK-20189] [core] Use tryReadFully in
Header.skipHeaderSilently
This is an automated email from the ASF dual-hosted git repository.
tzulitai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git
commit e5f5364828c38f6324cc7dc0ab46b6d92eef241f
Author: Tzu-Li (Gordon) Tai <tz...@apache.org>
AuthorDate: Tue Nov 17 18:52:52 2020 +0800
[FLINK-20189] [core] Use tryReadFully in Header.skipHeaderSilently
This also removes the redundant use of wrapping the input stream in a
BufferedInputStream.
---
.../flink/statefun/flink/core/logger/UnboundedFeedbackLogger.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/logger/UnboundedFeedbackLogger.java b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/logger/UnboundedFeedbackLogger.java
index 7464f09..7c24b15 100644
--- a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/logger/UnboundedFeedbackLogger.java
+++ b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/logger/UnboundedFeedbackLogger.java
@@ -19,7 +19,6 @@ package org.apache.flink.statefun.flink.core.logger;
import static org.apache.flink.util.Preconditions.checkState;
-import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
@@ -158,9 +157,8 @@ public final class UnboundedFeedbackLogger<T> implements FeedbackLogger<T> {
public static InputStream skipHeaderSilently(InputStream rawKeyedInput) throws IOException {
byte[] header = new byte[HEADER_BYTES.length];
- PushbackInputStream input =
- new PushbackInputStream(new BufferedInputStream(rawKeyedInput), header.length);
- int bytesRead = input.read(header);
+ PushbackInputStream input = new PushbackInputStream(rawKeyedInput, header.length);
+ int bytesRead = InputStreamUtils.tryReadFully(input, header);
if (bytesRead > 0 && !Arrays.equals(header, HEADER_BYTES)) {
input.unread(header, 0, bytesRead);
}