-
Notifications
You must be signed in to change notification settings - Fork 181
Removed unnecessary thread interrupt #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
temporal-sdk/src/test/java/io/temporal/worker/CleanWorkerShutdownTest.java
Show resolved
Hide resolved
Spikhalskiy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this PR cuts off an "interrupted" version of the test instead of fixing anything.
temporal-sdk/src/test/java/io/temporal/worker/CleanWorkerShutdownHeartBeatingActivityTest.java
Show resolved
Hide resolved
| Activity.getExecutionContext().heartbeat("foo"); | ||
| } catch (ActivityWorkerShutdownException e) { | ||
| return "workershutdown"; | ||
| if (now == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move these latches code block up from the try{} catch to improve readability.
I believe CountDownLatch#countDown shouldn't throw an InterruptedException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved, but it does not throw the InterruptedException
Activities that catch InterruptedException, restore the interrupted flag, and continue execution were unable to report their completion due to gRPC call failures. This occurred because gRPC calls fail when the thread's interrupted flag is set. The fix clears the interrupted flag before making gRPC calls in ActivityWorker.sendReply() and restores it afterward, ensuring: - Activity results are successfully reported to the server - Thread interruption semantics are preserved for worker shutdown - All activity completion scenarios work (success/failure/cancellation) Additionally, extract executeGrpcCallWithInterruptHandling() method to eliminate code duplication across the three gRPC response calls, improving maintainability and reducing the risk of inconsistent implementations. Fixes: temporalio#731 Related: temporalio#722
Activities that catch InterruptedException, restore the interrupted flag, and continue execution were unable to report their completion due to gRPC call failures. This occurred because gRPC calls fail when the thread's interrupted flag is set. The fix clears the interrupted flag before making gRPC calls in ActivityWorker.sendReply() and restores it afterward, ensuring: - Activity results are successfully reported to the server - Thread interruption semantics are preserved for worker shutdown - All activity completion scenarios work (success/failure/cancellation) Additionally, extract executeGrpcCallWithInterruptHandling() method to eliminate code duplication across the three gRPC response calls, improving maintainability and reducing the risk of inconsistent implementations. Fixes: temporalio#731 Related: temporalio#722
Activities that catch InterruptedException, restore the interrupted flag, and continue execution were unable to report their completion due to gRPC call failures. This occurred because gRPC calls fail when the thread's interrupted flag is set. The fix clears the interrupted flag before making gRPC calls in ActivityWorker.sendReply() and restores it afterward, ensuring: - Activity results are successfully reported to the server - Thread interruption semantics are preserved for worker shutdown - All activity completion scenarios work (success/failure/cancellation) Additionally, extract executeGrpcCallWithInterruptHandling() method to eliminate code duplication across the three gRPC response calls, improving maintainability and reducing the risk of inconsistent implementations. Fixes: temporalio#731 Related: temporalio#722
What was changed
Removed unnecessary thread interrupt that prevented the sdk from sending the activity task completed call.
Checklist
Closes CleanWorkerShutdownTest::testShutdownNow[Docker] #721
How was this tested:
Unit test