dev@grizzly.java.net

Re: About handling ReadHandler's error in processing multipart

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Wed, 12 Feb 2014 17:52:33 -0800

Hi Bongjae,

I think it's a bug, CompletionHandler#failed has to be called.
Do you have time to submit a fix?

Thanks.

WBR,
Alexey.


On 11.02.14 18:44, Bongjae Chang wrote:
> Hi,
>
> When I tested multipart with http-multipart-samples sources, I met
> some strange behavior.
> I expected a failed notification of CompletionHandler if an error was
> occurred in processing multipart, but there was no signal in some case.
>
> As you know, a user should implement two interfaces in order to call
> MultipartScanner.scan() successfully.
> 1. MultipartEntryHandler
> 2. ReadHandler in MultipartEntryHandler
>
> If ReadHandler throws an exception in processing some works,
> ReadHandler#onError() will be called. But user’s
> CompletionHandler#failed() was not called.
>
> You can reproduce this with samples easily like this.
>
> In UploaderHttpHandler.java
> —
> private void readAndSaveAvail() throws IOException {
> while(inputStream.isReady()) {
> final int readBytes = inputStream.read(buf);
>
> // limit max size for uploading a file.
> final long currentBytes = uploadedBytesCounter.addAndGet(readBytes);
> if (currentBytes >= 1024 * 1000) {
> // throw exception for stopping upload
> throw new IOException(“maximum size exceeded”);
> }
> ...
> }
> }
>
> I would like to know this behavior is intended.
> (In other words, I would like to know if user should call
> CompletionHandler#failed directly in ReadHandler#onError.)
>
> Thanks!
>
> Regards,
> Bongjae Chang
>