Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

fix: check workflow exists when executing #335

Merged
merged 2 commits into from
May 21, 2023

Conversation

eloycoto
Copy link
Collaborator

User may introduce a typo and the output is not great:

2023-05-11 10:23:13.200 ERROR 52759 --- [         task-6] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected exception occurred invoking async method: public void com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl.executeAsync(java.util.UUID,java.lang.String,com.redhat.parodos.workflows.work.WorkContext,java.util.UUID)

java.lang.NullPointerException: Cannot invoke "com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition.getName()" because "workflow" is null
        at com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionFactory.isMainWorkFlow(WorkFlowExecutionFactory.java:55) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionFactory.createExecutionHandler(WorkFlowExecutionFactory.java:38) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionAspect.executeAroundAdvice(WorkFlowExecutionAspect.java:86) ~[classes!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at com.redhat.parodos.workflows.workflow.ParallelFlow$$EnhancerBySpringCGLIB$$7530a326.execute(<generated>) ~[workflow-engine-1.0.11-SNAPSHOT.jar!/:na]
        at com.redhat.parodos.workflows.engine.WorkFlowEngineImpl.run(WorkFlowEngineImpl.java:38) ~[workflow-engine-1.0.11-SNAPSHOT.jar!/:na]
        at com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl.execute(WorkFlowExecutorImpl.java:35) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl.executeAsync(WorkFlowExecutorImpl.java:27) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl$$FastClassBySpringCGLIB$$510b4225.invoke(<generated>) ~[classes!/:na]
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[workflow-examples-1.0.11-SNAPSHOT-jar-with-dependencies.jar:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, use fixes #<issue_number>(, fixes #<issue_number>, ...) format, where issue_number might be a GitHub issue, or a Jira story (FLPATH-xxxx):
Fixes #

Change type

  • New feature
  • Bug fix
  • Unit tests
  • Integration tests
  • CI
  • Documentation
  • Auto-generated SDK code

Impacted services

  • Workflow Service
  • Notification Service

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.

@openshift-ci openshift-ci bot requested review from masayag and nirarg May 11, 2023 13:50
User may introduce a typo and the output is not great:

```
2023-05-11 10:23:13.200 ERROR 52759 --- [         task-6] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected exception occurred invoking async method: public void com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl.executeAsync(java.util.UUID,java.lang.String,com.redhat.parodos.workflows.work.WorkContext,java.util.UUID)

java.lang.NullPointerException: Cannot invoke "com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition.getName()" because "workflow" is null
        at com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionFactory.isMainWorkFlow(WorkFlowExecutionFactory.java:55) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionFactory.createExecutionHandler(WorkFlowExecutionFactory.java:38) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionAspect.executeAroundAdvice(WorkFlowExecutionAspect.java:86) ~[classes!/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at com.redhat.parodos.workflows.workflow.ParallelFlow$$EnhancerBySpringCGLIB$$7530a326.execute(<generated>) ~[workflow-engine-1.0.11-SNAPSHOT.jar!/:na]
        at com.redhat.parodos.workflows.engine.WorkFlowEngineImpl.run(WorkFlowEngineImpl.java:38) ~[workflow-engine-1.0.11-SNAPSHOT.jar!/:na]
        at com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl.execute(WorkFlowExecutorImpl.java:35) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl.executeAsync(WorkFlowExecutorImpl.java:27) ~[classes!/:na]
        at com.redhat.parodos.workflow.execution.service.WorkFlowExecutorImpl$$FastClassBySpringCGLIB$$510b4225.invoke(<generated>) ~[classes!/:na]
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[workflow-examples-1.0.11-SNAPSHOT-jar-with-dependencies.jar:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-5.3.20.jar!/:5.3.20]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
```

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@openshift-ci
Copy link

openshift-ci bot commented May 21, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: masayag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@masayag
Copy link
Collaborator

masayag commented May 21, 2023

/lgtm

@@ -132,10 +134,34 @@ public void ExecuteAroundAdviceWithValidDataTest() {
assertEquals(workReport.getStatus().toString(), COMPLETED);
assertEquals(workReport.getWorkContext().get(WORKFLOW_DEFINITION_NAME), TEST_WORK_FLOW);
assertEquals(workReport.getWorkContext().get(PROJECT_ID), projectID);
assertThat(workReport.getError()).isInstanceOf(ResourceNotFoundException.class);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eloycoto pls remove this change or replace with

assertThat(workReport.getError()).isNull();

This is a positive code path that shouldn't end with a failure

@masayag
Copy link
Collaborator

masayag commented May 21, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 21, 2023
Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@masayag
Copy link
Collaborator

masayag commented May 21, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 21, 2023
@openshift-merge-robot openshift-merge-robot merged commit 7a11533 into parodos-dev:main May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants