Skip to content
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

Optimize code to remove useless objects #7572

Closed
wants to merge 5 commits into from
Closed

Optimize code to remove useless objects #7572

wants to merge 5 commits into from

Conversation

srchen1987
Copy link

Optimize code to remove useless objects

update before
public void addAttachments(Map<String, String> attachments) {
if (attachments == null) {
return;
}
if (this.attachments == null) {
this.attachments = new HashMap<String, String>();
}
this.attachments.putAll(attachments);
}

update after
public void addAttachments(Map<String, String> attachments) {
if (attachments == null) {
return;
}
if (this.attachments == null) {
this.attachments = attachments;
}else{
this.attachments.putAll(attachments);
}
}

@@ -160,15 +160,16 @@ public void setAttachmentIfAbsent(String key, String value) {
attachments.put(key, value);
}
}

//Optimize code to remove useless objects
Copy link
Member

Choose a reason for hiding this comment

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

The comment is unnecessary

public void addAttachments(Map<String, String> attachments) {
if (attachments == null) {
return;
}
if (this.attachments == null) {
this.attachments = new HashMap<String, String>();
this.attachments = attachments;
}else{
Copy link
Member

Choose a reason for hiding this comment

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

indent problem.

@codecov-commenter
Copy link

codecov-commenter commented Apr 18, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@3e02287). Click here to learn what that means.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #7572   +/-   ##
=========================================
  Coverage          ?   59.07%           
  Complexity        ?      529           
=========================================
  Files             ?     1076           
  Lines             ?    43417           
  Branches          ?     6339           
=========================================
  Hits              ?    25648           
  Misses            ?    14923           
  Partials          ?     2846           
Impacted Files Coverage Δ Complexity Δ
...main/java/com/alibaba/dubbo/rpc/RpcInvocation.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e02287...6d56b90. Read the comment docs.

@gonwan
Copy link

gonwan commented May 8, 2021

Hi there,

Happened to look through the release notes, but this merge introduced side effects. It assumes the argument attachments is not going to be modified outside the method, which is not always correct. Should revert this.

@horizonzy
Copy link
Member

Hi there,

Happened to look through the release notes, but this merge introduced side effects. It assumes the argument attachments is not going to be modified outside the method, which is not always correct. Should revert this.

yep, it's indeed risk.

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.

5 participants