-
Notifications
You must be signed in to change notification settings - Fork 32
Extend MicroProfileConfig default-value validation #510
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
Open
E14
wants to merge
3
commits into
eclipse-lsp4mp:master
Choose a base branch
from
E14:default-values-no-fail-on-unsupported-types
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+144
−26
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...st/projects/maven/microprofile-configproperties/src/main/java/org/acme/DefaultValues.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package org.acme; | ||
|
|
||
| import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
| import java.util.Optional; | ||
|
|
||
| public class DefaultValuesValidation { | ||
| @ConfigProperty(defaultValue = "a string") | ||
| public String string; | ||
|
|
||
| @ConfigProperty(defaultValue = "yes") | ||
| public boolean bool; | ||
|
|
||
| @ConfigProperty(defaultValue = "4") | ||
| public int integer; | ||
|
|
||
| @ConfigProperty(defaultValue = "x") | ||
| public int invalidInteger; | ||
|
|
||
| @ConfigProperty(defaultValue = "a string") | ||
| public Custom custom; | ||
|
|
||
| @ConfigProperty(defaultValue = "/foo/bar") | ||
| public java.nio.file.Path path; | ||
|
|
||
| @ConfigProperty(defaultValue = "http://localhost/bar") | ||
| public java.net.URI uri; | ||
|
|
||
| @ConfigProperty(defaultValue = "2000-12-31T01:23:45Z") | ||
| public java.time.Instant instant; | ||
|
|
||
| @ConfigProperty(defaultValue = "PT2S") | ||
| public java.time.Duration duration; | ||
|
|
||
| @ConfigProperty(defaultValue = "boo") | ||
| public boolean boolUnexpectedFalse; | ||
|
|
||
| /** | ||
| * This type has a public Constructor with a single String parameter and as such | ||
| * represents a valid implicit converter as per Microprofile-Config | ||
| * specification (See {@link org.eclipse.microprofile.config.spi.Converter}). | ||
| */ | ||
| public static class Custom { | ||
| private final String value; | ||
|
|
||
| public Custom(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test (and others that are built similar) is unstable for me (and it seems gh CI) - sometimes it doesn't report any diagnostics.
I'm assuming there is issue resulting from an async result taking just a tiny bit too long, I don't know how to avoid it other than changing the assertion helper method to use busy waiting like awaitility does. That would however only work reliably with at least one diagnostic, and also cause higher CPU load during tests (tests are already being aborted by CI due to taking too long)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I dug a bit (a lot) deeper into this issue yesterday, and it seems it cannot be resolved by retrying.
I was able to narrow it down to "somewhere before"
MicroProfileConfigASTValidator#isAdaptedForDiagnostics, because when this method returns false (meaning whenJDTTypeUtils.findType(javaProject, CONFIG_PROPERTY_ANNOTATION)returnsnull), it will always do so for the test run. This leads me to believe it's related to project loading (but the project data seems fine)At that point, I'm out - I hope you can agree that this is well out of scope for this PR and stability issues of the test have nothing to do with my changes.