From f9b412ebb1f6cca7d30162bfe1a3dd4091fa224b Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 22 Jul 2022 16:43:08 +0530 Subject: [PATCH] Removed changes for FallbackFactory --- .../fileupload/service/FileUploadClient.java | 2 +- .../FileUploadClientFallbackFactory.java | 30 ------------------- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/fileupload/service/FileUploadClientFallbackFactory.java 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