diff --git a/build.gradle b/build.gradle index 3b9103d4..7a4abdcb 100644 --- a/build.gradle +++ b/build.gradle @@ -207,3 +207,7 @@ tasks.named("dependencyUpdates").configure { isNonStable(it.candidate.version) } } + +pmd { + sourceSets = [sourceSets.main] +} diff --git a/src/main/java/org/radarbase/appserver/exception/EmailMessageTransmitException.java b/src/main/java/org/radarbase/appserver/exception/EmailMessageTransmitException.java index 10e694fb..cb621fe2 100644 --- a/src/main/java/org/radarbase/appserver/exception/EmailMessageTransmitException.java +++ b/src/main/java/org/radarbase/appserver/exception/EmailMessageTransmitException.java @@ -1,6 +1,9 @@ package org.radarbase.appserver.exception; public class EmailMessageTransmitException extends MessageTransmitException { + + private static final long serialVersionUID = -1927189245766939L; + public EmailMessageTransmitException(String message) { super(message); } diff --git a/src/main/java/org/radarbase/appserver/exception/FcmMessageTransmitException.java b/src/main/java/org/radarbase/appserver/exception/FcmMessageTransmitException.java index 547b0b70..f085bedb 100644 --- a/src/main/java/org/radarbase/appserver/exception/FcmMessageTransmitException.java +++ b/src/main/java/org/radarbase/appserver/exception/FcmMessageTransmitException.java @@ -1,6 +1,9 @@ package org.radarbase.appserver.exception; public class FcmMessageTransmitException extends MessageTransmitException { + + private static final long serialVersionUID = -923871442166939L; + public FcmMessageTransmitException(String message) { super(message); } diff --git a/src/main/java/org/radarbase/appserver/service/scheduler/quartz/MessageJob.java b/src/main/java/org/radarbase/appserver/service/scheduler/quartz/MessageJob.java index 61959918..0b7fe77c 100644 --- a/src/main/java/org/radarbase/appserver/service/scheduler/quartz/MessageJob.java +++ b/src/main/java/org/radarbase/appserver/service/scheduler/quartz/MessageJob.java @@ -34,6 +34,7 @@ import org.radarbase.appserver.service.FcmNotificationService; import org.radarbase.appserver.service.MessageType; import org.radarbase.appserver.service.transmitter.DataMessageTransmitter; +import org.radarbase.appserver.service.transmitter.EmailNotificationTransmitter; import org.radarbase.appserver.service.transmitter.FcmTransmitter; import org.radarbase.appserver.service.transmitter.NotificationTransmitter; @@ -123,17 +124,15 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } catch (Exception e) { log.error("Could not transmit a message", e); throw new JobExecutionException("Could not transmit a message", e); - } finally { - // Here handle the exceptions that occurred while transmitting the message via the - // transmitters. At present, only the FcmTransmitter affects the job execution state. - Optional fcmException = exceptions.stream() - .filter(e -> e instanceof FcmMessageTransmitException) - .findFirst(); - if (fcmException.isPresent()) { - throw new JobExecutionException("Could not transmit a message", fcmException.get()); - } } + // Here handle the exceptions that occurred while transmitting the message via the + // transmitters. At present, only the FcmTransmitter affects the job execution state. + Optional fcmException = exceptions.stream() + .filter(e -> e instanceof FcmMessageTransmitException) + .findFirst(); + if (fcmException.isPresent()) { + throw new JobExecutionException("Could not transmit a message", fcmException.get()); + } } - } diff --git a/src/main/java/org/radarbase/appserver/service/transmitter/FcmTransmitter.java b/src/main/java/org/radarbase/appserver/service/transmitter/FcmTransmitter.java index 8fe4690e..be9ed5f9 100644 --- a/src/main/java/org/radarbase/appserver/service/transmitter/FcmTransmitter.java +++ b/src/main/java/org/radarbase/appserver/service/transmitter/FcmTransmitter.java @@ -27,6 +27,7 @@ @Slf4j @Component +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class FcmTransmitter implements NotificationTransmitter, DataMessageTransmitter { protected static final boolean IS_DELIVERY_RECEIPT_REQUESTED = true;