GithubHelp home page GithubHelp logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 27, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.