Buggy code:
@ ThreadSafe public class ConcurrentTaskExecutor < E > extends AbstractExecutorService implements ExecutorFactory < E > { private static final Set < ConcurrentTaskExecutor < ? > > EXECUTORS = Sets . newHashSet ( ) ; private static final int EMERGENCY_MARGIN = 4 ; private static final boolean ARCH_64 = System . getProperty ( "os.arch" ) . contains ( "64" ) ; private static final int TASK_LENGTH = ConcurrentTaskExecutor . calcTaskLen ( ) ; private static final int STARTING = 0 ; private static final int RUNNING = 1 ; private static final int SHUTTING_DOWN = 2 ; private static final int STOPPED = 3 ; private final AtomicReferenceArray < ConcurrentTaskExecutor < E > . ThreadWorker > executors ; private final int scale ; private final String name ; private final AtomicInteger emergencyScale = new AtomicInteger ( 1 ) ; private final Callable < ConcurrentTaskExecutor < E > . ThreadWorker > obtainWorker = new Callable < ConcurrentTaskExecutor < E > . ThreadWorker > ( ) { @ Override public ConcurrentTaskExecutor < E > . ThreadWorker call ( ) throws Exception { } } ; private final ConcurrentCache < E , ConcurrentTaskExecutor < E > . ThreadWorker > assigned = ConcurrentCache . create ( ) ; private volatile int state = ConcurrentTaskExecutor . STARTING ; @ GuardedBy ( "this" ) private int counter = 0 ; private ConcurrentTaskExecutor ( int scale , String name ) { } private static int calcTaskLen ( ) { int maxSizePossible = 10000 ; int objectSize = 4 ; if ( ConcurrentTaskExecutor . ARCH_64 ) objectSize = 8 ; int len ; long max = ( ( Runtime . getRuntime ( ) . freeMemory ( ) ) // objectSize ) // 15 ; if ( max > ( ( long ) ( maxSizePossible ) ) ) <START_BUG> len = ConcurrentTaskExecutor . maxSizePossible ( ) ; <END_BUG> else len = ( ( int ) ( max ) ) ; return len ; } public static < E > ConcurrentTaskExecutor < E > create ( int scale , String name ) { } @ InternalUseOnly public static Set < ConcurrentTaskExecutor < ? > > executors ( ) { } @ Override public TaskExecutor scaledThread ( ) { } @ Override public TaskExecutor assign ( E assignment ) { } @ Override public void set ( final TaskExecutor executor , E assignment ) { } @ Override public void removeAssignment ( E assignment ) { } @ Override public Collection < E > values ( ) { } @ Override public List < TaskExecutor > threadList ( ) { } @ Override public void shutdown ( ) { } @ Override public List < Runnable > shutdownNow ( ) { } @ Override public boolean isShutdown ( ) { } @ Override public boolean isTerminated ( ) { } @ Override public boolean awaitTermination ( long l , TimeUnit timeUnit ) throws InterruptedException { } @ Override public void execute ( Runnable runnable ) { } public void handleShutdown ( int index , Queue < Runnable > remaining ) { } @ AccessNoDoc private class ThreadWorker extends Thread implements TaskExecutor { protected final BlockingQueue < Runnable > tasks = new ArrayBlockingQueue < > ( ConcurrentTaskExecutor . TASK_LENGTH ) ; private final ConcurrentLinkedQueue < Runnable > overflow = new ConcurrentLinkedQueue < > ( ) ; private final int index ; private ThreadWorker ( int index , String name ) { } public ConcurrentTaskExecutor < E > . ThreadWorker startWorker ( ) { } public ConcurrentTaskExecutor < E > . ThreadWorker startWorker ( Queue < Runnable > tasks ) { } @ Override public void interrupt ( ) { } @ Override public boolean addTask ( Runnable task ) { } @ Override public void run ( ) { } private Runnable nextTask ( ) throws InterruptedException { } @ Override public Thread asThread ( ) { } } private class OverflowWorker extends ConcurrentTaskExecutor < E > . ThreadWorker { private OverflowWorker ( int index ) { } @ Override public boolean addTask ( Runnable task ) { } @ Override public void run ( ) { } } }

Fix:
len = maxSizePossible ;