fix Sonar critical issue - Define constant instead of duplicating the literal

This commit is contained in:
atayal
2021-10-30 23:23:05 +05:30
parent 61a50f50dd
commit 68ffdb6e28

View File

@ -91,6 +91,7 @@ public class Commander {
//we could also have another db where it stores all orders //we could also have another db where it stores all orders
private static final String ORDER = "Order "; private static final String ORDER = "Order ";
private static final String ERROR_CONNECTING_MSG_SVC = ": Error in connecting to messaging service ";
Commander(EmployeeHandle empDb, PaymentService paymentService, ShippingService shippingService, Commander(EmployeeHandle empDb, PaymentService paymentService, ShippingService shippingService,
MessagingService messagingService, QueueDatabase qdb, int numOfRetries, MessagingService messagingService, QueueDatabase qdb, int numOfRetries,
@ -366,7 +367,7 @@ public class Commander {
return (l) -> { return (l) -> {
if (!l.isEmpty()) { if (!l.isEmpty()) {
if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) { if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) {
LOG.debug(ORDER + order.id + ": Error in connecting to messaging service " LOG.debug(ORDER + order.id + ERROR_CONNECTING_MSG_SVC
+ "(Payment Success msg), trying again.."); + "(Payment Success msg), trying again..");
} else { } else {
LOG.debug(ORDER + order.id + ": Error in creating Payment Success" LOG.debug(ORDER + order.id + ": Error in creating Payment Success"
@ -423,7 +424,7 @@ public class Commander {
private void handlePaymentFailureRetryOperation(Order order, List<Exception> l) throws Exception { private void handlePaymentFailureRetryOperation(Order order, List<Exception> l) throws Exception {
if (!l.isEmpty()) { if (!l.isEmpty()) {
if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) { if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) {
LOG.debug(ORDER + order.id + ": Error in connecting to messaging service " LOG.debug(ORDER + order.id + ERROR_CONNECTING_MSG_SVC
+ "(Payment Failure msg), trying again.."); + "(Payment Failure msg), trying again..");
} else { } else {
LOG.debug(ORDER + order.id + ": Error in creating Payment Failure" LOG.debug(ORDER + order.id + ": Error in creating Payment Failure"
@ -480,7 +481,7 @@ public class Commander {
throws Exception { throws Exception {
if (!l.isEmpty()) { if (!l.isEmpty()) {
if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) { if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) {
LOG.debug(ORDER + order.id + ": Error in connecting to messaging service " LOG.debug(ORDER + order.id + ERROR_CONNECTING_MSG_SVC
+ "(Payment Error msg), trying again.."); + "(Payment Error msg), trying again..");
} else { } else {
LOG.debug(ORDER + order.id + ": Error in creating Payment Error" LOG.debug(ORDER + order.id + ": Error in creating Payment Error"