Quantcast
Channel: Adobe Community : Discussion List - ColdFusion
Viewing all articles
Browse latest Browse all 6243

NULL POINTER error when using ObjectLoad(ObjectSave())

$
0
0

Hi there.  I've already posted this up on stackoverflow, but thought it might be worth posting here too in case anyone here had some information.  The SO link is http://stackoverflow.com/questions/16103089/null-pointer-error-when-us ing-objectloadobjectsave


I've been having a problem with CF9 and NULL POINTER errors that do not appear to be an issue within Railo. I created a simple CFC and associated mxunit unit test to confirm this with.

 

On Railo (4.0.4) both unit tests pass. On Coldfusion (9.0.1), the unit test getMetaDataBeforeMethodInvocation fails with NULL POINTER error on the GetMetaData call.

 

At present I can only surmise that CF9 does not have access to the full metadata following ObjectLoad until a method within that component is called. Is anyone able to shed more light on this problem, and/or offer a better solution than to ensure that a method within the object is called prior to doing getMetaData?

 

Here is the CFC

 

// NullError.cfc
component
{
   
publicNullErrorfunction init(){
        variables
.uuid =CreateUUID();
       
returnthis;
   
}
   
publicstringfunction getUUID(){
       
return uuid;
   
}
}

 

and associated unit test

 

// NullErrorTest.cfc
component
extends='mxunit.framework.TestCase'{
   
private any function setupTheTests(){
       
var o =newNullError();
        debug
(o.getUUID());
       
// Dump meta data
        debug
(GetMetaData(o));
       
// Save and load it, and return
       
returnObjectLoad(ObjectSave(o));
   
}

   
publicvoidfunction getMetaDataBeforeMethodInvocation(){
       
var o = setupTheTests();
       
// Get meta data, and then get uuid, expecting this to ERROR (NULL POINTER)
        debug
(GetMetaData(o));// CF FAILS HERE, RAILO DOES NOT
        debug
(o.getUUID());
   
}

   
publicvoidfunction getMetaDataAfterMethodInvocation(){
       
var o = setupTheTests();
       
// Get uuid, and then get meta data, expecting this to be ok
        debug
(o.getUUID());
        debug
(GetMetaData(o));
   
}
}


Viewing all articles
Browse latest Browse all 6243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>