Skip to content

Commit 2cca3ec

Browse files
committed
fix nil-pointer dereference in detailed config log
Closes #719. Signed-off-by: Peter Schultz <peter.schultz@classmarkets.com>
1 parent c5fdb87 commit 2cca3ec

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Changelog
22

3+
### Unreleased
4+
5+
#### Bug Fixes
6+
7+
* [Issue #719](https://github.com/fabiolb/fabio/issues/719): Fix detailed config log
8+
39
### [v1.5.12](https://github.com/fabiolb/fabio/releases/tag/v1.5.12) - 11 Oct 2019
410

511
#### Breaking Changes

route/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func (t Table) String() string {
501501

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

506506
hosts := []string{}
507507
for k := range t {

route/table_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,3 +731,32 @@ func TestNewTableCustom(t *testing.T) {
731731
t.FailNow()
732732
}
733733
}
734+
735+
func TestTable_Dump(t *testing.T) {
736+
s := `
737+
route add svc / http://foo.com:800
738+
route add svc /foo http://foo.com:900
739+
route add svc abc.com/ http://foo.com:1000
740+
`
741+
742+
tbl, err := NewTable(bytes.NewBufferString(s))
743+
if err != nil {
744+
t.Fatal(err)
745+
}
746+
747+
want := `+-- host=
748+
| |-- path=/foo
749+
| | +-- addr=foo.com:900 weight 1.00 slots 1/1
750+
| +-- path=/
751+
| +-- addr=foo.com:800 weight 1.00 slots 1/1
752+
+-- host=abc.com
753+
+-- path=/
754+
+-- addr=foo.com:1000 weight 1.00 slots 1/1
755+
`
756+
757+
got := tbl.Dump()
758+
759+
if want != got {
760+
t.Errorf("Unexpected Dump() output:\nwant:\n%s\ngot:\n%s\n", want, got)
761+
}
762+
}

0 commit comments

Comments
 (0)