[JAVA-5302] Validate heartbeatFrequency in ServerSettings Created: 29/Jan/24  Updated: 29/Jan/24

Status: Backlog
Project: Java Driver
Component/s: Configuration
Affects Version/s: 4.11.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Slav Babanin Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Java Drivers

 Description   

The DefaultServerMonitor fails with an ArithmeticException due to Math.toIntExact(serverSettings.getHeartbeatFrequency(MILLISECONDS)) exceeding integer limits. This is caused by missing validation in ServerSettings for heartbeatFrequency, allowing inputs higher than Integer.MAX_VALUE and preventing DefaultServerMonitor from sending a hello command.

Proposed Changes:

  1. Implement integer validation in ServerSettings#heartbeatFrequency to check for values not exceeding Integer.MAX_VALUE similarly to SocketSettings.java#L288. 
  2. Update the Javadoc for heartbeatFrequency to clearly state the integer value limitation, aligning with the documentation style in SocketSettings#readTimeout and connectTimeout.

Acceptance Criteria:

  1. heartbeatFrequency in ServerSettings validates values to ensure they do not exceed Integer.MAX_VALUE.
  2. The updated Javadoc accurately reflects the integer value limitation.
  3. A test case confirms that an error is thrown when a long value exceeding Integer.MAX_VALUE is used.

Generated at Thu Feb 08 09:04:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.