Skip to content

Commit

Permalink
Merge pull request #218 from dbmdz/fix-error-in-error
Browse files Browse the repository at this point in the history
Fixed 404 handling on deletions
  • Loading branch information
clorenz authored Jan 9, 2025
2 parents e63df1f + a39821f commit 80eb3ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Fixed

- A deletion of a nonexistant resource no longer leads to a client error

## [9.4.0](https://github.com/dbmdz/metadata-service/releases/tag/9.4.0) - 2024-12-06

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,14 @@ private HttpRequest createPutRequest(String requestUrl, Object bodyObject)
protected String doDeleteRequestForString(String requestUrl) throws TechnicalException {
HttpRequest req = createDeleteRequest(requestUrl);
try {
HttpResponse<String> response = http.send(req, HttpResponse.BodyHandlers.ofString());
HttpResponse<byte[]> response = http.send(req, HttpResponse.BodyHandlers.ofByteArray());
Integer statusCode = response.statusCode();
if (statusCode >= 400) {
throw HttpErrorDecoder.decode("DELETE " + requestUrl, statusCode, response);
}
String body = response.body();
if (body == null || body.isBlank()) {
// This is the most performant approach for Jackson
final byte[] body = response.body();
if (body == null || body.length == 0) {
return null;
}
String result = mapper.readerFor(String.class).readValue(body);
Expand Down

0 comments on commit 80eb3ea

Please sign in to comment.