Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5302

Validate heartbeatFrequency in ServerSettings

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.11.0
    • Component/s: Configuration
    • Labels:
      None
    • Java Drivers

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            slav.babanin@mongodb.com Slav Babanin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: