Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in RiemannBatchClient #29

Open
kanakb opened this issue Nov 22, 2013 · 1 comment
Open

NPE in RiemannBatchClient #29

kanakb opened this issue Nov 22, 2013 · 1 comment

Comments

@kanakb
Copy link

kanakb commented Nov 22, 2013

I'm running jdk6 with jsr166y in my classpath , sample code:

RiemannClient c = RiemannClient.tcp("targethost", 5555);
RiemannBatchClient b = new RiemannBatchClient(100, c);
b.connect();
b.event().
    host(host).
    service("fridge" + i).
    state("running").
    metric(Math.random()).
    tags("appliance", "cold").
    send();
b.flush();

I get the following exception:

java.lang.NullPointerException
    at com.aphyr.riemann.client.RiemannBatchClient.queue(RiemannBatchClient.java:133)
    at com.aphyr.riemann.client.RiemannBatchClient.sendEvents(RiemannBatchClient.java:87)
    at com.aphyr.riemann.client.AbstractRiemannClient.sendEvents(AbstractRiemannClient.java:109)
    at com.aphyr.riemann.client.EventDSL.send(EventDSL.java:177)
    at testapp.clienttest.RiemannClientTest$1.run(RiemannClientTest.java:38)

If I write this code, which looks a lot like the code in RiemannBatchClient:

Class<?> klass = Class.forName("jsr166y.LinkedTransferQueue");
AbstractTransferQueue<Write> buffer = klass.asSubclass(AbstractTransferQueue.class)
    .newInstance();

I get this:

java.lang.ClassCastException: class jsr166y.LinkedTransferQueue
    at java.lang.Class.asSubclass(Class.java:3018)
    at testapp.clienttest.RiemannClientTest$1.run(RiemannClientTest.java:23)

Looks like it doesn't like swapping in jsr166y's LinkedTransferQueue?

@eribeiro
Copy link
Contributor

In fact, jsr166y.LinkedTransferQueue is not a subclass of AbstractTransferQueue (hence the ClassCastException). jsr166y.LTQ inherits of java.util.AbstractQueue instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants