Skip to content

Commit 692f489

Browse files
xeromankcoinone-xeromankkarenc-bq
authored
fix: MySQL host info type (#1423)
Co-authored-by: xeroman.k <xeroman.k@coinone.com> Co-authored-by: Karen <64801825+karenc-bq@users.noreply.github.com>
1 parent 3b84198 commit 692f489

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ protected HostSpec createHost(final ResultSet resultSet) throws SQLException {
435435
// should contain 4 columns: node ID, 1/0 (writer/reader), CPU utilization, node lag in time.
436436
String hostName = resultSet.getString(1);
437437
final boolean isWriter = resultSet.getBoolean(2);
438-
final float cpuUtilization = resultSet.getFloat(3);
439-
final float nodeLag = resultSet.getFloat(4);
438+
final double cpuUtilization = resultSet.getDouble(3);
439+
final double nodeLag = resultSet.getDouble(4);
440440
Timestamp lastUpdateTime;
441441
try {
442442
lastUpdateTime = resultSet.getTimestamp(5);

wrapper/src/test/java/software/amazon/jdbc/hostlistprovider/RdsHostListProviderTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,15 @@ void testGetTopology_StaleRecord() throws SQLException {
532532

533533
final String hostName1 = "hostName1";
534534
final String hostName2 = "hostName2";
535-
final Float cpuUtilization = 11.1F;
536-
final Float nodeLag = 0.123F;
535+
final Double cpuUtilization = 11.1D;
536+
final Double nodeLag = 0.123D;
537537
final Timestamp firstTimestamp = Timestamp.from(Instant.now());
538538
final Timestamp secondTimestamp = new Timestamp(firstTimestamp.getTime() + 100);
539539
when(mockResultSet.next()).thenReturn(true, true, false);
540540
when(mockResultSet.getString(1)).thenReturn(hostName1).thenReturn(hostName2);
541541
when(mockResultSet.getBoolean(2)).thenReturn(true).thenReturn(true);
542-
when(mockResultSet.getFloat(3)).thenReturn(cpuUtilization).thenReturn(cpuUtilization);
543-
when(mockResultSet.getFloat(4)).thenReturn(nodeLag).thenReturn(nodeLag);
542+
when(mockResultSet.getDouble(3)).thenReturn(cpuUtilization).thenReturn(cpuUtilization);
543+
when(mockResultSet.getDouble(4)).thenReturn(nodeLag).thenReturn(nodeLag);
544544
when(mockResultSet.getTimestamp(5)).thenReturn(firstTimestamp).thenReturn(secondTimestamp);
545545
long weight = Math.round(nodeLag) * 100L + Math.round(cpuUtilization);
546546
final HostSpec expectedWriter = new HostSpecBuilder(new SimpleHostAvailabilityStrategy())
@@ -565,13 +565,13 @@ void testGetTopology_InvalidLastUpdatedTimestamp() throws SQLException {
565565
rdsHostListProvider.isInitialized = true;
566566

567567
final String hostName = "hostName";
568-
final Float cpuUtilization = 11.1F;
569-
final Float nodeLag = 0.123F;
568+
final Double cpuUtilization = 11.1D;
569+
final Double nodeLag = 0.123D;
570570
when(mockResultSet.next()).thenReturn(true, false);
571571
when(mockResultSet.getString(1)).thenReturn(hostName);
572572
when(mockResultSet.getBoolean(2)).thenReturn(true);
573-
when(mockResultSet.getFloat(3)).thenReturn(cpuUtilization);
574-
when(mockResultSet.getFloat(4)).thenReturn(nodeLag);
573+
when(mockResultSet.getDouble(3)).thenReturn(cpuUtilization);
574+
when(mockResultSet.getDouble(4)).thenReturn(nodeLag);
575575
when(mockResultSet.getTimestamp(5)).thenThrow(WrongArgumentException.class);
576576

577577
final FetchTopologyResult result = rdsHostListProvider.getTopology(mockConnection, true);

0 commit comments

Comments
 (0)