diff --git a/pom.xml b/pom.xml
index 759c23be..563db644 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
An implementation of java.util.logging.LogManager
org.jboss.logmanager
jboss-logmanager
- 3.0.5.Final-SNAPSHOT
+ 3.1.0.Final-SNAPSHOT
diff --git a/src/main/java/org/jboss/logmanager/ExtLogRecord.java b/src/main/java/org/jboss/logmanager/ExtLogRecord.java
index cd0448c6..2152a934 100644
--- a/src/main/java/org/jboss/logmanager/ExtLogRecord.java
+++ b/src/main/java/org/jboss/logmanager/ExtLogRecord.java
@@ -19,6 +19,8 @@
package org.jboss.logmanager;
+import static java.security.AccessController.doPrivileged;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -26,6 +28,7 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.UndeclaredThrowableException;
+import java.security.PrivilegedAction;
import java.text.MessageFormat;
import java.util.Map;
import java.util.MissingResourceException;
@@ -108,7 +111,7 @@ public ExtLogRecord(final java.util.logging.Level level, final String msg, final
longThreadID = Thread.currentThread().getId(); // todo: threadId() on 19+
hostName = HostName.getQualifiedHostName();
processName = io.smallrye.common.os.Process.getProcessName();
- processId = io.smallrye.common.os.Process.getProcessId();
+ processId = doPrivileged((PrivilegedAction) ProcessHandle::current).pid();
}
/**
diff --git a/src/main/java/org/jboss/logmanager/handlers/SyslogHandler.java b/src/main/java/org/jboss/logmanager/handlers/SyslogHandler.java
index f15391ba..155df106 100644
--- a/src/main/java/org/jboss/logmanager/handlers/SyslogHandler.java
+++ b/src/main/java/org/jboss/logmanager/handlers/SyslogHandler.java
@@ -19,6 +19,7 @@
package org.jboss.logmanager.handlers;
+import static java.security.AccessController.doPrivileged;
import static java.time.temporal.ChronoField.DAY_OF_MONTH;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
import static java.time.temporal.ChronoField.MILLI_OF_SECOND;
@@ -34,6 +35,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
+import java.security.PrivilegedAction;
import java.text.Normalizer;
import java.text.Normalizer.Form;
import java.time.ZoneId;
@@ -346,7 +348,6 @@ public static enum SyslogType {
private String hostname;
private Facility facility;
private SyslogType syslogType;
- private final String pid;
private OutputStream out;
private Protocol protocol;
private boolean useCountingFraming;
@@ -503,8 +504,6 @@ public SyslogHandler(final InetAddress serverAddress, final int port, final Faci
this.serverAddress = serverAddress;
this.port = port;
this.facility = facility;
- final long pid = io.smallrye.common.os.Process.getProcessId();
- this.pid = (pid != -1 ? Long.toString(pid) : null);
this.appName = "java";
this.hostname = checkPrintableAscii("host name", hostname);
this.syslogType = (syslogType == null ? SyslogType.RFC5424 : syslogType);
@@ -780,14 +779,11 @@ public void setEscapeEnabled(final boolean escapeEnabled) {
* Returns the pid being used as the PROCID for RFC5424 messages.
*
* @return the pid or {@code null} if the pid could not be determined
+ * @deprecated Always returns the current process ID, as a string.
*/
+ @Deprecated(forRemoval = true, since = "3.1")
public String getPid() {
- lock.lock();
- try {
- return pid;
- } finally {
- lock.unlock();
- }
+ return String.valueOf(doPrivileged((PrivilegedAction) ProcessHandle::current).pid());
}
/**
@@ -1308,9 +1304,6 @@ protected byte[] createRFC5424Header(final ExtLogRecord record) throws IOExcepti
if (recordProcId != -1) {
buffer.append(recordProcId);
buffer.append(' ');
- } else if (pid != null) {
- buffer.appendPrintUSASCII(pid, 128);
- buffer.append(' ');
} else {
buffer.appendUSASCII(NILVALUE_SP);
}
@@ -1381,9 +1374,6 @@ protected byte[] createRFC3164Header(final ExtLogRecord record) throws IOExcepti
if (recordProcId != -1) {
buffer.append('[').append(recordProcId).append(']');
colon = true;
- } else if (pid != null) {
- buffer.append('[').appendUSASCII(pid).append(']');
- colon = true;
}
if (colon) {
buffer.append(':').append(' ');