Skip to content

Commit

Permalink
Avoid NPEs in getTaskHistograms if it races with profiler start/stop.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 375036917
  • Loading branch information
meisterT authored and copybara-github committed May 21, 2021
1 parent 2f0927a commit a64cd4a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ private void initHistograms() {
// TODO(ulfjack): This returns incomplete data by design. Maybe we should return the histograms on
// stop instead? However, this is currently only called from one location in a module, and that
// can't call stop itself. What to do?
public ImmutableList<StatRecorder> getTasksHistograms() {
return ImmutableList.copyOf(tasksHistograms);
public synchronized ImmutableList<StatRecorder> getTasksHistograms() {
return isActive() ? ImmutableList.copyOf(tasksHistograms) : ImmutableList.of();
}

public static Profiler instance() {
Expand Down

0 comments on commit a64cd4a

Please sign in to comment.