[ 
https://issues.apache.org/jira/browse/CXF-7549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16368822#comment-16368822
 ] 

ASF GitHub Bot commented on CXF-7549:
-------------------------------------

deki closed pull request #334: [CXF-7549] test for bug of feature inside a 
feature
URL: https://github.com/apache/cxf/pull/334
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java
 
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java
index 73e51c38113..2ac31d6c0de 100644
--- 
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java
+++ 
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.ws.rs.core.Feature;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ExceptionMapper;
 
@@ -64,6 +65,39 @@ public void testRegisterProviders() {
 
     }
 
+    @Test
+    public void testRegisterInFeature() {
+        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
+        bean.setAddress("http://localhost:8080/rest";);
+        bean.setResourceClasses(BookStore.class);
+        bean.setStart(false);
+        bean.setProvider((Feature)(context) -> {
+            context.register(new RuntimeExceptionMapper());
+
+            return true;
+        });
+
+        bean.create();
+    }
+
+    @Test
+    public void testRegisterFeatureInFeature() {
+        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
+        bean.setAddress("http://localhost:8080/rest";);
+        bean.setStart(false);
+        bean.setResourceClasses(BookStore.class);
+        bean.setProvider((Feature)(context) -> {
+            context.register((Feature) context2-> {
+                context2.register(new RuntimeExceptionMapper());
+
+                return true;
+            });
+
+            return true;
+        });
+
+        bean.create();
+    }
 
     private static class CustomExceptionMapper implements 
ExceptionMapper<Exception> {
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Can't register Feature from inside another Feature in JAX-RS
> ------------------------------------------------------------
>
>                 Key: CXF-7549
>                 URL: https://issues.apache.org/jira/browse/CXF-7549
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.2.0, 3.2.1
>            Reporter: Carlos Sierra
>            Assignee: Sergey Beryozkin
>            Priority: Major
>             Fix For: 3.2.2, 3.1.15
>
>
> Registering a Feature from within a Feature lead to ServiceConstruction 
> exception.
> It is explicitly stated in the spec that it must be possible to register a 
> feature inside another feature. In CXF this leads to a ServiceContruction 
> exception caused by a NullPointerException.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to