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
PersistentEntityResourceHandlerMethodArgumentResolver dump in PUT requests with HashMap [DATAREST-491] #868
Comments
Oliver Drotbohm commented That should be fixed! Thanks for reporting |
José Carlos Valero Sánchez commented I am using spring-data-rest 2.3.0 and It looks like this issue is not resolved. Same NPE in the same place. I'm working with spring data Mongo. For entity: @Document(collection = "formDefinitions")
public class CustomFormDefinition extends AbstractMongoDocument<CustomFormDefinition> {
private String name;
private String description;
private List<AgnosticCustomFieldDefinition> fieldDefinitions;
//public accessors
}
@Configurable
public class AbstractMongoDocument<T> implements Persistable<T>{
@Transient
@Autowired
private transient MongoTemplate mongoTemplate;
@Id
private String id;
@CreatedDate
private LocalDateTime createdDate = LocalDateTime.now();
@LastModifiedDate
public LocalDateTime modifiedDate = LocalDateTime.now();
//public accessors
} And tests @Test
public void fullUpdateShouldChangeAllValues() throws Exception {
cleanableCFD = new CustomFormDefinition();
cleanableCFD.setName("test");
cleanableCFD.setDescription("test desc");
mvc.perform(
put("/form-definitions/" + cleanableCFD.getId())
.content("{\"id\":\""+cleanableCFD.getId()+"\",\"name\":\"updated!!\"}")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful())
;
mvc.perform(get("/form-definitions/" + cleanableCFD.getId()))
.andExpect(jsonPath("$.name", is("updated!!")))
.andExpect(jsonPath("$.description", isEmptyOrNullString()))
.andExpect(status().is2xxSuccessful())
;
}
{{org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class net.pi.components.fds.core.model.CustomFormDefinition from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException |
José Carlos Valero Sánchez commented Oliver, It looks like changing my mongo configuration to inheriting from AbstractMongoConfiguration also workarounded this issue |
José Carlos Valero Sánchez commented As it did https://jira.spring.io/browse/DATAMONGO-1212 in DATAMONGO-1212 |
Sebastian Scheele opened DATAREST-491 and commented
When updating a existing resource with a JSON PUT with this sample code
and JSON
I get the following stack trace:
The reason seems to be that in
DomainObjectReader
thePersistentEntity
for aHashMap
isnull
.This works before DATAREST-461 was included.
You can find a example, to reproduce here https://github.com/sebastian-sch/mongo_data_rest
Affects: 2.2.2 (Evans SR2), 2.3 RC1 (Fowler)
Issue Links:
@JsonIgnored
properties must not be updated in PUT requestsReferenced from: commits 8414b29, f80bebf
Backported to: 2.2.3 (Evans SR3)
The text was updated successfully, but these errors were encountered: