Bug 214368 - Race when adding/removing breakpoints in remote ant
debugger
diff --git a/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF
index 6a734ed..5d82c6e 100644
--- a/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF
+++ b/ant/org.eclipse.ant.launching/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
 Bundle-Localization: plugin
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.ant.launching;singleton:=true
-Bundle-Version: 1.0.200.qualifier
+Bundle-Version: 1.0.300.qualifier
 Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching
 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
  org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)",
diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntDebugBuildLogger.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntDebugBuildLogger.java
index 10f5d35..c1e6e7d 100644
--- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntDebugBuildLogger.java
+++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntDebugBuildLogger.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -97,16 +97,26 @@
 								RemoteAntDebugBuildLogger.this.notifyAll();
 							}
 						} else if (message.startsWith(DebugMessageIds.TERMINATE)) {
-						    sendRequestResponse(DebugMessageIds.TERMINATED);
-							shutDown();
+							synchronized(RemoteAntDebugBuildLogger.this) {
+							    sendRequestResponse(DebugMessageIds.TERMINATED);
+								shutDown();
+							}
 						} else if (message.startsWith(DebugMessageIds.STACK)) {
-							marshallStack();
+							synchronized(RemoteAntDebugBuildLogger.this) {
+								marshallStack();
+							}
 						} else if (message.startsWith(DebugMessageIds.ADD_BREAKPOINT)) {
-							addBreakpoint(message);
+							synchronized(RemoteAntDebugBuildLogger.this) {
+								addBreakpoint(message);
+							}
 						} else if (message.startsWith(DebugMessageIds.REMOVE_BREAKPOINT)) {
-							removeBreakpoint(message);
+							synchronized(RemoteAntDebugBuildLogger.this) {
+								removeBreakpoint(message);
+							}
 						}  else if (message.startsWith(DebugMessageIds.PROPERTIES)) {
-							marshallProperties();
+							synchronized(RemoteAntDebugBuildLogger.this) {
+								marshallProperties();
+							}
 						}
 					}
 				} 
@@ -140,7 +150,7 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger#shutDown()
 	 */
-	protected void shutDown() {
+	protected synchronized void shutDown() {
 		if (fRequestWriter != null) {
 			fRequestWriter.close();
 			fRequestWriter= null;
@@ -190,7 +200,7 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.ant.internal.launching.remote.logger.RemoteAntBuildLogger#buildFinished(org.apache.tools.ant.BuildEvent)
 	 */
-	public void buildFinished(BuildEvent event) {
+	public synchronized void buildFinished(BuildEvent event) {
 		super.buildFinished(event);
 		fDebugState.buildFinished();
 		fDebugState = null;
@@ -212,7 +222,7 @@
 	/* (non-Javadoc)
 	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
 	 */
-	public void taskStarted(BuildEvent event) {
+	public synchronized void taskStarted(BuildEvent event) {
         super.taskStarted(event);
 		fDebugState.taskStarted(event);
 	}
@@ -298,7 +308,7 @@
 		return null;
 	}
 
-	private void sendRequestResponse(String message) {
+	private synchronized void sendRequestResponse(String message) {
 		if (fRequestWriter == null) {
 			return;
 		}
@@ -345,7 +355,7 @@
 	/* (non-Javadoc)
 	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
 	 */
-	public void targetStarted(BuildEvent event) {
+	public synchronized void targetStarted(BuildEvent event) {
 		fDebugState.targetStarted(event);
 		if (!fSentProcessId) {
 			establishConnection();
@@ -357,7 +367,7 @@
     /* (non-Javadoc)
      * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
      */
-    public void targetFinished(BuildEvent event) {
+    public synchronized void targetFinished(BuildEvent event) {
         super.targetFinished(event);
 		fDebugState.setTargetExecuting(null);
     }   
@@ -365,7 +375,7 @@
     /* (non-Javadoc)
      * @see org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger#configure(java.util.Map)
      */
-    public void configure(Map userProperties) {
+    public synchronized void configure(Map userProperties) {
        super.configure(userProperties);
        String requestPortProperty= (String) userProperties.remove("eclipse.connect.request_port"); //$NON-NLS-1$
         if (requestPortProperty != null) {