diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServices.java b/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServices.java index 38a508d02538c..3cbd66bbba4ac 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServices.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServices.java @@ -61,7 +61,7 @@ public StandaloneHaServices( checkNotNull(resourceManagerAddress, "resourceManagerAddress"); this.dispatcherAddress = checkNotNull(dispatcherAddress, "dispatcherAddress"); this.clusterRestEndpointAddress = - checkNotNull(clusterRestEndpointAddress, clusterRestEndpointAddress); + checkNotNull(clusterRestEndpointAddress, "clusterRestEndpointAddress"); } // ------------------------------------------------------------------------ diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServicesTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServicesTest.java index d31b763820a36..7749f2fe91a59 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServicesTest.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/standalone/StandaloneHaServicesTest.java @@ -30,6 +30,8 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -141,4 +143,36 @@ public void testJobMasterLeaderRetrieval() throws Exception { .notifyLeaderAddress( eq(jobManagerAddress2), eq(HighAvailabilityServices.DEFAULT_LEADER_ID)); } + + /** + * Tests that the constructor properly validates null parameters and provides meaningful error + * messages. + */ + @Test + public void testConstructorNullValidation() { + // Test null resourceManagerAddress + Exception exception = + assertThrows( + NullPointerException.class, + () -> new StandaloneHaServices(null, dispatcherAddress, webMonitorAddress)); + assertTrue(exception.getMessage().contains("resourceManagerAddress")); + + // Test null dispatcherAddress + exception = + assertThrows( + NullPointerException.class, + () -> + new StandaloneHaServices( + resourceManagerAddress, null, webMonitorAddress)); + assertTrue(exception.getMessage().contains("dispatcherAddress")); + + // Test null clusterRestEndpointAddress + exception = + assertThrows( + NullPointerException.class, + () -> + new StandaloneHaServices( + resourceManagerAddress, dispatcherAddress, null)); + assertTrue(exception.getMessage().contains("clusterRestEndpointAddress")); + } }