Reuse ObjectMapper in FieldPathPayloadSubsectionExtractor
Closes gh-431
This commit is contained in:
committed by
Andy Wilkinson
parent
d1881c30e2
commit
9bd9fa31dc
@@ -36,6 +36,8 @@ import org.springframework.restdocs.payload.JsonFieldProcessor.ExtractedField;
|
||||
public class FieldPathPayloadSubsectionExtractor
|
||||
implements PayloadSubsectionExtractor<FieldPathPayloadSubsectionExtractor> {
|
||||
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private final String fieldPath;
|
||||
|
||||
private final String subsectionId;
|
||||
@@ -66,7 +68,6 @@ public class FieldPathPayloadSubsectionExtractor
|
||||
|
||||
@Override
|
||||
public byte[] extractSubsection(byte[] payload, MediaType contentType) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
ExtractedField extractedField = new JsonFieldProcessor().extract(
|
||||
this.fieldPath, objectMapper.readValue(payload, Object.class));
|
||||
|
||||
Reference in New Issue
Block a user