-
Notifications
You must be signed in to change notification settings - Fork 641
[ISSUE #4474] Uniformly manage duplicate static variables #4495
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
|
@mxsm I ran the following command -> ./gradlew build -x test and it worked fine. But for a few modules, there were test-case failures. I can name them here as a reference. Is there any specific reason for that? Because I have made only small changes and if the compilation was successful then my changes should not have any impact on the test cases. Please suggest accordingly. I will look further into more detail if my changes are causing the issue.
|
|
@VishalMCF You may checkout |
| Preconditions.checkNotNull(cloudEvent.getDataContentType(), "DateContentType cannot be null"); | ||
| msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME); | ||
| msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, CLOUD_EVENTS_PROTOCOL_NAME); | ||
| msg.getHeader().putProperty(Constants.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString()); |
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.
Coding Style differs here. Please use static import only when this class uses single constant class.
Codecov Report
@@ Coverage Diff @@
## master #4495 +/- ##
============================================
+ Coverage 15.46% 15.47% +0.01%
Complexity 1452 1452
============================================
Files 691 691
Lines 28101 28106 +5
Branches 2624 2626 +2
============================================
+ Hits 4345 4349 +4
- Misses 23309 23312 +3
+ Partials 447 445 -2
... and 8 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Have all duplicate variables been optimized? If not, it is recommended that you create a new issue as a sub issue of issue #4474 and link this PR to the new issue. |
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.
I don't think this PR has done all it can do. @VishalMCF Please optimize it further when you have time~
|
|
||
| // protocol type | ||
| public static final String CLOUD_EVENTS_PROTOCOL_NAME = "cloudevents"; | ||
| public static final String EM_MESSAGE_PROTOCOL_NAME = "eventmeshmessage"; | ||
| public static final String OPEN_MESSAGE_PROTOCOL_NAME = "openmessage"; | ||
| } |
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.
cloudevents removed but eventmeshmessage and openmessage remaining here.
| public final class ProtocolConstant { | ||
|
|
||
| public static final String CE_PROTOCOL = "cloudevents"; | ||
| public static final String EM_MESSAGE_PROTOCOL = "eventmeshmessage"; | ||
| public static final String OP_MESSAGE_PROTOCOL = "openmessage"; | ||
| public static final String PROTOCOL_DESC = "http"; |
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.
Another cloudevents removed but eventmeshmessage and openmessage remaining here. The protocols are torn apart and still duplicate.
| package org.apache.eventmesh.client.tcp.common; | ||
|
|
||
| import static org.apache.eventmesh.common.Constants.CLOUD_EVENTS_PROTOCOL_NAME; | ||
|
|
||
| import org.apache.eventmesh.common.Constants; | ||
| import org.apache.eventmesh.common.protocol.SubscriptionItem; |
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.
Static imports should not be used here, because Constants class has already been imported.
…he#4495) * 4474 -> moved common constants to appache-common * shifted common static variables to a common Constants.java file in eventmesh.common module * removed unused constant from the file. * refactored constants related to HTTP, GRPC, TCP in the relevant files
fix #4474
Motivation
There were duplicate final static constants that could have been created in a single common file and could be reused anywhere in the project.
Modifications
The common file which is suitable for hosting the static constants was found to be inside the package -> package org.apache.eventmesh.common. The file is the Constants.java file. There I added the following String constants ->
{ HTTP = "HTTP", TCP = "TCP", GRPC = "GRPC"}
Other than this there is one more constant in the eventmesh-common.Constants file called ( CLOUD_EVENTS_PROTOCOL_NAME = "cloudevents" ) which I have added wherever applicable.
and changed the import statements accordingly.
Documentation