Skip to content

Commit

Permalink
Merge pull request #1016 from Graylog2/fix-1005
Browse files Browse the repository at this point in the history
Catch NotFoundException exceptions and log a warning
  • Loading branch information
joschi committed Mar 5, 2015
2 parents 7ba2292 + 187a98e commit b880f19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Lists;
import org.graylog2.database.NotFoundException;
import org.graylog2.inputs.Input;
import org.graylog2.inputs.InputService;
import org.graylog2.plugin.Message;
Expand Down Expand Up @@ -75,17 +76,22 @@ private List<Extractor> loadExtractors(final String inputId) {
public List<Extractor> call() throws Exception {
LOG.debug("Re-loading extractors for input <{}> into cache.", inputId);

Input input = inputService.find(inputId);
try {
Input input = inputService.find(inputId);

List<Extractor> sorted = Lists.newArrayList(inputService.getExtractors(input));
List<Extractor> sorted = Lists.newArrayList(inputService.getExtractors(input));

Collections.sort(sorted, new Comparator<Extractor>() {
public int compare(Extractor e1, Extractor e2) {
return e1.getOrder().intValue() - e2.getOrder().intValue();
}
});
Collections.sort(sorted, new Comparator<Extractor>() {
public int compare(Extractor e1, Extractor e2) {
return e1.getOrder().intValue() - e2.getOrder().intValue();
}
});

return sorted;
return sorted;
} catch (NotFoundException e) {
LOG.warn("Unable to load input: {}", e.getMessage());
return Collections.emptyList();
}
}
});
} catch (ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.graylog2.database.NotFoundException;
import org.graylog2.inputs.Input;
import org.graylog2.inputs.InputService;
import org.graylog2.plugin.Message;
Expand Down Expand Up @@ -75,8 +76,13 @@ private List<Map.Entry<String, String>> loadStaticFields(final String inputId) {
@Override
public List<Map.Entry<String, String>> call() throws Exception {
LOG.debug("Re-loading static fields for input <{}> into cache.", inputId);
final Input input = inputService.find(inputId);
return inputService.getStaticFields(input);
try {
final Input input = inputService.find(inputId);
return inputService.getStaticFields(input);
} catch (NotFoundException e) {
LOG.warn("Unable to load input: {}", e.getMessage());
return Collections.emptyList();
}
}
});
} catch (ExecutionException e) {
Expand Down

0 comments on commit b880f19

Please sign in to comment.