forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#30603 from mkouba/issue-30538
Log a warning when a deprecated extension config item is used
- Loading branch information
Showing
3 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
...yment/src/main/java/io/quarkus/deployment/steps/DeprecatedRuntimePropertiesBuildStep.java
This file contains 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,26 @@ | ||
package io.quarkus.deployment.steps; | ||
|
||
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; | ||
|
||
import java.util.Set; | ||
|
||
import io.quarkus.deployment.IsNormal; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.ConfigurationBuildItem; | ||
import io.quarkus.deployment.builditem.LaunchModeBuildItem; | ||
import io.quarkus.runtime.configuration.DeprecatedRuntimePropertiesRecorder; | ||
|
||
public class DeprecatedRuntimePropertiesBuildStep { | ||
|
||
@BuildStep(onlyIf = IsNormal.class) | ||
@Record(RUNTIME_INIT) | ||
void reportDeprecatedProperties(LaunchModeBuildItem launchMode, ConfigurationBuildItem configItem, | ||
DeprecatedRuntimePropertiesRecorder recorder) { | ||
Set<String> deprecatedProperties = configItem.getReadResult().getDeprecatedRuntimeProperties(); | ||
if (!deprecatedProperties.isEmpty()) { | ||
recorder.reportDeprecatedProperties(deprecatedProperties); | ||
} | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...e/src/main/java/io/quarkus/runtime/configuration/DeprecatedRuntimePropertiesRecorder.java
This file contains 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,24 @@ | ||
package io.quarkus.runtime.configuration; | ||
|
||
import java.util.Set; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.jboss.logging.Logger; | ||
|
||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class DeprecatedRuntimePropertiesRecorder { | ||
|
||
private static final Logger log = Logger.getLogger(DeprecatedRuntimePropertiesRecorder.class); | ||
|
||
public void reportDeprecatedProperties(Set<String> deprecatedRuntimeProperties) { | ||
Config config = ConfigProvider.getConfig(); | ||
for (String property : config.getPropertyNames()) { | ||
if (deprecatedRuntimeProperties.contains(property)) { | ||
log.warnf("The '%s' config property is deprecated and should not be used anymore", property); | ||
} | ||
} | ||
} | ||
} |