5608057 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

NPE in Counter on error = null #379

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Version: 1.49.0
Class: net.bull.javamelody.Counter
abstract: NPE on synchronized error

If Counter.addRequestForSystemError is called an error rises on line 539, 
because of a missing check if error is null.

        synchronized (errors) {
            errors.addLast(new CounterError(requestName, stackTrace));
            if (errors.size() > MAX_ERRORS_COUNT) {
                errors.removeFirst();
            }
        }

Original issue reported on code.google.com by hannes.a...@gmail.com on 13 Feb 2014 at 2:11

GoogleCodeExporter commented 8 years ago
I don't understand yet, how you can get this NPE.
Can you give a stack-trace?
Do you create an instance of Counter yourself?

Original comment by evernat@free.fr on 14 Feb 2014 at 9:03

GoogleCodeExporter commented 8 years ago
I've written an package-proxy-Class to net.bull.javamelody namespace to provide 
service post process. The class actually doing the melody reporting is a 
variant of the spring interceptor (see attached file).

Original comment by hannes.a...@gmail.com on 17 Feb 2014 at 7:15

Attachments:

GoogleCodeExporter commented 8 years ago
You probably know that you use an internal and undocumented API.

That said, I suggest to not record the stack-traces of exceptions for your 
spring like beans, because it may soon create a big overhead to compute all the 
stack-traces.
It means: don't use addRequestForSystemError in this case.
(Otherwise, note that the boolean errorCounter and the list errors are really 
supposed to be coherent with each other.)

By the way, if you want to use the addRequest method like you have written, you 
are supposed to call the bindContext method some time before.

I hope that you have what you need with this non-API.
But, this is of course an invalid issue for the reason given above.

Original comment by evernat@free.fr on 17 Feb 2014 at 3:52