You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@onami.apache.org by "Simone Tripodi (JIRA)" <ji...@apache.org> on 2013/01/08 13:58:14 UTC
[jira] [Commented] (ONAMI-45) Injector creation can fail and in
that case all created resources must be disposed anyway
[ https://issues.apache.org/jira/browse/ONAMI-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13546846#comment-13546846 ]
Simone Tripodi commented on ONAMI-45:
-------------------------------------
I got your POV and I agree about the issue topic, what it doesn't convince me is that the module wraps a {{Disposer}} logic.
Wouldn't be better if the module takes an existing {{Disposer}} instance, by adding a new {{/*@since 0.2.0*/ DisposerModule(Disposer)}} constructor, to handle that situation? I mean, something like:
{code}
@Test
public void disposeUsingModuleOnInjectorFailure()
{
Disposer disposer = new Disposer();
try
{
createInjector( new DisposeModule(disposer), new AbstractModule()
{
@Override
protected void configure()
{
bind( ThrowingExceptionConstructor.class ).asEagerSingleton();
}
} );
fail( "Expected exception was not thrown" );
}
catch( CreationException e )
{
Throwable cause = e.getCause();
assertTrue( cause instanceof IllegalArgumentException );
assertEquals( "Expected exception", cause.getMessage() );
}
finally
{
disposer.dispose( new DisposeHandler()
{
public <I> void onSuccess( I injectee )
{
assertTrue( injectee instanceof DisposableObject );
assertTrue( ((DisposableObject) injectee).disposed );
}
public <I, E extends Throwable> void onError( I injectee, E error )
{
fail( error.toString() );
}
});
}
}
{code}
WDYT?
> Injector creation can fail and in that case all created resources must be disposed anyway
> -----------------------------------------------------------------------------------------
>
> Key: ONAMI-45
> URL: https://issues.apache.org/jira/browse/ONAMI-45
> Project: Apache Onami
> Issue Type: Improvement
> Components: lifecycle
> Affects Versions: lifecycle-0.2.0
> Reporter: Mikhail Mazursky
> Attachments: ONAMI-45.patch
>
>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira