Closed GoogleCodeExporter closed 8 years ago
Looking at the line - two things might have happened:
- either the split didn't have a Stopwatch - while it is possible (anonymous
Split created directly), this method is called for Split's stopwatch (and
actually from stopwatch code), so we can rule this out
- or no timeline was found... which seems the probable cause
I can't say for sure what could be the reason.
org.javasimon.callback.timeline.TimelineCallback#onSimonCreated is called in
synchronized section on Manager and there should be no way how stopwatch
without the timeline gets out of this call. What could happen is that there
were some stopwatches already before the callback. These could be initialized
in the Callback's initialize() - however this does not get manager as a
parameter, so it should not use it (or we should introduce this feature).
This leads to lazy init the timeline attribute for the stopwatch if it does not
exist yet - or ignoring the event if the timeline is null. Right now I'll
commit those checks (ifs) and later we can investigate this a bit more.
Original comment by virgo47
on 3 Nov 2013 at 10:27
Fixed by http://code.google.com/p/javasimon/source/detail?r=1599a57f8eb0 -
added test as well.
Original comment by virgo47
on 3 Nov 2013 at 11:43
We implemented a method to reset all Simons, maybe it was used in that exact
time leading to a concurrency problem.
public void reset(String simonName) {
if (SimonManager.getSimon(simonName) == null) {
throw new IllegalArgumentException(String.format("Simon '%s' not found", simonName));
}
reset(SimonManager.getSimon(simonName));
}
private void reset(Simon simon) {
simon.reset();
for (Simon childSimon : simon.getChildren()) {
reset(childSimon);
}
}
Is it the recommended way to achieve this?
Thanks for looking after this issue.
Original comment by z...@summa.com.br
on 4 Nov 2013 at 4:46
Hi Ziba - your first method is ok, the second one is actually just a copy of
our org.javasimon.utils.SimonUtils#recursiveReset, so you can call that one
directly from the first one. Reset however does not affect attributes, so it
should not be a problem.
The only way I see now is that your app somehow accessed some stopwatch created
before the timeline callback was added. I'm not saying that's what happened, I
just don't see other way now. NPE was in any case too harsh, now worst can
happen is that you have some stopwatch without a timeline.
Original comment by virgo47
on 4 Nov 2013 at 8:17
Original issue reported on code.google.com by
z...@summa.com.br
on 25 Oct 2013 at 6:29