Re: [Simple-support] RegistryStrategy causes NPE when Converter is used
Brought to you by:
niallg
|
From: Shevek <sh...@an...> - 2012-05-07 04:35:36
|
On Sun, 2012-05-06 at 20:24 -0700, Shevek wrote: > Test case is a bit tangled, but I can provide it if the explanation > below isn't sufficient: > > * Interface Value has a method getType() which returns the type of the > value. > > * However ArrayValue implements this to return the type of the element, > not the array type. See TreeStrategy.read() lines circa 105, where > 'actual', not 'expect' is passed to readArray(). > > * This causes RegistryStrategy's read() method to call lookup() with an > element type, and return a Converter when it is actually holding the > array node, not the element node. > > * This causes the Converter to fail, since it gets given the InputNode > for the array itself, not the InputNode for the array element, and so > the attributes expected are not present. > > Possible solutions: > > 1) Pass 'actual', not 'expect' to ArrayValue. This makes ArrayValue > satisfy the contract of Value, but may break things which rely on > ArrayValue being a special case. > > 2) During deserialization, at the point where RegistryStrategy calls > lookup(), make it ignore Value.getType(), since that is invalid, and > rely on the expected type if present. This may still have to use > Value.getType() during serialization... Changing read() to call lookup(type, null) fixes the bug. write() still calls lookup(type, value) S. |