jersey
  1. jersey
  2. JERSEY-1295

Response#bufferEntity does not throw MessageProcessingException - if there was an error while buffering the entity input stream.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-m06
    • Fix Version/s: 2.0-m07, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      The Response#bufferEntity javadoc says:
      throws
      MessageProcessingException - if there was an error while buffering the entity input stream.
      but having a resource

      @Path("response")
      public class Resource {
      	public static final String ENTITY = "ENtiTy";
      	@GET
      	@Path("corrupted")
      	public CorruptedInputStream corrupted(){
      		return new CorruptedInputStream(ENTITY.getBytes());
      	}
      }
      
      public class CorruptedInputStream extends ByteArrayInputStream {
      	private boolean corrupted = false;
      	public CorruptedInputStream(byte[] buf) {
      		super(buf);
      	}
      	@Override
      	public void close() throws IOException {
      		if (corrupted)
      			throw new IOException("CorruptedInputStream test IOException");
      		else
      			super.close();
      	}
      	public boolean isCorrupted() {
      		return corrupted;
      	}
      	public void setCorrupted(boolean corrupted) {
      		this.corrupted = corrupted;
      	}
      }
      

      and client

      		ClientResponseFilter filter = new ClientResponseFilter() {
      			@Override
      			public void filter(ClientRequestContext arg0,
      					ClientResponseContext response) throws IOException {
      				CorruptedInputStream cis = new CorruptedInputStream(Resource.ENTITY.getBytes());
      				cis.setCorrupted(true);
      				response.setEntityStream(cis);
      			}
      		};
      
      
      Client client = ClientFactory.newClient();
      client.configuration().register(filter);
      WebTarget target = client.target(responseurl);
      Response response = target.request().buildGet().invoke();
      response.bufferEntity();
      

      throws

      19.7.2012 18:38:18 org.glassfish.jersey.message.internal.InboundMessageContext$ContentStream invalidateContentStream
      SEVERE: Error closing message content input stream.
      java.io.IOException: CorruptedInputStream test IOException
      at CorruptedInputStream.close(CorruptedInputStream.java:23)
      at org.glassfish.jersey.message.internal.InboundMessageContext$ContentStream.invalidateContentStream(InboundMessageContext.java:151)
      at org.glassfish.jersey.message.internal.InboundMessageContext.bufferEntity(InboundMessageContext.java:934)
      at org.glassfish.jersey.client.InboundJaxrsResponse.bufferEntity(InboundJaxrsResponse.java:128)

      but no MessageProcessingException

        Activity

        Hide
        jan.supol added a comment -

        Actually, it doesn't throw it, it just writes it down. There would be something like catch (Exception e)

        {e.printstackTrace();}

        instead of throw new MessageprocessingException(e);

        Show
        jan.supol added a comment - Actually, it doesn't throw it, it just writes it down. There would be something like catch (Exception e) {e.printstackTrace();} instead of throw new MessageprocessingException(e);

          People

          • Assignee:
            Michal Gajdos
            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 - 0 minutes
              0m
              Logged:
              Time Spent - 1 hour Time Not Required
              1h