-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cdc]Fix: When the value of entry is null, subsequent java.lang.NullPointerException is thrown #3167
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fix: When the value of entry is null, subsequent java.lang.NullPointerException is thrown
Fix: When the value of entry is null, subsequent java.lang.NullPointerException is thrown |
scottxing
changed the title
[cdc]Update RecordParser.java
[cdc]Fix: When the value of entry is null, subsequent java.lang.NullPointerException is thrown
Apr 11, 2024
Can you show the full exception stack? |
Test Code:There are String oggMsg = """
{
"after": {
"id": 111,
"name": null,
"description": "Big 2-wheel scooter",
"weight": 5.15
},
"op_type": "I",
"op_ts": "2020-05-13 15:40:06.000000",
"current_ts": "2020-05-13 15:40:07.000000",
"primary_keys": [
"id"
],
"pos": "00000000000000000000143",
"table": "PRODUCTS"
}
""";
RecordParser recordParser = new OggRecordParser(false, TypeMapping.defaultMapping(), new ArrayList<>());
recordParser.buildSchema(oggMsg); Source Code:public abstract class RecordParser implements FlatMapFunction<String, RichCdcMultiplexRecord> {
...
protected Map<String, String> extractRowData(JsonNode record, LinkedHashMap<String, DataType> paimonFieldTypes) {
paimonFieldTypes.putAll(this.fillDefaultTypes(record));
Map<String, Object> recordMap = (Map)JsonSerdeUtil.convertValue(record, new TypeReference<Map<String, Object>>() {
});
Map<String, String> rowData = (Map)recordMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, (entry) -> {
if (Objects.nonNull(entry.getValue()) && !TypeUtils.isBasicType(entry.getValue())) {
try {
return JsonSerdeUtil.writeValueAsString(entry.getValue());
} catch (JsonProcessingException var2) {
JsonProcessingException e = var2;
LOG.error("Failed to deserialize record.", e);
return Objects.toString(entry.getValue());
}
} else {
return Objects.toString(entry.getValue(), (String)null);
}
}));
this.evalComputedColumns(rowData, paimonFieldTypes);
return rowData;
}
...
} Exception:Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.apache.paimon.flink.action.cdc.format.RecordParser.extractRowData(RecordParser.java:146)
at org.apache.paimon.flink.action.cdc.format.RecordParser.processRecord(RecordParser.java:192)
at org.apache.paimon.flink.action.cdc.format.ogg.OggRecordParser.extractRecords(OggRecordParser.java:76)
at org.apache.paimon.flink.action.cdc.format.RecordParser.buildSchema(RecordParser.java:96)
at org.example.Main.main(Main.java:33) |
The latest branch has fixed this bug. |
I will close this PR. If you still have questions, you can open it again and continue to add your questions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: When the value of entry is null, subsequent java.lang.NullPointerException is thrown
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/format/RecordParser.java
Purpose
When the value of entry is null, subsequent java.lang.NullPointerException is thrown