From c0125b685e0caeaf2bf3a9110fef2ac095cf4f83 Mon Sep 17 00:00:00 2001 From: emcho Date: Sun, 31 Jan 2010 14:50:31 +0000 Subject: [PATCH] More x-stun4j refactoring --- test/org/ice4j/stack/DatagramCollector.java | 3 +++ test/org/ice4j/stack/ShallowStackTest.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/org/ice4j/stack/DatagramCollector.java b/test/org/ice4j/stack/DatagramCollector.java index 5824d55..3e37161 100644 --- a/test/org/ice4j/stack/DatagramCollector.java +++ b/test/org/ice4j/stack/DatagramCollector.java @@ -51,6 +51,9 @@ public class DatagramCollector { synchronized(this) { + if(receivedPacket != null) + return; + try { wait(50); diff --git a/test/org/ice4j/stack/ShallowStackTest.java b/test/org/ice4j/stack/ShallowStackTest.java index 1ddc1de..91d2a21 100644 --- a/test/org/ice4j/stack/ShallowStackTest.java +++ b/test/org/ice4j/stack/ShallowStackTest.java @@ -285,11 +285,10 @@ public class ShallowStackTest extends TestCase { Response collectedResponse = null; public void processResponse(StunMessageEvent evt) { - collectedResponse = (Response)evt.getMessage(); - logger.finest("Received response."); - synchronized(this) { + collectedResponse = (Response)evt.getMessage(); + logger.finest("Received response."); notifyAll(); } } @@ -310,6 +309,8 @@ public class ShallowStackTest extends TestCase { { try { + if (collectedResponse != null) + return; wait(50); } catch (InterruptedException e) @@ -327,12 +328,11 @@ public class ShallowStackTest extends TestCase { public void requestReceived(StunMessageEvent evt) { - collectedRequest = (Request)evt.getMessage(); - stunStack.removeRequestListener(this); - logger.finest("Received request."); - synchronized(this) { + collectedRequest = (Request)evt.getMessage(); + stunStack.removeRequestListener(this); + logger.finest("Received request."); notifyAll(); } } @@ -341,6 +341,9 @@ public class ShallowStackTest extends TestCase { { synchronized(this) { + if (collectedRequest != null) + return; + try { wait(50);