Skip to content

[SCB-1997] Small improvement when Muticastscoket receive data#1827

Merged
liubao68 merged 1 commit into
apache:masterfrom
jungan21:master
Jun 13, 2020
Merged

[SCB-1997] Small improvement when Muticastscoket receive data#1827
liubao68 merged 1 commit into
apache:masterfrom
jungan21:master

Conversation

@jungan21

Copy link
Copy Markdown
Contributor

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install -Pit to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@coveralls

coveralls commented Jun 10, 2020

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.008%) to 86.795% when pulling 366296c on jungan21:master into e54e0ea on apache:master.

Comment on lines 182 to +187
try {
byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
multicastSocket = new MulticastSocket(PORT);
group = InetAddress.getByName(GROUP);
multicastSocket.joinGroup(group); // need to join the group to be able to receive the data

initMulticastSocket();
while (true) {
DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
multicastSocket.receive(receivePacketBuffer);
try {

@liubao68 liubao68 Jun 11, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe need look at the outer try, if IOException is thrown, the task is exit.

@jungan21 jungan21 Jun 11, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct. But the outer try/catch(IOException) is for initializing the Multicastsocket object ......the failure should rarely happen. I don't think we need to handle this for now. I'm thinkg to throw exception, (like our servicecomb init task)...instead of the just logging.

throw new IllegalStateException("Zero-Config init failed.", e);

Comment on lines 181 to 183
private static void startListenerForRegisterUnregisterEvent() {
try {
byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cyclomatic complexity of startListenerForRegisterUnregisterEvent is a bit too high, can be refactored.

@liubao68
liubao68 merged commit 4065b34 into apache:master Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants