Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JsonNaming and JsonProperty for BeanIntrospectionModule #7139

Merged
merged 5 commits into from
Mar 30, 2022

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Mar 24, 2022

Support for JsonNaming was missing (same for the property-naming-strategy config property), and support for JsonProperty was spotty. This implements both.
Also removed some old code that special-cased the property names for Resource. Not needed anymore since #6254

Fixes #6904
Fixes #6665
Fixes #7129
Fixes micronaut-security/#946

Support for JsonNaming was missing (same for the `property-naming-strategy` config property), and support for JsonProperty was spotty. This implements support for both.
Also removed some old code that special-cased the property names for `Resource`. Not needed anymore since #6254

Fixes #6904
Fixes #6665
Fixes #7129
Fixes micronaut-security/#946
@yawkat yawkat requested review from graemerocher and sdelamo March 24, 2022 10:59
Comment on lines 238 to 246
if (clazz.isPresent()) {
try {
Constructor<?> emptyConstructor = clazz.get().getConstructor();
return (PropertyNamingStrategy) emptyConstructor.newInstance();
} catch (NoSuchMethodException ignored) {
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to construct configured PropertyNamingStrategy", e);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use InstantiationUtils.tryInstantiate for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i want to distinguish between constructor failure (-> error) and no constructor being present (-> default behavior)

@yawkat
Copy link
Member Author

yawkat commented Mar 24, 2022

the sonar failure is because the graal feature cant be tested

@graemerocher graemerocher added this to the 3.4.1 milestone Mar 24, 2022
} catch (NoSuchMethodException ignored) {
return mapperConfig.getPropertyNamingStrategy();
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to construct configured PropertyNamingStrategy", e);
Copy link
Contributor

@sdelamo sdelamo Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have addressed two sonar issues. The one remaning is that it is telling us to use a less generic exception.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

76.7% 76.7% Coverage
0.0% 0.0% Duplication

@sdelamo sdelamo merged commit a47efb4 into 3.4.x Mar 30, 2022
@sdelamo sdelamo deleted the property-naming branch March 30, 2022 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants