[messages] [Developers] Problem with SequenceEncoder

bobd bob__davison at hotmail.com
Tue Mar 8 14:51:47 MST 2011


Hi folks,

I created a DynamicProperty with an empty initial value and this causes
an IllegalStateException in Decorator.setState when you try to reload
the module.

I have logged this as bug 3465 with an explanation of how it happens
before searching for similar bugs (sorry) and discovered that there are
quite a few.

This bug is simple to fix, setting the initial value to "" rather than
null will mean that SequenceEncoder will handle it properly.

But there is an underlying problem, Decorator.getState() uses
SequenceEncoder to serializes the state in a maner such that if
myGetState() returns null only one token is created. 
Decorator.setState() on the other hand always requires two tokens.

The general problem seems to be that if a SequenceEncoder is created
with an initial value and that value is null then the first token will
not be created

i.e.  (new SequenceEncoder(nullString, delim)).append(valueString);     
         // creates one token
       (new
SequenceEncoder(delim)).append(nullString).append(valueString);   //
creates two tokens
 
I think that the first behaviour is wrong.

Bob

_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=22122#p22122


More information about the messages mailing list