• Bug
  • Status: Open
  • 2 Major
  • Resolution:
  • DSO:L1
  • prodmgmt
  • Reporter: ag_rocks
  • August 13, 2009
  • 2
  • Watchers: 4
  • November 02, 2010

Attachments

  • ag_rocks (2.00 k) application/x-zip-compressed project.zip

Description

With Terracotta if you put a Enum key with a value null, and then try to get it using Enum.get(Object) method, it returns a Enum.NULL object and not null. This results in ClassCastException.

This is illustrated by an example below.

I have attached the relevant files to reproduce this issue.

Cache is basically a wrapper class around EnumMap and CACHE is a root.

Run this program two times. First time with the 5th line not commented out and second time when it is commented out, you get ClassCastException.

Basically terracotta does not handle unmaskNull() method in EnumMap.get(Object) properly. Instead of returning a null for a Enum key which has a null value it returns Enum.NULL.

Enum.NULL being a Object type can not be casted to Data type and hence throws ClassCastException.

Comments

Chris Dennis 2009-08-13

I’ve confirmed this with a new test method in the EnumMapTest system test. I’ll check in the changes to the test (with the failing method commented for the moment).

Failure is caused by the NULL marker value being different for each L1 node (its a static member of the EnumMap class) so different node’s NULL markers are not referentially equal. Not sure if this can be fixed without moving to a class adapter for the EnumMap (which would be nice to avoid).

A G 2009-08-13

This problem could be handled if we make java.util.EnumMap.NULL as root but, even after adding it to the tc-config.xml file, I can not see it in the dev console. Do we know why am i not able to make it as root or do we have a work around.

Because of the same reason this problem is visible also when you try to serialize an EnumMap. The writeObject method of EnumMap, gives a call to EntryIterator.getValue(). This inturn tries to compare the NULL object in unmask() and this object being different from the one on the terracotta server, returns NULL Object instead of NULL and hence the serialiyation fails throwing java.io.NotSerializableException.

This problem is evident on eventually all methods of EnumMap which make use of unmaskNull() method of EnumMap. The result is EnumMap is potenially useless with terracotta till we resolve this down.

Tim Eck 2009-08-13

I didn’t try running it, but making that NULL field a root should do the trick. The thing about java.* classes is that they need to be pre-instrumented and places in the dso boot jar.

So to get that root configured in there, you need to run make-boot-jar.[sh bat] -f -w