diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java index f7f54138de..bb5524c30e 100644 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java +++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClient.java @@ -8,7 +8,7 @@ import org.springframework.web.multipart.MultipartFile; import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig; -@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class, fallbackFactory = FileUploadClientFallbackFactory.class) +@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class) public interface FileUploadClient { @PostMapping(value = "/upload-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) String fileUpload(@RequestPart(value = "file") MultipartFile file); diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java deleted file mode 100644 index 2ccb2709a0..0000000000 --- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.cloud.openfeign.fileupload.service; - -import org.springframework.cloud.openfeign.FallbackFactory; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import com.baeldung.cloud.openfeign.exception.BadRequestException; -import com.baeldung.cloud.openfeign.exception.NotFoundException; - -@Component -public class FileUploadClientFallbackFactory implements FallbackFactory { - @Override - public FileUploadClient create(Throwable cause) { - return new FileUploadClient() { - @Override - public String fileUpload(MultipartFile file) { - if (cause instanceof BadRequestException) { - return "Bad Request!!!"; - } - if (cause instanceof NotFoundException) { - return "Not Found!!!"; - } - if (cause instanceof Exception) { - return "Exception!!!"; - } - return "Successfully Uploaded file!!!"; - } - }; - } -} \ No newline at end of file