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

Validate heartbeatFrequency in ServerSettings

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • 4.11.0
    • Configuration
    • None
    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: