Title:
serializeJson on ORM entity throws a runtime NullPointerException in some cases.
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Geoffrey Demoulin / Geoffrey Demoulin (Geoffrey Demoulin)
Created: 03/08/2016
Components: Language, Serialization
Versions: 11.0
Failure Type: Crash
Found In Build/Fixed In Build: CF11_Final / 2016
Priority/Frequency: Critical / Some users will encounter
Locale/System: English / Windows 8.1/64bit
Vote Count: 1
Problem Description:
When trying to serialize an ORM entity to Json, a NullPointerException is thrown in specific situations.
To test, I have an extremely simple database with the following tables:
Delivery -> Package <-> PackageOrder -> Order
Delivery:
id
Package:
id
deliveryId
PackageOrder:
orderId
packageId
Order:
id
The Order entity has an extra field computed at runtime (persistent="false") with a custom getter:
property name="hashid" type="string" setter="false" persistent="false";
public string function getHashid(){
return "COMPUTED" & variables.id;
}
When using the following code, the crash happens:
public any function getObjectToSerialize(){
var delivery = entityLoadByPK("Delivery", 1);
var obj = delivery.getPackages()[1].getPackagedOrders()[1].getOrder();
return obj;
}
// Somewhere else:
try{
WriteDump(var=serializeJSON(getObjectToSerialize()), abort=true); // NullPointerException
}catch(any e){
WriteDump(var=e, abort=true);
}
Dumping the entity returned by getObjectToSerialize is working as intended.
The stack is available in the notes below.
Interestingly, deleting the custom getHashid getter will prevent the error from happening.
Steps to Reproduce:
Use the application in the attached zip.
Actual Result:
NullPointerException
Expected Result:
A Json representation of the entity
Any Workarounds:
N/A
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4126264
External Customer Info:
External Company:
External Customer Name: Geoffrey Demoulin
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
- March 09, 2016 00:00:00: 1_test_case.zip
Comments: