I have an object containing a list sent from a C# client to a Java server. The serialization with protobuf work perfectly and the object is received perfectly in Java. But the class generated with protoc.exe (can we call it a proto class?) have a list that i can’t modify. Basically, I have to add some values in it before returning it to C#, but when I try to add a value, i have an exception :
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:148)
at java.util.AbstractList.add(AbstractList.java:108)
...
Here’s how i’m adding values:
MyProtoObject.MyResult result = MyProtoObject.MyResut.NewBuilder()
.setId(1)
.setValue(9.135)
.build();
MyObject.getResultList().add(result);
How can i insert values in it?
Ok after regenerating the proto class, it appears some methods was missing (I probably made mistakes in first generation). So now i can add values in the list :
listOfCalculation is a List of results objects
or just :
CalculationResult is a single result object
Thanks to Flavio