tianshanxuester / gdata-objectivec-client

Automatically exported from code.google.com/p/gdata-objectivec-client
Other
0 stars 0 forks source link

GDataFeedbase calls setupFromXMLElement twice when init'd with data #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is for gdata-objectivec-client version 1.7.

What steps will reproduce the problem?
1. retrieve an Atom feed with a single Entry
2. Instantiate a GDataFeedBase (or subclass) using feedWithXMLData:
3. Get back a feed with two copies of the Entry

What is the expected output? What do you see instead?

When parsing a feed with a single Entry you get back a feed with two entries 
instead.

Please use labels and text to provide additional information.

In fact when instantiating a GDataFeedBase using feedWithXMLData: the 
GDataFeedBase sets up 
the feed twice; it's only apparent when parsing a feed with a single Entry 
because in that case 
the feed adds the entry rather than just setting the entries (when putting them 
in the 
NSMutableArray).

The flow is essentially as follows:

GDataFeedBase feedWithXMLData:
GDataFeedBase initWithData:
GDataFeedBase initWithData:serviceVersion:ignoreUnknowns:

Here's what the bug pops up.
1. That method calls [super 
initWithXMLElement:parent:serviceVersion:surrogates:shouldIgnoreUnknowns:] , 
which hits 
GDataObject's implementation, which calls initWithElement:parent:. That hits 
GDataFeedBase's 
implementation, which calls setupFromXMLElement: (GDataFeedBase's version).
2. The method then calls setupFromXMLElement: again (unnecessarily, since it's 
already gotten 
called).

The duplicate call doesn't show up because if the feed has more than one entry 
then 
GDataFeedBase's version of setupFromXMLElement: calls setEntries:, which 
overrides the initial 
set of entries on the 2nd call. However, if the feed has only one entry then 
setupFromXMLElement:calls addEntry: and you get a duplicate element.

Removing the second call to setupFromXMLElement: in 
initWithData:serviceVersion:ignoreUnknowns: solved the problem for me.

Original issue reported on code.google.com by drjpierce on 5 Jun 2009 at 7:20

GoogleCodeExporter commented 9 years ago
Great analysis, thanks.

This isn't the usual code path for fetching, but is used for testing and should 
be fixed.

Original comment by gregrobbins on 6 Jun 2009 at 2:28

GoogleCodeExporter commented 9 years ago
Fixed on top-of-trunk.

Original comment by gregrobbins on 20 Jun 2009 at 1:08