Skip to content

[BEAM-4775] mv function pkg from fn-harness to java-core - #7866

Merged
mxm merged 2 commits into
apache:masterfrom
ryan-williams:mv-fn
Feb 20, 2019
Merged

mxm merged 2 commits into
apache:masterfrom
ryan-williams:mv-fn

Conversation

@ryan-williams

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

Copy link
Copy Markdown
Contributor

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.

@mxm mxm left a comment

Copy link
Copy Markdown
Contributor

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

ryan-williams commented Feb 19, 2019 •

Copy link
Copy Markdown
Contributor Author

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.

@mxm mxm left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

mxm commented Feb 20, 2019

Copy link
Copy Markdown
Contributor

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.

2 participants