go1.18: address net.Error.Temporary() deprecation
Go 1.18 deprecated net.Error.Temporary().
This commit cleans up places where we use it incorrectly.
Also, the rpc layer defines some errors that implement
interface { Temporary() bool }
I added comments to all of the implementations to indicate
whether they will be required if net.Error.Temporary is ever
ever removed in the future.
For HandshakeError, the Temporary() return value is actually
important. I moved & rewrote a (previously misplaced) comment
there.
The ReadStreamError changes were
1. necessary to pacify newer staticcheck and
2. technically, an error can implement Temporary()
without being net.Err. This applies to some syscall
errors in the standard library.
Reading list for those interested:
- https://github.com/golang/go/issues/45729
- https://groups.google.com/g/golang-nuts/c/-JcZzOkyqYI
- https://man7.org/linux/man-pages/man2/accept.2.html
Note: This change was prompted by staticheck:
> SA1019: neterr.Temporary has been deprecated since Go 1.18 because it
> shouldn't be used: Temporary errors are not well-defined. Most
> "temporary" errors are timeouts, and the few exceptions are surprising.
> Do not use this method. (staticcheck)
This commit is contained in:
@@ -1,25 +1,5 @@
|
||||
// Package netadaptor implements an adaptor from
|
||||
// transport.AuthenticatedListener to net.Listener.
|
||||
//
|
||||
// In contrast to transport.AuthenticatedListener,
|
||||
// net.Listener is commonly expected (e.g. by net/http.Server.Serve),
|
||||
// to return errors that fulfill the Temporary interface:
|
||||
// interface Temporary { Temporary() bool }
|
||||
// Common behavior of packages consuming net.Listener is to return
|
||||
// from the serve-loop if an error returned by Accept is not Temporary,
|
||||
// i.e., does not implement the interface or is !net.Error.Temporary().
|
||||
//
|
||||
// The zrepl transport infrastructure was written with the
|
||||
// idea that Accept() may return any kind of error, and the consumer
|
||||
// would just log the error and continue calling Accept().
|
||||
// We have to adapt these listeners' behavior to the expectations
|
||||
// of net/http.Server.
|
||||
//
|
||||
// Hence, Listener does not return an error at all but blocks the
|
||||
// caller of Accept() until we get a (successfully authenticated)
|
||||
// connection without errors from the transport.
|
||||
// Accept errors returned from the transport are logged as errors
|
||||
// to the logger passed on initialization.
|
||||
package netadaptor
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user