Author: rmannibucau
Date: Fri Jun 16 17:52:19 2017
New Revision: 1798968
URL: http://svn.apache.org/viewvc?rev=1798968&view=rev
Log:
ensuring the executor for async methods works when there is at least an async
method
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1798968&r1=1798967&r2=1798968&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Fri Jun 16 17:52:19 2017
@@ -331,6 +331,14 @@ public class BeansDeployer
webBeansContext.getNotificationManager().clearCaches();
+ if
(webBeansContext.getNotificationManager().getObserverMethods().stream()
+ .anyMatch(ObserverMethod::isAsync))
+ {
+ // enforce it to be loaded and ensuring it works before
runtime
+
webBeansContext.getNotificationManager().getDefaultNotificationOptions()
+ .getExecutor().execute(() -> {});
+ }
+
// fire event
fireAfterDeploymentValidationEvent();
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1798968&r1=1798967&r2=1798968&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Fri Jun 16 17:52:19 2017
@@ -151,7 +151,7 @@ public final class NotificationManager
//
// logic is: if an Executor is registered as a spi use it, otherwise
use JVM default one
final Executor service = webBeansContext.getService(Executor.class);
- return service != null ? service : new
CloseableExecutor(ForkJoinPool.commonPool());
+ return service != null ? service : new CloseableExecutor();
}
/**
@@ -817,7 +817,7 @@ public final class NotificationManager
{
future.completeExceptionally(wbe.getCause());
}
- }, notificationOptions.getExecutor() == null ?
ForkJoinPool.commonPool() : notificationOptions.getExecutor());
+ }, notificationOptions.getExecutor() == null ?
defaultNotificationOptions.getExecutor() : notificationOptions.getExecutor());
return future;
}
@@ -932,15 +932,9 @@ public final class NotificationManager
private static final class CloseableExecutor implements Executor, Closeable
{
- private final Executor delegate;
private final Collection<Runnable> tracker = new
CopyOnWriteArrayList<>();
private volatile boolean reject = false;
- private CloseableExecutor(final Executor delegate)
- {
- this.delegate = delegate;
- }
-
@Override
public void close() throws IOException
{
@@ -966,7 +960,7 @@ public final class NotificationManager
}
tracker.add(command);
- delegate.execute(() ->
+ ForkJoinPool.commonPool().execute(() ->
{
try
{