Bug #44588 Streaming result set error message never displayed
Submitted: 30 Apr 2009 21:33 Modified: 26 May 2009 10:47
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.7 OS:Any
Assigned to: Todd Farmer CPU Architecture:Any

[30 Apr 2009 21:33] Todd Farmer
Description:
There is logic to generate a message text specifically for streaming result sets when there are CommunicationsExceptions, but this is never reached:

In CommunicationsException:

	private boolean streamingResultSetInPlay = false;

	public CommunicationsException(ConnectionImpl conn, long lastPacketSentTimeMs,
			long lastPacketReceivedTimeMs, Exception underlyingException) {

		this.exceptionMessage = SQLError.createLinkFailureMessageBasedOnHeuristics(conn,
				lastPacketSentTimeMs, lastPacketReceivedTimeMs, underlyingException, this.streamingResultSetInPlay);

streamingResultSetInPlay is always false, which causes the following to never be executed in SQLError.createLinkFailureMessageBasedOnHeuristics():

		if (streamingResultSetInPlay) {
			exceptionMessageBuf.append(Messages
					.getString("CommunicationsException.ClientWasStreaming")); //$NON-NLS-1$
		} else {
...

How to repeat:
See code referenced above.

Suggested fix:
Defer message creation until CommunicationsException.getMessage().
[30 Apr 2009 23:29] Todd Farmer
Patched in r791.
[2 May 2009 23:19] Todd Farmer
Fixed for 5.1.8.
[26 May 2009 10:47] Tony Bedford
An entry was added to the 5.1.8 changelog:

Connector/J contains logic to generate a message text specifically for streaming result sets when there are CommunicationsException exceptions generated. However, this code was never reached.

In the CommunicationsException code:

private boolean streamingResultSetInPlay = false;

public CommunicationsException(ConnectionImpl conn, long lastPacketSentTimeMs,
long lastPacketReceivedTimeMs, Exception underlyingException) {

this.exceptionMessage = SQLError.createLinkFailureMessageBasedOnHeuristics(conn,
      lastPacketSentTimeMs, lastPacketReceivedTimeMs, underlyingException,
      this.streamingResultSetInPlay);

streamingResultSetInPlay was always false, which in the following code in SQLError.createLinkFailureMessageBasedOnHeuristics() never being executed:

if (streamingResultSetInPlay) {
    exceptionMessageBuf.append(
    Messages.getString("CommunicationsException.ClientWasStreaming")); //$NON-NLS-1$
} else {
...