[
https://issues.apache.org/jira/browse/BEAM-4069?focusedWorklogId=91547&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-91547
]
ASF GitHub Bot logged work on BEAM-4069:
----------------------------------------
Author: ASF GitHub Bot
Created on: 16/Apr/18 23:35
Start Date: 16/Apr/18 23:35
Worklog Time Spent: 10m
Work Description: tgroh commented on a change in pull request #5126:
[BEAM-4069] Gracefully deserialize empty options structs
URL: https://github.com/apache/beam/pull/5126#discussion_r181915277
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java
##########
@@ -732,14 +732,22 @@ private void ensureSerializable(
@Override
public PipelineOptions deserialize(JsonParser jp, DeserializationContext
ctxt)
throws IOException, JsonProcessingException {
- ObjectNode objectNode = (ObjectNode) jp.readValueAsTree();
- ObjectNode optionsNode = (ObjectNode) objectNode.get("options");
+ ObjectNode objectNode = jp.readValueAsTree();
+ JsonNode rawOptionsNode = objectNode.get("options");
+ ObjectNode optionsNode;
+ if (rawOptionsNode == null || rawOptionsNode.isNull()) {
Review comment:
Can this not be pulled up some? e.g.
```
PipelineOptions options;
if (rawOptionsNode == null || rawOptionsNode.isNull()) {
options = PipelineOptionsFactory.create(); // or new
ProxyInvocationHandler..., but I believe these to be equivalent
} else {
// code
options = ProxyInvocationHandler...
}
ValueProvider.RuntimeValueProvider.setRuntimeOptions(options)
return options;
```
Because the two if statements aren't independent - so we can just glom them
together and have a more obvious path through the method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 91547)
Time Spent: 50m (was: 40m)
> Empty pipeline options can be gracefully serialized/deserialized
> ----------------------------------------------------------------
>
> Key: BEAM-4069
> URL: https://issues.apache.org/jira/browse/BEAM-4069
> Project: Beam
> Issue Type: Bug
> Components: runner-core
> Reporter: Ben Sidhom
> Assignee: Ben Sidhom
> Priority: Minor
> Time Spent: 50m
> Remaining Estimate: 0h
>
> PipelineOptionsTranslation.fromProto currently crashes with a
> NullPointerException when passed an empty options Struct. This is due to
> ProxyInvocationHandler.Deserializer expecting a non-empty enclosing Struct.
> Empty pipeline options may be passed by SDKs interacting with a job server,
> so this case needs to be handled. Note that testing a round-trip of an
> effectively-empty Java PipelineOptions object is not sufficient to catch this
> because "empty" Java options still contain default fields not defined in
> other SDKs.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)