Comment 4 for bug 1126496

Revision history for this message
Eric Lambert (elambert) wrote : Re: [Bug 1126496] worker always returns an empty string for Warnings and Exceptions

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://bugs.launchpad.net/bugs/1126496
>
> 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 AbstractGearmanFunction {
>
> @Override
> public GearmanJobResult executeFunction() {
>
> boolean jobResult = false;
>
> RuntimeException re = new RuntimeException("job Failed!");
> String warningMsg = "Test the warning";
>
>
> StringBuffer sb = new StringBuffer(ByteUtils.fromUTF8Bytes((byte[]) this.data));
>
> // tested by throwing an exception but still do not get warnings or exceptions on client side
> // throw re;
>
> GearmanJobResult gjr = new GearmanJobResultImpl(this.jobHandle,
> jobResult, sb.reverse().toString().getBytes(),
> warningMsg.getBytes(), re.toString().getBytes(), 0, 0);
> return gjr;
> }
> }
>
>
> Client:
>
>
> public String reverse(String input) {
> String function = ReverseFunction.class.getCanonicalName();
> String uniqueId = null;
> byte[] data = ByteUtils.toUTF8Bytes(input);
> GearmanJobResult res = null;
> GearmanJob job = GearmanJobImpl.createJob(function, data, uniqueId);
> String value = "";
> String valueWarn = "";
> String valueEx = "";
>
>
> client.submit(job);
>
> try {
> res = job.get();
> if (res.jobSucceeded()){
> value = ByteUtils.fromUTF8Bytes(res.getResults());
> valueEx = ByteUtils.fromUTF8Bytes(res.getExceptions());
> valueWarn = ByteUtils.fromUTF8Bytes(res.getWarnings());
> } else {
> value = ByteUtils.fromUTF8Bytes(res.getResults());
> valueEx = ByteUtils.fromUTF8Bytes(res.getExceptions());
> valueWarn = ByteUtils.fromUTF8Bytes(res.getWarnings());
>
> }
> } catch (Exception e) {
> e.printStackTrace(); //NOPMD
> }
>
> String resultMsg = value.toString()+","+valueWarn.toString()+","+valueEx.toString();
> return resultMsg; // never get anything for res.getWarnings() or res.getExceptions()
> }
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/gearman-java/+bug/1126496/+subscriptions