Skip to content

Commit aa8bbf4

Browse files
committed
Only warn about unmatched inputs in modules
We used to issue an error when the module service's run() method was called with inputs that are not specified explicitly in the corresponding ModuleInfo. That is fragile: should the implementing classes be modified and remove an input parameter, we should still do our best to continue. Therefore, let's just warn instead and continue, making the unmatched input available to the module and just skipping the conversion to an explicit type (because the info does not specify it). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 38ff1bb commit aa8bbf4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,20 @@ private void assignInputs(final Module module,
343343

344344
for (final String name : inputMap.keySet()) {
345345
final ModuleItem<?> input = module.getInfo().getInput(name);
346+
final Object value = inputMap.get(name);
347+
final Object converted;
346348
if (input == null) {
347-
log.error("No such input: " + name);
348-
continue;
349+
log.warn("Unmatched input: " + name);
350+
converted = value;
349351
}
350-
final Object value = inputMap.get(name);
351-
final Class<?> type = input.getType();
352-
final Object converted = ConversionUtils.convert(value, type);
353-
if (value != null && converted == null) {
354-
log.error("For input " + name + ": incompatible object " +
355-
value.getClass().getName() + " for type " + type.getName());
356-
continue;
352+
else {
353+
final Class<?> type = input.getType();
354+
converted = ConversionUtils.convert(value, type);
355+
if (value != null && converted == null) {
356+
log.error("For input " + name + ": incompatible object " +
357+
value.getClass().getName() + " for type " + type.getName());
358+
continue;
359+
}
357360
}
358361
module.setInput(name, converted);
359362
module.setResolved(name, true);

0 commit comments

Comments
 (0)