Project

General

Profile

Actions

bug #10075

closed

Fix deserialization exception for bytebuddy base hibernate SerializableProxy

Added by Andreas Müller almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Highest
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal
Found in Version:

Description

... this is related to hibernate upgrade to v5.4 (#10067)

This happens when deserializing a org.hibernate.proxy.pojo.bytebuddy.SerializableProxy during ehCache read from disc.

Generally hibernate proxies (org.hibernate.proxy.HibernateProxy) are serialized by using the writeReplace() method which transforms the HibernateProxy into a SerializableProxy. For deserializing the readResolve() method from SerializableProxy is used.

This works for serializing/deserializing during httpInvoker transportation. It also seems to work with the javassist SerializableProxy (org.hibernate.proxy.pojo.javassist.SerializableProxy). But does not work for the bytebuddy version.

The problem occurs during deserialization of bytebuddy.SerializableProxy itself (so still before calling readResolve()). The exact moment when it happens is deserialization of the parameter "Class[] SerializableProxy.identifierSetterMethodParams" which has as content "int" and the net.sf.ehcache.util.PreferredLoaderObjectInputStream used by ehCache uses Class.forName(String name, boolean initialize, ClassLoader loader) for class loading which does not handle primitive types ("this method cannot be used to obtain any of the Class objects representing primitive types").
httpInvoker uses org.springframework.remoting.rmi.CodebaseAwareObjectInputStream.
TODO: check what method spring uses for class loading.

javassist:

It is unclear why we did not observe this problem with javassist under hibernate 5.1. as the javassist.SerializableProxy looks equal in terms of datastructure to be loaded (https://docs.jboss.org/hibernate/orm/5.1/javadocs/org/hibernate/proxy/pojo/javassist/SerializableProxy.html).


Related issues

Related to EDIT - task #10077: upgrade ehcache to 3.xNewAndreas Müller

Actions
Actions #1

Updated by Andreas Müller almost 2 years ago

  • Description updated (diff)
Actions #2

Updated by Andreas Müller almost 2 years ago

it happens in readObject0.readOrdinaryObject.readSerialData.defaultReadFields.readObject0.(TCArray)checkResolve(readArray().readObject0.readClass.readClassDesc.readNonProxyDesc.resolveClass[classDesc.name=int] => catches ClassNotFoundException and handles primitive types in ordinary ObjectInputStream.resolveClass() used e.g. by CodbaseAwareOIS.

The ehCache PreferredLoaderObjectInputStream overrides this method and avoids the handling the primitive types. (The classloader used here is in current context EhCacheDefaultClassLoader by calling Class.forName(desc.getName(), false, loader).

So maybe it is possible to override resolveClass() with the same behaviour as in default ObjectInputStream or to avoid usage of PreferredLoaderObjectInputStream.

Note: default OIS uses latestUserDefinedLoader() which resolves to an EquinoxClassLoader in httpInvoker, but this is not really relevant here.

Actions #3

Updated by Andreas Müller almost 2 years ago

Actions #4

Updated by Andreas Müller almost 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 70
Actions #5

Updated by Andreas Müller almost 2 years ago

Fixed with a workaround by overriding the class net.sf.ehcache.util.PreferredLoaderObjectInputStream which does not correctly load primitive types.

This fix can probably be removed once we move to ehcache 3.x (#10077).

Actions #6

Updated by Andreas Müller almost 2 years ago

  • Assignee changed from Andreas Müller to Katja Luther

Please review.

Actions #7

Updated by Andreas Müller almost 2 years ago

  • Related to feature request #7648: Create taxonrelation to genus or species when subordinate names are created added
Actions #8

Updated by Andreas Müller almost 2 years ago

  • Related to deleted (feature request #7648: Create taxonrelation to genus or species when subordinate names are created)
Actions #9

Updated by Andreas Müller almost 2 years ago

  • Status changed from Resolved to Closed
  • Assignee changed from Katja Luther to Andreas Müller
  • % Done changed from 70 to 100

I think we can close this ticket as the problem did not show up anymore.

Actions

Also available in: Atom PDF