From a836864faceaa34e95e0d6338703797dbf192d9e Mon Sep 17 00:00:00 2001 From: rajesh Date: Tue, 13 May 2025 20:19:43 +0530 Subject: [PATCH] Code Fix. --- .../tendermanagement/dao/AppointmentDao.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/AppointmentDao.java b/src/main/java/net/gepafin/tendermanagement/dao/AppointmentDao.java index 5cfa0fe3..609ab87d 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/AppointmentDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/AppointmentDao.java @@ -181,6 +181,7 @@ public class AppointmentDao { int attempt = 0; boolean success = false; while (attempt < maxRetries && !success) { + attempt++; try { //code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call String authJwtToken = Utils.generateAuthTokenForLoginToOdessa(); @@ -244,16 +245,9 @@ public class AppointmentDao { } catch (IOException e) { log.error("Error parsing JSON response: {}", e.getMessage()); } - if (attempt + 1 < maxRetries) { - regenerateTokenAndSave(hub); - } else { - throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale("Maximum retry attempts reached while trying to login to Odessa.")); - } } catch (Exception e) { log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e); throw new RuntimeException("Authentication failed on Odessa. try again", e); - } finally { - attempt++; } } return null; @@ -436,6 +430,7 @@ public class AppointmentDao { int attempt = 0; boolean success = false; while (attempt < maxRetries && !success) { + attempt++; try { //code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call String authJwtToken = Utils.generateAuthTokenForLoginToOdessa(); @@ -501,16 +496,9 @@ public class AppointmentDao { } catch (IOException e) { log.error("Error parsing JSON response: {}", e.getMessage()); } - if (attempt + 1 < maxRetries) { - regenerateTokenAndSave(hub); - } else { - throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale("Maximum retry attempts reached while trying to login to Odessa.")); - } } catch (Exception e) { log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e); throw new RuntimeException("Authentication failed on Odessa. try again", e); - } finally { - attempt++; } } return null;