diff --git a/pom.xml b/pom.xml
index e611070..7f86ef3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
dev.vality
swag-disputes
- 1.16-063c381-server
+ 1.17-8e552ef-server
dev.vality
@@ -253,7 +253,7 @@
dev.vality
testcontainers-annotations
- 2.0.3
+ 2.0.4
test
diff --git a/src/main/java/dev/vality/disputes/api/controller/ErrorControllerAdvice.java b/src/main/java/dev/vality/disputes/api/controller/ErrorControllerAdvice.java
index c360971..102ac4d 100644
--- a/src/main/java/dev/vality/disputes/api/controller/ErrorControllerAdvice.java
+++ b/src/main/java/dev/vality/disputes/api/controller/ErrorControllerAdvice.java
@@ -3,7 +3,7 @@ package dev.vality.disputes.api.controller;
import dev.vality.disputes.exception.AuthorizationException;
import dev.vality.disputes.exception.NotFoundException;
import dev.vality.disputes.exception.TokenKeeperException;
-import dev.vality.swag.disputes.model.DefaultLogicError;
+import dev.vality.swag.disputes.model.GeneralError;
import jakarta.validation.ConstraintViolationException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -38,8 +38,7 @@ public class ErrorControllerAdvice {
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Object handleInvalidMimeTypeException(InvalidMimeTypeException e) {
log.warn("<- Res [400]: MimeType not valid", e);
- return new DefaultLogicError()
- .code(DefaultLogicError.CodeEnum.INVALIDREQUEST)
+ return new GeneralError()
.message(e.getMessage());
}
@@ -50,17 +49,15 @@ public class ErrorControllerAdvice {
var errorMessage = e.getConstraintViolations().stream()
.map(violation -> violation.getPropertyPath() + ": " + violation.getMessage())
.collect(Collectors.joining(", "));
- return new DefaultLogicError()
- .code(DefaultLogicError.CodeEnum.INVALIDREQUEST)
- .message(errorMessage);
+ return new GeneralError()
+ .message(e.getMessage());
}
@ExceptionHandler({MethodArgumentNotValidException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
log.warn("<- Res [400]: MethodArgument not valid", e);
- return new DefaultLogicError()
- .code(DefaultLogicError.CodeEnum.INVALIDREQUEST)
+ return new GeneralError()
.message(e.getMessage());
}
@@ -68,8 +65,7 @@ public class ErrorControllerAdvice {
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Object handleMissingServletRequestParameterException(MissingServletRequestParameterException e) {
log.warn("<- Res [400]: Missing ServletRequestParameter", e);
- return new DefaultLogicError()
- .code(DefaultLogicError.CodeEnum.INVALIDREQUEST)
+ return new GeneralError()
.message(e.getMessage());
}
diff --git a/src/main/java/dev/vality/disputes/config/ApplicationConfig.java b/src/main/java/dev/vality/disputes/config/ApplicationConfig.java
index acc59c8..46417f9 100644
--- a/src/main/java/dev/vality/disputes/config/ApplicationConfig.java
+++ b/src/main/java/dev/vality/disputes/config/ApplicationConfig.java
@@ -8,7 +8,7 @@ import dev.vality.file.storage.FileStorageSrv;
import dev.vality.token.keeper.TokenAuthenticatorSrv;
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -73,7 +73,7 @@ public class ApplicationConfig {
@Bean
public CloseableHttpClient httpClient() {
- return HttpClientBuilder.create().build();
+ return HttpClients.createDefault();
}
@Bean
diff --git a/src/main/java/dev/vality/disputes/service/external/impl/FileStorageServiceImpl.java b/src/main/java/dev/vality/disputes/service/external/impl/FileStorageServiceImpl.java
index eb65897..48c2c81 100644
--- a/src/main/java/dev/vality/disputes/service/external/impl/FileStorageServiceImpl.java
+++ b/src/main/java/dev/vality/disputes/service/external/impl/FileStorageServiceImpl.java
@@ -11,9 +11,8 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.classic.methods.HttpPut;
+import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.io.entity.HttpEntities;
import org.apache.thrift.TException;
import org.springframework.stereotype.Service;
@@ -41,8 +40,8 @@ public class FileStorageServiceImpl implements FileStorageService {
log.debug("Trying to upload data to file-storage with id: {}", fileDataId);
var requestPut = new HttpPut(result.getUploadUrl());
requestPut.setEntity(HttpEntities.create(data, null));
- var response = httpClient.execute(requestPut);
- checkResponse(fileDataId, response);
+ // execute() делает внутри try-with-resources + закрывает InputStream в EntityUtils.consume(entity)
+ httpClient.execute(requestPut, new BasicHttpClientResponseHandler());
log.debug("File has been successfully uploaded with id: {}", fileDataId);
return fileDataId;
}
@@ -64,13 +63,6 @@ public class FileStorageServiceImpl implements FileStorageService {
}
}
- private void checkResponse(String fileDataId, HttpResponse response) {
- if (response.getCode() != HttpStatus.SC_OK) {
- throw new FileStorageException(String.format(
- "Failed to upload file, fileDataId='%s', response='%s'", fileDataId, response));
- }
- }
-
private Instant getTime() {
return LocalDateTime.now(fileStorageProperties.getTimeZone())
.plusMinutes(fileStorageProperties.getUrlLifeTimeDuration())