From 2239bb5d28b82c9363d23288d8dd683185343dc0 Mon Sep 17 00:00:00 2001 From: limju Date: Wed, 18 Oct 2023 16:15:43 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20webclient=20timeout=20exception=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=20=20=20=20=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9C=A0=ED=9A=A8=EA=B8=B0=EA=B0=84=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java | 4 +++- .../src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java | 7 ++++--- .../main/java/kr/xit/ens/nice/service/NiceCiService.java | 1 + mens-api/src/main/resources/config/application-ens.yml | 4 ++-- mens-api/src/main/resources/config/application-local.yml | 6 ++++++ .../egovframework/messages/message-api.properties | 3 +++ .../java/kr/xit/core/spring/util/error/ErrorParse.java | 7 +++++-- 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java b/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java index 73ba04c..7b7a738 100644 --- a/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java +++ b/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java @@ -1,6 +1,7 @@ package kr.xit.ens.kt.cmm; import egovframework.com.cmm.EgovMessageSource; +import java.util.Objects; import kr.xit.biz.cmm.service.ICmmEnsCacheService; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; @@ -55,7 +56,8 @@ public class CmmKtMmsUtils { if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info")); // 토큰 유효기간 체크 - if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo(dto.getKtTokenExpiresIn()) < 0) return dto; + if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo( + Objects.requireNonNull(dto.getKtTokenExpiresIn(), () -> messageSource.getMessage("fail.api.kt.token.invalid.expired"))) < 0) return dto; ktMmsService.requestToken( KtMnsRequest.builder() diff --git a/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java b/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java index 5b9f755..8670903 100644 --- a/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java @@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import kr.xit.biz.cmm.service.ICmmEnsCacheService; import kr.xit.biz.common.ApiConstants.NiceCiWrkDiv; import kr.xit.biz.ens.model.nice.NiceCiDTO.CommonResponseDataBody; @@ -78,8 +79,7 @@ public class CmmNiceCiUtils { final NiceCiInfo niceDTO = getNiceCiInfo(reqDTO); if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info")); - if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getValidDtim()) < 0) return niceDTO; - + if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(Objects.requireNonNull(niceDTO.getValidDtim(), () -> messageSource.getMessage("fail.api.nice.token.invalid.expired"))) < 0) return niceDTO; // 1. 토큰 폐기 TokenRevokeResponse revokeResDTO = bizNiceService.revokeToken(reqDTO); @@ -106,7 +106,8 @@ public class CmmNiceCiUtils { */ public static NiceCiInfo getSymkeyNiceCiInfo(final NiceCiRequest reqDTO) { final NiceCiInfo niceDTO = getPublickeyNiceCiInfo(reqDTO); - if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getCurSymkeyValidDtim()) < 0) return niceDTO; + if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo( + Objects.requireNonNull(niceDTO.getCurSymkeyValidDtim(), () -> messageSource.getMessage("fail.api.nice.symkey.invalid.expired"))) < 0) return niceDTO; // 대칭키 발행 등록 //TODO::에러 처리 - throw exception diff --git a/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java index eb9e3dc..14e2760 100644 --- a/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java @@ -235,6 +235,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer final IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() .siteCode(niceDTO.getSiteCode()) //.infoReqType() //default: 1-CI제공 + .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) .juminId(reqDTO.getJuminId()) .reqNo(CmmEnsUtils.generateLengthUuid(30)) diff --git a/mens-api/src/main/resources/config/application-ens.yml b/mens-api/src/main/resources/config/application-ens.yml index bedd55e..798009f 100644 --- a/mens-api/src/main/resources/config/application-ens.yml +++ b/mens-api/src/main/resources/config/application-ens.yml @@ -4,8 +4,8 @@ contract: # milisecond connection: - timeout: 30000 - readTimeout: 30000 + timeout: 20000 + readTimeout: 20000 thread: # 동시 실행 스레드 개수 corePoolSize: 5 diff --git a/mens-api/src/main/resources/config/application-local.yml b/mens-api/src/main/resources/config/application-local.yml index 220deaf..9c23716 100644 --- a/mens-api/src/main/resources/config/application-local.yml +++ b/mens-api/src/main/resources/config/application-local.yml @@ -105,3 +105,9 @@ app: rcv: /rcv backup: /backup err: /err + +contract: + # milisecond + connection: + timeout: 60000 + readTimeout: 60000 diff --git a/mens-api/src/main/resources/egovframework/messages/message-api.properties b/mens-api/src/main/resources/egovframework/messages/message-api.properties index 1294452..85b37cd 100644 --- a/mens-api/src/main/resources/egovframework/messages/message-api.properties +++ b/mens-api/src/main/resources/egovframework/messages/message-api.properties @@ -5,9 +5,12 @@ fail.api.nice.info=NICE \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5 fail.api.nice.token.info=NICE Access token \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4 fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58) +fail.api.nice.token.invalid.expired=Nice token \uC720\uD6A8\uAE30\uAC04\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4[null]. +fail.api.nice.symkey.invalid.expired=Nice \uB300\uCE6D\uD0A4 \uC720\uD6A8\uAE30\uAC04\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4[null]. fail.api.rlaybsnm.info=\uBB38\uC11C\uC911\uACC4\uC790 \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.api.kt.token.request=KT \uD1A0\uD070 \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. +fail.api.kt.token.invalid.expired=kt access token \uC720\uD6A8\uAE30\uAC04\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4[null]. err.api.nice.pubKey.0000=\uACF5\uAC1C\uD0A4\uBC1C\uAE09 err.api.nice.pubKey.0001=\uD544\uC218 \uC785\uB825\uAC12 \uC624\uB958 diff --git a/mens-core/src/main/java/kr/xit/core/spring/util/error/ErrorParse.java b/mens-core/src/main/java/kr/xit/core/spring/util/error/ErrorParse.java index a6c6b06..e47b960 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/util/error/ErrorParse.java +++ b/mens-core/src/main/java/kr/xit/core/spring/util/error/ErrorParse.java @@ -40,13 +40,11 @@ public class ErrorParse { if(e instanceof ClientError) { ClientError ce = (ClientError)e; return ApiResponseDTO.error(String.valueOf(ce.getStatus()), ce.getBody(), ce.getStatus()); - //return ApiResponseDTO.error(String.valueOf(ce.getStatus().value()), ce.getBody(), ce.getStatus()); } if(e instanceof ServerError) { ServerError ce = (ServerError) e; return ApiResponseDTO.error(String.valueOf(ce.getStatus()), ce.getBody(), ce.getStatus()); - //return ApiResponseDTO.error(String.valueOf(ce.getStatus().value()), ce.getBody(), ce.getStatus()); } // Async(React) Exception 처리 @@ -67,6 +65,10 @@ public class ErrorParse { } } + if(e instanceof ReadTimeoutException){ + return getTimeoutException(); + } + // Async(React) Exception 처리 if(e.getCause() instanceof WebClientRequestException){ @@ -84,6 +86,7 @@ public class ErrorParse { return ApiResponseDTO.error(errCode, message, httpStatus); } + @SuppressWarnings("rawtypes") private static ApiResponseDTO getTimeoutException(){ return ApiResponseDTO.error( String.valueOf(HttpStatus.REQUEST_TIMEOUT.value()),