Skip to content

String to Number(e.g. Int) type conversions should marked as lossy type conversions #3848

@SamilCan

Description

@SamilCan

Use case

We have some mappings between different microservice models. In one example, some incremental ID fields are returned as a String from the source model, but the target model has an Integer field to map them. It has worked for a long time, but now String values are overflowing the Int max range, and we are getting NumberFormatException in mapStruct generated code like: Integer.parseInt(s).

I think we can utilize the existing NARROWING_LUT hierarchy to report this kind of lossy conversion.

WDYT?

Note: I used the same hierarchy number with BigDecimal because most of the time, both ways of these BigDecimal<->String conversions are not lossy.

Generated Code

No response

Possible workarounds

No response

MapStruct Version

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions