Skip to content

Commit

Permalink
Synchronize on a specific lock in static, rather than our mojo instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugojosefson committed Jun 21, 2011
1 parent 33e52c7 commit e3f9acd
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public abstract class AbstractAndroidMojo extends AbstractMojo {
*/
protected List testClasses;

private static final Object adbLock = new Object();
private static boolean adbInitialized = false;

/**
Expand Down Expand Up @@ -509,14 +510,16 @@ protected File resolveArtifactToFile(Artifact artifact) throws MojoExecutionExce
* the init call in the library is also synchronized .. just in case.
* @return
*/
private synchronized AndroidDebugBridge initAndroidDebugBridge() {
if (!adbInitialized) {
AndroidDebugBridge.init(false);
adbInitialized = true;
private AndroidDebugBridge initAndroidDebugBridge() {
synchronized (adbLock) {
if (!adbInitialized) {
AndroidDebugBridge.init(false);
adbInitialized = true;
}
AndroidDebugBridge androidDebugBridge = AndroidDebugBridge.createBridge();
waitUntilConnected(androidDebugBridge);
return androidDebugBridge;
}
AndroidDebugBridge androidDebugBridge = AndroidDebugBridge.createBridge();
waitUntilConnected(androidDebugBridge);
return androidDebugBridge;
}

/**
Expand Down

0 comments on commit e3f9acd

Please sign in to comment.