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-4775] mv function pkg from fn-harness to java-core #7866

Merged
merged 2 commits into from Feb 20, 2019

Conversation

ryan-williams
Copy link
Contributor

@ryan-williams ryan-williams commented Feb 17, 2019

also: parameterize ThrowingConsumer by Exception type

This is factored out of #7823, where a use-case for a ThrowingConsumer<IOException, …> exists, in Jackson JSON serde code.

R: @robertwb, @mxm

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Python Build Status --- Build Status
Build Status
Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

Copy link
Contributor

@mxm mxm left a comment

Choose a reason for hiding this comment

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

Could you explain why this is necessary? I'm assuming it has to do with the dependency structure.

@ryan-williams
Copy link
Contributor Author

ryan-williams commented Feb 19, 2019

Yea, sorry it's not clear. I need to think more about metrics/proto package-structures in #7823 that may affect this. Let me do that and circle back.

In the meantime, here's some context for the package-move, as it currently stands:

parameterizing ThrowingConsumer's Exception`-type:

Context for the other part of this PR:

  • I pass a JSON-serialization action as a lambda and need to encode that it throws IOException
  • If the code that receives that lambda declares a generic throws Exception, then code that calls that would have to do some unwieldy catching/casting to go from Exception back to IOException.

Copy link
Contributor

@mxm mxm left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying. I think moving them to the core makes sense.

public interface ThrowingConsumer<T> {
void accept(T t) throws Exception;
public interface ThrowingConsumer<ExceptionT extends Exception, T> {
void accept(T t) throws ExceptionT;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use case for this change? It looks like you only pass Exception as ExceptionT. Do you want to define contracts for other subclasses of Exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a note at the end of this comment about that part.

It's not used here, but I do have a motivating case for a ThrowingConsumer<IOException, T> in #7823.

@ryan-williams ryan-williams changed the title [BEAM-4775] mv function pkg from fn-harness to java-core [DO NOT MERGE] [BEAM-4775] mv function pkg from fn-harness to java-core Feb 20, 2019
@ryan-williams ryan-williams changed the title [DO NOT MERGE] [BEAM-4775] mv function pkg from fn-harness to java-core [BEAM-4775] mv function pkg from fn-harness to java-core Feb 20, 2019
@ryan-williams
Copy link
Contributor Author

I think this can be decoupled from metrics/module concerns, and is good to go, if you agree that java/core is a more logical place for such generic language-level helpers.

Even if the metrics code that uses it ends up somewhere higher-up than java/core, having it depend on these helpers in java/core seems reasonable.

Pulling things like this back out of java/core to dedicated packages later seems fine and good as well, if necessary.

@mxm
Copy link
Contributor

mxm commented Feb 20, 2019

Looks good. Thanks!

@mxm mxm merged commit 301fee4 into apache:master Feb 20, 2019
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

2 participants