Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weld5 needs Priority annotation on Interceptor #155

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
package org.apache.deltaspike.test.core.api.partialbean.shared;

import java.io.Serializable;

import jakarta.annotation.Priority;
import jakarta.inject.Inject;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;

@Priority(Interceptor.Priority.APPLICATION)
@Interceptor
@CustomInterceptor
public class CustomInterceptorImpl implements Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.deltaspike.test.core.api.partialbean.uc007;

import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptor;
import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl;
import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorState;
import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding;
Expand All @@ -39,8 +40,6 @@
@RunWith(Arquillian.class)
public class MethodLevelInterceptorTest
{
public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";

@Deployment
public static WebArchive war()
{
Expand All @@ -53,16 +52,9 @@ public static WebArchive war()
String simpleName = MethodLevelInterceptorTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

//don't create a completely empty web-archive
if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
{
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
}

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addPackage(MethodLevelInterceptorTest.class.getPackage())
.addPackage(TestPartialBeanBinding.class.getPackage())
.addPackage(PartialBean.class.getPackage())
.addPackage(CustomInterceptor.class.getPackage())
.addAsManifestResource(beansXml, "beans.xml");

return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
Expand All @@ -74,9 +66,6 @@ public static WebArchive war()
@Test
public void testMethodLevelInterceptor() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand All @@ -88,9 +77,6 @@ public void testMethodLevelInterceptor() throws Exception
@Test
public void testMethodLevelInterceptorStereotype() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand All @@ -102,9 +88,6 @@ public void testMethodLevelInterceptorStereotype() throws Exception
@Test
public void testMethodLevelInterceptorOnAbstractMethod() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
@RunWith(Arquillian.class)
public class ClassLevelInterceptorTest
{
public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";

@Deployment
public static WebArchive war()
{
Expand All @@ -53,13 +51,6 @@ public static WebArchive war()
String simpleName = ClassLevelInterceptorTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

//don't create a completely empty web-archive
if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
{
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
}

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addPackage(ClassLevelInterceptorTest.class.getPackage())
.addPackage(TestPartialBeanBinding.class.getPackage())
Expand All @@ -74,9 +65,6 @@ public static WebArchive war()
@Test
public void testClassLevelInterceptor() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand All @@ -89,9 +77,6 @@ public void testClassLevelInterceptor() throws Exception
@Test
public void testClassLevelInterceptorOnAbstractMethod() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class MethodLevelInterceptorTest
public class MethodLevelCacheInterceptorTest
{
public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";

@Deployment
public static WebArchive war()
{
Expand All @@ -50,18 +48,11 @@ public static WebArchive war()
"</class></interceptors></beans>"
);

String simpleName = MethodLevelInterceptorTest.class.getSimpleName();
String simpleName = MethodLevelCacheInterceptorTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

//don't create a completely empty web-archive
if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
{
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
}

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addPackage(MethodLevelInterceptorTest.class.getPackage())
.addPackage(MethodLevelCacheInterceptorTest.class.getPackage())
.addPackage(TestPartialBeanBinding.class.getPackage())
.addAsManifestResource(beansXml, "beans.xml");

Expand All @@ -75,17 +66,14 @@ public static WebArchive war()
@Test
public void testMethodLevelInterceptor() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

MyRepository myRepository = BeanProvider.getContextualReference(MyRepository.class);

List<String> users = myRepository.getAllUsers();

Assert.assertNotNull(users);
Assert.assertEquals(3, users.size());

Assert.assertSame(users, myRepository.getAllUsers());
Assert.assertEquals(users, myRepository.getAllUsers());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO assertSame is by design here as the result is cached - it needs to be the same object instance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on Wildfly-managed it is not, as it seems - or else no fail.
IMHO it is up to the container to serialize/deserialize request/response objects down the interceptor chain - whatever it may be.
Iff this poses a problem, I could try to identify where this - evident? - ser/deser happens to better understand what to do.
Another possibilty would be to check for "jboss.server.name" SysProp here to capture the case.
Any decision welcome!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no serialization here
The interceptor caches the method return value
If it doesnt, its still broken for weld
Therefore the exclude propably

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it also broken with deltaspike.bean-manager.delegate_lookup?

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public class SimpleCacheExtension implements Extension
{
void discoverInterceptorBindings(@Observes BeforeBeanDiscovery beforeBeanDiscoveryEvent)
{
beforeBeanDiscoveryEvent.addInterceptorBinding(SimpleCache.class);
//beforeBeanDiscoveryEvent.addInterceptorBinding(SimpleCache.class);
}
}
Loading