Search in sources :

Example 1 with InterruptibleCharSequence

use of org.graylog2.utilities.InterruptibleCharSequence in project graylog2-server by Graylog2.

the class RegexMatcher method match.

@Override
public boolean match(Message msg, StreamRule rule) {
    if (msg.getField(rule.getField()) == null)
        return rule.getInverted();
    try {
        final Pattern pattern = patternCache.get(rule.getValue());
        final CharSequence charSequence = new InterruptibleCharSequence(msg.getField(rule.getField()).toString());
        return rule.getInverted() ^ pattern.matcher(charSequence).find();
    } catch (ExecutionException e) {
        LOG.error("Unable to get pattern from regex cache: ", e);
    }
    return false;
}
Also used : Pattern(java.util.regex.Pattern) InterruptibleCharSequence(org.graylog2.utilities.InterruptibleCharSequence) InterruptibleCharSequence(org.graylog2.utilities.InterruptibleCharSequence) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)1 Pattern (java.util.regex.Pattern)1 InterruptibleCharSequence (org.graylog2.utilities.InterruptibleCharSequence)1