Skip to content

Commit

Permalink
http2: use net.ErrClosed
Browse files Browse the repository at this point in the history
Use errors.Is(err, net.ErrClosed) instead of checking for a known
string. net.ErrClosed is available since Go 1.16, the current minimum
version in go.mod is Go 1.18.

For golang/go#4373

Change-Id: Id98771874434bae7d9c6d1d4d36fddb28822eb39
Reviewed-on: https://go-review.googlesource.com/c/net/+/583016
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
tklauser authored and gopherbot committed May 6, 2024
1 parent b20cd59 commit e0324fc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,7 @@ func isClosedConnError(err error) bool {
return false
}

// TODO: remove this string search and be more like the Windows
// case below. That might involve modifying the standard library
// to return better error types.
str := err.Error()
if strings.Contains(str, "use of closed network connection") {
if errors.Is(err, net.ErrClosed) {
return true
}

Expand Down

0 comments on commit e0324fc

Please sign in to comment.