FINERACT-942 Added and Enforced EmptyCatchBlock checkstyle

This commit is contained in:
Manthan Surkar
2020-06-14 13:37:08 +02:00
committed by Michael Vorburger ⛑️
parent f2624b584c
commit bc7d75d7b2
11 changed files with 50 additions and 16 deletions
@@ -77,6 +77,9 @@
</module>
<module name="OneStatementPerLine"/>
<module name="EmptyStatement"/>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected|ignore"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="\.printStackTrace?\("/>
<property name="message" value="Line contains printStacktrace()."/>
@@ -184,6 +184,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
throw new GLAccountDisableException();
}
} catch (EmptyResultDataAccessException e) {
LOG.error("Problem encountered in validateForAttachedProduct()",e);
}
}
@@ -32,6 +32,8 @@ import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.PaginationHelper;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -40,7 +42,7 @@ import org.springframework.stereotype.Service;
@Service
public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningEntriesReadPlatformService {
private final static Logger LOG = LoggerFactory.getLogger(ProvisioningEntriesReadPlatformServiceImpl.class);
private final JdbcTemplate jdbcTemplate;
private final PaginationHelper<LoanProductProvisioningEntryData> loanProductProvisioningEntryDataPaginationHelper = new PaginationHelper<>();
@@ -245,7 +247,7 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
try {
data = this.jdbcTemplate.queryForObject(sql1, mapper1, new Object[] {date});
} catch (EmptyResultDataAccessException e) {
LOG.error("Problem occurred in retrieveProvisioningEntryData function",e);
}
return data;
@@ -59,13 +59,15 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
import org.apache.fineract.useradministration.domain.AppUser;
import org.joda.time.LocalDate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@Service
public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements ProvisioningEntriesWritePlatformService {
private final static Logger LOG = LoggerFactory.getLogger(ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl.class);
private final ProvisioningEntriesReadPlatformService provisioningEntriesReadPlatformService;
private final ProvisioningCriteriaReadPlatformService provisioningCriteriaReadPlatformService ;
private final LoanProductRepository loanProductRepository;
@@ -160,7 +162,11 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
//FIXME: Do we need to throw NoProvisioningCriteriaDefinitionFound()?
}
createProvsioningEntry(currentDate, addJournalEntries);
} catch (ProvisioningEntryAlreadyCreatedException peace) {} catch (DataIntegrityViolationException dive) {}
} catch (ProvisioningEntryAlreadyCreatedException peace) {
LOG.error("{}",peace.getDefaultUserMessage());
} catch (DataIntegrityViolationException dive) {
LOG.error("Problem occurred in generateLoanLossProvisioningAmount function",dive);
}
}
@Override
@@ -28,6 +28,8 @@ import org.apache.fineract.infrastructure.campaigns.email.EmailApiConstants;
import org.apache.fineract.infrastructure.campaigns.email.data.EmailMessageWithAttachmentData;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailConfiguration;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailConfigurationRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
@@ -35,7 +37,7 @@ import org.springframework.stereotype.Service;
@Service
public class EmailMessageJobEmailServiceImpl implements EmailMessageJobEmailService {
private final static Logger LOG = LoggerFactory.getLogger(EmailMessageJobEmailServiceImpl.class);
private EmailConfigurationRepository emailConfigurationRepository;
@Autowired
@@ -73,7 +75,7 @@ public class EmailMessageJobEmailServiceImpl implements EmailMessageJobEmailServ
javaMailSenderImpl.send(mimeMessage);
}catch(MessagingException e){
LOG.error("Could not send emai Problem occurred in sendEmailWithAttachment function",e);
}
}
@@ -34,6 +34,8 @@ import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityEx
import org.apache.fineract.portfolio.calendar.domain.CalendarWeekDaysType;
import org.apache.fineract.portfolio.calendar.service.CalendarEnumerations;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
@@ -45,7 +47,7 @@ import org.springframework.web.client.RestTemplate;
@Service
public class SmsCampaignDropdownReadPlatformServiceImpl implements SmsCampaignDropdownReadPlatformService {
private final static Logger LOG = LoggerFactory.getLogger(SmsCampaignDropdownReadPlatformServiceImpl.class);
private final RestTemplate restTemplate;
private final SmsConfigUtils smsConfigUtils ;
@@ -19,6 +19,8 @@
package org.apache.fineract.infrastructure.hooks.processor;
import com.squareup.okhttp.OkHttpClient;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
@@ -65,7 +67,10 @@ public class ProcessorHelper {
try {
ctx = SSLContext.getInstance("TLS");
ctx.init(null, certs, new SecureRandom());
} catch (final java.security.GeneralSecurityException ex) {
} catch (KeyManagementException ex) {
LOG.error("Problem occurred in configureClient function",ex);
} catch (NoSuchAlgorithmException e) {
LOG.error("No Provider supports a TrustManagerFactorySpi implementation for the specified protocol.", e);
}
try {
@@ -79,6 +84,7 @@ public class ProcessorHelper {
client.setHostnameVerifier(hostnameVerifier);
client.setSslSocketFactory(ctx.getSocketFactory());
} catch (final Exception e) {
LOG.error("Problem occurred in configureClient function",e);
}
return client;
@@ -35,13 +35,15 @@ import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.template.service.TemplateMergeService;
import org.apache.fineract.useradministration.domain.AppUser;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import retrofit.Callback;
@Service
public class TwilioHookProcessor implements HookProcessor {
private final static Logger LOG = LoggerFactory.getLogger(TwilioHookProcessor.class);
private final HookConfigurationRepository hookConfigurationRepository;
private final TemplateMergeService templateMergeService;
private final ClientRepositoryWrapper clientRepositoryWrapper;
@@ -140,6 +142,7 @@ public class TwilioHookProcessor implements HookProcessor {
}
}
} catch (IOException e) {
LOG.error("Problem occurred in processUgdTemplate function",e);
}
return json;
}
@@ -20,7 +20,8 @@ package org.apache.fineract.infrastructure.reportmailingjob.helper;
import java.net.InetAddress;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This utility provides methods to either convert an IPv4 address to its long format or a 32bit dotted format.
*
@@ -34,7 +35,8 @@ public class IPv4Helper {
* @return the long format of <code>ipAddress</code>
* @throws IllegalArgumentException if <code>ipAddress</code> is invalid
*/
public static long ipAddressToLong(String ipAddress) {
private final static Logger LOG = LoggerFactory.getLogger(IPv4Helper.class);
public static long ipAddressToLong(String ipAddress) {
if (ipAddress == null || ipAddress.isEmpty()) {
throw new IllegalArgumentException("ip address cannot be null or empty");
}
@@ -126,7 +128,9 @@ public class IPv4Helper {
}
}
catch (Exception exception) { }
catch (Exception exception) {
LOG.error("Problem occurred in applicationIsRunningOnLocalMachine function",exception);
}
return isRunningOnLocalMachine;
}
@@ -33,6 +33,8 @@ import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatf
import org.apache.fineract.useradministration.domain.AppUser;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -43,6 +45,7 @@ public class CashierTransactionDataValidator {
private final TellerManagementReadPlatformService tellerManagementReadPlatformService;
private final JdbcTemplate jdbcTemplate;
private final static Logger LOG = LoggerFactory.getLogger(CashierTransactionDataValidator.class);
@Autowired
public CashierTransactionDataValidator(
@@ -145,7 +148,7 @@ public class CashierTransactionDataValidator {
validateSettleCashAndCashOutTransactions(cashierId,
currencyCode, transactionAmount);
} catch (EmptyResultDataAccessException e) {
LOG.error("Problem occurred in validateOnLoanDisbursal function",e);
}
}
@@ -23,9 +23,11 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.StringTokenizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DateRange {
private final static Logger LOG = LoggerFactory.getLogger(DateRange.class);
private static final String ISO_8601_DATE_PATTERN = "yyy-MM-dd";
private static final String RANGE_DELIMITER = "..";
@@ -70,7 +72,7 @@ public class DateRange {
try {
cal.setTime(sdf.parse(tokenizer.nextToken()));
} catch (ParseException ex) {
LOG.error("Problem occurred in DateRange function Could not parse the date recieved.",ex);
}
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
@@ -83,7 +85,7 @@ public class DateRange {
try {
cal.setTime(sdf.parse(tokenizer.nextToken()));
} catch (ParseException ex) {
LOG.error("Problem occurred in DateRange function Could not parse the date recieved.",ex);
}
}
cal.set(Calendar.HOUR_OF_DAY, 23);