Skip to content

Instantly share code, notes, and snippets.

@bcalmac
Created June 3, 2015 16:04
Show Gist options
  • Save bcalmac/42f9254337bf38cc32e4 to your computer and use it in GitHub Desktop.
Save bcalmac/42f9254337bf38cc32e4 to your computer and use it in GitHub Desktop.
Infinite loop in JBoss 7.1.1 on Java 8
package org.jboss.as.server;
import java.util.concurrent.ConcurrentSkipListSet;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.Phase;
import org.jboss.as.server.deployment.SubDeploymentProcessor;
import org.jboss.as.server.deployment.annotation.AnnotationIndexProcessor;
import org.jboss.as.server.deployment.module.DeploymentRootExplodedMountProcessor;
import org.jboss.as.server.deployment.module.DeploymentRootMountProcessor;
import org.jboss.as.server.deployment.module.ManifestAttachmentProcessor;
import org.jboss.as.server.deployment.module.ModuleIdentifierProcessor;
public class InfiniteLoop {
public static void main(String[] args) {
ConcurrentSkipListSet<RegisteredProcessor> set = new ConcurrentSkipListSet<RegisteredProcessor>();
set.add(new RegisteredProcessor(Phase.STRUCTURE_SERVICE_MODULE_LOADER, new DeploymentUnitProcessor() {
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
}
public void undeploy(DeploymentUnit context) {
}
}));
set.add(new RegisteredProcessor(Phase.STRUCTURE_EXPLODED_MOUNT, new DeploymentRootExplodedMountProcessor()));
set.add(new RegisteredProcessor(Phase.STRUCTURE_MOUNT, new DeploymentRootMountProcessor()));
set.add(new RegisteredProcessor(Phase.STRUCTURE_MANIFEST, new ManifestAttachmentProcessor()));
set.add(new RegisteredProcessor(Phase.STRUCTURE_ADDITIONAL_MANIFEST, new ManifestAttachmentProcessor()));
set.add(new RegisteredProcessor(Phase.STRUCTURE_SUB_DEPLOYMENT, new SubDeploymentProcessor()));
set.add(new RegisteredProcessor(Phase.STRUCTURE_MODULE_IDENTIFIERS, new ModuleIdentifierProcessor()));
set.add(new RegisteredProcessor(Phase.STRUCTURE_ANNOTATION_INDEX, new AnnotationIndexProcessor()));
System.out.println("Items in set:" + set.size());
}
static final class RegisteredProcessor implements Comparable<RegisteredProcessor> {
private final int priority;
private final DeploymentUnitProcessor processor;
private static int i = 1;
RegisteredProcessor(final int priority, final DeploymentUnitProcessor processor) {
this.priority = priority;
this.processor = processor;
}
public int compareTo(final RegisteredProcessor o) {
final int rel = Integer.signum(priority - o.priority);
// BUG below
return rel == 0 ? Integer.signum(processor.getClass().getName().compareTo(o.getClass().getName())) : rel;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment