Is anybody familiar with the Cascades class in the Engine
namespace? Most of the static Cascade methods on that class all
take a parameter of type object called “anything”. There is
no documentation on what this parameter is supposed to be. Sometimes a LockMode
is passed, sometimes a ReplicationMode and more often then not a null value.
The ActionLockClass will then eventually try and cast “anything” as
LockMode and then call Lock on the event source.
Besides the non descriptive name of “anything”,
the main problem is that eventually a null “anything” makes it to AbstractLockUpgradeEventListener.UpgradeLock,
as requestedLockMode. There
are no null checks on the requestedLockMock and eventually the code will blow
up with a null reference exception if an object graph with cascades is
reassociated to a session.
It looks like adding a null check inside of UpgradeLock
would fix the problem with passing null values as the LockMode, but the upgrade
lock and cascade code has been alive for quite a while, (UpgradeLock was simply
moved from sessionImpl to AbstractLockUpgradeEventListener when the event
framework was inserted), so I’m not sure if this is the correct approach,
since at one point in time passing in null for “anything” seemed
like a good thing to do.
Does anybody really know what “anything” is
supposed to be?