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 — Conversion of BigDecimal to primitive double wrong with 1.5.2 · Issue #2913 · mapstruct/mapstruct

Conversion of BigDecimal to primitive double wrong with 1.5.2 #2913

New issue
Copy link
New issue
Copy link
Closed
#3032
Closed
Conversion of BigDecimal to primitive double wrong with 1.5.2#2913
#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

@urswiss
urswiss
opened on Jun 29, 2022
Issue body actions

After migrating from 1.4.2 to 1.5.2 a test failed. The result from BigDecimal to double is not the same anymore. Please have a look. Thanks.

https://github.com/urswiss/mapstruct-bigdecimal-to-double

Activity

  1. Zegveld commented on Jun 29, 2022

    @Zegveld
    Zegveld
    on Jun 29, 2022
    Contributor
    More actions

    Here is the analysis:

    available method to use:

        default Long mapAmount(BigDecimal amount) {
            return amount.movePointRight(2).longValue();
        }

    Reason

    As it is legal to assign a long to a double, mapstruct will use this method because it is user defined.

    Generated code

    1.4.2

    simpleDestination.setRoundingDiff( source.getRoundingDifference().doubleValue() );

    1.5.2

    simpleDestination.setRoundingDiff( mapAmount( source.getRoundingDifference() ) );

    work around

    Use qualifiers to mark the mapAmount method as one specific for certain mappings and use qualfiedBy there to link them.

    What will we do about this

    I think this is also related to: #2840 and #1216
    Because if we pick the exact match, there might be a better workaround by manually creating the default double map(BigDecimal decimal) method.

    @filiphr: WDYT ?

  2. filiphr
    added
    for:team-discussion
    on Jun 30, 2022
  3. filiphr
    added this to the 1.6.0 milestone on Jun 30, 2022
  4. filiphr commented on Jun 30, 2022

    @filiphr
    filiphr
    on Jun 30, 2022
    Member
    More actions

    Thanks for the analysis @Zegveld. This is most definitely related to #2840 and #1216. We'll need to figure out what actually broke this behaviour.

    I think that we need to fix this inconsistency, because mapping from BigDecimal to double shouldn't use BigDecimal to long.

    Reacted by Urs Wiss
  5. filiphr commented on Aug 21, 2022

    @filiphr
    filiphr
    on Aug 21, 2022
    Member
    More actions

    After doing some analysis on this one and #2849 it seems like the work we did in #2320 broke this. I still need to analyse why this happened. This was not supposed to happen when we did that PR. What do you think @sjaakd? It feels like the fact that the return type can be assigned to the expected type is causing the problem.

  6. filiphr
    added
    backport-1.5.xIssues that should be backported to 1.5Issues that should be backported to 1.5
    on Aug 21, 2022
  7. filiphr
    added
    bug
    and removed
    for:team-discussion
    on Sep 26, 2022
  8. filiphr
    added a commit that references this issue on Sep 26, 2022

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

    50db7bd
  9. 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 and Urs Wiss
  10. filiphr
    self-assigned this
    on Sep 26, 2022
  11. filiphr
    modified the milestones: 1.6.0, 1.5.3 on Sep 26, 2022
  12. filiphr
    closed this as completedin #3032on Sep 27, 2022
  13. 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 01402520 — 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.