I have encountered a strange behaviour, and it is not clear for me if it
is a bug or I have just skipped an important part in the documentation.
When I create an IList instance, put some mutable object in it and
change its value, it is not reflected in the stored IList.
Here's an example what I mean:
// Some dummy wrapper class
class MyMutableWrapper implements Serializable {
private static final long serialVersionUID = 1L;
int value = 0;
public int getValue() {
return value;
}
public void setValue(final int value) {
this.value = value;
}
}
What I would like to do is something like the following:
final IList<MyMutableWrapper> list = hazelcast.getList( "updatedList" );
for (int i = 0; i < 10; ++i) {
list.add( new MyMutableWrapper() );
}
// Before setting, should be 000...0
list.get( 4 ).setValue( 1 );
// After update, should be 0001000...0
// Check if update was successful
assertEquals( 1, list.get( 4 ).getValue() );
A strange thing is that this is working if I'm using only one Hazelcast
instance. Should I use some sort of explicit synchronization in this
particular case or something?
I would thank anyone a small clarification in the subject. Any pointers
or references to the documentation is more than welcome.
A workaround for my case is to replace the element with a new
MyMutableWrapper instance (containing the updated state), it seems
working; although I would like to understand what's going on here.
I've also attached a small test case that reproduces the problem. I'm
not sure but I think the same stands for IMap as well.
Thank you all in advance!
All the best,
Richard
--
Richard O. Legendi
PhD Student
E�tv�s Lor�nd University, Faculty of Informatics
Department of Programming Languages and Compilers
http://people.inf.elte.hu/legendi/
MyMutableWrapper item = list.get(4); // get the copy
item.setValue(1); // update the copy
list.set(4, item); // put it back.
Same goes for all other distributed data structures.
> Eötvös Loránd University, Faculty of Informatics
> Department of Programming Languages and Compilers
> http://people.inf.elte.hu/legendi/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hazelcast" group.
> To post to this group, send email to haze...@googlegroups.com.
> To unsubscribe from this group, send email to
> hazelcast+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hazelcast?hl=en.
>
>
Best,
Richard
--
Richard O. Legendi
PhD Student
E�tv�s Lor�nd University, Faculty of Informatics
Department of Programming Languages and Compilers
http://people.inf.elte.hu/legendi/
>> E�tv�s Lor�nd University, Faculty of Informatics