Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
Remove code flaws detected by PMD.

PMD Rules:

* NP_LOAD_OF_KNOWN_NULL_VALUE
* DCN_NULLPOINTER_EXCEPTION
  • Loading branch information
fabiolimace committed Jul 7, 2024
1 parent 84fd314 commit 39575d5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public String encode(UUID uuid) {
public UUID decode(final String string) {

if (string == null) {
throw InvalidUuidException.newInstance(string);
throw InvalidUuidException.newInstance(null);
}

final String modified = modify(string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static boolean isValid(final char[] uuid, int version) {
*/
public static void validate(final UUID uuid) {
if (uuid == null) {
throw InvalidUuidException.newInstance(uuid);
throw InvalidUuidException.newInstance(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static synchronized String mac(NetworkInterface nic) {
}

try {
if (nic != null) {
if (nic != null && nic.getHardwareAddress() != null) {
byte[] ha = nic.getHardwareAddress();
String[] hex = new String[ha.length];
for (int i = 0; i < ha.length; i++) {
Expand All @@ -112,7 +112,7 @@ public static synchronized String mac(NetworkInterface nic) {
mac = String.join("-", hex);
return mac;
}
} catch (SocketException | NullPointerException e) {
} catch (SocketException e) {
return null;
}

Expand Down

0 comments on commit 39575d5

Please sign in to comment.