GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Ambiguous mapping methods when upgrading to Mapstruct 1.5.0.RC1 · Issue #2840 · mapstruct/mapstruct

Ambiguous mapping methods when upgrading to Mapstruct 1.5.0.RC1 #2840

New issue
Copy link
New issue
Copy link
Closed
#3032
Closed
Ambiguous mapping methods when upgrading to Mapstruct 1.5.0.RC1#2840
#3032
Copy link
Assignees
filiphr
Labels
backport-1.5.xIssues that should be backported to 1.5Issues that should be backported to 1.5bug
Milestone
1.5.3

Description

@saw303
saw303
opened on May 5, 2022
Issue body actions

When upgrading from Mapstruct 1.4.2 to 1.5.0.RC1 I get Ambiguous mapping methods error.

Given the following MappingConfiguration I want to make use of the support of the new Jakarta annotations.

@MapperConfig(
    componentModel = "jakarta",
    unmappedTargetPolicy = ReportingPolicy.ERROR,
    injectionStrategy = InjectionStrategy.CONSTRUCTOR,
    nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
    nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public class MicronautMappingConfig {}

The following mapper maps Short and Integer to their primitive value which used to work in Mapstruct 1.4.2

@Mapper(config = MicronautMappingConfig.class)
public interface NumberousMapper {

    NumberDto toNumberDto(Short shortValue, Integer intValue);

    default int toInt(Number number) {
        return number.intValue();
    }

    default short toShort(Number number) {
        return number.shortValue();
    }
}

class NumberDto {

    private int intValue;
    private short shortValue;

    public int getIntValue() {
        return intValue;
    }

    public void setIntValue(int intValue) {
        this.intValue = intValue;
    }

    public short getShortValue() {
        return shortValue;
    }

    public void setShortValue(short shortValue) {
        this.shortValue = shortValue;
    }
}

With Mapstruct 1.5.0.RC1 I get the following error

NumberousMapper.java:8: error: Ambiguous mapping methods found for mapping property "Integer intValue" to int: int toInt(Number number), short toShort(Number number). See https://mapstruct.org/faq/#ambiguous for more info.
    NumberDto toNumberDto(Short shortValue, Integer intValue);
              ^

Activity

  1. filiphr commented on May 30, 2022

    @filiphr
    filiphr
    on May 30, 2022
    Member
    More actions

    It is weird how this used to work, because we have #1216 for a similar scenario. We are going to investigate it

    Reacted by Silvio Wangler
  2. filiphr
    added
    for:team-discussion
    on May 30, 2022
  3. filiphr
    added this to the 1.6.0 milestone on Jun 6, 2022
  4. filiphr
    added a commit that references this issue on Sep 26, 2022

    mapstruct#2840, mapstruct#2913, mapstruct#2921: MethodMatcher should …

    50db7bd
  5. filiphr commented on Sep 26, 2022

    @filiphr
    filiphr
    on Sep 26, 2022
    Member
    More actions

    I am happy to announce that we have managed to find the root cause for this problem and we have a pending fix in #3032

    Reacted by Silvio Wangler
  6. filiphr
    added
    bug
    backport-1.5.xIssues that should be backported to 1.5Issues that should be backported to 1.5
    and removed
    for:team-discussion
    on Sep 26, 2022
  7. filiphr
    self-assigned this
    on Sep 26, 2022
  8. saw303 commented on Sep 26, 2022

    @saw303
    saw303
    on Sep 26, 2022
    Author
    More actions

    @filiphr that's amazing news! Thank you

    Any indication when 1.6.0 is GA? Or when the backport in 1.5.x is GA?

  9. filiphr
    modified the milestones: 1.6.0, 1.5.3 on Sep 26, 2022
  10. filiphr commented on Sep 26, 2022

    @filiphr
    filiphr
    on Sep 26, 2022
    Member
    More actions

    @saw303 for 1.6 we still do not have an Alpha / Beta release that would take a while. However, I would like to have a 1.5.3 released in the next 2 weeks. There are 2 PRs (one of them being the fix for this issue and 2 other ones like this one 😄) that are left for review before we have everything that we want for 1.5.3.

    Reacted by Silvio Wangler
  11. filiphr
    closed this as completedin #3032on Sep 27, 2022
  12. filiphr
    added 2 commits that reference this issue on Sep 27, 2022

    #2840, #2913, #2921: MethodMatcher should not match widening methods

    73e8fd6

    #2840, #2913, #2921: MethodMatcher should not match widening methods

    73f70b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @filiphr
    filiphr

Labels

backport-1.5.xIssues that should be backported to 1.5Issues that should be backported to 1.5bug

Type

No type

Projects

No projects

    Milestone

    • 1.5.3

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.