MAPREDUCE-7302. Upgrading to JUnit 4.13 causes testcase TestFetcher.testCorruptedIFile() to fail. Contributed by Peter Bacsko. Reviewed by Akira Ajisaka.

(cherry picked from commit da93cd962c)
This commit is contained in:
Eric Badger 2021-04-23 18:42:50 +00:00
parent b743d56eb4
commit 930f384e30
2 changed files with 15 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import org.apache.hadoop.io.nativeio.NativeIO;
import static org.apache.hadoop.io.nativeio.NativeIO.POSIX.POSIX_FADV_WILLNEED;
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
@ -60,6 +61,16 @@ public class ReadaheadPool {
}
}
@VisibleForTesting
public static void resetInstance() {
synchronized (ReadaheadPool.class) {
if (instance != null) {
instance.pool.shutdownNow();
instance = null;
}
}
}
private ReadaheadPool() {
pool = new ThreadPoolExecutor(POOL_SIZE, MAX_POOL_SIZE, 3L, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(CAPACITY));

View File

@ -46,6 +46,7 @@ import java.util.ArrayList;
import javax.crypto.SecretKey;
import org.apache.hadoop.io.ReadaheadPool;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.Counters;
import org.apache.hadoop.mapred.IFileInputStream;
@ -92,6 +93,8 @@ public class TestFetcher {
@SuppressWarnings("unchecked") // mocked generics
public void setup() {
LOG.info(">>>> " + name.getMethodName());
// to avoid threading issues with JUnit 4.13+
ReadaheadPool.resetInstance();
job = new JobConf();
job.setBoolean(MRJobConfig.SHUFFLE_FETCH_RETRY_ENABLED, false);
jobWithRetry = new JobConf();