Skip to content

No way to explicitly disable wrapping in custom annotation processor #4595

@SimonCockx

Description

@SimonCockx

When upgrading from Jackson 2.15.0 to 2.17.1, we noticed our custom annotation processor stopped working due to a change in behaviour in the way PropertyNames are merged. See #4364. I would like to know whether this is intended, and if it is, how I should migrate my code.

We have a custom XML annotation introspector which explicitly sets the wrapper name to Property.NO_NAME if our custom annotation is present and the type is a list:

    @Override
    public PropertyName findWrapperName(Annotated ann) {
        if (ann.hasAnnotation(RosettaAttribute.class) && hasCollectionType(ann)) {
            // Disable wrapping of lists.
            return PropertyName.NO_NAME;
        }
        return super.findWrapperName(ann);
    }

This used to work in Jackson 2.15.

Unfortunately, due to the change in #4364, PropertyName.NO_NAME is now merged with PropertyName.DEFAULT from the default Jackson XML annotation introspector, and the new behaviour prefers PropertyName.DEFAULT over PropertyName.NO_NAME. The previous behaviour would prefer PropertyName.NO_NAME.

I have not found a way to fix this. Is there a way to get rid of the default annotation processor?

Originally posted by @SimonCockx in #4364 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions