Merge remote-tracking branch 'upstream/develop' into FINCN-180
diff --git a/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java b/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java
index 412ea3c..32452a9 100644
--- a/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java
+++ b/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java
@@ -44,7 +44,6 @@
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;
/**
@@ -53,8 +52,6 @@
@SuppressWarnings("WeakerAccess")
@Service
public class BeatPublisherService {
- private final DiscoveryClient discoveryClient;
-
private final EurekaClient eurekaClient;
private final ApplicationPermissionRequestCreator applicationPermissionRequestCreator;
private final ApplicationAccessTokenService applicationAccessTokenService;
@@ -65,7 +62,6 @@
@Autowired
public BeatPublisherService(
- @SuppressWarnings("SpringJavaAutowiringInspection") final DiscoveryClient discoveryClient,
@SuppressWarnings("SpringJavaAutowiringInspection") final EurekaClient eurekaClient,
@SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationPermissionRequestCreator applicationPermissionRequestCreator,
@SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationAccessTokenService applicationAccessTokenService,
@@ -73,7 +69,6 @@
final ApiFactory apiFactory,
final RhythmProperties properties,
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
- this.discoveryClient = discoveryClient;
this.eurekaClient = eurekaClient;
this.applicationPermissionRequestCreator = applicationPermissionRequestCreator;
this.applicationAccessTokenService = applicationAccessTokenService;
diff --git a/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/Drummer.java b/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/Drummer.java
index e373bf2..b9371b2 100644
--- a/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/Drummer.java
+++ b/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/Drummer.java
@@ -22,6 +22,7 @@
import java.time.LocalDateTime;
import java.util.function.Predicate;
import java.util.stream.Stream;
+
import org.apache.fineract.cn.rhythm.api.v1.domain.ClockOffset;
import org.apache.fineract.cn.rhythm.service.ServiceConstants;
import org.apache.fineract.cn.rhythm.service.internal.mapper.BeatMapper;
@@ -31,7 +32,7 @@
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.dao.InvalidDataAccessResourceUsageException;
+import org.springframework.dao.PessimisticLockingFailureException;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -73,20 +74,20 @@
final Stream<BeatEntity> beats = beatRepository.findByNextBeatBefore(now);
beats.forEach((beat) -> {
final boolean applicationHasRequestForAccessPermission
- = identityPermittableGroupService.checkThatApplicationHasRequestForAccessPermission(
- beat.getTenantIdentifier(), beat.getApplicationIdentifier());
+ = identityPermittableGroupService.checkThatApplicationHasRequestForAccessPermission(
+ beat.getTenantIdentifier(), beat.getApplicationIdentifier());
if (!applicationHasRequestForAccessPermission) {
logger.info("Not checking if beat {} needs publishing, because application access needed to publish is not available.", beat);
}
else {
logger.info("Checking if beat {} needs publishing.", beat);
final LocalDateTime nextBeat = checkBeatForPublish(
- now,
- beat.getBeatIdentifier(),
- beat.getTenantIdentifier(),
- beat.getApplicationIdentifier(),
- beat.getAlignmentHour(),
- beat.getNextBeat());
+ now,
+ beat.getBeatIdentifier(),
+ beat.getTenantIdentifier(),
+ beat.getApplicationIdentifier(),
+ beat.getAlignmentHour(),
+ beat.getNextBeat());
if (!nextBeat.equals(beat.getNextBeat())) {
beat.setNextBeat(nextBeat);
beatRepository.save(beat);
@@ -96,9 +97,13 @@
});
}
- catch (final InvalidDataAccessResourceUsageException e) {
- logger.info("InvalidDataAccessResourceUsageException in check for scheduled beats, probably " +
- "because initialize hasn't been called yet. {}", e);
+ catch (final PessimisticLockingFailureException e) {
+ if (e.getMessage() != null && e.getMessage().contains("relation \"khepri_beats\" does not exist")) {
+ logger.info("Exception in check for scheduled beats as table khepri_beats does not exist. Probably cause initialize hasn't been called yet.");
+ }
+ else {
+ logger.warn("PessimisticLockingFailureException in check for scheduled beats", e);
+ }
}
logger.info("checkForBeatsNeeded end.");
}
@@ -163,4 +168,4 @@
{
return BeatMapper.alignDateTime(toIncrement.plusDays(1), alignmentHour, clockOffset);
}
-}
\ No newline at end of file
+}