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

BlackBird not support fluent setter #123

Closed
wujimin opened this issue Dec 28, 2020 · 7 comments
Closed

BlackBird not support fluent setter #123

wujimin opened this issue Dec 28, 2020 · 7 comments
Labels
Milestone

Comments

@wujimin
Copy link

@wujimin wujimin commented Dec 28, 2020

Environment

  • jdk 11
  • jackson 2.12.0 with BlackBird

Reproduce case

define a model with fluent setter

public class BlackBirdBug {
  public static class Model {
      private int value = 10;

      public int getValue() {
          return value;
      }

      public Model setValue(int value) {
          this.value = value;

          return this;
      }
  }

  public static void main(String[] args) throws JsonProcessingException {
      ObjectMapper mapper = new ObjectMapper()
          .registerModule(new BlackbirdModule());
      String json = mapper.writeValueAsString(new Model());
      System.out.println(json);

      Model model = mapper.readValue(json, Model.class);
      System.out.println(model.getValue());
  }
}

will throw exception:

Caused by: java.lang.invoke.LambdaConversionException: Type mismatch for instantiated parameter 1: int is not a subtype of class java.lang.Object
	at java.base@11.0.6/java.lang.invoke.AbstractValidatingLambdaMetafactory.checkDescriptor(AbstractValidatingLambdaMetafactory.java:308)
	at java.base@11.0.6/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:294)
	at java.base@11.0.6/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:328)
	at com.fasterxml.jackson.module.blackbird.deser.BBDeserializerModifier.createSetter(BBDeserializerModifier.java:221)
	at com.fasterxml.jackson.module.blackbird.deser.BBDeserializerModifier.nextProperty(BBDeserializerModifier.java:179)
	at com.fasterxml.jackson.module.blackbird.deser.BBDeserializerModifier.findOptimizableProperties(BBDeserializerModifier.java:126)
	... 14 more

we are trying switch from AfterBurner to BlackBird, because AfterBurner not support ToStringSerializer via @JsonSerialize in boolean oroperty

cowtowncoder added a commit that referenced this issue Jan 1, 2021
@cowtowncoder cowtowncoder added the 2.12 label Jan 1, 2021
@cowtowncoder
Copy link
Member

@cowtowncoder cowtowncoder commented Jan 1, 2021

@wujimin Thank you for reporting this: I can reproduce the problem.

@stevenschlansker Looks like code might assume that all setters are of type void? I added a test under "..../failing" ( named BasicDeserialize123Test) and will see if I can see how this could be fixed, but if you have a chance to look at some point that'd be great as you know code much better :) .

@stevenschlansker
Copy link
Contributor

@stevenschlansker stevenschlansker commented Jan 1, 2021

That could be it, or maybe a spot where the VM would autobox for us but invokeExact doesn't. Either way I can take a look in the next few days (on vacation this week technically, happy new year all! )

@cowtowncoder
Copy link
Member

@cowtowncoder cowtowncoder commented Jan 1, 2021

@stevenschlansker yeah that sounds plausible. Return type is part of the signature, anyway. Could either filter out such cases (not optimize) or ideally handle, either would work.
Happy new year -- no rush obviously, I just added note as I had a chance to look at things reported for 2.12, before modest New Year's celebrations. :-)

@stevenschlansker
Copy link
Contributor

@stevenschlansker stevenschlansker commented Jan 4, 2021

Makes sense. Should be an easy enough fix.

@stevenschlansker
Copy link
Contributor

@stevenschlansker stevenschlansker commented Jan 5, 2021

@wujimin, it turned out to not be quite the same bug, but if you have a chance please verify that #124 fixes your issue

@wujimin
Copy link
Author

@wujimin wujimin commented Jan 5, 2021

@stevenschlansker
i have verified the new code
it fixed my issue.
thanks.

and find a new issue of https://github.com/FasterXML/jackson-modules-base/blob/2.12/blackbird/README.md

<dependency>
  <groupId>com.fasterxml.jackson.modules</groupId>
  <artifactId>jackson-module-blackbird</artifactId>
</dependency>

groupId should be com.fasterxml.jackson.module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants