Uses method references instead of anonymous class
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/d2d44e6d Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/d2d44e6d Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/d2d44e6d Branch: refs/heads/master Commit: d2d44e6d6ddf36bfefbf564405e0daef5d32cc99 Parents: 7ad0923 Author: Otavio Santana <otaviopolianasant...@gmail.com> Authored: Thu Dec 20 09:14:02 2018 -0200 Committer: Otavio Santana <otaviopolianasant...@gmail.com> Committed: Thu Dec 20 09:14:02 2018 -0200 ---------------------------------------------------------------------- .../java/org/apache/openejb/core/mdb/MdbInstanceManager.java | 7 +------ .../apache/openejb/core/security/AbstractSecurityService.java | 7 +------ .../java/org/apache/openejb/core/stateful/SimpleCache.java | 6 +----- .../main/java/org/apache/openejb/threads/task/CUCallable.java | 7 +------ .../src/main/java/org/apache/openejb/threads/task/CUTask.java | 7 +------ .../java/org/apache/openejb/util/JavaSecurityManagers.java | 7 +------ .../src/main/java/org/apache/openejb/util/Logger.java | 7 +------ .../resource/jdbc/MultiThreadedManagedDataSourceTest.java | 7 +------ .../apache/openejb/threads/ManagedExecutorServiceTest.java | 7 +------ 9 files changed, 9 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java index fd699f1..9f04c45 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java @@ -200,12 +200,7 @@ public class MdbInstanceManager { final Data data = new Data(builder.build(), accessTimeout, closeTimeout); - MdbContext mdbContext = new MdbContext(securityService, new Flushable() { - @Override - public void flush() throws IOException { - data.flush(); - } - }); + MdbContext mdbContext = new MdbContext(securityService, data::flush); try { final Context context = beanContext.getJndiEnc(); http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java b/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java index ff62082..4d72bc8 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java @@ -420,12 +420,7 @@ public abstract class AbstractSecurityService implements DestroyableResource, Se @SuppressWarnings("unchecked") public SecurityContext(final Subject subject) { this.subject = subject; - this.acc = (AccessControlContext) Subject.doAsPrivileged(subject, new PrivilegedAction() { - @Override - public Object run() { - return AccessController.getContext(); - } - }, null); + this.acc = (AccessControlContext) Subject.doAsPrivileged(subject, (PrivilegedAction) AccessController::getContext, null); } } http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java b/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java index 59b3163..ea151a5 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java @@ -107,11 +107,7 @@ public class SimpleCache<K, V> implements Cache<K, V> { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(SimpleCache.class.getClassLoader()); try { - future = executor.scheduleWithFixedDelay(new Runnable() { - public void run() { - processLRU(); - } - }, frequency, frequency, TimeUnit.MILLISECONDS); + future = executor.scheduleWithFixedDelay(this::processLRU, frequency, frequency, TimeUnit.MILLISECONDS); } finally { Thread.currentThread().setContextClassLoader(loader); } http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUCallable.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUCallable.java b/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUCallable.java index 4a988ff..2ea832a 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUCallable.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUCallable.java @@ -28,11 +28,6 @@ public class CUCallable<T> extends CUTask<T> implements Callable<T> { @Override public T call() throws Exception { - return invoke(new Callable<T>() { - @Override - public T call() throws Exception { - return delegate.call(); - } - }); + return invoke(delegate::call); } } http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUTask.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUTask.java b/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUTask.java index e264178..5cdcdea 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUTask.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/threads/task/CUTask.java @@ -279,12 +279,7 @@ public abstract class CUTask<T> extends ManagedTaskListenerTask implements Compa if (errors.size() == 1) { throw errors.iterator().next(); } - throw new OpenEJBRuntimeException(Join.join("\n", new Join.NameCallback<RuntimeException>() { - @Override - public String getName(final RuntimeException object) { - return object.getMessage(); - } - }, errors)); + throw new OpenEJBRuntimeException(Join.join("\n", Throwable::getMessage, errors)); } } http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java b/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java index b22fd21..44c77ab 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java @@ -23,12 +23,7 @@ import java.util.Properties; // WARN: don't add any logger or container dependency, it should stay self contained public final class JavaSecurityManagers { - private static final PrivilegedAction<Properties> GET_SYSTEM_PROPERTIES = new PrivilegedAction<Properties>() { - @Override - public Properties run() { - return System.getProperties(); - } - }; + private static final PrivilegedAction<Properties> GET_SYSTEM_PROPERTIES = System::getProperties; private JavaSecurityManagers() { // no-op http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java b/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java index e7cb77c..e424779 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java @@ -252,12 +252,7 @@ public class Logger { /** * Creates a MessageFormat object for a message and returns it */ - private static final Computable<String, MessageFormat> messageFormatResolver = new Computable<String, MessageFormat>() { - @Override - public MessageFormat compute(final String message) throws InterruptedException { - return new MessageFormat(message); - } - }; + private static final Computable<String, MessageFormat> messageFormatResolver = MessageFormat::new; /** * Cache of parent-child relationships between resource names http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java index 9c116eb..af4ad91 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java @@ -226,12 +226,7 @@ public class MultiThreadedManagedDataSourceTest { private void run(final Runnable runnable) { final ExecutorService es = Executors.newFixedThreadPool(20); for (int i = 0; i < INSERTS_NB; i++) { - es.submit(new Runnable() { - @Override - public void run() { - runnable.run(); - } - }); + es.submit(runnable::run); } es.shutdown(); try { http://git-wip-us.apache.org/repos/asf/tomee/blob/d2d44e6d/container/openejb-core/src/test/java/org/apache/openejb/threads/ManagedExecutorServiceTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/threads/ManagedExecutorServiceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/threads/ManagedExecutorServiceTest.java index 815142b..a813a84 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/threads/ManagedExecutorServiceTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/threads/ManagedExecutorServiceTest.java @@ -115,12 +115,7 @@ public class ManagedExecutorServiceTest { public boolean submitRunnable() { final CountDownLatch done = new CountDownLatch(1); - es.submit(new Runnable() { - @Override - public void run() { - done.countDown(); - } - }); + es.submit(done::countDown); try { done.await(); } catch (final InterruptedException e) {