This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 8bb9dfccb Return null for out-of-range offset in
FastTimeZone.getGmtTimeZone (#1788).
8bb9dfccb is described below
commit 8bb9dfccb46b06b9c721e48fe8cece893c8c2918
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Sep 12 08:06:57 2026 -0700
Return null for out-of-range offset in FastTimeZone.getGmtTimeZone
(#1788).
Parameterize test and add invalid inputs.
---
src/changes/changes.xml | 1 +
.../apache/commons/lang3/time/FastTimeZoneTest.java | 20 ++++++++++----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a6770692a..3801cfd96 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -283,6 +283,7 @@ java.lang.NullPointerException: Cannot invoke
<action type="fix" dev="ggregory" due-to="Jeff Lenamon,
Gary Gregory">Fix Fraction.add and subtract for operands not in lowest terms
(#1784).</action>
<action type="fix" dev="ggregory" due-to="Jeff Lenamon,
Gary Gregory">Fix MethodUtils.invokeMethod on instances of non-public classes
(#1783).</action>
<action type="fix" dev="ggregory" due-to="Jeff Lenamon,
Gary Gregory">Fraction.add and subtract return the reduced form when an operand
is zero (#1787).</action>
+ <action type="fix" dev="ggregory" due-to="alhuda, Gary
Gregory">Return null for out-of-range offset in FastTimeZone.getGmtTimeZone
(#1788).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add JavaVersion.JAVA_27.</action>
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add SystemUtils.IS_JAVA_27.</action>
diff --git a/src/test/java/org/apache/commons/lang3/time/FastTimeZoneTest.java
b/src/test/java/org/apache/commons/lang3/time/FastTimeZoneTest.java
index 960c8ebcd..ee2f8f585 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastTimeZoneTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastTimeZoneTest.java
@@ -30,6 +30,8 @@
import org.apache.commons.lang3.AbstractLangTest;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
/**
* Tests {@link FastTimeZone}.
@@ -117,16 +119,14 @@ void testOlson() {
assertEquals(TimeZones.getTimeZone("America/New_York"),
FastTimeZone.getTimeZone("America/New_York"));
}
- @Test
- void testOutOfRangeOffsetReturnsNull() {
- // A pattern that matches the regex but whose hours or minutes are out
of range is not a valid GMT id.
- // Before the fix these threw IllegalArgumentException from the
GmtTimeZone constructor.
- assertNull(FastTimeZone.getGmtTimeZone("GMT+24"));
- assertNull(FastTimeZone.getGmtTimeZone("+24"));
- assertNull(FastTimeZone.getGmtTimeZone("-24"));
- assertNull(FastTimeZone.getGmtTimeZone("+99"));
- assertNull(FastTimeZone.getGmtTimeZone("+12:60"));
- assertNull(FastTimeZone.getGmtTimeZone("00:99"));
+ /**
+ * A pattern that matches the regex but whose hours or minutes are out of
range is not a valid GMT id. Before the fix these threw IllegalArgumentException
+ * from the GmtTimeZone constructor.
+ */
+ @ParameterizedTest
+ @ValueSource(strings = { "GMT+24", "+24", "-24", "+99", "+12:60", "00:99",
"99:99" , "0099", "9999" })
+ void testOutOfRangeOffsetReturnsNull(final String pattern) {
+ assertNull(FastTimeZone.getGmtTimeZone(pattern));
}
@Test