https://bz.apache.org/bugzilla/show_bug.cgi?id=63182

            Bug ID: 63182
           Summary: Servlet 3.1 ReadListener got exception(sometime) when
                    invoking servletinputstream.read method, after isReady
                    returns true.
           Product: Tomcat 8
           Version: 8.5.38
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: xax...@gmail.com
  Target Milestone: ----

using the following code can reproduce the error, with large size post request.

ServletInputStream in = req.getInputStream();
                        in.setReadListener(new ReadListener() {

                                @Override
                                public void onError(Throwable t) {
                                        System.out.println("error: " + t);
                                        d.resolve(null);
                                }

                                int count = 0;

                                @Override
                                public void onDataAvailable() throws
IOException {
                                        System.out.println("onDataAvailable");
                                        int c = in.read(new byte[1024]);
                                        System.out.println("read: " + c);
                                        if (c > 0) {
                                                count += c;
                                               
System.out.println("\t\t\t\ttotal: " + MessageFormat.format("{0,number,#,##0}",
count));
                                        }
                                        boolean ready = in.isReady();
                                        System.out.println("ready after: " +
ready);
                                        if (ready) {
                                                onDataAvailable();
                                        }
                                }

                                @Override
                                public void onAllDataRead() throws IOException
{
                                        System.out.println("all read");
                                        d.resolve(null);
                                }
                        });

Console output sample:
...
...
ready after: true
onDataAvailable
read: 1024
                                total: 21,050,368
ready after: true
onDataAvailable
read: 1024
2019-02-16 23:27:09,654 ERROR com.webclient.web.LoginForm$3$1.run:444 -
java.lang.IllegalStateException: In non-blocking mode you may not read from the
ServletInputStream until the previous read has completed and isReady() returns
true
java.lang.IllegalStateException: In non-blocking mode you may not read from the
ServletInputStream until the previous read has completed and isReady() returns
true
        at
org.apache.catalina.connector.CoyoteInputStream.checkNonBlockingRead(CoyoteInputStream.java:287)
        at
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:128)

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to