Class SentryRandom

java.lang.Object
io.sentry.util.SentryRandom

public final class SentryRandom extends Object
This SentryRandom is a compromise used for improving performance of the SDK.

We did some testing where using Random from multiple threads degrades performance significantly. We opted for this approach as it wasn't easily possible to vendor ThreadLocalRandom since it's using advanced features that can cause java.lang.IllegalAccessError.

  • Constructor Details

    • SentryRandom

      public SentryRandom()
  • Method Details

    • current

      @NotNull public static @NotNull Random current()
      Returns the current threads instance of Random. An instance of Random will be created the first time this is invoked on each thread.

      NOTE: Avoid holding a reference to the returned Random instance as sharing a reference across threads (while being thread-safe) will likely degrade performance significantly.

      Returns:
      random