logstash/logstash — pull request #84 by bitprophet (2012-01-10 23:56:21+00:00)
Title: Prevent grep filter from dropping when field is nil & negate is true

## Description

Incorrect logic order was causing the grep filter to automatically drop events in the following scenario:

* Any field names mentioned in the plugin conf or `match` were nonexistent (or had a nil value, thanks Ruby ;)), e.g. `match => ["lol_doesnt_exist", "mypattern"]`
* This can happen due to operator error *or* due to field-altering filters occurring prior to the `grep` in question
* `negate => true`

When both factors are in place, `grep` will drop all events matching that filter's `type`, or all events if it lacks a `type`.

Code did exist to correctly handle `negate => true`, but it was never reached due to the bug in question.

## Solution

* Merge the field-skipping logic with the negate-testing logic, while ensuring that the main body is still skipped (avoids problems with regex testing & `match_count`)
* See linked diffs for specifics, naturally.

I've tested the solution with each combination of `negate` true/false, field name valid/invalid, and field value matching/not matching the regex. Seems to work fine.