Skip to content

Commit 06897ac

Browse files
committed
HTTP202 Amend deserialize to work with flink 2
Signed-off-by: davidradl <[email protected]>
1 parent 00e5f5f commit 06897ac

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased]
44

55
- allow format options to be applied to the http response decoding.
6+
- change deserialize method so it can work with Flink 2
67

78
## [0.24.0] - 2025-11-26
89

src/main/java/com/getindata/connectors/http/internal/table/lookup/JavaNetHttpPollingClient.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.flink.configuration.ReadableConfig;
2626
import org.apache.flink.table.data.RowData;
2727
import org.apache.flink.table.functions.FunctionContext;
28+
import org.apache.flink.util.Collector;
2829
import org.apache.flink.util.ConfigurationException;
2930
import org.apache.flink.util.StringUtils;
3031

@@ -269,9 +270,19 @@ private Collection<RowData> deserialize(String responseBody) throws IOException
269270
}
270271

271272
private List<RowData> deserializeSingleValue(byte[] rawBytes) throws IOException {
272-
return Optional.ofNullable(responseBodyDecoder.deserialize(rawBytes))
273-
.map(Collections::singletonList)
274-
.orElse(Collections.emptyList());
273+
List<RowData> result = new ArrayList<>();
274+
responseBodyDecoder.deserialize(rawBytes, new Collector<>() {
275+
@Override
276+
public void collect(RowData record) {
277+
result.add(record);
278+
}
279+
280+
@Override
281+
public void close() {
282+
// No-op
283+
}
284+
});
285+
return result;
275286
}
276287

277288
private List<RowData> deserializeArray(byte[] rawBytes) throws IOException {
@@ -281,11 +292,10 @@ private List<RowData> deserializeArray(byte[] rawBytes) throws IOException {
281292
List<RowData> result = new ArrayList<>();
282293
for (JsonNode rawObject : rawObjects) {
283294
if (!(rawObject instanceof NullNode)) {
284-
RowData deserialized =
285-
responseBodyDecoder.deserialize(rawObject.toString().getBytes());
286-
// deserialize() returns null if deserialization fails
287-
if (deserialized != null) {
288-
result.add(deserialized);
295+
List<RowData> deserialized = deserializeSingleValue(rawObject.toString().getBytes());
296+
// deserialize() may return empty list if deserialization fails
297+
if (deserialized != null && !deserialized.isEmpty()) {
298+
result.addAll(deserialized);
289299
}
290300
}
291301
}

0 commit comments

Comments
 (0)