Re: EOFException in Connector/j
Posted by: Mark Matthews
Date: January 03, 2005 03:27PM

Kris Younger wrote:
> Now, I'm not the clearest thinking guy on this,
> but should the block above:
> if (count < 0) {
> throw new EOFException();
> }
> be something else - as in, doesn't count < 0
> mean EOF as a standard matter of course??
> that there is nothing to read any more and you
> should return with 'n' set at whatever number of
> bytes have been read?


No, it is not correct to return in this case, because the caller of readFully() expects that you can either return all of the bytes asked for, or it's an error. If a read() from the underlying stream returns -1, that means the stream was closed...If the stream was closed before all the bytes requested were read, that's an error as far as the caller of readFully() is concerened.

Are you sure your server isn't restarting/clobbering connections when this happens? Whenever I've had a user chase this down the cause has been one of five things:

1) wait_timeout (which you say isn't the issue)
2) flaky network
3) bad values for various server-side timeout variables (net_read_timeout and friends)
4) Bad MySQL build that crashes...usually a non-official-MySQL-AB binary

and very infrequently

5) A server bug, where a given query was actually crashing the server


> and not throw a new Nested Exception?
> will return -1 at EOF, otherwise the number of
> bytes, but what if it returns 0? isn't that a real
> exception.... on another tack, how about if it did
> an "count = in.available();" call and only read
> that number of bytes... (read without
> blocking...)

.available() isn't guaranteed to work on all input streams, and it's return value is time-sensitive. Since JDBC itself is a blocking API, there is no reason to implement it in a non-blocking way.

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

Options: ReplyQuote

Written By
January 03, 2005 01:31PM
Re: EOFException in Connector/j
January 03, 2005 03:27PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.