Re: [jboss-user] [JBoss Microcontainer] - AbstractRealDeployerWithInput fails to call undeploy() on DeploymentVisitor, for failed deployments
by jaikiran pai
jaikiran pai [http://community.jboss.org/people/jaikiran] replied to the discussion
"AbstractRealDeployerWithInput fails to call undeploy() on DeploymentVisitor, for failed deployments"
To view the discussion, visit: http://community.jboss.org/message/555224#555224
--------------------------------------------------------------
> Ales Justin wrote:
>
> > That would effectively mean, that *every* implementation of the org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor interface, has to have the following code in their deploy:
> >
> No, why?
>
Because, in it's current form, if some *unexpected* exception occurs then the undeploy will never get called with that try{}catch(Throwable t) block.
> Ales Justin wrote:
>
>
> See existing impl, none has that.
And all those will fail (i.e. their undeploy() will not get called) if they happen to run into runtime exceptions in their deploy.
> Ales Justin wrote:
>
> Either they don't have anything, since the deploy action is very simple
Doesn't matter if it's simple or not :) Even if it's a couple of lines code, it can end up throwing a runtime.
> Ales Justin wrote:
>
> (almost atomic :) ),
That's just an assumption :)
> Ales Justin wrote:
>
> The idea is that the visitor's deploy is very simple, or you missused the deployer.
Consider this again, in my visitor's deploy:
void deploy(DeploymentUnit unit, T deployment) throws DeploymentException
{
Ejb3Registry.register(...);
callThirdPartyCodeWhichRunsIntoNullPointerException();
}
I don't see any misuse here. So when I call the callThirdPartyCodeWhichRunsIntoNullPointerException(), which as the name suggests will run into a NPE (for some reason), I have no way of unregistering from Ejb3Registry, unless I wrap all this in a try{}catch(Throwable t) block or at the very least in a try{}catch(RuntimeException re) block.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/555224#555224]
Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months
Re: [jboss-user] [JBoss Microcontainer] - AbstractRealDeployerWithInput fails to call undeploy() on deployer, for failed deployments
by Ales Justin
Ales Justin [http://community.jboss.org/people/alesj] replied to the discussion
"AbstractRealDeployerWithInput fails to call undeploy() on deployer, for failed deployments"
To view the discussion, visit: http://community.jboss.org/message/555221#555221
--------------------------------------------------------------
> That would effectively mean, that *every* implementation of the org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor interface, has to have the following code in their deploy:
>
No, why?
See existing impl, none has that.
Either they don't have anything, since the deploy action is very simple (almost atomic :) ),
or they have some other additional undeploy logic; e.g. remove added components.
The idea is that the visitor's deploy is very simple, or you missused the deployer.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/555221#555221]
Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months
[JBoss Microcontainer] - AbstractRealDeployerWithInput fails to call undeploy() on deployer, for failed deployments
by jaikiran pai
jaikiran pai [http://community.jboss.org/people/jaikiran] created the discussion
"AbstractRealDeployerWithInput fails to call undeploy() on deployer, for failed deployments"
To view the discussion, visit: http://community.jboss.org/message/555208#555208
--------------------------------------------------------------
While investigating this issue http://community.jboss.org/message/555195#555195 http://community.jboss.org/message/555195#555195, I have stumbled upon a MC deployer bug. Here's an simplified version of what's happening:
public class MyDeployer extends AbstractRealDeployerWithInput<JBossEnterpriseBeanMetaData>
implements
DeploymentVisitor<JBossEnterpriseBeanMetaData>
{
...
@Override
public void deploy(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMetaData) throws DeploymentException
{
doStepOne(); // like register component to some service name
doStepTwo(); // can be any operation which ends up throwing an runtime exception
}
@Override
public void undeploy(DeploymentUnit unit, JBossEnterpriseBeanMetaData enterpriseBean)
{
undoStepOne(); // i.e. unregister the service
}
}
As can be seen, the deploy() involves more than one step. The first step does registering of services (or some functionality internal to my deployer). The second step of deploy() does some other thing but ends up throwing an exception. I would expect that the undeploy() method
would be called on MyDeployer for this (failed) deployment unit, so that I can undo/cleanup whatever was done in doStepOne() of deploy() operation.
However, the undeploy() never gets called. Looking at MC's AbstractRealDeployerWithInput.deploy() method:
protected <U> void deploy(DeploymentUnit unit, DeploymentVisitor<U> visitor) throws DeploymentException
{
if (visitor == null)
throw new IllegalArgumentException("Null visitor.");
List<U> visited = new ArrayList<U>();
try
{
Set<? extends U> deployments = unit.getAllMetaData(visitor.getVisitorType());
for (U deployment : deployments)
{
visitor.deploy(unit, deployment);
visited.add(deployment);
}
}
catch (Throwable t)
{
for (int i = visited.size()-1; i >= 0; --i)
{
try
{
visitor.undeploy(unit, visited.get(i));
}
catch (Throwable ignored)
{
log.warn("Error during undeploy: " + unit.getName(), ignored);
}
}
throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);
}
}
More specifically:
visitor.deploy(unit, deployment);
visited.add(deployment);
visitor.deploy(...) throws the exception and hence the deployment is never added to "visited" which effectively means that in the catch block:
for (int i = visited.size()-1; i >= 0; --i)
{
try
{
visitor.undeploy(unit, visited.get(i));
}
catch (Throwable ignored)
{
log.warn("Error during undeploy: " + unit.getName(), ignored);
}
}
The "visited" will never contain this failed deployment. Ultimately, the undeploy() will never get called for that failed deployment unit.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/555208#555208]
Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months