André Warnier wrote:
Jesse Barnum wrote:
On Dec 18, 2013, at 1:40 PM, André Warnier <a...@ice-sa.com> wrote:
Jesse Barnum wrote:
On Dec 18, 2013, at 12:27 PM, Jesse Barnum <jsb_tom...@360works.com>
wrote:
I'm seeing this error a lot in my log files. It happens when I am
trying to read from the request InputStream. Should I be concerned
about this, or is it just the equivalent of the user clicking
'stop' in their browser?
SEVERE: An error occurred while handling request
/WSMRegister/LicenseCheck/handshake
java.io.EOFException
Forgot to mention, I'm running version 7.0.35 on Ubuntu Linux on
Amazon EC2.
Well, it seems that you have the explanation right there.
If "com.prosc.licensecheck.LicenseCheck.doPost" is your code, then
that's where the problem is : you are trying to read from the request
input stream, when there is no more data to read and you have already
seen it's EOF.
Why there is no more data to read is another question, and it could
be that the client did something wrong. But the code in those
classes who do the read, obviously is not coping well with that case.
Yes, com.prosc.licensecheck.ListCheck.doPost is my code. It would not
be hard to catch the exception there and ignore it.
I guess another way to phrase the question is, "what would cause a
java.io.EOFException to get thrown?" I don't want to ignore it if it's
trying to tell me something important.
I am used to seeing "ClientAbortException: java.net.SocketException:
Broken pipe". Is the EOFException basically the same thing? My concern
is that there might be some misconfiguration between the Apache front
end and the Tomcat NIO connector that might be causing it.
First I will state that I am not a Java specialist, so take the
following with a grain of caution.
This being said, I believe that these two exceptions mean two different
things.
A "broken pipe" exception occurs when your program can legitimately
expect more data to be present on the stream being read, tries to read
it, and gets back an error because the stream, unexpectedly, does not
exist anymore (typically, because the other party supposed to write to
that stream has gone away without warning).
An EOF exception is different : you are reading from a stream. At some
point, the read() returns an EOF condition, indicating that no more data
is present. That's not an exception yet, it is a normal condition for
which you should be testing, and when it occurs you should stop reading.
(I do not remember precisely how your code should test for this in
Java. It may be that an EOF is indicated by the fact that the read()
returns 0 bytes. Or maybe you should test explicitly by means of
something like "if (stream.eof) then ..) after each read().
But you do NOT stop reading, and you do one more read() nevertheless.
/Then/ you get this exception, because now, you are trying to read
/past/ the end of the file/stream (EOF).
(It's like : you are approaching train-track crossing; you see the red
light, and you should stop; but you don't, and you proceed
nevertheless. The EOF exception is the train that happens to be passing
just then).
Note that it may not be directly your code per se which already reads
the request input-stream and already reaches the EOF. An earlier call
to HttpServletRequest.getParameters() for example, would trigger the
reading of the whole body of a POST request, to parse the POST
parameters, and would already leave the request input-stream at EOF,
before you even try your first explicit read().
Just adding something, to make the distinction clearer still:
These 2 exceptions are really different, in the sense that
- for the "broken pipe" exception, there is essentially nothing that your code can do
about it, other than catching the exception and trying to recover cleanly from it.
That the client writing to the socket that you are reading, would suddenly abort and go
away, is not something that you can control.
- for the EOFexception however, it indicates that you do something wrong in your logic.
You should not be trying to read from that stream anymore, because
- either you already got a warning that it was at EOF, and you just ignored it
- or else you are not properly testing for EOF while reading
In this case, just catching the exception and ignoring it is not really the right thing to
do. You should fix the logic that causes it to happen.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org