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

Protobuf method not allow override #13155

Merged
merged 24 commits into from
Oct 19, 2023
Merged

Protobuf method not allow override #13155

merged 24 commits into from
Oct 19, 2023

Conversation

SpringStudent
Copy link
Contributor

What is the purpose of the change

Fix protobuf method overrided cause provider NPE.See #13142

Brief changelog

Verifying this change

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@SpringStudent SpringStudent changed the title Protobuf method could not allow override Protobuf method not allow override Oct 8, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 8, 2023

Codecov Report

❗ No coverage uploaded for pull request base (3.2@fa11b68). Click here to learn what that means.
The diff coverage is n/a.

@@          Coverage Diff           @@
##             3.2   #13155   +/-   ##
======================================
  Coverage       ?   69.49%           
  Complexity     ?        2           
======================================
  Files          ?     1650           
  Lines          ?    68729           
  Branches       ?    10012           
======================================
  Hits           ?    47760           
  Misses         ?    16374           
  Partials       ?     4595           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@EarthChen
Copy link
Member

pls add some ut & it.

@SpringStudent
Copy link
Contributor Author

pls add some ut & it.

pls add some ut & it.

i added some in dubbo-rpc-triple/test/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocolTest.java

@EarthChen
Copy link
Member

pls format your code by dubbo checkstyle

@SpringStudent
Copy link
Contributor Author

pls format your code by dubbo checkstyle

ok,my pleasure

Copy link
Member

@EarthChen EarthChen left a comment

Choose a reason for hiding this comment

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

LGTM

@SpringStudent
Copy link
Contributor Author

`public class ProtobufUtils {

private static volatile Class<?> protobufClss;
private static volatile Boolean supportProtobuf;

private static boolean loadProtobufClss() {
    if (supportProtobuf == null) {
        synchronized (ProtobufUtils.class) {
            if (supportProtobuf == null) {
                try {
                    protobufClss = ClassUtils.forNameWithThreadContextClassLoader(PROTOBUF_MESSAGE_CLASS_NAME);
                    supportProtobuf = protobufClss != null;
                } catch (Throwable t) {
                    supportProtobuf = false;
                }
            }
        }
    }
    return supportProtobuf;
}

public static boolean isProtobufClass(Class<?> pojoClazz) {
    if (loadProtobufClss()) {
        return protobufClss.isAssignableFrom(pojoClazz);
    }
    return false;
}

}
`
I don't understand why the above code find a bug by sonar

@EarthChen
Copy link
Member

pls fix conflicts

@SpringStudent
Copy link
Contributor Author

pls fix conflicts

resolved

@sonarcloud
Copy link

sonarcloud bot commented Oct 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

79.2% 79.2% Coverage
0.0% 0.0% Duplication

@EarthChen EarthChen merged commit 416374c into apache:3.2 Oct 19, 2023
14 checks passed
AlbumenJ added a commit that referenced this pull request Nov 1, 2023
AlbumenJ added a commit that referenced this pull request Nov 1, 2023
@AlbumenJ
Copy link
Member

AlbumenJ commented Nov 1, 2023

Revert first and should fix for server stream and check only for Triple protocol.
image

@SpringStudent
Copy link
Contributor Author

Revert first and should fix for server stream and check only for Triple protocol. image

hi i don't know what your mean about fix for server stream and check only for Triple protocol,Because of only tripe protocol had protobuf method ,I think check whether if triple protocol is not necessary

@AlbumenJ
Copy link
Member

AlbumenJ commented Nov 1, 2023

Revert first and should fix for server stream and check only for Triple protocol. image

hi i don't know what your mean about fix for server stream and check only for Triple protocol,Because of only tripe protocol had protobuf method ,I think check whether if triple protocol is not necessary

  1. For triple's stub, Server Steam will create two method.
  2. For Dubbo protocol, protobuf serialization is allowed and you can use protobuf message as a data trandfer object in network.

@SpringStudent
Copy link
Contributor Author

Revert first and should fix for server stream and check only for Triple protocol. image

hi i don't know what your mean about fix for server stream and check only for Triple protocol,Because of only tripe protocol had protobuf method ,I think check whether if triple protocol is not necessary

  1. For triple's stub, Server Steam will create two method.
  2. For Dubbo protocol, protobuf serialization is allowed and you can use protobuf message as a data trandfer object in network.
    okay, i will fix it in next

@SpringStudent
Copy link
Contributor Author

SpringStudent commented Nov 6, 2023

Revert first and should fix for server stream and check only for Triple protocol. image

hi i don't know what your mean about fix for server stream and check only for Triple protocol,Because of only tripe protocol had protobuf method ,I think check whether if triple protocol is not necessary

  1. For triple's stub, Server Steam will create two method.
  2. For Dubbo protocol, protobuf serialization is allowed and you can use protobuf message as a data trandfer object in network.
    okay, i will fix it in next

i found tri protocol,if the provider create two stream method like below,invoke streamserver method will invoke the wrong method,is this a right behavior
`public interface DemoService {

GreeterReply greet(GreeterRequest request);
void greet(GreeterRequest request, StreamObserver<GreeterReply> streamObserver);

}`
@AlbumenJ

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.

None yet

4 participants