Bug 566226 - Team.isExecutingCallin() may have threading issues

- make flag ThreadLocal
- fix nullness warning re getRole()
diff --git a/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF
index 670cf69..99f9ebd 100644
--- a/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.objectteams.runtime/META-INF/MANIFEST.MF
@@ -3,13 +3,13 @@
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.objectteams.runtime
 Automatic-Module-Name: org.eclipse.objectteams.runtime
-Bundle-Version: 2.8.1.qualifier
+Bundle-Version: 2.8.2.qualifier
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.jdt.annotation;bundle-version="[2.2.0,3.0.0)";resolution:=optional;visibility:=reexport
-Export-Package: org.eclipse.objectteams.otredyn.runtime;version="2.8.1",
- org.eclipse.objectteams.runtime;version="2.8.1",
- org.objectteams;version="2.8.1"
+Export-Package: org.eclipse.objectteams.otredyn.runtime;version="2.8.2",
+ org.eclipse.objectteams.runtime;version="2.8.2",
+ org.objectteams;version="2.8.2"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ClassPath: .
 
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeam.java b/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeam.java
index 0ffa7be..ad50a81 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeam.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/ITeam.java
@@ -17,6 +17,8 @@
  **********************************************************************/
 package org.objectteams;
 
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * Public interface of all team classes.
  */
@@ -121,7 +123,7 @@
 	 * @return
 	 * @throws IllegalArgumentException if <code>roleType</code> does not represent a member type of this team.
 	 */
-	public abstract <T> T getRole(Object aBase, Class<T> roleType) throws IllegalArgumentException;
+	public abstract <T> @Nullable T getRole(Object aBase, Class<T> roleType) throws IllegalArgumentException;
 
 	/**
 	 * Retrieve all bound roles registered in the current team.
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/Team.java b/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/Team.java
index f60f76b..39386ca 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/Team.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/objectteams/Team.java
@@ -24,6 +24,8 @@
 import java.util.Iterator;
 import java.util.WeakHashMap;
 
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  *  This is the root class of all team definitions.
  *  Any class with the <tt>team</tt> modifier implicitly inherits from this class.
@@ -432,7 +434,7 @@
 	/**
 	 * {@inheritDoc}
 	 */
-	public <T> T getRole(Object aBase, Class<T> roleType) throws IllegalArgumentException {
+	public <T> @Nullable T getRole(Object aBase, Class<T> roleType) throws IllegalArgumentException {
 		// overriding method to be generated by the compiler for each team with bound roles.
 		return null;
 	}
@@ -454,22 +456,22 @@
 	}
 
 	/** Internal variable to be set from generated code. */
-	private boolean _OT$isExecutingCallin = false;
+	private ThreadLocal<Boolean> _OT$isExecutingCallin = new ThreadLocal<>();
 
 	/**
 	 * Method only for internal use by generated code.
 	 */
 	public boolean _OT$setExecutingCallin(boolean newFlag) {
-		boolean oldVal = _OT$isExecutingCallin;
-		_OT$isExecutingCallin = newFlag;
-		return oldVal;
+		Boolean oldVal = _OT$isExecutingCallin.get();
+		_OT$isExecutingCallin.set(newFlag);
+		return Boolean.TRUE == oldVal;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public boolean isExecutingCallin() {
-		return _OT$isExecutingCallin;
+		return _OT$isExecutingCallin.get() == Boolean.TRUE;
 	}
 
 	/**
diff --git a/releng/map/otdt.map.in b/releng/map/otdt.map.in
index 795b04b..77226ba 100644
--- a/releng/map/otdt.map.in
+++ b/releng/map/otdt.map.in
@@ -20,7 +20,7 @@
 plugin@org.eclipse.objectteams.otdt.doc=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otdt.doc,tag=builds/201606070956

 !plugin@org.eclipse.objectteams.otdt.metrics=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otdt.metrics,tag=builds/201101290806

 

-plugin@org.eclipse.objectteams.runtime=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.runtime,tag=builds/202006091155

+plugin@org.eclipse.objectteams.runtime=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.runtime

 plugin@org.eclipse.objectteams.otre=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otre,tag=builds/201806120901

 plugin@org.eclipse.objectteams.otredyn=GIT,repo=git://git.eclipse.org/gitroot/objectteams/org.eclipse.objectteams.git,path=plugins/org.eclipse.objectteams.otredyn

 !the following is also referenced in otdt.doc/buildDoc.xml (plugin-name without version):