Jens Deppe created GEODE-6559:
---------------------------------

             Summary: PdxInstance.getObject() is using class from older jar  in 
case of Reconnect
                 Key: GEODE-6559
                 URL: https://issues.apache.org/jira/browse/GEODE-6559
             Project: Geode
          Issue Type: Bug
          Components: configuration, management, serialization
            Reporter: Jens Deppe


Given a function as below:


{code:java}
public void execute(FunctionContext context) {

        RegionFunctionContext rctx = (RegionFunctionContext)context;
        Region<Object, Object> dataSet = rctx.getDataSet();
        Object o = ((PdxInstance)context.getArguments()).getObject();
        LogService.getLogger().warn(o.getClass() + " loaded from " + 
getClassLoaderJar(o.getClass()));
        printCallerStack("Function execution called from");
        LogService.getLogger().warn("Thread context classloader is " + 
Thread.currentThread().getContextClassLoader());
        LogService.getLogger().error(this);
        LogService.getLogger().warn(Student.class + " loaded from " + 
getClassLoaderJar(Student.class));
        LogService.getLogger().warn(o.getClass() + " args class parent is " + 
o.getClass().getClassLoader().getParent());
        LogService.getLogger().warn(o.getClass() + " loaded from " + 
getClassLoaderJar(o.getClass()));
        LogService.getLogger().warn(this.getClass() + " loaded from " + 
getClassLoaderJar(this.getClass()));

        Student args = (Student) o;

        LogService.getLogger().warn("args = " + args);

        Integer first = 1;
        Integer second = 2;

        LogService.getLogger().info("Function returning result " + 
this.getClass() + " loaded from " + this.getClass().getClassLoader());

        rctx.getResultSender().lastResult(first * second);
    }
{code}




It works fine in case of normal operations and jar --deploy , but in case of 
auto-reconnect, the below line

{code}
 Object o = ((PdxInstance)context.getArguments()).getObject();
{code}

Loads the class from older jar

{code}
[warning 2019/03/14 14:23:43.420 IST server2 <Function Execution Processor1> 
tid=0x11f] class com.pivotal.support.hot.deploy.Student loaded from 
[file:/Users/rajiv/kumar/gemfire/deployJarTest/server2/deploy.v1.jar]
{code}

Mostly due to the caching in the InternalDeserializer.

Whereas the below

{code}
        Student args = (Student) o;
{code}

Loads the class from the latest jar, for each reconnect attempt the jar is 
downloaded from the locators and the version is increased

{code}
[warning 2019/03/14 14:23:43.426 IST server2 <Function Execution Processor1> 
tid=0x11f] class com.pivotal.support.hot.deploy.Student loaded from 
[file:/Users/rajiv/kumar/gemfire/deployJarTest/server2/deploy.v3.jar]
{code}

This is causing ClassCastExcetpion

{code}
[warning 2019/03/14 14:23:43.426 IST server2 <Function Execution Processor1> 
tid=0x11f] Exception on server while executing function : 
com.pivotal.support.hot.deploy.Multiply@3e484c00
java.lang.ClassCastException: com.pivotal.support.hot.deploy.Student cannot be 
cast to com.pivotal.support.hot.deploy.Student
        at com.pivotal.support.hot.deploy.Multiply.execute(Multiply.java:43)
        at 
org.apache.geode.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:332)
        at 
org.apache.geode.internal.cache.execute.AbstractExecution$1.run(AbstractExecution.java:274)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at 
org.apache.geode.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:665)
        at 
org.apache.geode.distributed.internal.DistributionManager$9$1.run(DistributionManager.java:1111)
        at java.lang.Thread.run(Thread.java:745)
{code}





--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to