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

net/rpc: error reported in server, when it shouldn't #20862

Closed
available-username opened this issue Jun 30, 2017 · 2 comments
Closed

net/rpc: error reported in server, when it shouldn't #20862

available-username opened this issue Jun 30, 2017 · 2 comments

Comments

@available-username
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.3 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

I attempted to register, net/rpc Register, a type which contains some public methods that should be exposed as RPC methods, and some methods that are public but shouldn't be exposed as RPC methods. According to the net/rpc documentation...

    Only methods that satisfy these criteria will be made available for
    remote access; other methods will be ignored:

        - the method's type is exported.
        - the method is exported.
        - the method has two arguments, both exported (or builtin) types.
        - the method's second argument is a pointer.
        - the method has return type error.

... a public method that has only one argument should be ignored, but instead an error message is printed when such a method is encountered. Please see this example which reproduces the behaviour.

What did you expect to see?

Nothing should be printed.

What did you see instead?

From the go playground example above
2009/11/10 23:00:00 method ShouldNotBeExposedByRPC has wrong number of ins: 2

Suggested solution

In net/rpc/server.go:262 the function suitableMethods is called with reportErr=true, this eventually causes the printout, see net/rpc/server.go:298. If methods don't satisfy the criteria for exposure they should be ignored as the documentation says.

@odeke-em odeke-em changed the title net/rpc reports error when it shouldn't net/rpc: error reported in server, when it shouldn't Jul 21, 2017
@odeke-em
Copy link
Member

Tagging this for Go1.10. This a bug report and not a feature request so I don't think that affects whether net/rpc is frozen, what do y'all think: @robpike @adg?

@robpike
Copy link
Contributor

robpike commented Jul 21, 2017

Duplicate of #19957

@robpike robpike marked this as a duplicate of #19957 Jul 21, 2017
@robpike robpike closed this as completed Jul 21, 2017
@golang golang locked and limited conversation to collaborators Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants