Endlessly running JavaSnippets can't be canceled


I made the experience, that JavaSnippets node sometimes can’t get canceled.

Easiest example is a Java Snippet with the following code


Cancelling this JavaSnippet with F9 or rightclick won’t work for me

1 Like

Hi @tbtt,
Typically a node will check if the user cancelled between processing of rows. That seems like reasonable behavior to me. The Java Snippet node probably shouldn’t (somehow) perform cancel checks while your code is in the middle of processing a given row. As a Java programmer you must take care to ensure your code can’t enter an endless loop.
Kind regards,

Why? I think that this is a cheap implementation but, according to me, this is a strange behaviour.
The endless loop is only a example but I could have a complex (non endless) row processing that take a lot of seconds for every row (or any row).
Why the tool doesn’t give to me a method to cancel operation during the row process? Why I have to wait the next row process to stop operations?

Perhaps the problem is that workflow doesn’t run in a new process…

I definitely can understand the implementation, but endless loops can always happen and having an endlessly running Node makes the complete workflow unusuable until you restart (atleast as far as I know), which shouldnt be possible in my opinion.

1 Like

Hi , I would need to delve into the source code to verify when/how cancel checks are made in the JS node (perhaps a KNIME developer could chime in). My concern would be that the snippet should be terminated in a safe, controlled manner. What if you were in the middle of writing to a file, for example?

But I think your concern is a valid one. It makes me wonder whether it would be feasible for KNIME to make the ExecutionContext#checkCanceled() method accessible within the snippet for long-running Java Snippets? Then the snippet writer could react to cancel events in a safe manner.

Hi folks - just chiming in to let you know we’re looking at this. Thanks @tbtt for the easily reproducible example. Once I know more I can followup up on this thread :slight_smile:

(Internal: AP-14266)


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.