Skip to content
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

[BEAM-3081] NonNull by default in the rest of the core SDK and shared runner code #4058

Merged
merged 10 commits into from Nov 10, 2017

Conversation

kennknowles
Copy link
Member

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.
  • Each commit in the pull request should have a meaningful subject line and body.
  • 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, how, and why.
  • 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.

@kennknowles kennknowles force-pushed the NonNull-by-default branch 6 times, most recently from 3eef21a to 1a26480 Compare October 31, 2017 15:00
@kennknowles
Copy link
Member Author

run java precommit

@kennknowles kennknowles force-pushed the NonNull-by-default branch 2 times, most recently from 6b4518f to e221627 Compare November 8, 2017 15:25
@kennknowles
Copy link
Member Author

R: @jkff another :-)

@@ -27,11 +28,13 @@
public class FlinkNoOpStepContext implements StepContext {

@Override
@Nullable
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these also throw an exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -229,7 +230,9 @@ public void populateDisplayData(DisplayData.Builder builder) {

private class Reader extends BoundedReader<ValueWithRecordId<T>> {
private long recordsRead = 0L;
private Instant endTime = Instant.now().plus(getMaxReadTime());

@Nullable private Instant endTime = Instant.now().plus(getMaxReadTime());
Copy link
Contributor

Choose a reason for hiding this comment

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

Does plus(null) work?

Copy link
Member Author

Choose a reason for hiding this comment

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

It turns out that it does "work": "If the amount is zero or null, then this is returned.". Certainly not the spec I would have chosen. Of course, if it didn't work we would have crashes already.

On the other hand, this initial value is always overwritten in the constructor in a way that contradicts the logic here. So I've just removed this.

@@ -259,6 +259,10 @@ public static ResourceId convertToFileResourceIfPossible(String outputPrefix) {
* #getSideInputs()}.
*/
protected final <SideInputT> SideInputT sideInput(PCollectionView<SideInputT> view) {
checkState(
sideInputAccessor != null,
"sideInput called on %s but side inputs" + " have not been initialized",
Copy link
Contributor

Choose a reason for hiding this comment

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

Join literals

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

private byte[] currentValue;
private ReadableByteChannel inChannel;
private TFRecordCodec codec;
private @Nullable byte[] currentValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

We have inconsistent placement of @Nullable - sometimes before the access modifier, sometimes after. Is it an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Google style, which we tend to follow, indicates

Annotations applying to a class, method or constructor[, or field] appear immediately after the documentation block
...
There are no specific rules for formatting annotations on parameters, local variables, or types.

I view @Nullable as always applying to a type, consistent with Java 8+ pluggable type systems, and more future-proof because it actually makes sense. In Java 7, applying @Nullable to a method is a necessary hack implying that the return type was @Nullable. You could debate whether it applies to the field or the type of the field. In all these cases, the actual lexemes can be ordered in any way with the same effect. I regret the many times I have written these in the wrong order. Perhaps I will do a global search and replace some day.

@asfgit asfgit merged commit 87b07d8 into apache:master Nov 10, 2017
asfgit pushed a commit that referenced this pull request Nov 10, 2017
…core SDK and shared runner code

  NonNull by default in runners/core
  NonNull by default in runners/core/metrics
  NonNull by default in runners/core/fn
  NonNull by default in runners/core/triggers
  NonNull by default in runners/core/construction/metrics
  NonNull by default in runners/core/construction
  NonNull by default in sdk/io/range
  NonNull by default in sdk/io/fs
  NonNull by default in sdk/values
  NonNull by default in sdk/io
@kennknowles kennknowles deleted the NonNull-by-default branch April 24, 2018 21:20
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.

None yet

3 participants