fix: make URLToStringConversion generate URI.create(String).toURL() instead of new URL(String) - #4044
Conversation
…)` instead of `new URL(String)`
|
@yvasyliev In general, I agree that We'll discuss internally whether to include this change in the upcoming release. |
|
@hduelme I think that it is actually fine to do this. If using the constructor is not the recommended way of creating URLs then we should not stand in the way. We should only mention this in our release notes.
People will always have the option of writing their own mapping if they want to keep this behaviour
That's completely fine @hduelme. People should not be relying on how we generate the code for their expressions. We also have So I would say that we should go ahead and merge this |
This pull request refactors the handling of URL conversions in the codebase, standardizing the approach by using
URI.create(...).toURL()instead of directnew URL(...)construction. This change affects both the internal conversion logic and the related tests, aiming for improved consistency and reliability in URL handling.Refactoring of URL Conversion Logic:
ConversionUtils.urlmethod and related imports ofjava.net.URLwere removed, and all references were updated to useURIand theConversionUtils.urimethod instead.URLToStringConversion.java, the conversion now constructs URLs usingURI.create(<SOURCE>).toURL()rather thannew URL(<SOURCE>). This also updates the import types fromURLtoURI.Test Adjustments for New Conversion Approach:
URLConversionTest.java, all usages ofnew URL(...)were replaced withURI.create(...).toURL()to match the new conversion logic."xxxxxx://mapstruct.org/") instead of arbitrary invalid strings, ensuring the tests accurately reflect the new conversion path.Closes #4041