Skip to content

Commit

Permalink
Merge remote-tracking branch
Browse files Browse the repository at this point in the history
'origin/issues/137_142_Static_Code_Analysis_Logging_Fix' into develop
  • Loading branch information
hhund committed Dec 16, 2023
2 parents 55ce3d8 + cf61f0d commit bb96a85
Show file tree
Hide file tree
Showing 260 changed files with 1,563 additions and 1,655 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public final void execute(DelegateExecution execution) throws Exception
// Error boundary event, do not stop process execution
catch (BpmnError error)
{
logger.debug("Error while executing service delegate " + getClass().getName(), error);
logger.debug("Error while executing service delegate {}", getClass().getName(), error);
logger.error(
"Process {} encountered error boundary event in step {} for task {}, error-code: {}, message: {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
Expand All @@ -82,7 +82,7 @@ public final void execute(DelegateExecution execution) throws Exception
// Not an error boundary event, stop process execution
catch (Exception exception)
{
logger.debug("Error while executing service delegate " + getClass().getName(), exception);
logger.debug("Error while executing service delegate {}", getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task {}, reason: {} - {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
api.getTaskHelper().getLocalVersionlessAbsoluteUrl(variables.getStartTask()),
Expand Down Expand Up @@ -148,7 +148,9 @@ private void updateAndHandleException(Task task)
}
catch (Exception e)
{
logger.error("Unable to update Task " + api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task), e);
logger.debug("Unable to update Task {}", api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task), e);
logger.error("Unable to update Task {}: {} - {}", api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task),
e.getClass().getName(), e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,20 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw
catch (Exception e)
{
String exceptionMessage = e.getMessage();
if (e instanceof WebApplicationException && (e.getMessage() == null || e.getMessage().isBlank()))
if (e instanceof WebApplicationException w && (e.getMessage() == null || e.getMessage().isBlank()))
{
StatusType statusInfo = ((WebApplicationException) e).getResponse().getStatusInfo();
StatusType statusInfo = w.getResponse().getStatusInfo();
exceptionMessage = statusInfo.getStatusCode() + " " + statusInfo.getReasonPhrase();
}

logger.debug("Error while sending Task", e);
String errorMessage = "Task " + instantiatesCanonical + " send failed [recipient: "
+ target.getOrganizationIdentifierValue() + ", endpoint: " + target.getEndpointIdentifierValue()
+ ", businessKey: " + businessKey
+ (target.getCorrelationKey() == null ? "" : ", correlationKey: " + target.getCorrelationKey())
+ ", message: " + messageName + ", error: " + e.getClass().getName() + " - " + exceptionMessage
+ "]";
logger.warn(errorMessage);
logger.debug("Error while sending Task", e);

if (execution.getBpmnModelElementInstance() instanceof IntermediateThrowEvent)
handleIntermediateThrowEventError(execution, variables, e, errorMessage);
Expand All @@ -227,7 +227,7 @@ else if (execution.getBpmnModelElementInstance() instanceof SendTask)
protected void handleIntermediateThrowEventError(DelegateExecution execution, Variables variables,
Exception exception, String errorMessage)
{
logger.debug("Error while executing Task message send " + getClass().getName(), exception);
logger.debug("Error while executing Task message send {}", getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task {}, reason: {} - {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
api.getTaskHelper().getLocalVersionlessAbsoluteUrl(variables.getStartTask()),
Expand All @@ -242,7 +242,7 @@ protected void handleIntermediateThrowEventError(DelegateExecution execution, Va
protected void handleEndEventError(DelegateExecution execution, Variables variables, Exception exception,
String errorMessage)
{
logger.debug("Error while executing Task message send " + getClass().getName(), exception);
logger.debug("Error while executing Task message send {}", getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task {}, reason: {} - {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
api.getTaskHelper().getLocalVersionlessAbsoluteUrl(variables.getStartTask()),
Expand Down Expand Up @@ -275,8 +275,8 @@ protected void handleSendTaskError(DelegateExecution execution, Variables variab
// if we are not a multi instance message send task or all sends have failed (targets emtpy)
else
{
logger.debug("Error while executing Task message send " + getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task {}, last reason: {} - ",
logger.debug("Error while executing Task message send {}", getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task {}, last reason: {} - {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
api.getTaskHelper().getLocalVersionlessAbsoluteUrl(variables.getStartTask()),
exception.getClass().getName(), exception.getMessage());
Expand Down Expand Up @@ -342,7 +342,9 @@ private void updateAndHandleException(Task task)
}
catch (Exception e)
{
logger.error("Unable to update Task " + api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task), e);
logger.debug("Unable to update Task {}", api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task), e);
logger.error("Unable to update Task {}: {} - {}", api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task),
e.getClass().getName(), e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public final void notify(DelegateTask userTask)
}
catch (Exception exception)
{
logger.debug("Error while executing user task listener " + getClass().getName(), exception);
logger.debug("Error while executing user task listener {}", getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task {}, reason: {} - {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
api.getTaskHelper().getLocalVersionlessAbsoluteUrl(variables.getStartTask()),
Expand Down Expand Up @@ -255,7 +255,9 @@ private void updateAndHandleException(Task task)
}
catch (Exception e)
{
logger.error("Unable to update Task " + api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task), e);
logger.debug("Unable to update Task {}", api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task), e);
logger.error("Unable to update Task {}: {} - {}", api.getTaskHelper().getLocalVersionlessAbsoluteUrl(task),
e.getClass().getName(), e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ private void start(Resource resource) throws Exception
{
FhirWebserviceClient client = createClient(baseUrl);

if (resource instanceof Bundle)
if (resource instanceof Bundle bundle)
{
Bundle bundle = (Bundle) resource;
bundle.getEntry().stream().map(e -> e.getResource().getResourceType()).filter(ResourceType.Task::equals)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Bundle does not contain a Task resource"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import dev.dsf.common.jetty.Log4jInitializer;
import dev.dsf.tools.db.DbMigrator;

public class BpeJettyServer
public final class BpeJettyServer
{
static
{
Expand All @@ -19,6 +19,10 @@ public class BpeJettyServer
Log4jInitializer.initializeLog4j();
}

private BpeJettyServer()
{
}

public static void main(String[] args)
{
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import dev.dsf.common.jetty.Log4jInitializer;
import dev.dsf.tools.db.DbMigrator;

public class BpeJettyServerHttps
public final class BpeJettyServerHttps
{
static
{
Expand All @@ -19,6 +19,10 @@ public class BpeJettyServerHttps
Log4jInitializer.initializeLog4j();
}

private BpeJettyServerHttps()
{
}

public static void main(String[] args)
{
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ else if (value.getValue() != null)
return null;
}

@SuppressWarnings("rawtypes")
private String getName(TypedValue value)
{
if (value == null)
return null;

if (value instanceof PrimitiveValue)
return ((PrimitiveValue) value).getType().getJavaType().getName();
if (value instanceof PrimitiveValue p)
return p.getType().getJavaType().getName();
else if (value.getValue() != null)
return value.getClass().getName();
else if (value.getType() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,16 @@ protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution executi

Object delegateInstance = instantiateDelegate(processKeyAndVersion, className, fieldDeclarations);

if (delegateInstance instanceof ActivityBehavior)
{
return new CustomActivityBehavior((ActivityBehavior) delegateInstance);
}
else if (delegateInstance instanceof JavaDelegate)
{
return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance);
}
if (delegateInstance instanceof ActivityBehavior b)
return new CustomActivityBehavior(b);

else if (delegateInstance instanceof JavaDelegate d)
return new ServiceTaskJavaDelegateActivityBehavior(d);

else
{
throw LOG.missingDelegateParentClassException(delegateInstance.getClass().getName(),
JavaDelegate.class.getName(), ActivityBehavior.class.getName());
}
};
}

private Object instantiateDelegate(ProcessIdAndVersion processKeyAndVersion, String className,
List<FieldDeclaration> fieldDeclarations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,12 @@ protected ExecutionListener getExecutionListenerInstance(ProcessIdAndVersion pro
{
Object delegateInstance = instantiateDelegate(processKeyAndVersion, className, fieldDeclarations);

if (delegateInstance instanceof ExecutionListener)
{
return (ExecutionListener) delegateInstance;
}
if (delegateInstance instanceof ExecutionListener l)
return l;

else
{
throw new ProcessEngineException(
delegateInstance.getClass().getName() + " doesn't implement " + ExecutionListener.class);
}
}

private Object instantiateDelegate(ProcessIdAndVersion processKeyAndVersion, String className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ protected TaskListener getTaskListenerInstance(ProcessIdAndVersion processKeyAnd
{
Object delegateInstance = instantiateDelegate(processKeyAndVersion, className, fieldDeclarations);

if (delegateInstance instanceof TaskListener)
{
return (TaskListener) delegateInstance;
}
if (delegateInstance instanceof TaskListener l)
return l;

else
{
throw new ProcessEngineException(
delegateInstance.getClass().getName() + " doesn't implement " + TaskListener.class);
}
}

private Object instantiateDelegate(ProcessIdAndVersion processKeyAndVersion, String className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ public void disconnectAll()
}
catch (Exception e)
{
logger.warn("Error while disconnecting websocket client", e);
logger.debug("Error while disconnecting websocket client", e);
logger.warn("Error while disconnecting websocket client: {} - {}", e.getClass().getName(),
e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void doNotify(DelegateExecution execution, ListenerVariables variables) t
updateIfInprogress(task);
boolean subProcess = execution.getParentId() != null
&& !execution.getParentId().equals(execution.getProcessInstanceId());
logEnd(logger, subProcess, task, subProcess ? variables.getStartTask() : null);
logEnd(subProcess, task, subProcess ? variables.getStartTask() : null);
}

variables.onEnd();
Expand Down Expand Up @@ -78,11 +78,13 @@ private void updateAndHandleException(Task task)
}
catch (Exception e)
{
logger.error("Unable to update Task " + getLocalVersionlessAbsoluteUrl(task), e);
logger.debug("Unable to update Task {}", getLocalVersionlessAbsoluteUrl(task), e);
logger.error("Unable to update Task {}: {} - {}", getLocalVersionlessAbsoluteUrl(task),
e.getClass().getName(), e.getMessage());
}
}

private void logEnd(Logger logger, boolean subProcess, Task endTask, Task mainTask)
private void logEnd(boolean subProcess, Task endTask, Task mainTask)
{
String processUrl = endTask.getInstantiatesCanonical();
String businessKey = getFirstInputParameter(endTask, BpmnMessage.businessKey());
Expand Down Expand Up @@ -111,7 +113,7 @@ private void logEnd(Logger logger, boolean subProcess, Task endTask, Task mainTa
processUrl, getCurrentTime(), endTaskUrl, requester, businessKey, correlationKey);
else
logger.info("Process {} finished at {} [task: {}, requester: {}, business-key: {}]", processUrl,
getCurrentTime(), endTaskUrl, requester, businessKey, correlationKey);
getCurrentTime(), endTaskUrl, requester, businessKey);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ private Optional<InternetAddress> toInternetAddress(String fromAddress)
}
catch (AddressException e)
{
logger.debug("Unable to create {} from {}", InternetAddress.class.getName(), fromAddress, e);
logger.warn("Unable to create {} from {}: {} - {}", InternetAddress.class.getName(), fromAddress,
e.getClass().getName(), e.getMessage());

Expand Down Expand Up @@ -347,7 +348,9 @@ public SSLSocketFactory createSslSocketFactory(KeyStore trustStore, KeyStore key
}
catch (UnrecoverableKeyException | KeyManagementException | KeyStoreException | NoSuchAlgorithmException e)
{
logger.debug("Unable to create custom ssl socket factory", e);
logger.warn("Unable to create custom ssl socket factory: {} - {}", e.getClass().getName(), e.getMessage());

throw new RuntimeException(e);
}
}
Expand All @@ -372,7 +375,7 @@ private SMIMESignedGenerator createSmimeSignedGenerator(String fromAddress, KeyS
Optional<PrivateKey> pivateKey = getFirstPrivateKey(signStore, signStorePassword);
if (pivateKey.isEmpty())
{
logger.warn("Mail signing certificate store has no private key, not signing mails", fromAddress);
logger.warn("Mail signing certificate store has no private key, not signing mails");
return null;
}

Expand Down Expand Up @@ -535,7 +538,9 @@ public void send(String subject, MimeBodyPart body, Consumer<MimeMessage> messag
}
catch (MessagingException e)
{
logger.debug("Unable to send message", e);
logger.warn("Unable to send message: {} - {}", e.getClass().getName(), e.getMessage());

throw new RuntimeException(e);
}
}
Expand Down
Loading

0 comments on commit bb96a85

Please sign in to comment.