Vinayak, Is this because when a new array is created its by reference and not a copy?
Preston On Wed, Aug 8, 2012 at 2:10 AM, Vinayak Borkar <[email protected]> wrote: > Preston, > > > I see some of your code using ArrayBackedValueStorage incorrectly. > > For example, look at this snippet from ValueEqComparisonOperation > > @Override > public boolean operateTimeTime(XSTimePointable timep1, XSTimePointable > timep2, DynamicContext dCtx) > throws SystemException, IOException { > abvs.reset(); > DateTime.getTimezoneDateTime(timep1, dCtx, dOut); > byte[] bytes1 = abvs.getByteArray(); > > abvs.reset(); > DateTime.getTimezoneDateTime(timep2, dCtx, dOut); > byte[] bytes2 = abvs.getByteArray(); > > return XSDateTimePointable.getDayTime(bytes1, 0) == > XSDateTimePointable.getDayTime(bytes2, 0); > } > > > ABVS reuses the byte array when the existing byte array is large enough to > hold the new value. In effect bytes1 and bytes2 will point to the same > byte[] in all likelihood and hence the comparison is wrong. > > I saw some other places that reuse ABVSs and hold the byte array across > resets on the same ABVS. Never do that. > > The class should hold on to two different ABVS objects and use those in the > two places instead of sharing the same ABVS for both the values. > > Vinayak
