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

PATCH returns NPE when it should be a not found [DATAREST-529]

Open
#904 0 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

Luan Nguyen opened DATAREST-529 and commented

Line 156 of PersistentEntityResourceHandlerMethodArgumentResolver.java possibly missed a "throw" statement. I.e. it should be "throw new ResourceNotFoundException();" instead of just "new ResourceNotFoundException();"

Test case:

@Entity
public class Person {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
}
curl -H "Content-Type: application/json" -X PATCH -d '{"name": "John Doe"}' localhost:8080/persons/1000
{"timestamp":1430770675151,"status":500,"error":"Internal Server Error","exception":"java.lang.NullPointerException","message":"No message available"}

No further details from DATAREST-529

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.