java - Usage of AsyncListener#onError -


I do not understand when the AsyncListener # onError method is called. Javadoc does not help:

This informs AsyncListener that an asynchronous operation has failed to complete.

How could this fail? How can I regenerate this error?

Update:

  // in the HTTPSortlet doGet method asyncContext asyncContext = req.startAsync (); AsyncContext.addListener (New AsyncListener () {// Some Code Override Error on Public Zero (AsyncEvent Event) {// When Is It Called?}}); ExecuteInSomeOtherThread (asyncContext);  

What do I need to do in the other thread to fend off this asynchronous operation?

They are generally throbbles which cause an unreliable cause of I / O failures due to java Enhance .io.IOException. Due to a logical error due to mismatch between the client and the server, the exception of the connection or protocol level.

When called on the phone, you can get throwsheet:

  event.getThrowable ();  

To address the follow-up questions of MJGard

Forget about the Async contact for each other, consider the following class: / P> The public class executes myRunnableClass Runnable {Private listener; mListener; Interface listener {error at zero (throttle error); } Public Zero Set Listener {listen to listener} {mListener = listener; } @ Override Public Wide Run () {// Some important code can be executed / shows here / exception was caught in an attempt / grip / end / block which was performing an I / O operation. Some arrows = new IoExation (); If (mListener! = Null) {mListener.onError (someError); }}}

Is it even more evident how the on-line method of the listeners will be implemented because the exception was raised when the method of running MyRunnableClass was implemented?

  MyRunnableClass mrc = New MyRunnableClass (); Mrc.setListener (New Audience) {@Override Error on Public Zero (Throttle Error) {}}); Executor EnslinglingTabrade Scheduled Exeter (). Schedule (MRC, 1000 L, Time United States. MILILXNDNS);  

How does this place an AsyncContext listener and it indicates that if he has to face an exception, then it is no different that he wants to report to the listener. How the run method is implemented, it is actually secondary to the fact that the master who executes the code is also the one who reflects the context of the listener.


Comments