Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java	(revision 1561)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java	(revision 1614)
@@ -142,46 +142,51 @@
      */
     @Override
-    public void handleHttpExchange(HttpExchange httpExchange) {
+    public synchronized void handleHttpExchange(HttpExchange httpExchange) {
         // send the exchange to the server and wait for completion
-        synchronized (openRequests) {
-            Request httpMonitorRequest = httpClient.newRequest(httpMonitorServer, httpMonitorPort);
-            httpMonitorRequest.method(HttpMethod.POST);
-            httpMonitorRequest.version(HttpVersion.HTTP_1_1);
-
-            OutputStreamContentProvider out = new OutputStreamContentProvider();
-            httpMonitorRequest.content(out);
-            httpMonitorRequest.send(this);
-
-            try {
-                JAXBContext jaxbContext =
-                        JAXBContext.newInstance(HttpExchange.class.getPackage().getName());
-                Marshaller marshaller = jaxbContext.createMarshaller();
-
-                OutputStreamWriter writer = new OutputStreamWriter(out.getOutputStream(), "UTF-8");
-                marshaller.marshal(new ObjectFactory().createHttpExchange(httpExchange), writer);
-
-                out.getOutputStream().close();
-            }
-            catch (JAXBException e) {
-                Console.printerrln("could not convert request and response to XML string: " + e);
-                Console.logException(e);
-            }
-            catch (IOException e) {
-                Console.printerrln
+        Request httpMonitorRequest = httpClient.newRequest(httpMonitorServer, httpMonitorPort);
+        httpMonitorRequest.method(HttpMethod.POST);
+        httpMonitorRequest.version(HttpVersion.HTTP_1_1);
+
+        OutputStreamContentProvider out = new OutputStreamContentProvider();
+        httpMonitorRequest.content(out);
+        
+        openRequests.add(httpMonitorRequest);
+        httpMonitorRequest.send(this);
+
+        try {
+            JAXBContext jaxbContext =
+                JAXBContext.newInstance(HttpExchange.class.getPackage().getName());
+            Marshaller marshaller = jaxbContext.createMarshaller();
+
+            OutputStreamWriter writer = new OutputStreamWriter(out.getOutputStream(), "UTF-8");
+            marshaller.marshal(new ObjectFactory().createHttpExchange(httpExchange), writer);
+
+            out.getOutputStream().close();
+        }
+        catch (JAXBException e) {
+            Console.printerrln("could not convert request and response to XML string: " + e);
+            Console.logException(e);
+        }
+        catch (IOException e) {
+            Console.printerrln
                 ("could not close the stream for sending data to the HTML monitor: " + e);
-                Console.logException(e);
-            }
-            
-            openRequests.add(httpMonitorRequest);
-            
-            try {
-                // wait for the request to be removed fromt the list asynchronously
-                while (openRequests.contains(httpMonitorRequest)) {
-                    openRequests.wait();
+            Console.logException(e);
+        }
+
+        try {
+            // wait for the request to be removed from the list asynchronously
+            int count = 30;
+            while (openRequests.contains(httpMonitorRequest)) {
+                this.wait(1000);
+                
+                if (--count == 0) {
+                    // after 30 seconds, cancel the sending of the loggin request
+                    openRequests.remove(httpMonitorRequest);
+                    break;
                 }
             }
-            catch (InterruptedException e) {
-                // ignore, as this may only happen on system shutdown
-            }
+        }
+        catch (InterruptedException e) {
+            // ignore, as this may only happen on system shutdown
         }
     }
@@ -191,5 +196,5 @@
      */
     @Override
-    public void onComplete(Result result) {
+    public synchronized void onComplete(Result result) {
         if (result.isFailed()) {
             Console.traceln
@@ -198,8 +203,6 @@
         }
         
-        synchronized (openRequests) {
-            openRequests.remove(result.getRequest());
-            openRequests.notify();
-        }
+        openRequests.remove(result.getRequest());
+        this.notify();
     }
 
