Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-18956

StreamTask.invoke should catch Throwable instead of Exception

    XMLWordPrintableJSON

    Details

      Description

      In StreamTask.invoke, we should catch Throwable. Otherwise, cleanUpInvoke() will not be called if Error is thrown:

      	@Override
      	public final void invoke() throws Exception {
      		try {
      			beforeInvoke();
      
      			// final check to exit early before starting to run
      			if (canceled) {
      				throw new CancelTaskException();
      			}
      
      			// let the task do its work
      			runMailboxLoop();
      
      			// if this left the run() method cleanly despite the fact that this was canceled,
      			// make sure the "clean shutdown" is not attempted
      			if (canceled) {
      				throw new CancelTaskException();
      			}
      
      			afterInvoke();
      		}
      		catch (Exception invokeException) {
      			failing = !canceled;
      			try {
      				cleanUpInvoke();
      			}
      			// TODO: investigate why Throwable instead of Exception is used here.
      			catch (Throwable cleanUpException) {
      				Throwable throwable = ExceptionUtils.firstOrSuppressed(cleanUpException, invokeException);
      				throw (throwable instanceof Exception ? (Exception) throwable : new Exception(throwable));
      			}
      			throw invokeException;
      		}
      		cleanUpInvoke();
      	}
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dian.fu Dian Fu
                Reporter:
                dian.fu Dian Fu
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: