Skip to content

Commit

Permalink
[java] Enhance Null Check in Exception Handling (SeleniumHQ#14810)
Browse files Browse the repository at this point in the history
  • Loading branch information
iampopovich authored Dec 4, 2024
1 parent 966bed6 commit 454ae25
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions java/src/org/openqa/selenium/internal/Require.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ public static int positive(String argName, Integer number, String message) {
throw new IllegalArgumentException(String.format(MUST_BE_SET, argName));
}
if (number <= 0) {
if (message == null) {
throw new IllegalArgumentException(String.format(MUST_BE_POSITIVE, argName));
} else {
throw new IllegalArgumentException(message);
}
throw new IllegalArgumentException(
Objects.requireNonNullElseGet(message, () -> String.format(MUST_BE_POSITIVE, argName)));
}
return number;
}
Expand All @@ -143,11 +140,8 @@ public static double positive(String argName, Double number, String message) {
throw new IllegalArgumentException(String.format(MUST_BE_SET, argName));
}
if (number <= 0) {
if (message == null) {
throw new IllegalArgumentException(String.format(MUST_BE_POSITIVE, argName));
} else {
throw new IllegalArgumentException(message);
}
throw new IllegalArgumentException(
Objects.requireNonNullElseGet(message, () -> String.format(MUST_BE_POSITIVE, argName)));
}
return number;
}
Expand Down

0 comments on commit 454ae25

Please sign in to comment.