Skip to content

Bug when serializing resources with HalEmbeddedBuilder #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

chringwer
Copy link

I encountered a bug in HalEmbeddedBuilder. Adding more than 2 values with the same reltype to an embedded collection will result in somthing like this:

  "_embedded" : {
    "listItem" : {
      "label" : "lorem",
      "_links" : {
        "self" : {
          "href" : "http://localhost:3000/rest/lists/lorem"
        }
      }
    },
    "listItems" : [ {
      "label" : "ipsum",
      "_links" : {
        "self" : {
          "href" : "http://localhost:3000/rest/lists/ipsum"
        }
      }
    }, {
      "label" : "dolor",
      "_links" : {
        "self" : {
          "href" : "http://localhost:3000/rest/lists/dolor"
        }
      }
    } ]
  }

A fourth item would be merged with the single listItem and then replace the collection and so on...

@chringwer
Copy link
Author

There is another bug occurring when serializing a Resources collection containing mixed resource types. The appropriate JsonSerializer instance in OptionalListJackson2Serializer was retrieved only for the first element's type and then cached for the whole process. I pushed a another commit fixing this issue.

@Laures
Copy link
Contributor

Laures commented Dec 6, 2013

@olivergierke can we merge this soon?

@gregorriegler
Copy link

please. i need this. its critical for my project -_-

@gregorriegler
Copy link

@olivergierke
i suggest to improve this project further towards the Open-Closed principle. Everything is tightly coupled.


//inside HypermediaSupportBeanDefinitionRegistrar

registerWithGeneratedName(new RootBeanDefinition(Jackson2ModuleRegisteringBeanPostProcessor.class), registry);

//inside serializer

HalEmbeddedBuilder builder = new HalEmbeddedBuilder(relProvider);

thus i am not able to replace the HalEmbeddedBuilder with a customized or "corrected" version as a "user"

@@ -366,7 +373,8 @@ private void serializeContents(Iterator<?> value, JsonGenerator jgen, Serializer
*/
@Override
public JsonSerializer<?> getContentSerializer() {
return serializer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that make sense here? It seems we're now arbitrarily picking a serializer to return it, don't we?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that it is just as "random" as it was befor (the type of the first item is not less random)

@odrotbohm
Copy link
Member

@gregorriegler Let's try to keep tickets focused on a single change (SRP). Feel free to open a new one and suggest changes.

@gregorriegler
Copy link

@olivergierke good point. yes, of course. ill might even do that in the near future ;-)

@drdamour
Copy link

drdamour commented May 6, 2014

i believe this can be closed

@odrotbohm odrotbohm closed this Jun 30, 2014
@odrotbohm
Copy link
Member

This is working in current versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants