> On April 27, 2015, 8 p.m., Bill Farner wrote:
> > src/main/java/org/apache/aurora/scheduler/base/AsyncUtil.java, line 71
> > <https://reviews.apache.org/r/33456/diff/1/?file=940089#file940089line71>
> >
> >     Have you considered creating factory methods that apply decorators to 
> > ExecutorServices?  That would potentially save this code from the 
> > combinatoric explosion we seem to be heading towards.  
> > ForwardingExecutorService [1] could be helpful to minimize the code to 
> > implement decorators.
> >     
> >     [1] 
> > http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/util/concurrent/ForwardingExecutorService.html

I could not figure out how to make it useful for this particular case. The 
`afterExecute` is defined in a more concrete ThreadPoolExecutor rather than in 
ExecutorService that ForwardingExecutorService implements. The implementation 
does not leave a second chance to handle unhandled error 
(ThreadPoolExecutor.runWorker):
```
                try {
                    beforeExecute(wt, task);
                    Throwable thrown = null;
                    try {
                        task.run();
                    } catch (RuntimeException x) {
                        thrown = x; throw x;
                    } catch (Error x) {
                        thrown = x; throw x;
                    } catch (Throwable x) {
                        thrown = x; throw new Error(x);
                    } finally {
                        afterExecute(task, thrown);
                    }
                } finally {
                    task = null;
                    w.completedTasks++;
                    w.unlock();
                }
```


- Maxim


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/33456/#review81725
-----------------------------------------------------------


On April 22, 2015, 10:58 p.m., Maxim Khutornenko wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/33456/
> -----------------------------------------------------------
> 
> (Updated April 22, 2015, 10:58 p.m.)
> 
> 
> Review request for Aurora and Bill Farner.
> 
> 
> Repository: aurora
> 
> 
> Description
> -------
> 
> Our async EventBus is using a regular executor thus potentially hiding 
> unhandled errors.
> 
> 
> Diffs
> -----
> 
>   src/main/java/org/apache/aurora/scheduler/base/AsyncUtil.java 
> f657e057b5bbff69971876e104ff0e47b2dc4faa 
>   src/main/java/org/apache/aurora/scheduler/events/PubsubEventModule.java 
> 3a4d40adc1abe170b5b80644db9f079751d8a9bf 
>   src/test/java/org/apache/aurora/scheduler/base/AsyncUtilTest.java 
> e990f528aac768b5c9b829c9544045a831e094fe 
> 
> Diff: https://reviews.apache.org/r/33456/diff/
> 
> 
> Testing
> -------
> 
> ./gradlew -Pq build
> 
> 
> Thanks,
> 
> Maxim Khutornenko
> 
>

Reply via email to