You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2012/09/07 17:51:58 UTC
svn commit: r1382074 - in /qpid/trunk/qpid/java/perftests/src:
main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
Author: kwall
Date: Fri Sep 7 15:51:58 2012
New Revision: 1382074
URL: http://svn.apache.org/viewvc?rev=1382074&view=rev
Log:
QPID-4275: Java Performance Tests - race condition between closing test consumer and test connection
Applied patch from Philip Harvey <ph...@philharveyonline.com>
Modified:
qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java?rev=1382074&r1=1382073&r2=1382074&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java Fri Sep 7 15:51:58 2012
@@ -108,8 +108,16 @@ public class ParticipantExecutor
}
finally
{
+ try
+ {
+ _participant.releaseResources();
+ }
+ catch(Exception e)
+ {
+ LOGGER.error("Participant " + _participant + " unable to release resources", e);
+ }
+
_client.sendResults(result);
- _participant.releaseResources();
}
}
}
Modified: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java?rev=1382074&r1=1382073&r2=1382074&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java (original)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java Fri Sep 7 15:51:58 2012
@@ -20,6 +20,7 @@
package org.apache.qpid.disttest.client;
import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -69,8 +70,8 @@ public class ParticipantExecutorTest ext
InOrder inOrder = inOrder(_participant, _client);
inOrder.verify(_participant).doIt(CLIENT_NAME);
- inOrder.verify(_client).sendResults(_mockResult);
inOrder.verify(_participant).releaseResources();
+ inOrder.verify(_client).sendResults(_mockResult);
}
public void testParticipantThrowsException() throws Exception
@@ -82,13 +83,28 @@ public class ParticipantExecutorTest ext
InOrder inOrder = inOrder(_participant, _client);
inOrder.verify(_participant).doIt(CLIENT_NAME);
+ inOrder.verify(_participant).releaseResources();
inOrder.verify(_client).sendResults(argThat(HAS_ERROR));
+ }
+
+ public void testReleaseResourcesThrowsException() throws Exception
+ {
+ when(_participant.doIt(CLIENT_NAME)).thenReturn(_mockResult);
+ doThrow(DistributedTestException.class).when(_participant).releaseResources();
+
+ _participantExecutor.start(_client);
+
+ InOrder inOrder = inOrder(_participant, _client);
+
+ inOrder.verify(_participant).doIt(CLIENT_NAME);
inOrder.verify(_participant).releaseResources();
+
+ // check that sendResults is called even though releaseResources threw an exception
+ inOrder.verify(_client).sendResults(_mockResult);
}
public void testThreadNameAndDaemonness() throws Exception
{
-
ThreadPropertyReportingParticipant participant = new ThreadPropertyReportingParticipant(PARTICIPANT_NAME);
_participantExecutor = new ParticipantExecutor(participant);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org