JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report JPPF-48  -  Impossible to get the class loader of a Runnable submitted via JPPFExecutorService
Posted Aug 25, 2012 - updated Aug 26, 2012
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
  • Estimated time
    Not estimated
  • Category
    Client
  • Resolution
    RESOLVED
  • Priority
    Normal
  • Reproducability
    Always
  • Severity
    Normal
  • Targetted for
    icon_milestones.png JPPF 3.1.2
Issue description
When a Runnable is submitted via JPPFExecutorService.submit(Runnable), it is not possible to get the corresponding class loader on the node side using a public API. For instance, this happens from a NodeLifeCycleListener implementation.

Steps to reproduce this issue
Using this NodeLifeCycleListener implementation:
public class NodeListener implements NodeLifeCycleListener {
  @Override
  public void nodeStarting(final NodeLifeCycleEvent event) { }
 
  @Override
  public void nodeEnding(final NodeLifeCycleEvent event) { }
 
  @Override
  public void jobStarting(final NodeLifeCycleEvent event) {
    System.out.println("test.NodeListener: job starting");
    JPPFTask task = (JPPFTask) event.getTasks().get(0);
    Class c = task.getClass();
    System.out.println("task=" + task + ", class=" + c + ", classloader=" + c.getClassLoader());
    System.out.println("task object=" + task.getTaskObject());
  }
 
  @Override
  public void jobEnding(final NodeLifeCycleEvent event) { }
}
and this client-side implementation:
public class Main {
  public static void main(final String[] args) {
    JPPFClient client = new JPPFClient();
    JPPFExecutorService executor = new JPPFExecutorService(client);
    try {
      while (!client.hasAvailableConnection()) Thread.sleep(10L);
      List<Future<?>> futures = new ArrayList<Future<?>>();
      futures.add(executor.submit(new MyRunnableTask()));
      futures.get(i).get();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      executor.shutdownNow();
      client.close();
    }
  }
 
  public static class MyRunnableTask implements Runnable, Serializable {
    @Override
    public void run() {
      System.out.println("running MyRunnableTask");
    }
  }
}
When the Runnable is submmitted, it is wrapped into a RunnableWrapper. When the NodeListener attempts to print JPPFTask.getObject(), this will show the RunnableWrapper<T> instance. The problem is that RunnableWrapper doesn't have a public method to get the underlying Runnable, which is the real task submitted by the user.

#7
Comment posted by
 lolo4j
Aug 26, 10:24
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.