Skip to content

Commit a45c1f4

Browse files
authored
Make FieldKey.fromFieldKey return null for invalid input (#2524)
1 parent d45efd2 commit a45c1f4

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/org/labkey/test/params/FieldKey.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.apache.commons.lang3.StringUtils;
44
import org.jetbrains.annotations.NotNull;
5+
import org.jetbrains.annotations.Nullable;
56

67
import java.util.ArrayList;
78
import java.util.Arrays;
@@ -65,15 +66,22 @@ public static FieldKey fromParts(String... parts)
6566
* @param fieldKey String or FieldKey
6667
* @return FieldKey representation of the String, or the identity if a FieldKey was provided
6768
*/
68-
public static FieldKey fromFieldKey(CharSequence fieldKey)
69+
public static @Nullable FieldKey fromFieldKey(CharSequence fieldKey)
6970
{
7071
if (fieldKey instanceof WrapsFieldKey fk)
7172
{
7273
return fk.getFieldKey();
7374
}
7475
else
7576
{
76-
return fromParts(Arrays.stream(fieldKey.toString().split(SEPARATOR)).map(FieldKey::decodePart).toList());
77+
try
78+
{
79+
return fromParts(Arrays.stream(fieldKey.toString().split(SEPARATOR)).map(FieldKey::decodePart).toList());
80+
}
81+
catch (IllegalArgumentException iae)
82+
{
83+
return null; // FieldReferenceManager depends on this returning null.
84+
}
7785
}
7886
}
7987

0 commit comments

Comments
 (0)