jersey
  1. jersey
  2. JERSEY-1575

Canceling Resumed AsynResponse Throws IllegalStateException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-m09
    • Fix Version/s: 2.0-m13
    • Component/s: core
    • Labels:
      None

      Description

      javadoc of AsyncResponse#cancel() says:

      Invoking a cancel(...) method on an asynchronous response instance that has already been resumed has no effect and the method call is ignored.

      But when it is resumed and cancel is called:

      @Path("resource")
      public class Resource {
      	private static AsyncResponse lastResponse = null;
      
      	@GET
      	@Path("suspend")
      	public void suspend(@Suspended AsyncResponse asyncResponse) {
      		lastResponse = asyncResponse;
      	}
      
      	@GET
      	@Path("cancelvoid")
      	public void cancel(){
      		AsyncResponse response = lastResponse;
      		response.cancel();
      	}
      
      	@POST
      	@Path("resume")
      	public String resume(String response) {
      		AsyncResponse async = lastResponse;
      		async.resume(response);
      		return "RESUMED";
      	}
      }
      

      the following exception is thrown:

      java.lang.IllegalStateException: Not suspended
      at org.glassfish.jersey.server.ServerRuntime$AsyncResponder.cancel(ServerRuntime.java:684)
      at org.glassfish.jersey.server.ServerRuntime$AsyncResponder.cancel(ServerRuntime.java:644)

        Activity

        Hide
        jan.supol added a comment -

        Currently, it works

        Show
        jan.supol added a comment - Currently, it works

          People

          • Assignee:
            Unassigned
            Reporter:
            jan.supol
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 3 hours
              3h
              Remaining:
              Remaining Estimate - 3 hours
              3h
              Logged:
              Time Spent - Not Specified
              Not Specified