Permalink
Browse files

Merge pull request #9476 from ctomc/mem-leaks

WFLY-7728  Increased Memory footprint in recent builds
  • Loading branch information...
2 parents 32bfda0 + fc93a28 commit 9e648dc2f885d77c6522107314dccaf4c0a35c16 @kabir kabir committed on GitHub Dec 16, 2016
View
@@ -114,6 +114,10 @@
<artifactId>jboss-interceptors-api_1.2_spec</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.spec.javax.el</groupId>
+ <artifactId>jboss-el-api_3.0_spec</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -26,6 +26,8 @@
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+import org.jboss.el.cache.FactoryFinderCache;
+import org.jboss.modules.Module;
/**
* Cleans up references to EE structures in the deployment unit
@@ -46,6 +48,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
@Override
public void undeploy(final DeploymentUnit context) {
-
+ final Module module = context.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
+ FactoryFinderCache.clearClassLoader(module.getClassLoader());
}
}
@@ -26,11 +26,9 @@
import org.jboss.as.ee.component.Attachments;
import org.jboss.as.ee.component.BindingConfiguration;
-import org.jboss.as.ee.component.Component;
import org.jboss.as.ee.component.ComponentConfiguration;
import org.jboss.as.ee.component.ComponentConfigurator;
import org.jboss.as.ee.component.ComponentDescription;
-import org.jboss.as.ee.component.DependencyConfigurator;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.component.InjectionSource;
import org.jboss.as.ee.component.ViewDescription;
@@ -48,8 +46,8 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.EjbDeploymentMarker;
import org.jboss.msc.inject.Injector;
-import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
+import org.jboss.msc.service.ServiceName;
import org.jboss.msc.value.InjectedValue;
import org.jboss.msc.value.Values;
import org.wildfly.extension.requestcontroller.ControlPoint;
@@ -215,17 +213,10 @@ private void registerControlPointBinding(final EJBComponentDescription component
final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
final InjectedValue<ControlPoint> controlPointInjectedValue = new InjectedValue<>();
final RemoteViewInjectionSource delegate = new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader);
-
- componentDescription.getConfigurators().add(new ComponentConfigurator() {
- public void configure(DeploymentPhaseContext context, ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
- viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
- configuration.getCreateDependencies().add(new DependencyConfigurator<Service<Component>>() {
- @Override
- public void configureDependency(ServiceBuilder<?> serviceBuilder, Service<Component> service) throws DeploymentUnitProcessingException {
- serviceBuilder.addDependency(ControlPointService.serviceName(deploymentUnit.getParent() == null ? deploymentUnit.getName() : deploymentUnit.getParent().getName(), EJBComponentSuspendDeploymentUnitProcessor.ENTRY_POINT_NAME + deploymentUnit.getName() + "." + componentDescription.getComponentName()), ControlPoint.class, controlPointInjectedValue);
- }
- });
- }
+ final ServiceName depName = ControlPointService.serviceName(deploymentUnit.getParent() == null ? deploymentUnit.getName() : deploymentUnit.getParent().getName(), EJBComponentSuspendDeploymentUnitProcessor.ENTRY_POINT_NAME + deploymentUnit.getName() + "." + componentDescription.getComponentName());
+ componentDescription.getConfigurators().add((context, description, configuration) -> {
+ viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader()));
+ configuration.getCreateDependencies().add((serviceBuilder, service) -> serviceBuilder.addDependency(depName, ControlPoint.class, controlPointInjectedValue));
});
//we need to wrap the injection source to allow graceful shutdown to function, although this is not ideal
//as it will also reject local lookups as well, although in general local code should never be looking up the
@@ -24,19 +24,8 @@
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
-import java.util.List;
-
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-
-import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PersistentResourceXMLDescription;
-import org.jboss.as.controller.persistence.SubsystemMarshallingContext;
-import org.jboss.dmr.ModelNode;
-import org.jboss.staxmapper.XMLElementReader;
-import org.jboss.staxmapper.XMLElementWriter;
-import org.jboss.staxmapper.XMLExtendedStreamReader;
-import org.jboss.staxmapper.XMLExtendedStreamWriter;
+import org.jboss.as.controller.PersistentResourceXMLParser;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.LiveOnlyDefinition;
import org.wildfly.extension.messaging.activemq.ha.ReplicationColocatedDefinition;
@@ -60,7 +49,7 @@
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2015 Red Hat inc.
*/
-public class MessagingSubsystemParser_1_1 implements XMLStreamConstants, XMLElementReader<List<ModelNode>>, XMLElementWriter<SubsystemMarshallingContext> {
+public class MessagingSubsystemParser_1_1 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:1.1";
@@ -69,7 +58,7 @@
private static final PersistentResourceXMLDescription xmlDescription;
static {
- xmlDescription = builder(MessagingExtension.SUBSYSTEM_PATH)
+ xmlDescription = builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
@@ -608,14 +597,7 @@ private MessagingSubsystemParser_1_1() {
}
@Override
- public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
- ModelNode model = new ModelNode();
- model.get(MessagingSubsystemRootResourceDefinition.INSTANCE.getPathElement().getKeyValuePair()).set(context.getModelNode());
- xmlDescription.persist(writer, model, NAMESPACE);
- }
-
- @Override
- public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
- xmlDescription.parse(reader, PathAddress.EMPTY_ADDRESS, list);
+ public PersistentResourceXMLDescription getParserDescription() {
+ return xmlDescription;
}
}
@@ -39,6 +39,7 @@
<module name="javax.annotation.api"/>
<module name="javax.api"/>
<module name="javax.enterprise.concurrent.api"/>
+ <module name="javax.el.api"/>
<module name="javax.interceptor.api"/>
<module name="javax.transaction.api"/>
<module name="javax.xml.ws.api" optional="true"/>
@@ -47,7 +47,7 @@
public class DefaultDistinctNameTestCase {
@ArquillianResource
- private static Context context;
+ private Context context;
private static final String APP_NAME = "";
private static final String DISTINCT_NAME = "distinct-name-in-jboss-ejb3-xml";
@@ -30,15 +30,14 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.test.categories.CommonCriteria;
import org.jboss.as.test.integration.security.common.AbstractSecurityDomainSetup;
import org.jboss.as.test.shared.integration.ejb.security.Util;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
@@ -50,18 +49,8 @@
@Category(CommonCriteria.class)
@ServerSetup({EjbSecurityDomainSetup.class})
public class EJBInWarDefaultSecurityDomainTestCase {
- private static Context ctx;
-
- @AfterClass
- public static void afterClass() throws NamingException {
- if (ctx != null)
- ctx.close();
- }
-
- @BeforeClass
- public static void beforeClass() throws NamingException {
- ctx = new InitialContext();
- }
+ @ArquillianResource
+ private Context ctx;
@Deployment
public static WebArchive createDeployment() {
@@ -78,9 +67,7 @@ public static WebArchive createDeployment() {
return war;
}
- private static <T> T lookup(final Class<?> beanClass, final Class<T> viewClass) throws NamingException {
- if (ctx == null)
- ctx = new InitialContext(); // to circumvent an Arquillian issue
+ private <T> T lookup(final Class<?> beanClass, final Class<T> viewClass) throws NamingException {
return viewClass.cast(ctx.lookup("java:module/" + beanClass.getSimpleName() + "!" + viewClass.getName()));
}
@@ -31,12 +31,11 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.categories.CommonCriteria;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
@@ -47,18 +46,9 @@
@RunWith(Arquillian.class)
@Category(CommonCriteria.class)
public class EJBSecurityTestCase {
- private static Context ctx;
- @AfterClass
- public static void afterClass() throws NamingException {
- if (ctx != null)
- ctx.close();
- }
-
- @BeforeClass
- public static void beforeClass() throws NamingException {
- ctx = new InitialContext();
- }
+ @ArquillianResource
+ private Context ctx;
@Deployment
public static JavaArchive createDeployment() {
@@ -70,9 +60,7 @@ public static JavaArchive createDeployment() {
return jar;
}
- private static <T> T lookup(final Class<?> beanClass, final Class<T> viewClass) throws NamingException {
- if (ctx == null)
- ctx = new InitialContext(); // to circumvent an Arquillian issue
+ private <T> T lookup(final Class<?> beanClass, final Class<T> viewClass) throws NamingException {
return viewClass.cast(ctx.lookup("java:module/" + beanClass.getSimpleName() + "!" + viewClass.getName()));
}
@@ -107,6 +107,7 @@ public void testPassivationMaxSize() throws Exception {
}
Assert.assertTrue("invalid: " + PassivationInterceptor.getPrePassivateTarget(), PassivationInterceptor.getPrePassivateTarget() instanceof TestPassivationBean);
Assert.assertTrue("invalid: " + PassivationInterceptor.getPostActivateTarget(), PassivationInterceptor.getPostActivateTarget() instanceof TestPassivationBean);
+ PassivationInterceptor.reset();
}
/**
@@ -247,5 +248,6 @@ public void testPassivationFailure() throws Exception {
} catch (NoSuchEJBException e) {
// Expected
}
+ PassivationInterceptor.reset();
}
}
@@ -36,7 +36,6 @@
import org.jboss.as.web.common.StartupContext;
import org.jboss.as.web.common.WebInjectionContainer;
import org.jboss.as.web.host.ContextActivator;
-import org.jboss.el.cache.FactoryFinderCache;
import org.jboss.msc.inject.Injector;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceController;
@@ -133,7 +132,6 @@ public void stopContext() {
DeploymentInfo deploymentInfo = deploymentInfoInjectedValue.getValue();
Thread.currentThread().setContextClassLoader(deploymentInfo.getClassLoader());
try {
- FactoryFinderCache.clearClassLoader(deploymentInfo.getClassLoader());
if (deploymentManager != null) {
Deployment deployment = deploymentManager.getDeployment();
try {

0 comments on commit 9e648dc

Please sign in to comment.