Comments (6)
This is by design.
If you have an empty list, nothing gets serialized from that list.
The concept is about "merging" data on deserialization.
Therefore your list won't be touched because there is nothing to merge from the
serialized bytes.
I suggest you declare your list as:
private List<String> list = new ArrayList<String>();
Its a common javabean convention.
Original comment by [email protected]
on 15 Sep 2010 at 6:38
- Changed state: WontFix
from protostuff-googlecode-exported.
The other solution to this is make the RuntimeSchema.writeTo obtrusive.
E.g when it sees an empty list, it sets it to null.
I'm not entirely sure if this is the way to go.
Original comment by [email protected]
on 15 Sep 2010 at 6:44
from protostuff-googlecode-exported.
I disagree. A list itself is a java object, regardless of it's empty or not.
It would impose too many restrictions on class definitions if empty collections
or any other container class to be instantiated at declaration time.
For example, if you comment out this line in issue 30, the test would fail.
// foo.getList().add("New String");
Original comment by [email protected]
on 15 Sep 2010 at 5:33
from protostuff-googlecode-exported.
A list simply holds the values of the repeated fields. The values are the ones
being serialized and deserialized.
From a java standpoint you are correct. Since java's built-in serialization
also serializes the list that holds the values. It serializes all the objects
while protostuff serializes all the values. That is by design (think protobuf)
Original comment by [email protected]
on 16 Sep 2010 at 3:53
from protostuff-googlecode-exported.
If by design, the design is flawed. User has control over protobuf on what
goes in and what comes out, whereas in protostuff case, one can only hope the
same object comes out as the on goes in. Anything less renders it less useful
for general purpose serialization/deserialization. Also, I found it's a
nuisance that protostuff requires each class to declare a zero argument
constructor, instead of searching for any available constructor.
Original comment by [email protected]
on 16 Sep 2010 at 4:22
from protostuff-googlecode-exported.
Fixed. Simply set the property
-Dprotostuff.runtime.collection_schema_on_repeated_fields ... w/c serializes
the collection itself (even if its empty).
Original comment by [email protected]
on 8 Feb 2011 at 7:54
- Changed state: Fixed
from protostuff-googlecode-exported.
Related Issues (20)
- Would like support for repeated accessors with out "List" appeneded
- Enter one-line summary HOT 2
- getSchema() of java.util.Properties fails HOT 2
- optimize xml format
- Enum alias support
- YamlOutput bug on repeated message fields HOT 1
- Deserializing a message which is protostuff-runtime serialized and has custom class as field HOT 3
- Visual disturbance of @Deprecated annotation HOT 12
- Support for newing object instances on Android 4.3+ devices HOT 2
- ConcurrentLinkedDeque support HOT 1
- Produces uncompilable Java when a field is called "default" HOT 4
- 1.0.7 Build error: ProtoParserTest fails HOT 2
- protostuff-parser and protostuff-compiler disagree on required version of antlr
- Optimize ProtobufOuput for small nested messages (max size of 127) HOT 1
- How can I serialize a negative int32 to the protobuf format using zigzag encoding? HOT 2
- How to Ignore Array of Null Values in JSON
- enums_by_name does not seem to be working using maven plugin
- The value of DataInput.readByte() should not be eof-checked since that method throws EOFException HOT 1
- Wrong output path is generated in Windows for .java files HOT 3
- Unable to parse proto enum containing hex constants HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protostuff-googlecode-exported.