-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Emanuel,

On 1/16/18 10:13 AM, Emanuel Hategan wrote:
> I'm running a tomcat 8.5.23 instance on ubuntu 16.04 (spring boot 
> application with embedded tomcat) configured with 2 connectors: 
> Http11NioProtocol and AjpNioProtocol. The AJP one is accessed
> through an apache2 instance configured with mod_jk.It all works
> well in the normal use case.
> 
> The application has code to look for the EOFExceptions during read
> e.g. the client aborts the request which works well with HTTP but
> not AJP. In my test I'm simulating this by closing the connection
> half way through (some headers have been sent but no body)
> 
> The problem I'm seeing is an inconsistent behaviour for 
> CoyoteInputStream.read() The HTTP connector throws an EOFException
> in this case while the AJP one just returns -1.
> 
> The relevant call stack is this at 
> org.apache.coyote.ajp.AjpProcessor.refillReadBuffer(AjpProcessor.java:
684)
>
> 
at
> org.apache.coyote.ajp.AjpProcessor$SocketInputBuffer.doRead(AjpProcess
or.java:1433)
>
> 
at org.apache.coyote.Request.doRead(Request.java:581)
> at 
> org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.ja
va:326)
>
> 
at
> org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuff
er.java:642)
>
> 
at
> org.apache.catalina.connector.InputBuffer.readByte(InputBuffer.java:33
7)
>
> 
at
> org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream
.java:93)
>
>  Now based on this old and unrelated thread 
> https://mail-archives.apache.org/mod_mbox/tomcat-users/201312.mbox/%3C
15ff6f04-b4c9-4d9b-b1b3-5c10ca955...@360works.com%3E
>
> 
I understand that the AJP connector is perfectly capable of raising an
> EOFException but it's just not doing that for me.
> 
> The documentation
> https://tomcat.apache.org/tomcat-8.0-doc/config/ajp.html does not
> suggest I need to do anything special.
> 
> I guess it's possible that this has something to do with the way
> apache2 talks to the AJP connector. Any help is appreciated.

Interesting.

If your servlet simply reads the InputStream like this, you don't get
an EOFException?

ServletInputStream in = request.getInputStream();
for(;;)
  in.read();

What part of the Servlet specification or Servlet API leads you to
believe that EOFException should be thrown when the request has been
completely read (or has been truncated, and no further data is available
)?

I don't see anything to suggest that such behavior is either required
or expected.

In fact, I'm surprised that the HTTP connector throws an EOFException
instead of simply returning -1 like the API says it should.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpeHIodHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFjbTxAAwai0iMmly2VgCpJN
2JwON09y1X42+5G+xf/EgVf8CXlCVLUUlJKhbnwG9bJ8sJU0gi2/Uepk+oaOq7PV
pPNNA1PJBkKIQf3y3LPEbA5qIn5g/ucq1J5bgP5fCLAw6tmlNbHTwChQwhXKMOl0
UH+ehSo2BMaO1wXalNBY1+W60ZkaXSkvlXhVOICP8cDE3MWftGh6vLxjRtPLHVvK
219+xdRF7Bp7LnMdfg6PvI0eFpODGHMmAAShAaxZkNLR9ltebOkjY1e/HPgfP8iK
26Svf32nJNciKVOTJUW6W8JhiJpxz82sbiCotnNVMPBt2NoJbOjBjESDQgY7kjqm
/oUoK8AE4a30BUv40ZPzGhBsoFhHCHkEeilNwVhFtK76wmyyqh364s4cRTCnAWke
QJ6BGFXTXENbOIhgJeCJBi4IkliXKlIoxJdSpqnnA6osdb/5sjgEmflLoZavMz22
rV1CdRM7JTRd/hw9DjqUAFm87xtz/eGe37B67UIUhLes/c8VTIg+TlU65R0COTu8
PwY4U6SOXu/hcgdmSJxZ+PVREC6t5hiR8stNyulCGED1W2t52LXdr/q442ihZhpV
oEUwcDbAx3Ue6qDJq8tVpU1k7D8/Bn3smIuKdIoKXHIT4olSmDM4xh73ZwaISBzv
5bWCtDWNX2jgb5jK2K352m19364=
=udZE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to