"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-api/src/main/java/org/apache/logging/log4j/util/ProcessIdUtil.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

ProcessIdUtil.java  (apache-log4j-2.11.1-src):ProcessIdUtil.java  (apache-log4j-2.11.2-src)
skipping to change at line 33 skipping to change at line 33
/** /**
* @Since 2.9 * @Since 2.9
*/ */
public class ProcessIdUtil { public class ProcessIdUtil {
public static final String DEFAULT_PROCESSID = "-"; public static final String DEFAULT_PROCESSID = "-";
public static String getProcessId() { public static String getProcessId() {
try { try {
// LOG4J2-2126 use reflection to improve compatibility with Android Platform which does not support JMX extensions // LOG4J2-2126 use reflection to improve compatibility with Android Platform which does not support JMX extensions
Class<?> managementFactoryClass = Class.forName("java.lang.managemen final Class<?> managementFactoryClass = Class.forName("java.lang.man
t.ManagementFactory"); agement.ManagementFactory");
Method getRuntimeMXBean = managementFactoryClass.getDeclaredMethod(" final Method getRuntimeMXBean = managementFactoryClass.getDeclaredMe
getRuntimeMXBean"); thod("getRuntimeMXBean");
Class<?> runtimeMXBeanClass = Class.forName("java.lang.management.Ru final Class<?> runtimeMXBeanClass = Class.forName("java.lang.managem
ntimeMXBean"); ent.RuntimeMXBean");
Method getName = runtimeMXBeanClass.getDeclaredMethod("getName"); final Method getName = runtimeMXBeanClass.getDeclaredMethod("getName
");
Object runtimeMXBean = getRuntimeMXBean.invoke(null); final Object runtimeMXBean = getRuntimeMXBean.invoke(null);
String name = (String) getName.invoke(runtimeMXBean); final String name = (String) getName.invoke(runtimeMXBean);
//String name = ManagementFactory.getRuntimeMXBean().getName(); //JM X not allowed on Android //String name = ManagementFactory.getRuntimeMXBean().getName(); //JM X not allowed on Android
return name.split("@")[0]; // likely works on most platforms return name.split("@")[0]; // likely works on most platforms
} catch (final Exception ex) { } catch (final Exception ex) {
try { try {
return new File("/proc/self").getCanonicalFile().getName(); // t ry a Linux-specific way return new File("/proc/self").getCanonicalFile().getName(); // t ry a Linux-specific way
} catch (final IOException ignoredUseDefault) { } catch (final IOException ignoredUseDefault) {
// Ignore exception. // Ignore exception.
} }
} }
return DEFAULT_PROCESSID; return DEFAULT_PROCESSID;
 End of changes. 2 change blocks. 
9 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)