private final void checkValid() { // Fastpath if assertions are disabled. if (!isVerifying()) { return; } if (!valid) { throw new IllegalStateException("This Random instance has been invalidated and " + "is probably used out of its allowed context (test or suite)."); } final Thread owner = ownerRef.get(); if (owner == null || Thread.currentThread() != owner) { Throwable allocationEx = new StackTraceHolder("Original allocation stack for this Random (" + "allocated by " + ownerName + ")"); allocationEx.setStackTrace(allocationStack); throw new IllegalStateException( "This Random was created for/by another thread (" + ownerName + ")." + " Random instances must not be shared (acquire per-thread). Current thread: " + Thread.currentThread().toString(), allocationEx); } }
private final void checkValid() { // Fastpath if assertions are disabled. if (!isVerifying()) { return; } if (!valid) { throw new IllegalStateException("This Random instance has been invalidated and " + "is probably used out of its allowed context (test or suite)."); } final Thread owner = ownerRef.get(); if (owner == null || Thread.currentThread() != owner) { Throwable allocationEx = new StackTraceHolder("Original allocation stack for this Random (" + "allocated by " + ownerName + ")"); allocationEx.setStackTrace(allocationStack); throw new IllegalStateException( "This Random was created for/by another thread (" + ownerName + ")." + " Random instances must not be shared (acquire per-thread). Current thread: " + Thread.currentThread().toString(), allocationEx); } }
public Randomness(Thread owner, RandomSupplier supplier, long seed, SeedDecorator... decorators) { this.seed = seed; this.decorators = decorators; this.supplier = supplier; Random delegate = supplier.get(decorate(seed, decorators)); if (AssertingRandom.isVerifying()) { this.random = new AssertingRandom(owner, delegate); } else { this.random = delegate; } }
public Randomness(Thread owner, RandomSupplier supplier, long seed, SeedDecorator... decorators) { this.seed = seed; this.decorators = decorators; this.supplier = supplier; Random delegate = supplier.get(decorate(seed, decorators)); if (AssertingRandom.isVerifying()) { this.random = new AssertingRandom(owner, delegate); } else { this.random = delegate; } }