Skip to content

Commit 04b4b19

Browse files
committed
Allow enabling auto reload without using dynamic config itself
1 parent 4ff3b48 commit 04b4b19

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

api/src/main/java/io/kafbat/ui/service/app/ConfigReloadService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.IOException;
88
import java.nio.file.ClosedWatchServiceException;
99
import java.nio.file.FileSystems;
10+
import java.nio.file.Files;
1011
import java.nio.file.Path;
1112
import java.nio.file.StandardWatchEventKinds;
1213
import java.nio.file.WatchEvent;
@@ -18,7 +19,7 @@
1819
import org.springframework.stereotype.Service;
1920

2021
@Service
21-
@ConditionalOnProperty(value = {"dynamic.config.enabled", "dynamic.config.autoreload"}, havingValue = "true")
22+
@ConditionalOnProperty(value = "dynamic.config.autoreload", havingValue = "true")
2223
@RequiredArgsConstructor
2324
@Slf4j
2425
public class ConfigReloadService {
@@ -35,6 +36,12 @@ public class ConfigReloadService {
3536

3637
@PostConstruct
3738
public void init() {
39+
var configPath = dynamicConfigOperations.dynamicConfigFilePath();
40+
if (!Files.exists(configPath) || !Files.isReadable(configPath)) {
41+
log.warn("Dynamic config file {} doesnt exist or is not readable. Auto reload is disabled", configPath);
42+
return;
43+
}
44+
3845
log.debug("Auto reload is enabled, will watch for config changes");
3946

4047
try {

api/src/main/java/io/kafbat/ui/util/DynamicConfigOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Optional<PropertySource<?>> loadDynamicPropertySource() {
7777
if (dynamicConfigEnabled()) {
7878
Path configPath = dynamicConfigFilePath();
7979
if (!Files.exists(configPath) || !Files.isReadable(configPath)) {
80-
log.warn("Dynamic config file {} doesnt exist or not readable", configPath);
80+
log.warn("Dynamic config file {} doesnt exist or is not readable", configPath);
8181
return Optional.empty();
8282
}
8383
var propertySource = new CompositePropertySource("dynamicProperties");

0 commit comments

Comments
 (0)