Jethro Borsje

personal website

  • Increase font size
  • Default font size
  • Decrease font size

2014-02-02 - Hiking @ Het Weegje

On Sunday the second of February we went hiking at Het Weegje, a small park with a lake near our home. The weather was pretty nice (more spring then winter) so we decided to do a slightly different route than we usually do here. Along the way we saw various water birds such as the swan, the Eurasian Wigeon, and the Great Crested Grebe who were fishing. We even caught one on camera carrying a fish! We hiked somewhere around 5,8 kilometers on this nice winter day.

Bellow are some pictures and a GPS track log:

Show on bigger map


2014-01-24 - Hiking @ Goeree Overflakkee

On Friday the 24th of January we went hiking together on Goeree Overflakkee which is a peninsula in our province. We didn't hike here before but thanks to Roots Magazine this part of Zuid-Holland was brought to our attention. The hike started out at a small harbor close to the sea. From there it went through the dunes after which we eventually ended up on the beach from where we hiked back to our starting point. The entire hike was about 6,3 kilometers across diverse terrain. The weather was very good with clear visibility so we enjoyed the environment around us very much. We ended up spotting a Barnacle Goose, a Canada Goose, a Common Merganser, a Tufted Duck, and a Common Pochard. We had a great day hiking at this new location and we plan on going back there again in the future.

Bellow you'll find some pictures and the GPS track log:

View 2014-01-24 - Hiking @ Goeree Overflakkee in a larger map


2014-01-18 - Hiking @ Hitland

In January we went hiking in Hitland a couple of times, one of those times was Saturday the 18th of January. The weather here in The Netherlands is very warm for this time of year, so instead of ice skating we plan to go hiking regularly. During our visits to Hitland we saw various types of birds. The most notable one was the Great Egret also known as the White Heron. Although the Grey Heron is very common in The Netherlands the White Heron is seen here less often (although it is not rare). We didn't spot the White Heron before in Hitland, but this year we've seen a few of them on several different occasions. It is nice to see that the diversity of birds is increasing in Hitland. Other birds we saw this year include the Gadwell, the Common Pochard and the Red-crested Pochard.

Bellow are some pictures of the 18th:


2014-01-12 - Hiking @ Meijendel

On Sunday the 12th of January we went hiking with the three of us for one of the first times. We decided to go to the Meijendel which is a coastal area near The Hague. The area is comprised of dunes and woods and is a nice place to go for a hike. In the weekends it can be a bid crowded, especially if the weather is nice like it was on the 12th. When we arrived it was less crowded than we expected and we ended up hiking about 7km without to much crowds.

Bellow are some pictures of this hike:

Last Updated on Tuesday, 25 February 2014 15:24

Spring @Async and exception handling


When using Spring to asynchronously execute pieces of your code you typically use the @Async annotation on your Spring @Components methods. When using the @Async annotation Spring will use AOP (Aspect Oriented Programming) to wrap your call in a Runnable. This Runnable will then be scheduled for execution on a TaskExecutor. More information about asynchronous execution and its transactional context can be found here.

Exception handling

Spring comes with a number of pre-packaged TaskExecutors which are documented in the Spring documentation here. In practice you will likely use the ThreadPoolTaskExecutor or the SimpleAsyncTaskExecutor. When doing so you might at times wonder why a task has not been executed. This happens when an exception occurs inside the method you are trying to execute asynchronous. The aforementioned task executors do not handle the exceptions so the execution fails silently. This problem can be solved by implementing your own AsyncTaskExecutor which handles the exceptions by logging them (or in any other way you wish). Bellow you'll find an example implementation of such a AsyncTaskExecutor.


import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

public class ExceptionHandlingAsyncTaskExecutor implements AsyncTaskExecutor {
    private AsyncTaskExecutor executor;

    public ExceptionHandlingAsyncTaskExecutor(AsyncTaskExecutor executor) {
        this.executor = executor;

    public void execute(Runnable task) {

    public void execute(Runnable task, long startTimeout) {
        executor.execute(createWrappedRunnable(task), startTimeout);

    public Future submit(Runnable task) {
        return executor.submit(createWrappedRunnable(task));

    public  Future submit(final Callable task) {
        return executor.submit(createCallable(task));

    private  Callable createCallable(final Callable task) {
        return new Callable() {
            public T call() throws Exception {
                try {
                } catch (Exception ex) {
                    throw ex;

    private Runnable createWrappedRunnable(final Runnable task) {
        return new Runnable() {
            public void run() {
                try {
                } catch (Exception ex) {

    private void handle(Exception ex) {
        System.err.println("Error during @Async execution: " + ex);

This task executor decorates another task executor and wraps all Runnables and Callables in versions which handle the exception. In order to be able to use this task executor it has to be configured in the Spring application context as a managed bean and it has to be passed the real executor (the one that does the actual work) in its constructor. An example of such a configuration can be found bellow.


JUnit testing

In the application context used for JUnit testing Spring beans the asynchronous execution of methods can be cumbersome. You typically want to validate the inner workings of your methods not Springs asynchronicity. To achieve this you can use the SyncTaskExecutor provided by Spring. This task executor runs the tasks it is given immediately on the thread that adds the task instead of using a thread pool and running the tasks asynchronous. This task executor is configured in the test scope application context as follows.

Last Updated on Sunday, 26 January 2014 09:12

Page 3 of 4


Latest Comments

Recently played

My apps

Who's Online

We have 62 guests online