Skip to content

Commit

Permalink
Removed final deadlock caused by ForgeTestMethodExecutor. Container w…
Browse files Browse the repository at this point in the history
…orks. Please verify and rock on.
  • Loading branch information
lincolnthree committed Mar 20, 2013
1 parent 7be44d3 commit 424027d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.jboss.forge.container.util.Addons;
import org.jboss.forge.container.util.ClassLoaders;
import org.jboss.forge.container.util.Files;
import org.jboss.forge.container.util.Threads;
import org.jboss.forge.maven.dependencies.FileResourceFactory;
import org.jboss.forge.maven.dependencies.MavenContainer;
import org.jboss.forge.maven.dependencies.MavenDependencyResolver;
Expand Down Expand Up @@ -70,7 +69,6 @@ public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException

repository.deploy(addonToDeploy, ((ForgeArchive) archive).getAddonDependencies(), new ArrayList<File>());
repository.enable(addonToDeploy);
Threads.sleep(200);
}
else if (archive instanceof ForgeRemoteAddon)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,40 +90,32 @@ public Void call() throws Exception
lock.start();
lock.join();

final Object instance = forge.getLockManager().performLocked(LockMode.WRITE, new Callable<Object>()
Object instance = null;
for (Addon addon : addonRegistry.getRegisteredAddons())
{
@Override
public Object call() throws Exception
Future<Addon> future = addonRegistry.start(addon.getId());
future.get();

if (addon.getStatus().isStarted())
{
Object result = null;
for (Addon addon : addonRegistry.getRegisteredAddons())
{
Future<Addon> future = addonRegistry.start(addon.getId());
future.get();
ServiceRegistry registry = addon.getServiceRegistry();
ExportedInstance<?> testInstance = registry.getExportedInstance(testClassName);

if (addon.getStatus().isStarted())
if (testInstance != null)
{
if (instance == null)
{
ServiceRegistry registry = addon.getServiceRegistry();
ExportedInstance<?> testInstance = registry.getExportedInstance(testClassName);

if (testInstance != null)
{
if (result == null)
{
result = testInstance.get();
}
else
{
throw new IllegalStateException(
"Multiple test classes found in deployed addons. " +
"You must have only one @Deployment(testable=true\"); deployment");
}
}
instance = testInstance.get();
}
else
{
throw new IllegalStateException(
"Multiple test classes found in deployed addons. " +
"You must have only one @Deployment(testable=true\"); deployment");
}
}
return result;
}
});
}

if (instance == null)
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ public boolean isFailed()

public boolean isStarted()
{
return this == STARTED;
}

public boolean isStopped()
{
return this == LOADED || this == FAILED;
return this == STARTED || this == FAILED;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void waitUntilStarted(Addon addon)
{
try
{
while (!addon.getStatus().isStarted() && !addon.getStatus().isFailed())
while (!addon.getStatus().isStarted())
{
Thread.sleep(10);
}
Expand All @@ -34,7 +34,7 @@ public static void waitUntilStopped(Addon addon)
{
try
{
while (!(addon.getStatus().isStopped() || addon.getStatus().isMissing()))
while (addon.getStatus().isStarted())
{
Thread.sleep(10);
}
Expand Down

0 comments on commit 424027d

Please sign in to comment.