fix mac null bug

This commit is contained in:
Looly
2020-09-04 17:51:10 +08:00
parent 2e6515ef06
commit 9d8f4d725c
2 changed files with 7 additions and 2 deletions

View File

@@ -507,9 +507,12 @@ public class NetUtil {
return null;
}
byte[] mac;
byte[] mac = null;
try {
mac = NetworkInterface.getByInetAddress(inetAddress).getHardwareAddress();
final NetworkInterface networkInterface = NetworkInterface.getByInetAddress(inetAddress);
if(null != networkInterface){
mac = networkInterface.getHardwareAddress();
}
} catch (SocketException e) {
throw new UtilException(e);
}
@@ -526,6 +529,7 @@ public class NetUtil {
}
return sb.toString();
}
return null;
}