More x-stun4j refactoring

This commit is contained in:
emcho 2010-01-31 14:50:31 +00:00
parent ed3bf01531
commit c0125b685e
2 changed files with 13 additions and 7 deletions

View File

@ -51,6 +51,9 @@ public class DatagramCollector
{ {
synchronized(this) synchronized(this)
{ {
if(receivedPacket != null)
return;
try try
{ {
wait(50); wait(50);

View File

@ -285,11 +285,10 @@ public class ShallowStackTest extends TestCase {
Response collectedResponse = null; Response collectedResponse = null;
public void processResponse(StunMessageEvent evt) public void processResponse(StunMessageEvent evt)
{ {
collectedResponse = (Response)evt.getMessage();
logger.finest("Received response.");
synchronized(this) synchronized(this)
{ {
collectedResponse = (Response)evt.getMessage();
logger.finest("Received response.");
notifyAll(); notifyAll();
} }
} }
@ -310,6 +309,8 @@ public class ShallowStackTest extends TestCase {
{ {
try try
{ {
if (collectedResponse != null)
return;
wait(50); wait(50);
} }
catch (InterruptedException e) catch (InterruptedException e)
@ -327,12 +328,11 @@ public class ShallowStackTest extends TestCase {
public void requestReceived(StunMessageEvent evt) public void requestReceived(StunMessageEvent evt)
{ {
collectedRequest = (Request)evt.getMessage();
stunStack.removeRequestListener(this);
logger.finest("Received request.");
synchronized(this) synchronized(this)
{ {
collectedRequest = (Request)evt.getMessage();
stunStack.removeRequestListener(this);
logger.finest("Received request.");
notifyAll(); notifyAll();
} }
} }
@ -341,6 +341,9 @@ public class ShallowStackTest extends TestCase {
{ {
synchronized(this) synchronized(this)
{ {
if (collectedRequest != null)
return;
try try
{ {
wait(50); wait(50);