Is there a generic issue with AsyncFutureListener and DistributedTask?
Hi,
I am unable to setup an AsyncFutureListener appropriately when using DistributedTask<t, r="">. When using AsyncFutureListener<r> or public void onResult(AsyncResult<r> result) { } this method is never invoked. If I use AsyncFutureListener<t> or public void onResult(AsyncResult<t> result) { T t = result.getResult(); } I can see the system entering onResult (by debugging) but I get ClassCastException when R is not cast-able to T. I workaround this problem by specifying: Object resultObject = result.getResult(); R r = (R) resultObject; but it shouldn't be like this. It seems to me the generics are mixed (bug). Am I doing something wrong?
If you try to do the same with the ExecutorExample from the page http://wiki.gigaspaces.com/wiki/displ... , you'll get the same results.
Just change (in MyTask.java):
public class MyTask implements DistributedTask
If you deploy the space in this situation and run the ExecutorTaskClientMain in async mode, it will not enter the onResult method from ExecutorTaskClientMain. This is because the listener is intended to take the results from the reduce, not the intermediate results. Ok. Then if you change (,to cover up for this): implements AsyncFutureListener<integer> to implements AsyncFutureListener<string> it will make u change the onResult from: public void onResult(AsyncResult<integer> result) { to public void onResult(AsyncResult<string> result) {
In this case you get a ClassCastException(java.lang.Integer cannot be cast to java.lang.String) when you try to do the following: String someString = result.getResult();
Can anyone confirm this? Does this bug really exist?
Kind Regards, despot
p.s.: It would be great if you could make the example log the RuntimeException (with a try catch clause for example) since it never shows it in logs or console. When people try to use it, they want be able to trace the problem if it happens.
Edited by: Despot Jakimovski on Nov 29, 2012 5:55 AM
{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3971]{quote}