<commit_before>package com.twitter.gizzard

import java.util.concurrent.{CountDownLatch, ExecutionException, SynchronousQueue,
  ThreadPoolExecutor, TimeoutException, TimeUnit}
import scala.collection.mutable
import com.twitter.xrayspecs.TimeConversions._
import org.specs.Specification
import org.specs.mock.{ClassMocker, JMocker}


object FutureSpec extends ConfiguredSpecification with JMocker with ClassMocker {

  "Future" should {
    var future: Future = null

    doBefore {
      future = new Future("test", 1, 1, 1.hour, 50.milliseconds)
    }

    doAfter {
      future.shutdown()
    }

    "execute in the future" in {
      future { 3 * 4 }.get mustEqual 12
    }

    "timeout appropriately" in {
      future { Thread.sleep(20) }.get(10, TimeUnit.MILLISECONDS) must throwA[TimeoutException]
    }

    "timeout a stuffed-up queue" in {
      val startFlag = new CountDownLatch(1)
      val continueFlag = new CountDownLatch(1)
      future { startFlag.await(); continueFlag.countDown(); Thread.sleep(200) }
      startFlag.countDown()
      continueFlag.await()
      future { 3 * 4 }.get must throwA[ExecutionException]
    }
  }
}<commit_msg>fix test, maybe.<commit_after>package com.twitter.gizzard

import java.util.concurrent.{CountDownLatch, ExecutionException, TimeoutException, TimeUnit}
import scala.collection.mutable
import com.twitter.xrayspecs.TimeConversions._
import org.specs.Specification
import org.specs.mock.{ClassMocker, JMocker}


object FutureSpec extends ConfiguredSpecification with JMocker with ClassMocker {

  "Future" should {
    var future: Future = null

    doBefore {
      future = new Future("test", 1, 1, 1.hour, 50.milliseconds)
    }

    doAfter {
      future.shutdown()
    }

    "execute in the future" in {
      future { 3 * 4 }.get mustEqual 12
    }

    "timeout appropriately" in {
      future { Thread.sleep(20) }.get(10, TimeUnit.MILLISECONDS) must throwA[TimeoutException]
    }

    "timeout a stuffed-up queue" in {
      val startFlag = new CountDownLatch(1)
      val continueFlag = new CountDownLatch(1)
      future { startFlag.await(); continueFlag.countDown(); Thread.sleep(2000) }
      startFlag.countDown()
      continueFlag.await()
      3 mustEqual 3
      future { 3 * 4 }.get must throwA[Exception]
    }
  }
}
{'fraction_non_alphanumeric': 0.1001306051371354, 'fraction_numerical': 0.01872006965607314, 'mean_word_length': 3.344045368620038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2885835', 'n_tokens_mistral': 756, 'n_tokens_neox': 708, 'n_words': 177}