#2622: Let ThrottleTest work independently of real time
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package net.md_5.bungee;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Ticker;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -13,8 +15,15 @@ public class ConnectionThrottle
|
||||
private final int throttleLimit;
|
||||
|
||||
public ConnectionThrottle(int throttleTime, int throttleLimit)
|
||||
{
|
||||
this(Ticker.systemTicker(), throttleTime, throttleLimit);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
ConnectionThrottle(Ticker ticker, int throttleTime, int throttleLimit)
|
||||
{
|
||||
this.throttle = CacheBuilder.newBuilder()
|
||||
.ticker(ticker)
|
||||
.concurrencyLevel( Runtime.getRuntime().availableProcessors() )
|
||||
.initialCapacity( 100 )
|
||||
.expireAfterWrite( throttleTime, TimeUnit.MILLISECONDS )
|
||||
|
Reference in New Issue
Block a user