jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: resume(Throwable) question

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 05 Feb 2013 09:06:12 -0500

On 2/5/2013 8:48 AM, Bill Burke wrote:
>
>
> On 2/5/2013 8:37 AM, Bill Burke wrote:
>> Javadoc says for AsyncResponse.resume(Throwable)
>>
>> * For the provided throwable same rules apply as for an exception
>> thrown
>> * by a {_at_link javax.ws.rs.HttpMethod JAX-RS resource method}.
>> * The processing of the throwable by JAX-RS framework follows the
>> same path
>> * as it would for any exception thrown by a JAX-RS resource method.
>>
>>
>> So, if the Throwable is a WebApplicationException, or there is a mapper,
>> then resume can send a response. If neither of those conditions are
>> met, then return false?
>>
>
> ANother question is, shouldn't the connection be closed if there is an
> error while resuming or cancelling?

So, given this algorithm, what to do at the '?????':

    boolean resume(Object obj) {
       if (completed)return false;

       try {
          sendResponse(obj);
          connection.close();
          callbacks.onComplete(null);
       } catch (Throwable t) {
          return resume(t);
       }
       return true;
    }

    boolean resume(Throwable t) {
       if (completed)return false;

       try {
          if (mappable(t)) {
              mapException(t);
          } else {
              ??????
          }
          callbacks.onComplete(t);
       } catch (Throwable t) {
          ??????
       } finally {
         connection.close();
       }
    }





-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com