Skip to content

Commit

Permalink
fix nil-pointer dereference in detailed config log
Browse files Browse the repository at this point in the history
Closes #719.

Signed-off-by: Peter Schultz <peter.schultz@classmarkets.com>
  • Loading branch information
pschultz committed Nov 18, 2019
1 parent c5fdb87 commit 2cca3ec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

### Unreleased

#### Bug Fixes

* [Issue #719](https://github.com/fabiolb/fabio/issues/719): Fix detailed config log

### [v1.5.12](https://github.com/fabiolb/fabio/releases/tag/v1.5.12) - 11 Oct 2019

#### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion route/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (t Table) String() string {

// Dump returns the routing table as a detailed
func (t Table) Dump() string {
var w *bytes.Buffer
w := new(bytes.Buffer)

hosts := []string{}
for k := range t {
Expand Down
29 changes: 29 additions & 0 deletions route/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,3 +731,32 @@ func TestNewTableCustom(t *testing.T) {
t.FailNow()
}
}

func TestTable_Dump(t *testing.T) {
s := `
route add svc / http://foo.com:800
route add svc /foo http://foo.com:900
route add svc abc.com/ http://foo.com:1000
`

tbl, err := NewTable(bytes.NewBufferString(s))
if err != nil {
t.Fatal(err)
}

want := `+-- host=
| |-- path=/foo
| | +-- addr=foo.com:900 weight 1.00 slots 1/1
| +-- path=/
| +-- addr=foo.com:800 weight 1.00 slots 1/1
+-- host=abc.com
+-- path=/
+-- addr=foo.com:1000 weight 1.00 slots 1/1
`

got := tbl.Dump()

if want != got {
t.Errorf("Unexpected Dump() output:\nwant:\n%s\ngot:\n%s\n", want, got)
}
}

0 comments on commit 2cca3ec

Please sign in to comment.