diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go index 8e5df34e60be7..66b2602d3bf2e 100644 --- a/modules/indexer/code/bleve.go +++ b/modules/indexer/code/bleve.go @@ -173,6 +173,10 @@ func NewBleveIndexer(indexDir string) (*BleveIndexer, bool, error) { indexDir: indexDir, } created, err := indexer.init() + if err != nil { + indexer.Close() + return nil, false, err + } return indexer, created, err } diff --git a/modules/indexer/code/elastic_search.go b/modules/indexer/code/elastic_search.go index 49633c31916df..f76f316f6494f 100644 --- a/modules/indexer/code/elastic_search.go +++ b/modules/indexer/code/elastic_search.go @@ -82,7 +82,10 @@ func NewElasticSearchIndexer(url, indexerName string) (*ElasticSearchIndexer, bo indexerAliasName: indexerName, } exists, err := indexer.init() - + if err != nil { + indexer.Close() + return nil, false, err + } return indexer, !exists, err } diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index 981167a8254a5..c56b1b2bb0c5d 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -185,9 +185,6 @@ func Init() { rIndexer, populate, err = NewBleveIndexer(setting.Indexer.RepoPath) if err != nil { - if rIndexer != nil { - rIndexer.Close() - } cancel() indexer.Close() close(waitChannel) @@ -205,9 +202,6 @@ func Init() { rIndexer, populate, err = NewElasticSearchIndexer(setting.Indexer.RepoConnStr, setting.Indexer.RepoIndexerName) if err != nil { - if rIndexer != nil { - rIndexer.Close() - } cancel() indexer.Close() close(waitChannel) diff --git a/routers/web/base.go b/routers/web/base.go index 16d3192da21dc..98713bc8818f6 100644 --- a/routers/web/base.go +++ b/routers/web/base.go @@ -130,14 +130,6 @@ func Recovery() func(next http.Handler) http.Handler { log.Error("%v", combinedErr) sessionStore := session.GetSession(req) - if sessionStore == nil { - if setting.IsProd { - http.Error(w, http.StatusText(500), 500) - } else { - http.Error(w, combinedErr, 500) - } - return - } var lc = middleware.Locale(w, req) var store = dataStore{