Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit eb24152

Browse files
author
Jochen Schalanda
committed
Ensure MacAddress#create() returns a valid MacAddress if input is null or empty
1 parent 24400cd commit eb24152

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/org/graylog/plugins/usagestatistics/dto/MacAddress.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public abstract class MacAddress {
3030
private static final Pattern PATTERN = Pattern.compile("[0-9a-f]{2}([:-][0-9a-f]{2}){5}", Pattern.CASE_INSENSITIVE);
3131

3232
public static MacAddress create(String macAddress) {
33+
if(macAddress == null || macAddress.isEmpty()) {
34+
return EMPTY;
35+
}
3336
checkArgument(PATTERN.matcher(macAddress).matches());
3437

3538
return new AutoValue_MacAddress(macAddress.substring(0, 8));

0 commit comments

Comments
 (0)