JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report JPPF-49  -  JPPFTask.getTaskObject() should not return null
Posted Aug 25, 2012 - updated Dec 27, 2014
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Closed
  • Assigned to
     lolo4j
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     lolo4j
  • Owned by
    Not owned by anyone
  • Category
    Core
  • Resolution
    RESOLVED
  • Priority
    Normal
  • Reproducability
    Always
  • Severity
    Normal
  • Targetted for
    icon_milestones.png JPPF 3.1.x
Issue description
JPPFTask.getTaskObject() is used when a uer submits a task that is not a subclass of JPPFTask, to get the actual task object submitted by the user.

For tasks that are subclasses of JPPFTask, the method returns null. This causes an incovenience in terms of coding, since you have to check for nullity if you need to perform operations on a task (on the node-side for instance), regardless the way it was submitted. You have to code things like this:
JPPFTask task = ...;
Object taskObject = task.getTaskObject();
if (taskObject == null) {
  // do something with 'task'
} else {
  // do something with 'taskObject'
}
Instead, by default JPPFask.getTaskObject() should return the task instance itself:
public Object getTaskObject() {
  return this;
}
Steps to reproduce this issue
1) Create a task that is a subclass of JPPFTask:
public static class MyTask extends JPPFTask {
  @Override
  public void run() {
    // task code here
  }
}
2) Add this task to a JPPFJob and print its getTaskObject():
JPPFJob job = new JPPFJob();
JPPFTask task = job.addTask(new MyTask());
System.out.println("task object = " + task.getTaskObject());
3) The print will show a null task object


#8
Comment posted by
 lolo4j
Aug 26, 10:23
Fixed. Changes committed to SVN:

The issue was updated with the following change(s):
  • This issue has been closed
  • The status has been updated, from New to Closed.
  • This issue's progression has been updated to 100 percent completed.
  • The resolution has been updated, from Not determined to RESOLVED.
  • Information about the user working on this issue has been changed, from lolo4j to Not being worked on.
  • Time spent on this issue, from No time spent to 1 day, 3 hours.