Skip to content

[BEAM-4069] Gracefully deserialize empty options structs#5126

Merged
tgroh merged 1 commit into
apache:masterfrom
bsidhom:empty-options
Apr 18, 2018
Merged

[BEAM-4069] Gracefully deserialize empty options structs#5126
tgroh merged 1 commit into
apache:masterfrom
bsidhom:empty-options

Conversation

@bsidhom
Copy link
Copy Markdown
Contributor

@bsidhom bsidhom commented Apr 13, 2018


Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand:
    • What the pull request does
    • Why it does it
    • How it does it
    • Why this approach
  • Each commit in the pull request should have a meaningful subject line and body.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@bsidhom
Copy link
Copy Markdown
Contributor Author

bsidhom commented Apr 13, 2018

R: @kennknowles

@bsidhom
Copy link
Copy Markdown
Contributor Author

bsidhom commented Apr 13, 2018

If I'm reading the Jenkins output correctly, this appears to be failing due to ERROR: beam2 is offline; cannot locate JDK 1.8 (latest). I'm not sure if it even attempted to run any tests.

@bsidhom
Copy link
Copy Markdown
Contributor Author

bsidhom commented Apr 16, 2018

R: @tgroh

ObjectNode objectNode = jp.readValueAsTree();
JsonNode rawOptionsNode = objectNode.get("options");
ObjectNode optionsNode;
if (rawOptionsNode == null || rawOptionsNode.isNull()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it turns out, the second if statement is completely redundant. ;)

I wasn't confident about the equivalence between an empty ProxyInvocationHandler reconstruction and PipelineOptionsFactory.create(), so I've left that as it was.

@tgroh
Copy link
Copy Markdown
Member

tgroh commented Apr 18, 2018

Cool LGTM

@tgroh tgroh merged commit b8b4510 into apache:master Apr 18, 2018
@bsidhom bsidhom deleted the empty-options branch April 18, 2018 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants