On Wed, Jan 16, 2019 at 8:53 PM Vetle Leinonen-Roeim <[email protected]>
wrote:
> Hi,
>
> When specifying @JsonInclude(value = JsonInclude.Include.CUSTOM,
> valueFilter = FooFilter.class) on a *boolean *type, it is not applied,
> but on *Boolean* types it *is* applied.
> Is this intended behaviour?
>
No, behavior should not differ. This sounds like a bug.
>
> Here's an example. Given this Spock test:
> def 'zot'() {
> given:
> def foo = new Foo()
>
> when:
> def serialized = MAPPER.writeValueAsString(foo)
>
> then:
> print serialized
> }
>
> static class Foo {
> Foo() {}
>
> boolean someBoolean
>
> Boolean customBoolean = true
>
> @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter =
> FooFilter.class)
> boolean isSomeBoolean() {
> return someBoolean
> }
>
> @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter =
> FooFilter.class)
> Boolean isCustomBoolean() {
> return customBoolean
> }
>
> }
>
> static class FooFilter {
> @Override
> boolean equals(Object o) {
> return true
> }
> }
>
> The filter is the same both for the boolean and Boolean field.
> The resulting output would be that both fields should be excluded from the
> serialization, but someBolean is included:
> {
> "someBoolean" : false
> }
>
> Through debugging, I see that BooleanMethodPropertyWriter is used for
> someBoolean, and ObjectMethodPropertyWriter is used for the customBoolean.
> The former does not implement the custom filtering.
>
> Thanks in advance,
> Vetle Leinonen-Roeim
>
Quick question: are you using Afterburner module? It might not be handling
this properly in overrides: I know there are specific optimizations for
(some) primitive types, including `boolean`. If so, it'd be good to file
issue for `jackson-modules-base` repo that contains Afterburner.
-+ Tatu +-
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.