-
Notifications
You must be signed in to change notification settings - Fork 369
Description
The default implementation of InputStream.readAllBytes() always creates a new byte[]. By relying on the default implementation, EntityInputStream always reflects this default behavior, instead of reflecting the behavior of the wrapped stream.
An application that wants to make the request body readable more than once can call request.setEntityStream(new MyInputStreamWrapper(request.getEntityStream())) in a ContainerRequestFilter. If the application also wants to avoid creating multiple copies of the request body, MyInputStreamWrapper.readAllBytes() can return the original underlying byte[].
However, resource handlers receive an EntityInputStream wrapping the MyInputStreamWrapper, and a call to EntityInputStream.readAllBytes() will create an unwanted copy of the byte[], since EntityInputStream.readAllBytes() does not call MyInputStreamWrapper.readAllBytes().