Skip to content

Commit

Permalink
Merge bac7122 into 4245418
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovic committed Oct 31, 2020
2 parents 4245418 + bac7122 commit 55bda91
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -14,7 +14,6 @@ env:
go_import_path: github.com/nats-io/nats-streaming-server
install:
- go get -t ./...
- go get github.com/nats-io/nats-server
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
go get -u honnef.co/go/tools/cmd/staticcheck;
go get -u github.com/client9/misspell/cmd/misspell;
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -38,8 +38,8 @@ under the Apache Version 2.0 license found in the LICENSE file.

[License-Url]: https://www.apache.org/licenses/LICENSE-2.0
[License-Image]: https://img.shields.io/badge/License-Apache2-blue.svg
[Build-Status-Url]: http://travis-ci.org/nats-io/nats-streaming-server
[Build-Status-Image]: https://travis-ci.org/nats-io/nats-streaming-server.svg?branch=master
[Build-Status-Url]: https://travis-ci.com/github/nats-io/nats-streaming-server
[Build-Status-Image]: https://travis-ci.com/nats-io/nats-streaming-server.svg?branch=master
[Coverage-Url]: https://coveralls.io/r/nats-io/nats-streaming-server?branch=master
[Coverage-image]: https://coveralls.io/repos/github/nats-io/nats-streaming-server/badge.svg?branch=master&t=kIxrDE
[ReportCard-Url]: http://goreportcard.com/report/nats-io/nats-streaming-server
Expand Down
7 changes: 5 additions & 2 deletions server/server.go
Expand Up @@ -1714,14 +1714,17 @@ func RunServerWithOpts(stanOpts *Options, natsOpts *server.Options) (newServer *
// We used to issue panic for common errors but now return error
// instead. Still we want to log the reason for the panic.
if r := recover(); r != nil {
s.Shutdown()
s.log.Noticef("Failed to start: %v", r)
// For tests, we still shutdown server even before panic since
// some tests will do a recover().
s.Shutdown()
panic(r)
} else if returnedError != nil {
s.Shutdown()
// Log it as a fatal error, process will exit (if
// running from executable or logger is configured).
s.log.Fatalf("Failed to start: %v", returnedError)
// For tests, we call shutdown() for proper cleanup.
s.Shutdown()
}
}()

Expand Down
5 changes: 3 additions & 2 deletions server/server_run_test.go
Expand Up @@ -60,7 +60,7 @@ func TestRunServer(t *testing.T) {
}

func TestRunServerFailureLogsCause(t *testing.T) {
d := &dummyLogger{}
d := &captureFatalLogger{}

sOpts := GetDefaultOptions()
sOpts.NATSServerURL = "nats://127.0.0.1:4444"
Expand All @@ -72,8 +72,9 @@ func TestRunServerFailureLogsCause(t *testing.T) {
s.Shutdown()
t.Fatal("Expected error, got none")
}

// We should get a trace in the log
if !strings.Contains(d.msg, "available for connection") {
if !strings.Contains(d.fatal, "available for connection") {
t.Fatalf("Expected to get a cause as invalid connection, got: %v", d.msg)
}
}
Expand Down

0 comments on commit 55bda91

Please sign in to comment.