worker always returns an empty string for Warnings and Exceptions
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| Gearman Java |
Fix Released
|
Undecided
|
Eric Lambert | ||
Bug Description
It looks like the worker always returns an empty string for getExceptions() and getWarnings(). It doesn't matter whether the worker function succeeded or failed.
I used the reverse worker and client examples to test...
Worker:
public class ReverseFunction extends AbstractGearman
@Override
public GearmanJobResult executeFunction() {
boolean jobResult = false;
String warningMsg = "Test the warning";
// tested by throwing an exception but still do not get warnings or exceptions on client side
// throw re;
return gjr;
}
}
Client:
public String reverse(String input) {
String function = ReverseFunction
String uniqueId = null;
byte[] data = ByteUtils.
GearmanJob job = GearmanJobImpl.
String value = "";
String valueWarn = "";
String valueEx = "";
try {
res = job.get();
if (res.jobSucceed
} else {
}
} catch (Exception e) {
}
String resultMsg = value.toString(
return resultMsg; // never get anything for res.getWarnings() or res.getExceptions()
}
My Environment:
using gearman-
Dev machine: Ubuntu SMP Tue Jan 8 21:41:11 UTC 2013 i686 i686 i686 GNU/Linux
gearman server: gearmand ver. 0.27 on Ubuntu SMP Wed Sep 26 21:53:42 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Khai:
I've committed a fix for this. Now if your function throws an exception, the stack trace for that exception should be available by calling getExceptions on the job result --as I write this it occurred to me that perhaps the stack trace is not always what you might want here, let me know if that is an issue.
In case you are interested, the main problem was that by default the Gearman Job Server does not forward WORK_EXCEPTION packets back to the client. This needs to be enabled by the client on a per-connection basis which the client was not doing. As part of this fix, the client now by default will enable this behavior.
Also, if the GearmanJobResult given back to the worker from the function has any warnings, those too should be sent back to the client.
If you have questions about how these work you can either let me know or see the GearmanClientJo
Eric
PS
I refrained from pushing this fix to my maven SNAPSHOT repo as based on our last email exchange it seemed like you might be pulling from SNAPSHOT latest and I wanted to give you a chance to look at this before it appeared in your environment.
Also, assuming no major issues with this patch, i suspect I will be releasing 0.06 soon
Hi Eric. I have verified this fix. It works exactly as i expect. Thanks for the detailed info because i'm experiencing the same problem when I use the python client with this worker. Please do your release so I can pickup from the repo. Thanks!
Snapshot deployed ...
On Mar 5, 2013, at 3:55 PM, Khai Do wrote:
> Hi Eric. I have verified this fix. It works exactly as i expect.
> Thanks for the detailed info because i'm experiencing the same problem
> when I use the python client with this worker. Please do your release
> so I can pickup from the repo. Thanks!
>
> --
> You received this bug notification because you are a bug assignee.
> https:/
>
> Title:
> worker always returns an empty string for Warnings and Exceptions
>
> Status in Gearman Java:
> Fix Committed
>
> Bug description:
> It looks like the worker always returns an empty string for
> getExceptions() and getWarnings(). It doesn't matter whether the
> worker function succeeded or failed.
>
> I used the reverse worker and client examples to test...
>
> Worker:
>
> public class ReverseFunction extends AbstractGearman
>
> @Override
> public GearmanJobResult executeFunction() {
>
> boolean jobResult = false;
>
> RuntimeException re = new RuntimeExceptio
> String warningMsg = "Test the warning";
>
>
> StringBuffer sb = new StringBuffer(
>
> // tested by throwing an exception but still do not get warnings or exceptions on client side
> // throw re;
>
> GearmanJobResult gjr = new GearmanJobResul
> jobResult, sb.reverse(
> warningMsg.
> return gjr;
> }
> }
>
>
> Client:
>
>
> public String reverse(String input) {
> String function = ReverseFunction
> String uniqueId = null;
> byte[] data = ByteUtils.
> GearmanJobResult res = null;
> GearmanJob job = GearmanJobImpl.
> String value = "";
> String valueWarn = "";
> String valueEx = "";
>
>
> client.submit(job);
>
> try {
> res = job.get();
> if (res.jobSucceed
> value = ByteUtils.
> valueEx = ByteUtils.
> valueWarn = ByteUtils.
> } else {
> value = ByteUtils.
> valueEx = ByteUtils.
> valueWarn = ByteUtils.
>
> }
> } catch (Exception e) {
> e.printStackTra
> }
>
> String resultMsg = value.toString(
> return resultMsg; // never get anything for res.getWarnings() or res.getExceptions()
> }
>
> To manage notifications about this bug go to:
> https:/