Skip to content

Commit 39575d5

Browse files
committed
Improve code quality
Remove code flaws detected by PMD. PMD Rules: * NP_LOAD_OF_KNOWN_NULL_VALUE * DCN_NULLPOINTER_EXCEPTION
1 parent 84fd314 commit 39575d5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/main/java/com/github/f4b6a3/uuid/codec/StandardStringCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public String encode(UUID uuid) {
167167
public UUID decode(final String string) {
168168

169169
if (string == null) {
170-
throw InvalidUuidException.newInstance(string);
170+
throw InvalidUuidException.newInstance(null);
171171
}
172172

173173
final String modified = modify(string);

src/main/java/com/github/f4b6a3/uuid/util/UuidValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static boolean isValid(final char[] uuid, int version) {
146146
*/
147147
public static void validate(final UUID uuid) {
148148
if (uuid == null) {
149-
throw InvalidUuidException.newInstance(uuid);
149+
throw InvalidUuidException.newInstance(null);
150150
}
151151
}
152152

src/main/java/com/github/f4b6a3/uuid/util/internal/NetworkUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static synchronized String mac(NetworkInterface nic) {
103103
}
104104

105105
try {
106-
if (nic != null) {
106+
if (nic != null && nic.getHardwareAddress() != null) {
107107
byte[] ha = nic.getHardwareAddress();
108108
String[] hex = new String[ha.length];
109109
for (int i = 0; i < ha.length; i++) {
@@ -112,7 +112,7 @@ public static synchronized String mac(NetworkInterface nic) {
112112
mac = String.join("-", hex);
113113
return mac;
114114
}
115-
} catch (SocketException | NullPointerException e) {
115+
} catch (SocketException e) {
116116
return null;
117117
}
118118

0 commit comments

Comments
 (0)