Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8358318

JFR: Tighten up PlatformTracer initialization

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 25
    • hotspot
    • jfr
    • master

      Started as SonarCloud complaint that MethodSetting.apply initializes a static field. But I think there is a larger problem here, which I completely missed during JDK-8352738 review:

      public final class MethodSetting extends FilterSetting {
         ...
          private static volatile boolean initialized;

          @Override
          protected void apply(PlatformEventType eventType, List<String> filters) {
              if (!initialized) {
                  PlatformTracer.initialize();
                  initialized = true;
              }
              PlatformTracer.setFilters(modification, filters);
          }
      }

      This initialization is not atomic, and it looks to me we can plausibly (though unlikely) enter this code from multiple threads. Then we will call into PlatformTracer.initialize several times. It would be nice to tighten up this initialization.

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: