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

@ -13,6 +13,7 @@
* 【extra 】 新增方便引入SpringUtil的注解@EnableSpringUtilpr#172@Gitee * 【extra 】 新增方便引入SpringUtil的注解@EnableSpringUtilpr#172@Gitee
* 【poi 】 RowUtil增加插入和删除行pr#1060@Github * 【poi 】 RowUtil增加插入和删除行pr#1060@Github
* 【extra 】 SpringUtil增加注册beanpr#174@Gitee * 【extra 】 SpringUtil增加注册beanpr#174@Gitee
* 【core 】 修改NetUtil.getMacAddress避免空指针issue#1057@Github
### Bug修复# ### Bug修复#
* 【core 】 重新整理农历节假日解决一个pr过来的玩笑导致的问题 * 【core 】 重新整理农历节假日解决一个pr过来的玩笑导致的问题

View File

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