Skip to content

Commit 876e9bf

Browse files
committed
DefaultModuleService: change persisting of items
Disable the persisting of a ModuleItems if an initialize() method is set and is not empty. This way, initialize() can overwrite the value of a ModuleItem even if persist=true is assumed implicitly. See: * imagej/imagej-legacy#137 (comment)
1 parent eb2ca6f commit 876e9bf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/org/scijava/module/DefaultModuleService.java

+3
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ public ModuleItem<?> getSingleOutput(Module module, Collection<Class<?>> types)
291291
public <T> void save(final ModuleItem<T> item, final T value) {
292292
if (!item.isPersisted()) return;
293293

294+
// NB: Do not persist values which are computed via an initializer.
295+
if (item.getInitializer() != null && !item.getInitializer().isEmpty()) return;
296+
294297
if (MiscUtils.equal(item.getDefaultValue(), value)) {
295298
// NB: Do not persist the value if it is the default.
296299
// This is nice if the default value might change later,

0 commit comments

Comments
 (0)