Bug #45419 C/J reports incorrect time since last packets

Submitted: 9 Jun 2009 23:35 Modified: 23 Jun 2009 10:25
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1-bzr OS:Any
Assigned to: Todd Farmer CPU Architecture:Any

[9 Jun 2009 23:35] Todd Farmer
Description:
While executing a test case for patch to bug#44587, it was noticed that the reported milliseconds since last server packets received/sent are off by 1000x.  Apparently this is done for ease of comparison, as these values are compared to server variables defined in seconds.

How to repeat:
SQLError.createLinkFailureMessageBasedOnHeuristics(
				(ConnectionImpl) this.conn, 
				System.currentTimeMillis() - 1000,
				System.currentTimeMillis() - 2000,
				e, 
				false);

returns a string which says:

"The last packet successfully received from the server was 2 milliseconds ago.The last packet sent successfully to the server was 1 milliseconds ago."

Suggested fix:
Create additional variables that hold the time since last packets in ms, in addition to the current ones that apparently store it in seconds:

		long timeSinceLastPacket = (System.currentTimeMillis() - lastPacketSentTimeMs) / 1000;
		long timeSinceLastPacketMs = (System.currentTimeMillis() - lastPacketSentTimeMs);
		long timeSinceLastPacketReceivedMs = (System.currentTimeMillis() - lastPacketReceivedTimeMs);
[10 Jun 2009 23:43] Todd Farmer
Fixed in r819.
[23 Jun 2009 10:25] Tony Bedford
An entry was added to the 5.1.8 changelog:

The reported milliseconds since the last server packets were received/sent was incorrect by a factor of 1000. For example, the following method call:

SQLError.createLinkFailureMessageBasedOnHeuristics(
(ConnectionImpl) this.conn, 
System.currentTimeMillis() - 1000,
System.currentTimeMillis() - 2000,
e, 
false);

returned the following string:

The last packet successfully received from the server 
was 2 milliseconds ago. The last packet sent successfully to the 
server was 1 milliseconds ago.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
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.