From 29f9ee01ced60bcf2f5f52972134bc50cf10b445 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Wed, 9 Apr 2014 16:50:25 +0000 Subject: [PATCH] svn merge -c 1586030 from trunk for HADOOP-10473. TestCallQueueManager should interrupt before counting calls. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1586031 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../apache/hadoop/ipc/TestCallQueueManager.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index ec59a46e2c3..4030d978ba2 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -73,6 +73,9 @@ Release 2.4.1 - UNRELEASED HADOOP-10456. Bug in Configuration.java exposed by Spark (ConcurrentModificationException). (Nishkam Ravi via cnauroth) + HADOOP-10473. TestCallQueueManager should interrupt before counting calls. + (szetszwo) + Release 2.4.0 - 2014-04-07 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java index 446edfb2f8a..1b618b1ce8b 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallQueueManager.java @@ -19,7 +19,6 @@ package org.apache.hadoop.ipc; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.HashMap; @@ -49,7 +48,7 @@ public class TestCallQueueManager { public volatile int callsAdded = 0; // How many calls we added, accurate unless interrupted private final int maxCalls; - private boolean isRunning = true; + private volatile boolean isRunning = true; public Putter(CallQueueManager aCq, int maxCalls, int tag) { this.maxCalls = maxCalls; @@ -201,16 +200,22 @@ public class TestCallQueueManager { // Ensure no calls were dropped long totalCallsCreated = 0; - long totalCallsConsumed = 0; - for (Putter p : producers) { - totalCallsCreated += p.callsAdded; threads.get(p).interrupt(); } + for (Putter p : producers) { + threads.get(p).join(); + totalCallsCreated += p.callsAdded; + } + + long totalCallsConsumed = 0; for (Taker t : consumers) { - totalCallsConsumed += t.callsTaken; threads.get(t).interrupt(); } + for (Taker t : consumers) { + threads.get(t).join(); + totalCallsConsumed += t.callsTaken; + } assertEquals(totalCallsConsumed, totalCallsCreated); }