Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2019-06-10 21:30:46 +0000
committerThomas Watson2019-06-11 12:54:34 +0000
commitc5d548da544dfb951dd9b07bbc9b2fc8d3c88f41 (patch)
tree577cc778bd3c028398633c1a7887b7634de06644
parente36c67ba1fa688f046a7cbeca8a0166c9602aaf3 (diff)
downloadrt.equinox.framework-c5d548da544dfb951dd9b07bbc9b2fc8d3c88f41.tar.gz
rt.equinox.framework-c5d548da544dfb951dd9b07bbc9b2fc8d3c88f41.tar.xz
rt.equinox.framework-c5d548da544dfb951dd9b07bbc9b2fc8d3c88f41.zip
Bug 284498 - [log] LogEntry topic required to log events
Change-Id: I3868cffc0f978f36264bb2b9f9fd3ccb0dbe90a0 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java45
1 files changed, 28 insertions, 17 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java
index 5a09fad1f..b1544ea89 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java
@@ -13,6 +13,9 @@ package org.eclipse.osgi.internal.log;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.equinox.log.SynchronousLogListener;
@@ -49,8 +52,8 @@ public class EventAdminLogListener implements SynchronousLogListener {
public static final String EXCEPTION_CLASS = "exception.class"; //$NON-NLS-1$
public static final String EXCEPTION_MESSAGE = "exception.message"; //$NON-NLS-1$
- private final Object eventAdmin;
- private final Method postEvent;
+ final Object eventAdmin;
+ final Method postEvent;
private final Constructor<?> event;
public EventAdminLogListener(Object eventAdmin) throws ClassNotFoundException, NoSuchMethodException {
@@ -64,26 +67,34 @@ public class EventAdminLogListener implements SynchronousLogListener {
}
@Override
- public void logged(LogEntry entry) {
+ public void logged(final LogEntry entry) {
try {
- Object convertedEvent = convertEvent(entry);
- postEvent.invoke(eventAdmin, convertedEvent);
- } catch (InvocationTargetException e) {
- Throwable t = e.getTargetException();
- if ((t instanceof RuntimeException))
- throw (RuntimeException) t;
- if ((t instanceof Error))
- throw (Error) t;
- // unexpected
- throw new RuntimeException(e);
- } catch (IllegalAccessException | InstantiationException e) {
- // unexpected
- throw new RuntimeException(e);
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ Object convertedEvent = convertEvent(entry);
+ postEvent.invoke(eventAdmin, convertedEvent);
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof InvocationTargetException) {
+ Throwable t = ((InvocationTargetException) cause).getTargetException();
+ if ((t instanceof RuntimeException))
+ throw (RuntimeException) t;
+ if ((t instanceof Error))
+ throw (Error) t;
+ // unexpected
+ throw new RuntimeException(t);
+ }
+ throw new RuntimeException(cause);
}
+
}
@SuppressWarnings("deprecation")
- private Object convertEvent(LogEntry entry) throws InstantiationException, IllegalAccessException, InvocationTargetException {
+ Object convertEvent(LogEntry entry) throws InstantiationException, IllegalAccessException, InvocationTargetException {
String topic = TOPIC;
int level = entry.getLevel();
switch (level) {

Back to the top