JPPF Issue Tracker
Please log in to bookmark issues
CLOSED  Bug report JPPF-482  -  Kryo serialization uses wrong class loader upon deserialization
Posted Dec 29, 2016 - updated Dec 30, 2016
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
  • Assigned to
  • Progress
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
  • Owned by
    Not owned by anyone
  • Category
  • Resolution
  • Priority
  • Reproducability
  • Severity
  • Targetted for
    icon_milestones.png JPPF 5.2.4
Issue description
From this forums post. We found evidence that Kryo instances cache a mapping of class name to class object, causing class objects from the same class loader to always be used and preventing classes with the same name but from a new class laoder from being used.
Steps to reproduce this issue
In a simple 1 server + 1 node grid configured for Kryo serialization, submit tasks like this:
public class MyTask extends AbstractTask<String> {
  private static int myfield = 1;
  public void run() {
    setResult(String.format("myfield = %d", myfield));
then run a client application to submit a job with one instance of the task, like this:
public class TestKryo {
  public static void main(final String[] args) {
    JPPFConfiguration.set(JPPFProperties.OBJECT_SERIALIZATION_CLASS, "org.jppf.serialization.kryo.KryoSerialization");
    try (JPPFClient client = new JPPFClient()) {
      JPPFJob job = new JPPFJob();
      job.add(new MyTask());
      Task<?> task = client.submitJob(job).get(0);
      if (task.getThrowable() != null) System.out.println("got exception: " + ExceptionUtils.getStackTrace(task.getThrowable()));
      else System.out.println("result: " + task.getResult());
    } catch (Exception e) {
==> this will output "result: myfield = 1"

Then change the value of "myfield" to 2 in the task code, and run the client application a 2nd time: the output still shows "myfield = 1", indicating that the new version of the class was not used.

Comment posted by
Dec 30, 08:46
Fixed in: