spring-projects / spring-projects/spring-data-rest

Infinite recursion when HTTP header is Accept:application/vnd+json [DATAREST-734]

Open
#1,092 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Raggie Sui opened DATAREST-734 and commented

Hi there,
In STS, I follow menu File/New/Import Getting Started Content, choose project Accessing Data Rest, then click Finish.
Then I run the gs-accessing-data-rest-complete project, and add(POST) one record to the people. When I send to the server with request as follow:

GET /people HTTP/1.1
Host: localhost:8080
Content-Type: application/json;charset=UTF-8
*Accept: application/vnd+json*
Cache-Control: no-cache

the server come into Infinite recursion and report these exception:

at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693) ~[jackson-databind-2.6.4.jar:2.6.4]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675) ~[jackson-databind-2.6.4.jar:2.6.4].
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:693) ~[jackson-databind-2.6.4.jar:2.6.4]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675) ~[jackson-databind-2.6.4.jar:2.6.4].

I debug into the BeanPropertyWriter and BeanSerializerBase, and get the content of output buffer of the JsonGenerator, as follow:

{
  "links" : [ {
    "rel" : "self",
    "href" : "http://localhost:8080/people"
  }, {
    "rel" : "profile",
    "href" : "http://localhost:8080/profile/people"
  }, {
    "rel" : "search",
    "href" : "http://localhost:8080/people/search"
  } ],
  "content" : [ {
    "firstName" : "John",
    "lastName" : "Smith",
    "embeddeds" : {
      "content" : [ ]
    },
    "propertyAccessor" : {
      "bean" : {
        "firstName" : "John",
        "lastName" : "Smith"
      }
    },
    "persistentEntity" : {
      "idProperty" : {
        "name" : "id",
        "rawType" : "long",
        "field" : {
          "name" : "id",
          "type" : "long",
          "modifiers" : 2,
          "annotations" : [ { }, { } ],
          "declaredAnnotations" : [ { }, { } ],
          "synthetic" : false,
          "declaringClass" : "hello.Person",
          "enumConstant" : false,
          "genericType" : "long",
          "accessible" : true
        },
        "association" : false,
        "owner" : {
          "idProperty" : {
            "name" : "id",
            "rawType" : "long",
            "field" : {
              "name" : "id",
              "type" : "long",
              "modifiers" : 2,
              "annotations" : [ { }, { } ],
              "declaredAnnotations" : [ { }, { } ],
              "synthetic" : false,
              "declaringClass" : "hello.Person",
              "enumConstant" : false,
              "genericType" : "long",
              "accessible" : true
            },
            "association" : false,
            "owner" : {
              "idProperty" : {
                "name" : "id",
                "rawType" : "long",
                "field" : {
                  "name" : "id",
                  "type" : "long",
                  "modifiers" : 2,
                  "annotations" : [ { }, { } ],
                  "declaredAnnotations" : [ { }, { } ],
                  "synthetic" : false,
                  "declaringClass" : "hello.Person",
                  "enumConstant" : false,
                  "genericType" : "long",
                  "accessible" : true
                },
                "association" : false,
                "owner" : {
                  "idProperty" : {
                    "name" : "id",
                    "rawType" : "lon...

It looks like the IdProperty take itself as its owner, I guess.

BTW, it goes well when use Accept: application/hal+json

thanks & regards


Affects: 2.4.2 (Gosling SR2)

2 votes, 5 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.