-
Notifications
You must be signed in to change notification settings - Fork 641
[ISSUE #4268] Used switch to replace the if-else [CloudEventsProtocolAdaptor] #4298
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
| return SendMessageRequestProtocolResolver.buildEvent(header, body); | ||
| } else { | ||
| throw new ProtocolHandleException(String.format("unsupported requestCode: %s", requestCode)); | ||
| switch (RequestCode.valueOf(requestCode)) { |
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.
valueOf method is to transfer an Enum constant specified name to return an Enum constant.So It can not transfer requestCode as specified name to get any Enum constant.

So as the same as #4270.It causes client to fail to connect to the runtime server.

| return SendMessageRequestProtocolResolver.buildEvent(header, body); | ||
| } else { | ||
| throw new ProtocolHandleException(String.format("unsupported requestCode: %s", requestCode)); | ||
| switch (RequestCode.valueOf(requestCode)) { |
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.
Sorry, my mistake here, the valueof here returns the enum constant for the specified string value, here it is judged by the requestCode, so it won't match up by doing so.
You might consider writing a method in the RequestCode class that returns the corresponding Enum type constant based on the requestCode.
Codecov Report
@@ Coverage Diff @@
## master #4298 +/- ##
=========================================
Coverage 16.35% 16.35%
Complexity 1359 1359
=========================================
Files 594 594
Lines 25419 25419
Branches 2394 2394
=========================================
Hits 4158 4158
Misses 20838 20838
Partials 423 423 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
This method already exists in this class, and the valueOf() method can be changed to get(): Also please fix pr #4270. |
|
@devCod3r This pr brought a bug. Refer the #4298 (comment). If you are willing, you can post a new issue and pr to fix the bug. |
[ISSUE apache#4268] Used switch to replace the if-else [CloudEventsProtocolAdaptor]

Fixes #4268
Motivation
Replaced the if-else statements with switch.
Issue #4268
Modifications
Replaced the if-else statements with switch.
Documentation