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 10:06:28 -0500

I'm thinking it should be like this:

    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 {
             sendError(500);
          }
       } catch (Throwable t) {
          log.error(t);
       } finally {
         connection.close();
       }
       callbacks.onComplete(t);
       return true;
    }


The Javadoc should change to say that the connection will be
completed/closed after resume() is finished. If there is an exception,
it will be handled according to the resource method rules. Unhandled
exceptions are turned into a 500, InternalServiceError response to the
client.

These methods return false if the connection has been closed or
completed already.

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