Merge pull request #3937 from deitch/logread-exit-not-panic

logread should not panic on an EOF, instead exiting gracefully
This commit is contained in:
Avi Deitcher 2023-06-20 00:03:43 -07:00 committed by GitHub
commit 8e790a5417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,8 +2,10 @@ package main
import (
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"net"
"strings"
"time"
@ -65,6 +67,9 @@ func main() {
decoder := json.NewDecoder(conn)
for {
if err := decoder.Decode(&entry); err != nil {
if errors.Is(err, net.ErrClosed) || errors.Is(err, io.EOF) {
return
}
panic(err)
}