Search in sources :

Example 6 with SuppressForbidden

use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.

the class JmxProcessProbe method findMethod.

@SuppressForbidden("Reflection necessary")
private static Method findMethod(final String methodName, final Class<?> clazz) {
    try {
        final Method method = clazz.getDeclaredMethod(methodName);
        method.setAccessible(true);
        return method;
    } catch (Exception e) {
        return null;
    }
}
Also used : Method(java.lang.reflect.Method) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 7 with SuppressForbidden

use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.

the class MongoDbSession method setAttributes.

@SuppressForbidden("Deliberate use of ObjectOutputStream")
public void setAttributes(Map<Object, Object> attributes) {
    try {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        // FIXME: This could break backward compatibility if different Java versions are being used.
        final ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(attributes);
        oos.close();
        fields.put("attributes", bos.toByteArray());
    } catch (IOException e) {
        LOG.error("too bad :(", e);
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 8 with SuppressForbidden

use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.

the class StaticFieldFilterTest method testFilterIsNotOverwritingExistingKeys.

@Test
@SuppressForbidden("Executors#newSingleThreadExecutor() is okay for tests")
public void testFilterIsNotOverwritingExistingKeys() throws Exception {
    Message msg = new Message("hello", "junit", Tools.nowUTC());
    msg.addField("foo", "IWILLSURVIVE");
    final StaticFieldFilter filter = new StaticFieldFilter(inputService, new EventBus(), Executors.newSingleThreadScheduledExecutor());
    filter.filter(msg);
    assertEquals("hello", msg.getMessage());
    assertEquals("junit", msg.getSource());
    assertEquals("IWILLSURVIVE", msg.getField("foo"));
}
Also used : Message(org.graylog2.plugin.Message) EventBus(com.google.common.eventbus.EventBus) Test(org.junit.Test) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Aggregations

SuppressForbidden (org.graylog2.shared.SuppressForbidden)8 Test (org.junit.Test)5 Message (org.graylog2.plugin.Message)3 EventBus (com.google.common.eventbus.EventBus)2 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Map (java.util.Map)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Method (java.lang.reflect.Method)1 RawMessage (org.graylog2.plugin.journal.RawMessage)1 DateTime (org.joda.time.DateTime)1