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

#10797 Re-add Try-Catch for ConfigurationExceptions To DefaultPropertyPlaceholderResolver #10798

Merged
merged 3 commits into from
May 8, 2024

Conversation

helios2k6
Copy link
Contributor

Summary

This PR fixes a regression that was introduced in PR #9701, which removed a try-catch statement within an implementation of the Segment::findValue() function.

The contract for this interface implies that no exception should be thrown from it, and indeed the default implementation directly catches ConfigurationExceptions and returns Optional.empty().

The regression manifests itself as an exception when trying to resolve property placeholders that are expected to be nullable, and thus are not present in the environment or any other property resolver.

Prior behavior simply returned a value of null for these missing and nullable placeholders, which is the expected behavior.

This PR restores this behavior.

@CLAassistant
Copy link

CLAassistant commented May 3, 2024

CLA assistant check
All committers have signed the CLA.

@graemerocher
Copy link
Contributor

Adding a test case that reproduces this codepath would be good

@helios2k6
Copy link
Contributor Author

I would, but I actually don't know Groovy. Is there any guidance on how to write unit tests for Micronaut?

@graemerocher
Copy link
Contributor

@helios2k6
Copy link
Contributor Author

Understood. Writing it now.

@helios2k6
Copy link
Contributor Author

@graemerocher PR + UTs are ready.

@graemerocher graemerocher added this to the 4.5.0 milestone May 7, 2024
@graemerocher graemerocher requested a review from sdelamo May 7, 2024 15:52
@sdelamo sdelamo merged commit 12fa3c3 into micronaut-projects:4.5.x May 8, 2024
12 checks passed
@sdelamo sdelamo added the type: regression A breaking change was introduced in a minor or patch release label May 8, 2024
sdelamo pushed a commit that referenced this pull request May 8, 2024
…laceholderResolver (#10798)

Fixes #10797 
* Adding try-catch for ConfigurationExceptions which are thrown when resolving env properties
* Adding test cases for placeholder resolution, both with and without the placeholder set
* Removing irrelevant print statement and method call to vehicle for the purposes of the specified unit tests
@helios2k6 helios2k6 deleted the issue-10797 branch May 8, 2024 13:19
sdelamo pushed a commit that referenced this pull request May 9, 2024
…laceholderResolver (#10798)

Fixes #10797 
* Adding try-catch for ConfigurationExceptions which are thrown when resolving env properties
* Adding test cases for placeholder resolution, both with and without the placeholder set
* Removing irrelevant print statement and method call to vehicle for the purposes of the specified unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A breaking change was introduced in a minor or patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants