hayakou / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

NullPointerException in Atom Feed parser for links with empty content #285

Open Ragsboss opened 9 years ago

Ragsboss commented 9 years ago

Stack trace given at the end. When client uses $select and specifies properties of related entities it's possible for the result to have link with empty content. This causes NullPointerException in OData4J

Example atom feed to reproduce the issue <?xml version="1.0" encoding="utf-8"?> <feed xml:base="https://example.com/Repository/Data/MyEntities.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

https://example.com/repository/data/MyEntities.svc/HostReservations
<title type="text">HostReservations</title>
<updated>2015-07-01T23:02:07Z</updated>
<link rel="self" title="HostReservations" href="HostReservations" />
<entry>
    <id>https://example.com/Repository/Data/MyEntities.svc/HostReservations(guid'ccd9482b-43be-40d3-bb54-9711b4b1a41d')</id>
    <category term="Example.ManagementModel.HostReservation" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" title="HostReservation" href="HostReservations(guid'ccd9482b-43be-40d3-bb54-9711b4b1a41d')" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Host" type="application/atom+xml;type=entry" title="Host" href="HostReservations(guid'ccd9482b-43be-40d3-bb54-9711b4b1a41d')/Host">
        <m:inline>
            <entry>
                <id>https://example.com/Repository/Data/MyEntities.svc/Hosts(guid'db2a6b65-fbf8-49fd-8369-6bb95bb83f6e')</id>
                <category term="Example.ManagementModel.Host" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
                <link rel="edit" title="Host" href="Hosts(guid'db2a6b65-fbf8-49fd-8369-6bb95bb83f6e')" />
                <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ManagementEndpoint" type="application/atom+xml;type=entry" title="ManagementEndpoint" href="Hosts(guid'db2a6b65-fbf8-49fd-8369-6bb95bb83f6e')/ManagementEndpoint">
                    <m:inline>
                        <entry>
                            <id>https://example.com/Repository/Data/MyEntities.svc/ManagementEndpoints(guid'ad747230-838c-4e09-8c2c-da5bfe49dbfb')</id>
                            <category term="Example.ManagementModel.ManagementEndpoint" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
                            <link rel="edit" title="ManagementEndpoint" href="ManagementEndpoints(guid'ad747230-838c-4e09-8c2c-da5bfe49dbfb')" />
                            <title />
                            <updated>2015-07-01T23:02:07Z</updated>
                            <author>
                                <name />
                            </author>
                            <content type="application/xml">
                                <m:properties>
                                    <d:ManagementEndpointID m:type="Edm.Guid">ad747230-838c-4e09-8c2c-da5bfe49dbfb/d:ManagementEndpointID
                                /m:properties
                            </content>
                        </entry>
                    /m:inline
                </link>
                <title />
                <updated>2015-07-01T23:02:07Z</updated>
                <author>
                    <name />
                </author>
                <content type="application/xml" />
            </entry>
        /m:inline
    </link>
    <title />
    <updated>2015-07-01T23:02:07Z</updated>
    <author>
        <name />
    </author>
    <content type="application/xml">
        <m:properties>
            <d:HostReservationID m:type="Edm.Guid">ccd9482b-43be-40d3-bb54-9711b4b1a41d/d:HostReservationID
        /m:properties
    </content>
</entry>

java.lang.NullPointerException at org.odata4j.format.xml.AtomFeedFormatParser.parseEntry(AtomFeedFormatParser.java:338) ~[odata4j-core-0.7.0.jar:?] at org.odata4j.format.xml.AtomFeedFormatParser.parseAtomLink(AtomFeedFormatParser.java:266) ~[odata4j-core-0.7.0.jar:?] at org.odata4j.format.xml.AtomFeedFormatParser.parseEntry(AtomFeedFormatParser.java:369) ~[odata4j-core-0.7.0.jar:?] at org.odata4j.format.xml.AtomFeedFormatParser.parseFeed(AtomFeedFormatParser.java:169) ~[odata4j-core-0.7.0.jar:?] at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:157) ~[odata4j-core-0.7.0.jar:?] at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:45) ~[odata4j-core-0.7.0.jar:?]

Ragsboss commented 9 years ago

This is in odata4j version 0.7.0