Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

use jackson for @JsonSerialize annotated types #174

Closed
wants to merge 6 commits into from

Conversation

danielnorberg
Copy link
Contributor

@danielnorberg danielnorberg commented Oct 5, 2018

Hey, I just made a Pull Request!

Description

use jackson serializaion for @JsonSerialize annotated types

Motivation and Context

Some types (e.g. beam PipelineOptions) are not kryo nor java
serializable, but they are jackson serializable.

Have you tested this? If so, how?

Added a test for PipelineOptions.

Checklist for PR author(s)

  • Changes are covered by unit test
  • All tests pass
  • Code coverage check passes
  • Error handling is tested
  • Errors are handled at the appropriate layer
  • Errors that cannot be handled where they occur are propagated
  • Relevant documentation updated
  • This PR has NO breaking change to public API
  • This PR has breaking change to public API and it is documented

Checklist for PR reviewer(s)

  • This PR has been incorporated in release note for the coming version
  • Risky changes introduced by this PR have been all considered

Daniel Norberg added 2 commits October 5, 2018 16:18
Some types (e.g. beam PipelineOptions) are not kryo nor java
serializable, but they are jackson serializable.
@danielnorberg
Copy link
Contributor Author

Addresses #170

@danielnorberg
Copy link
Contributor Author

Not sure why tests fail, works on my laptop! 😄

@danielnorberg
Copy link
Contributor Author

For some reason scala-maven-plugin is failing.

@ulzha
Copy link
Contributor

ulzha commented Oct 5, 2018

Looks cool to me (pun intended... I don't know much about Kryo and what effects kryo.setRegistrationRequired(false); will bring, for example).

@danielnorberg
Copy link
Contributor Author

danielnorberg commented Oct 5, 2018

@ulzha kryo registration required already defaults to false. I just kept the explicit call because the chill-scala kryo setup was explicitly setting it.

@codecov
Copy link

codecov bot commented Oct 5, 2018

Codecov Report

Merging #174 into master will increase coverage by 0.11%.
The diff coverage is 67.34%.

@@             Coverage Diff             @@
##             master    #174      +/-   ##
===========================================
+ Coverage     69.59%   69.7%   +0.11%     
- Complexity      363     376      +13     
===========================================
  Files            67      68       +1     
  Lines          1618    1654      +36     
  Branches        110     112       +2     
===========================================
+ Hits           1126    1153      +27     
- Misses          425     433       +8     
- Partials         67      68       +1

kryo = new Kryo();
kryo = new Kryo() {
@Override
public Registration getRegistration(Class type) {
Copy link

Choose a reason for hiding this comment

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

It isn't completely valid to override getRegistration, because it looks more like default serializer. There is getDefaultSerializerForAnnotatedType to override.

Copy link

Choose a reason for hiding this comment

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

For instance, this will make not possible to register custom serializers for anything that JacksonJsonSerializer can comprehend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately Kryo special handles Proxy instances in a way which means that getDefaultSerializerForAnnotatedType can't be used to handle PipelineOptions.

Copy link
Member

@honnix honnix left a comment

Choose a reason for hiding this comment

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

Let's also make codecov happy about delta change.

<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill_2.11</artifactId>
<version>0.9.2</version>
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to parent pom.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an awkward dependency to have in the parent pom because then we should move the chill dependencies from the scala submodules as well into the parent pom and then we end up enumerating the scala versions in the parent pom... do we want that?

Copy link
Member

Choose a reason for hiding this comment

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

Ok then.

: Optional.empty();
}

static void register(Kryo kryo) {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking, this method reads a bit strange. Will it be better called registerTo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You have nominated yourself for a nitpick award ;P

}
}

private static class ScalaKryoSetup {
Copy link
Member

Choose a reason for hiding this comment

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

What's the benefit having a static class here instead of just a static method? And why is the branch using chill-java inlined instead of being factored out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to be a static class because we don't want the method to be class-loaded before we know that we have chill-scala available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@honnix
Copy link
Member

honnix commented Oct 10, 2018

👍

@honnix
Copy link
Member

honnix commented Oct 10, 2018

Oh, wait, please fix coverage.

@honnix
Copy link
Member

honnix commented Oct 15, 2018

Let's close this in favour of #178 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants