deal with empty learder() cases

This commit is contained in:
Chris Lu 2014-03-16 13:50:46 -07:00
parent 1040761ab6
commit f8b1d48f82

View file

@ -94,8 +94,8 @@ func (ms *MasterServer) proxyToLeader(f func(w http.ResponseWriter, r *http.Requ
ms.bounedLeaderChan <- 1
defer func() { <-ms.bounedLeaderChan }()
targetUrl, err := url.Parse("http://" + ms.Topo.RaftServer.Leader())
if err != nil {
writeJsonQuiet(w, r, map[string]interface{}{"error": "Leader URL Parse Error " + err.Error()})
if err != nil || ms.Topo.RaftServer.Leader() == "" {
writeJsonQuiet(w, r, map[string]interface{}{"error": "Leader URL http://" + ms.Topo.RaftServer.Leader() + " Parse Error " + err.Error()})
return
}
glog.V(4).Infoln("proxying to leader", ms.Topo.RaftServer.Leader())