Merge pull request #407 from vieux/fix_panic_token

fix panic in token discovery
This commit is contained in:
Andrea Luzzardi 2015-02-19 11:39:06 -08:00
commit f5205cb7ca
1 changed files with 6 additions and 5 deletions

View File

@ -49,9 +49,7 @@ func (s *TokenDiscoveryService) Fetch() ([]*discovery.Entry, error) {
return nil, err return nil, err
} }
if resp.Body != nil { defer resp.Body.Close()
defer resp.Body.Close()
}
var addrs []string var addrs []string
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
@ -81,9 +79,12 @@ func (s *TokenDiscoveryService) Register(addr string) error {
resp, err := http.Post(fmt.Sprintf("%s/%s/%s", s.url, resp, err := http.Post(fmt.Sprintf("%s/%s/%s", s.url,
"clusters", s.token), "application/json", buf) "clusters", s.token), "application/json", buf)
// Force connection close if err != nil {
return err
}
resp.Body.Close() resp.Body.Close()
return err return nil
} }
// CreateCluster returns a unique cluster token // CreateCluster returns a unique cluster token