Skip to content

Commit d2420bc

Browse files
committed
Delegate exception during notifyListener()
And fix a screw-up of mine for row push. Signed-off-by: Squareys <squareys@googlemail.com>
1 parent 71e1053 commit d2420bc

3 files changed

Lines changed: 22 additions & 21 deletions

File tree

org.knime.scijava.commands/src/org/knime/scijava/commands/MultiOutputListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface MultiOutputListener {
1010

1111
/**
1212
* Notify this listener that a new output row has been pushed.
13+
* @throws Exception
1314
*/
14-
public void notifyListener();
15+
public void notifyListener() throws Exception;
1516
}

org.knime.scijava.commands/src/org/knime/scijava/commands/SciJavaTestCommand.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ public class SciJavaTestCommand implements Command {
2828

2929
@Override
3030
public void run() {
31-
for (int i = 0; i < fromInt; i++) {
32-
outInt = i;
33-
rowOutput.notifyListener();
31+
try {
32+
for (int i = 0; i < fromInt; i++) {
33+
outInt = i;
34+
rowOutput.notifyListener();
35+
}
36+
} catch (final Exception e) {
37+
throw new RuntimeException(e);
3438
}
3539
}
3640
}

org.knime.scijava.commands/src/org/knime/scijava/commands/module/DefaultNodeModule.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,21 @@ public NodeModuleOutputChangedListener(final boolean manualPush) {
172172
}
173173

174174
@Override
175-
public void notifyListener() {
176-
try {
177-
// output can be null if sink node
178-
if (output != null) {
179-
final List<DataCell> cells = new ArrayList<DataCell>();
180-
181-
final ModuleItem<?> result = module.getInfo()
182-
.getOutput("result");
183-
if (result != null) {
184-
// FIXME hack because e.g. python script contains
185-
// result log
175+
public void notifyListener() throws Exception {
176+
// output can be null if sink node
177+
if (output != null) {
178+
final List<DataCell> cells = new ArrayList<DataCell>();
179+
for (final ModuleItem<?> entry : module.getInfo().outputs()) {
180+
// FIXME hack because e.g. python script contains
181+
// result log
182+
if (!entry.getName().equals("result")) {
186183
cells.add(cs.convertToKnime(
187-
module.getOutput(result.getName()),
188-
result.getType(), outputMapping.get(result),
184+
module.getOutput(entry.getName()),
185+
entry.getType(), outputMapping.get(entry),
189186
ctx));
190187
}
191-
output.push(cells.toArray(new DataCell[cells.size()]));
192188
}
193-
} catch (final Exception e) {
194-
logService.error("Unable to push output row.", e);
189+
output.push(cells.toArray(new DataCell[cells.size()]));
195190
}
196191
}
197192

@@ -218,8 +213,9 @@ public void setCellOutput(final CellOutput output) {
218213
/**
219214
* Final flush. Will push a row in case module does not handle pushing
220215
* output rows.
216+
* @throws Exception
221217
*/
222-
public void flush() {
218+
public void flush() throws Exception {
223219
if (!manualPush) {
224220
notifyListener();
225221
}

0 commit comments

Comments
 (0)