Author: rgoers
Date: Fri Feb 3 18:16:30 2012
New Revision: 1240277
URL: http://svn.apache.org/viewvc?rev=1240277&view=rev
Log:
Protect against null network and mac address values
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
URL:
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java?rev=1240277&r1=1240276&r2=1240277&view=diff
==============================================================================
---
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
(original)
+++
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/helpers/UUIDUtil.java
Fri Feb 3 18:16:30 2012
@@ -66,19 +66,24 @@ public final class UUIDUtil {
byte[] mac = null;
try {
InetAddress address = InetAddress.getLocalHost();
-
try {
NetworkInterface ni =
NetworkInterface.getByInetAddress(address);
- if (!ni.isLoopback() && ni.isUp()) {
+ if (ni != null && !ni.isLoopback() && ni.isUp()) {
Method method =
ni.getClass().getMethod("getHardwareAddress");
- mac = (byte[]) method.invoke(ni);
- } else {
+ if (method != null) {
+ mac = (byte[]) method.invoke(ni);
+ }
+ }
+
+ if (mac == null) {
Enumeration<NetworkInterface> enumeration =
NetworkInterface.getNetworkInterfaces();
while (enumeration.hasMoreElements() && mac == null) {
ni = enumeration.nextElement();
- if (ni.isUp() && !ni.isLoopback()) {
+ if (ni != null && ni.isUp() && !ni.isLoopback()) {
Method method =
ni.getClass().getMethod("getHardwareAddress");
- mac = (byte[]) method.invoke(ni);
+ if (method != null) {
+ mac = (byte[]) method.invoke(ni);
+ }
}
}
}