Skip to content

Commit 7998558

Browse files
committed
Use annotation for enabledByDefault if no config
1 parent 6dd7dbb commit 7998558

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

core/src/main/java/org/restheart/plugins/ProvidersChecker.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,21 @@ private static boolean enabled(PluginDescriptor plugin) {
101101

102102
// In native images, plugin.enabled() is forced to true at build time
103103
// to ensure all plugins are compiled into the image. At runtime we need
104-
// the real enabledByDefault value from the annotation.
105-
boolean enabledByDefault;
106-
try {
107-
var clazz = Class.forName(plugin.clazz());
108-
var regPlugin = clazz.getAnnotation(RegisterPlugin.class);
109-
enabledByDefault = regPlugin != null && regPlugin.enabledByDefault();
110-
} catch (ClassNotFoundException e) {
111-
enabledByDefault = plugin.enabled();
104+
// the real enabledByDefault value from the annotation when no config
105+
// override exists.
106+
boolean enabledByDefault = plugin.enabled();
107+
108+
if (pluginConf == null) {
109+
// No config entry — check the annotation for the real default
110+
try {
111+
var clazz = Class.forName(plugin.clazz());
112+
var regPlugin = clazz.getAnnotation(RegisterPlugin.class);
113+
if (regPlugin != null) {
114+
enabledByDefault = regPlugin.enabledByDefault();
115+
}
116+
} catch (ClassNotFoundException e) {
117+
// keep plugin.enabled()
118+
}
112119
}
113120

114121
return PluginRecord.isEnabled(enabledByDefault, pluginConf);

0 commit comments

Comments
 (0)