This code executes in the separate thread. To be thread safe (since you are using classes and operations that might be thread safe, like the controller), you should return as result the recovered data from the URL and move all its processing to the done method of the BackgroundTaskListener, that is executed in the UI thread (where you are safe to use the controller again).