Skip to content

Commit

Permalink
Change error back to lower case, convert incoming error to lower before
Browse files Browse the repository at this point in the history
check.
  • Loading branch information
kozlovic committed Jan 29, 2016
1 parent e546ba4 commit 5a74e0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions nats.go
Expand Up @@ -44,7 +44,7 @@ const (
)

// STALE_CONNECTION is for detection and proper handling of stale connections.
const STALE_CONNECTION = "Stale Connection"
const STALE_CONNECTION = "stale connection"

// Errors
var (
Expand Down Expand Up @@ -1489,7 +1489,7 @@ func (nc *Conn) LastError() error {
// sets the connection's lastError.
func (nc *Conn) processErr(e string) {
// FIXME(dlc) - process Slow Consumer signals special.
if e == STALE_CONNECTION {
if strings.ToLower(e) == STALE_CONNECTION {
nc.processOpErr(ErrStaleConnection)
} else {
nc.mu.Lock()
Expand Down
7 changes: 5 additions & 2 deletions nats_test.go
Expand Up @@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -391,8 +392,10 @@ func TestParserErr(t *testing.T) {
if c.ps.argBuf == nil {
t.Fatal("ArgBuf should not be nil")
}
if string(c.ps.argBuf) != STALE_CONNECTION {
t.Fatalf("Wrong error, got '%v' expected '%v'", string(c.ps.argBuf), STALE_CONNECTION)
// processErr converts incoming error to lower case to do the check
lowerCaseErr := strings.ToLower(string(c.ps.argBuf))
if lowerCaseErr != STALE_CONNECTION {
t.Fatalf("Wrong error, got '%v' expected '%v'", lowerCaseErr, STALE_CONNECTION)
}

err = c.parse(errProto[len(errProto)-2:])
Expand Down

0 comments on commit 5a74e0c

Please sign in to comment.