change switch to jdk-17
@@ -64,22 +64,20 @@ public class ConfigReloadAutoConfiguration {
public ConfigurationUpdateStrategy configurationUpdateStrategy(ConfigReloadProperties properties,
ConfigurableApplicationContext ctx, Optional<RestartEndpoint> restarter, ContextRefresher refresher) {
String strategyName = properties.getStrategy().name();
- switch (properties.getStrategy()) {
- case RESTART_CONTEXT:
+ return switch (properties.getStrategy()) {
+ case RESTART_CONTEXT -> {
restarter.orElseThrow(() -> new AssertionError("Restart endpoint is not enabled"));
- return new ConfigurationUpdateStrategy(strategyName, () -> {
+ yield new ConfigurationUpdateStrategy(strategyName, () -> {
wait(properties);
restarter.get().restart();
});
- case REFRESH:
- return new ConfigurationUpdateStrategy(strategyName, refresher::refresh);
- case SHUTDOWN:
- return new ConfigurationUpdateStrategy(strategyName, () -> {
+ }
+ case REFRESH -> new ConfigurationUpdateStrategy(strategyName, refresher::refresh);
+ case SHUTDOWN -> new ConfigurationUpdateStrategy(strategyName, () -> {
wait(properties);
ctx.close();
});
- }
- throw new IllegalStateException("Unsupported configuration update strategy: " + strategyName);
+ };
}
private static void wait(ConfigReloadProperties properties) {
