Repository navigation
Use constructor injection for @ConfigProperty and qualified fields - #74
Merged
Merged
Conversation
Lombok copies `@ConfigProperty` and `@Readiness` to the generated constructor, so the fields can be `private final`. Quarkus never injects into a final field, so the IDE warning about private CDI members does not apply to them. Assisted-by: Claude:claude-opus-5-5
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checkstyle failed on
PasswordFingerprintService.secretName, because a@ConfigPropertyfield must be package-private for Quarkus field injection, andVisibilityModifierrejects a non-private field. This PR moves every@ConfigPropertyand qualified@Injectfield to constructor injection with@RequiredArgsConstructor.lombok.config: Lombok copies@ConfigPropertyand@Readinessto the parameter of the generated constructor. Without this, the constructor parameter has no qualifier and Quarkus injects the wrong value or fails.PasswordFingerprintService,Given,ClusterConnectionReconcilerTest: the@ConfigPropertyfields are nowprivate final. The@SuppressWarnings("NullAway.Init")on them is gone, because the constructor sets them.PostgreSQLInstanceReadinessCheckTest,ClusterConnectionReconcilerErrorTest:@Injectfields replaced withprivate finalfields.@InjectMockstays a field, because Quarkus supports it on fields only.PasswordFingerprintServiceTest: passes the Secret name to the constructor instead of setting the field.IntelliJ warning "Private access modifier usage is not recommended for Quarkus CDI members"
IntelliJ shows this warning on the
private final@ConfigPropertyfields. It is a false positive:AutoInjectFieldProcessor, which adds the implicit@Injectto a field with a qualifier, skips final fields. ArC also ignores@Injecton a final field. The code is the same in Quarkus 3.35.3, 3.40.1, andmain.Tests
checkstyleMainandcheckstyleTestpass. The 48 tests ofPasswordFingerprintServiceTest,PostgreSQLInstanceReadinessCheckTest,ClusterConnectionReconcilerTest,ClusterConnectionReconcilerErrorTest, andRoleReconcilerTest(which usesGiven) pass. I did not run the full suite locally.