-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Property Placeholder No Longer Resolves to Null for Nullable Arguments When Environment Variable Does Not Exist #10797
Comments
you actually shouldn't need the nullable annotation |
I just tried it without the nullable annotation. It still throws an exception: |
Looking through the code and change history, I've narrowed down the change that has caused the issue. In #9701, @dstepanov removed a try-catch statement in the Now, since the I propose we reintroduce this try-catch statement to preserve original behavior. |
I should have added this before, but here's the relevant stack-trace for my bug:
|
In another note, the |
Submitted PR #10798 for review. |
…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
…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
Expected Behavior
Property placeholders should resolve to null when they are not specified by an environment variable.
Summary
Given a Bean Factory, a
@Nullable
argument that retrieves its value from a property via the@Value
annotation, and this value is expected to be resolved through the environment property source, Micronaut will now throw an exception stating that it could not resolve the placeholder.Example
Configuration File
Assume the
SOME_OPTIONAL_VALUE_PLACEHOLDER
environment variable has not been set.Factory Class
Actual Behaviour
An exception is thrown stating that the placeholder could not be resolved.
Steps To Reproduce
@Singleton
annotation and a nullable argument that has the@Nullable
and@Value
annotationsEnvironment Information
OS: Pop!_OS 22.04 LTS
Java Version:
Micronaut Dependencies and Versions:
gradle.properties
gradle.build
It should be noted that this bug does not present itself in micronaut versions:
With the remaining dependencies held the same.
Example Application
No response
Version
4.4.6
The text was updated successfully, but these errors were encountered: