Skip to content

Commit

Permalink
fix null pointer when no content is returned from fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Mancke committed Nov 23, 2016
1 parent 997a9db commit ddc0d16
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions composition/content_fetcher.go
Expand Up @@ -3,8 +3,8 @@ package composition
import (
"errors"
"github.com/tarent/lib-compose/logging"
"sync"
"sort"
"sync"
)

// IsFetchable returns, whether the fetch definition refers to a fetchable resource
Expand Down Expand Up @@ -33,7 +33,6 @@ func (fr FetchResults) Less(i, j int) bool {
return fr[i].Def.Priority < fr[j].Def.Priority
}


// ContentFetcher is a type, which can fetch a set of Content pages in parallel.
type ContentFetcher struct {
activeJobs sync.WaitGroup
Expand Down Expand Up @@ -74,7 +73,7 @@ func (fetcher *ContentFetcher) WaitForResults() []*FetchResult {
results := fetcher.r.results

//to keep initial order if no priority settings are given, do a check before for sorting
if(hasPrioritySetting(results)) {
if hasPrioritySetting(results) {
sort.Sort(FetchResults(results))
}

Expand Down Expand Up @@ -123,7 +122,7 @@ func (fetcher *ContentFetcher) AddFetchJob(d *FetchDefinition) {
}
} else {
// 404 Error already become logged in logger.go
if fetchResult.Content.HttpStatusCode() != 404 {
if fetchResult.Content == nil || fetchResult.Content.HttpStatusCode() != 404 {
logging.Logger.WithError(fetchResult.Err).
WithField("fetchDefinition", d).
WithField("correlation_id", logging.GetCorrelationId(definitionCopy.Header)).
Expand Down

0 comments on commit ddc0d16

Please sign in to comment.