protected void invokeCallback ( ICompletionListener listener , AbstractAsyncFuture future , Object userState ) { try { ExecutorService executorService = CHFWBundle . getExecutorService ( ) ; if ( null == executorService ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Unable to schedule callback, using this thread" ) ; } listener . futureCompleted ( future , userState ) ; } else { if ( null == this . myCallback ) { this . myCallback = new WorkCallback ( listener , userState ) ; } else { this . myCallback . myListener = listener ; this . myCallback . myState = userState ; } executorService . execute ( this . myCallback ) ; } } catch ( Throwable problem ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Error invoking callback, exception: " + problem + " : " + problem . getMessage ( ) ) ; } FFDCFilter . processException ( problem , getClass ( ) . getName ( ) + ".invokeCallback" , "182" , this ) ; } }
Runs a callback on the given listener safely . We cannot allow misbehaved application callback code to spoil the notification of subsequent listeners or other tidy - up work so the callbacks have to be tightly wrappered in an exception hander that ignores the error and continues with the next callback . This could lead to creative problems in the app code so callbacks must be written carefully .