Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Wellmann2021-07-14 21:57:24 +0000
committerThomas Watson2021-08-02 19:39:55 +0000
commit005994e26c8345f42eb03b22bfddc3e98b8f9a0f (patch)
tree0ddddec2a81cb6b4f76aeea49c21f958f4720358
parent27aa1e2c54d958b39af762bc0566f1b9a85e4ef9 (diff)
downloadrt.equinox.framework-005994e26c8345f42eb03b22bfddc3e98b8f9a0f.tar.gz
rt.equinox.framework-005994e26c8345f42eb03b22bfddc3e98b8f9a0f.tar.xz
rt.equinox.framework-005994e26c8345f42eb03b22bfddc3e98b8f9a0f.zip
Bug 574872 - [Clean-up] Simplify lambdas & use method-references (5)
Use Sonar-Lint Eclipse plug-in to find remaining locations where lambdas can be simplified. Change-Id: Ie6dc3c9f3c5e488ab04c6de3262edf6ec5391e43 Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183107 Tested-by: Equinox Bot <equinox-bot@eclipse.org> Reviewed-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java2
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java65
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java7
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java14
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java2
13 files changed, 63 insertions, 65 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
index 7d2d6c2c5..50bc6a608 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
@@ -312,7 +312,7 @@ public class AbstractBundleTests extends CoreTest {
final Exception[] failureException = new BundleException[1];
final FrameworkEvent[] success = new FrameworkEvent[] { null };
final String uuid = getUUID(equinox);
- Thread waitForUpdate = new Thread((Runnable) () -> success[0] = waitForStop(equinox, uuid, false, 10000), "test waitForStop thread"); //$NON-NLS-1$
+ Thread waitForUpdate = new Thread(() -> success[0] = waitForStop(equinox, uuid, false, 10000), "test waitForStop thread"); //$NON-NLS-1$
waitForUpdate.start();
try {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index e12ce5674..11f37e8d5 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -600,7 +600,7 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
final Bundle osgiE = installer.installBundle("osgi.lazystart.e"); //$NON-NLS-1$
assertTrue("osgi lazy start resolve", installer.resolveBundles(new Bundle[] {osgiD, osgiE})); //$NON-NLS-1$
- Thread t = new Thread((Runnable) () -> {
+ Thread t = new Thread(() -> {
try {
osgiD.loadClass("osgi.lazystart.d.DTest");
} catch (ClassNotFoundException e) {
@@ -2158,7 +2158,7 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
};
getContext().addBundleListener(delayB1);
try {
- new Thread((Runnable) () -> {
+ new Thread(() -> {
try {
System.out.println(getName() + ": Initial load test.");
a1.loadClass("test.bug490902.a.TestLoadA1").newInstance();
@@ -2168,7 +2168,7 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
}, "Initial load test thread.").start();
startingB.await();
- Thread secondThread = new Thread((Runnable) () -> {
+ Thread secondThread = new Thread(() -> {
try {
System.out.println(getName() + ": Second load test.");
a1.loadClass("test.bug490902.a.TestLoadA1").newInstance();
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
index 1dbf74eec..afd38db6c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
@@ -569,10 +569,8 @@ public class ConnectTests extends AbstractBundleTests {
ModuleContainer.createRequirement(IdentityNamespace.IDENTITY_NAMESPACE, //
Collections.singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, "(tags=osgi.connect)"), //
Collections.emptyMap()));
- osgiConnectTags.forEach(c -> {
- assertTrue("Unexpected tag on bundle: " + c.getRevision().getBundle(),
- locations.contains(c.getRevision().getBundle().getLocation()));
- });
+ osgiConnectTags.forEach(c -> assertTrue("Unexpected tag on bundle: " + c.getRevision().getBundle(),
+ locations.contains(c.getRevision().getBundle().getLocation())));
}
public void testConnectContentActivatorsWithFrameworkLoaders() {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
index 45b5fea23..16e776c9f 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
@@ -484,7 +484,7 @@ public class BasicLocationTests extends CoreTest {
try {
final List<LogEntry> logEntries = new ArrayList<>();
LogReaderService logReaderService = getLogReaderService(equinox);
- SynchronousLogListener logListener = entry -> logEntries.add(entry);
+ SynchronousLogListener logListener = logEntries::add;
logReaderService.addLogListener(logListener);
Map<String, Location> locations = getLocations(equinox);
Location userLocation = locations.get(Location.USER_FILTER);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
index 2b6113bad..bdd3f2a94 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
@@ -47,7 +47,8 @@ public class SecureAction {
private AccessControlContext controlContext;
// This ClassLoader is used in loadSystemClass if System.getClassLoader() returns null
- static final ClassLoader bootClassLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */});
+ static final ClassLoader bootClassLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>)
+ () -> new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */});
/*
* Package privaet constructor a new SecureAction object.
@@ -80,7 +81,7 @@ public class SecureAction {
public String getProperty(final String property) {
if (System.getSecurityManager() == null)
return System.getProperty(property);
- return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property), controlContext);
+ return doPrivileged(() -> System.getProperty(property), controlContext);
}
/**
@@ -91,7 +92,7 @@ public class SecureAction {
public Properties getProperties() {
if (System.getSecurityManager() == null)
return System.getProperties();
- return AccessController.doPrivileged((PrivilegedAction<Properties>) System::getProperties, controlContext);
+ return doPrivileged(System::getProperties, controlContext);
}
/**
@@ -105,7 +106,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new FileInputStream(file);
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<FileInputStream>) () -> new FileInputStream(file), controlContext);
+ return doPrivilegedWithException(() -> new FileInputStream(file), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof FileNotFoundException)
throw (FileNotFoundException) e.getException();
@@ -125,7 +126,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new FileOutputStream(file.getAbsolutePath(), append);
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<FileOutputStream>) () -> new FileOutputStream(file.getAbsolutePath(), append), controlContext);
+ return doPrivilegedWithException(() -> new FileOutputStream(file.getAbsolutePath(), append), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof FileNotFoundException)
throw (FileNotFoundException) e.getException();
@@ -142,7 +143,7 @@ public class SecureAction {
public long length(final File file) {
if (System.getSecurityManager() == null)
return file.length();
- return AccessController.doPrivileged((PrivilegedAction<Long>) () -> Long.valueOf(file.length()), controlContext).longValue();
+ return doPrivileged(file::length, controlContext);
}
/**
@@ -156,7 +157,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return file.getCanonicalPath();
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> file.getCanonicalPath(), controlContext);
+ return doPrivilegedWithException(file::getCanonicalPath, controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
@@ -173,9 +174,10 @@ public class SecureAction {
public File getAbsoluteFile(final File file) {
if (System.getSecurityManager() == null)
return file.getAbsoluteFile();
- return AccessController.doPrivileged((PrivilegedAction<File>) () -> file.getAbsoluteFile(), controlContext);
+ return doPrivileged(file::getAbsoluteFile, controlContext);
}
+
/**
* Returns the canonical file. Same as calling
* file.getCanonicalFile().
@@ -186,7 +188,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return file.getCanonicalFile();
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<File>) () -> file.getCanonicalFile(), controlContext);
+ return doPrivilegedWithException(file::getCanonicalFile, controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
@@ -203,13 +205,13 @@ public class SecureAction {
public boolean exists(final File file) {
if (System.getSecurityManager() == null)
return file.exists();
- return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> file.exists() ? Boolean.TRUE : Boolean.FALSE, controlContext).booleanValue();
+ return doPrivileged(file::exists, controlContext);
}
public boolean mkdirs(final File file) {
if (System.getSecurityManager() == null)
return file.mkdirs();
- return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> file.mkdirs() ? Boolean.TRUE : Boolean.FALSE, controlContext).booleanValue();
+ return doPrivileged(file::mkdirs, controlContext);
}
/**
@@ -221,7 +223,7 @@ public class SecureAction {
public boolean isDirectory(final File file) {
if (System.getSecurityManager() == null)
return file.isDirectory();
- return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> file.isDirectory() ? Boolean.TRUE : Boolean.FALSE, controlContext).booleanValue();
+ return doPrivileged(file::isDirectory, controlContext);
}
/**
@@ -233,7 +235,7 @@ public class SecureAction {
public long lastModified(final File file) {
if (System.getSecurityManager() == null)
return file.lastModified();
- return AccessController.doPrivileged((PrivilegedAction<Long>) () -> Long.valueOf(file.lastModified()), controlContext).longValue();
+ return doPrivileged(file::lastModified, controlContext);
}
/**
@@ -245,7 +247,7 @@ public class SecureAction {
public String[] list(final File file) {
if (System.getSecurityManager() == null)
return file.list();
- return AccessController.doPrivileged((PrivilegedAction<String[]>) () -> file.list(), controlContext);
+ return doPrivileged(file::list, controlContext);
}
/**
@@ -261,12 +263,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new ZipFile(file);
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<ZipFile>) () -> {
- if (verify) {
- return new JarFile(file);
- }
- return new ZipFile(file);
- }, controlContext);
+ return doPrivilegedWithException(() -> verify ? new JarFile(file) : new ZipFile(file), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
@@ -296,7 +293,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new URL(protocol, host, port, file, handler);
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<URL>) () -> new URL(protocol, host, port, file, handler), controlContext);
+ return doPrivilegedWithException(() -> new URL(protocol, host, port, file, handler), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof MalformedURLException)
throw (MalformedURLException) e.getException();
@@ -315,7 +312,7 @@ public class SecureAction {
public Thread createThread(final Runnable target, final String name, final ClassLoader contextLoader) {
if (System.getSecurityManager() == null)
return createThread0(target, name, contextLoader);
- return AccessController.doPrivileged((PrivilegedAction<Thread>) () -> createThread0(target, name, contextLoader), controlContext);
+ return doPrivileged(() -> createThread0(target, name, contextLoader), controlContext);
}
Thread createThread0(Runnable target, String name, ClassLoader contextLoader) {
@@ -335,7 +332,7 @@ public class SecureAction {
public <S> S getService(final ServiceReference<S> reference, final BundleContext context) {
if (System.getSecurityManager() == null)
return context.getService(reference);
- return AccessController.doPrivileged((PrivilegedAction<S>) () -> context.getService(reference), controlContext);
+ return doPrivileged(() -> context.getService(reference), controlContext);
}
/**
@@ -349,7 +346,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return Class.forName(name);
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<Class<?>>) () -> Class.forName(name), controlContext);
+ return doPrivilegedWithException(() -> Class.forName(name), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof ClassNotFoundException)
throw (ClassNotFoundException) e.getException();
@@ -370,7 +367,7 @@ public class SecureAction {
return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
}
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction<Class<?>>) () -> {
+ return doPrivilegedWithException(() -> {
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
}, controlContext);
@@ -390,7 +387,7 @@ public class SecureAction {
tracker.open();
return;
}
- AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ doPrivileged(() -> {
tracker.open();
return null;
}, controlContext);
@@ -408,11 +405,10 @@ public class SecureAction {
return;
}
try {
- AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ doPrivilegedWithException(() -> {
module.start(options);
return null;
}, controlContext);
- return;
} catch (PrivilegedActionException e) {
if (e.getException() instanceof BundleException)
throw (BundleException) e.getException();
@@ -424,13 +420,22 @@ public class SecureAction {
if (System.getSecurityManager() == null) {
return bundle.getBundleContext();
}
- return AccessController.doPrivileged((PrivilegedAction<BundleContext>) () -> bundle.getBundleContext(), controlContext);
+ return doPrivileged(bundle::getBundleContext, controlContext);
}
public String getLocation(final Bundle bundle) {
if (System.getSecurityManager() == null) {
return bundle.getLocation();
}
- return AccessController.doPrivileged((PrivilegedAction<String>) () -> bundle.getLocation(), controlContext);
+ return doPrivileged(bundle::getLocation, controlContext);
+ }
+
+ private static <T> T doPrivileged(PrivilegedAction<T> action, AccessControlContext context) {
+ return AccessController.doPrivileged(action, context);
+ }
+
+ private static <T> T doPrivilegedWithException(PrivilegedExceptionAction<T> action, AccessControlContext context)
+ throws PrivilegedActionException {
+ return AccessController.doPrivileged(action, context);
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
index 8d58f96c9..3ac050a04 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
@@ -151,7 +151,8 @@ public class ConnectHookConfigurator implements HookConfigurator {
bundlefile = chain.getBundleFile();
}
if (bundlefile instanceof ConnectBundleFile) {
- return ((ConnectBundleFile) bundlefile).getClassLoader().map(l -> new DelegatingConnectClassLoader(parent, configuration, delegate, generation, l)).orElse(null);
+ return ((ConnectBundleFile) bundlefile).getClassLoader().map(
+ l -> new DelegatingConnectClassLoader(parent, configuration, delegate, generation, l)).orElse(null);
}
}
return null;
@@ -160,7 +161,7 @@ public class ConnectHookConfigurator implements HookConfigurator {
hookRegistry.addActivatorHookFactory(() -> {
final List<BundleActivator> activators = new ArrayList<>();
- moduleConnector.newBundleActivator().ifPresent(a -> activators.add(a));
+ moduleConnector.newBundleActivator().ifPresent(activators::add);
return new BundleActivator() {
@Override
public void start(BundleContext context) throws Exception {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
index 3d358d9f0..bb3a3dcb7 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
@@ -254,9 +254,8 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
if (debug.DEBUG_HOOKS) {
Debug.println("notifyBundleFindHooks(" + allBundles + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
- container.getServiceRegistry().notifyHooksPrivileged(FindHook.class, "find", (hook, hookRegistration) -> { //$NON-NLS-1$
- hook.find(context, allBundles);
- });
+ container.getServiceRegistry().notifyHooksPrivileged(FindHook.class, "find", //$NON-NLS-1$
+ (hook, hookRegistration) -> hook.find(context, allBundles));
}
@Override
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
index fecdf7a95..9ee0c0e71 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
@@ -219,7 +219,7 @@ public class EquinoxBundle implements Bundle, BundleReference {
if (Module.ACTIVE_SET.contains(getState())) {
// TODO this still has a chance of a race condition:
// multiple threads could get started if stop is called over and over
- Thread t = new Thread((Runnable) () -> {
+ Thread t = new Thread(() -> {
try {
stop();
} catch (Throwable e) {
@@ -240,7 +240,7 @@ public class EquinoxBundle implements Bundle, BundleReference {
lockStateChange(ModuleEvent.UPDATED);
try {
if (Module.ACTIVE_SET.contains(getState())) {
- Thread t = new Thread((Runnable) () -> {
+ Thread t = new Thread(() -> {
try {
update();
} catch (Throwable e) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
index cd52303cc..6fed57fc2 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
@@ -249,9 +249,7 @@ public class EquinoxEventPublisher {
ServiceRegistry serviceRegistry = container.getServiceRegistry();
if (serviceRegistry != null) {
- serviceRegistry.notifyHooksPrivileged(EventHook.class, "event", (hook, hookRegistration) -> { //$NON-NLS-1$
- hook.event(event, result);
- });
+ serviceRegistry.notifyHooksPrivileged(EventHook.class, "event", (hook, r) -> hook.event(event, result)); //$NON-NLS-1$
}
}
@@ -419,7 +417,8 @@ public class EquinoxEventPublisher {
}
void flushFrameworkEvents() {
- EventDispatcher<Object, Object, CountDownLatch> dispatcher = (eventListener, listenerObject, eventAction, flushedSignal) -> flushedSignal.countDown();
+ // Signal that we have flushed all events
+ EventDispatcher<Object, Object, CountDownLatch> dispatcher = (el, lo, ea, signal) -> signal.countDown();
ListenerQueue<Object, Object, CountDownLatch> queue = newListenerQueue();
queue.queueListeners(Collections.<Object, Object> singletonMap(dispatcher, dispatcher).entrySet(), dispatcher);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
index c5c422947..615bd4347 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
@@ -113,9 +113,8 @@ class OSGiFrameworkHooks {
}
ServiceRegistry registry = container.getServiceRegistry();
if (registry != null) {
- registry.notifyHooksPrivileged(CollisionHook.class, "filterCollisions", (hook, hookRegistration) -> { //$NON-NLS-1$
- hook.filterCollisions(operationType, target, collisionCandidates);
- });
+ registry.notifyHooksPrivileged(CollisionHook.class, "filterCollisions", //$NON-NLS-1$
+ (hook, hookRegistration) -> hook.filterCollisions(operationType, target, collisionCandidates));
}
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index 33ec54992..b90ca0db1 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -261,7 +261,8 @@ public class BundleLoader extends ModuleLoader {
result = createClassLoaderPrivledged(parent, generation.getBundleInfo().getStorage().getConfiguration(), this, generation, hooks);
} else {
final ClassLoader cl = parent;
- result = AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>) () -> createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks));
+ result = AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>)
+ () -> createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks));
}
// Synchronize on classLoaderCreatedMonitor in order to ensure hooks are called before returning.
@@ -583,7 +584,7 @@ public class BundleLoader extends ModuleLoader {
private static ClassLoader getClassLoader(final Class<?> clazz) {
if (System.getSecurityManager() == null)
return clazz.getClassLoader();
- return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> clazz.getClassLoader());
+ return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) clazz::getClassLoader);
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
index a271d3b3a..4a75b4516 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
@@ -1241,9 +1241,8 @@ public class ServiceRegistry {
if (debug.DEBUG_HOOKS) {
Debug.println("notifyServiceFindHooks(" + context.getBundleImpl() + "," + clazz + "," + filterstring + "," + allservices + "," + result + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
- notifyHooksPrivileged(FindHook.class, "find", (hook, hookRegistration) -> { //$NON-NLS-1$
- hook.find(context, clazz, filterstring, allservices, result);
- });
+ notifyHooksPrivileged(FindHook.class, "find", //$NON-NLS-1$
+ (hook, hookRegistration) -> hook.find(context, clazz, filterstring, allservices, result));
}
/**
@@ -1259,9 +1258,8 @@ public class ServiceRegistry {
if (debug.DEBUG_HOOKS) {
Debug.println("notifyServiceEventHooks(" + event.getType() + ":" + event.getServiceReference() + "," + result + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- notifyHooksPrivileged(org.osgi.framework.hooks.service.EventHook.class, "event", (hook, hookRegistration) -> { //$NON-NLS-1$
- hook.event(event, result);
- });
+ notifyHooksPrivileged(org.osgi.framework.hooks.service.EventHook.class, "event", //$NON-NLS-1$
+ (hook, hookRegistration) -> hook.event(event, result));
}
/**
@@ -1276,9 +1274,7 @@ public class ServiceRegistry {
if (debug.DEBUG_HOOKS) {
Debug.println("notifyServiceEventListenerHooks(" + event.getType() + ":" + event.getServiceReference() + "," + result + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- notifyHooksPrivileged(EventListenerHook.class, "event", (hook, hookRegistration) -> { //$NON-NLS-1$
- hook.event(event, result);
- });
+ notifyHooksPrivileged(EventListenerHook.class, "event", (hook, r) -> hook.event(event, result)); //$NON-NLS-1$
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
index 2a1017c77..e2226b7f3 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
@@ -232,7 +232,7 @@ public abstract class MultiplexingFactory {
private boolean isSystemClass(final Class<?> clazz) {
// we want to ignore classes from the system
- ClassLoader cl = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> clazz.getClassLoader());
+ ClassLoader cl = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) clazz::getClassLoader);
return cl == null || systemLoaders.contains(cl);
}

Back to the top