Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.0.6, 3.1.3
-
None
-
None
-
Unknown
Description
I'm implementing a service that dynamically creates JAXRS applications from configuration. One of the tests that I created for this service is:
- Configure app1 on the path /hello
- Configure another application mistakenly also on the path /hello
Expected: the second registration fails and app1 is still responsive
Actual: the second registration fails and I get a 404 for app1
In other words, the bug that I want to report is that creating a second server on a path that is already in use destroys the original server.
Below the code of my test. It fails on the last line of the test, the server at /another remains available.
public void addEndpoint(String path, String message) { Application application = new Application() { public Set<Object> getSingletons() { Set<Object> singletons = new HashSet<>(); singletons.add(new HelloWorldResource(message)); return singletons; } }; JAXRSServerFactoryBean endpointFactory = ResourceUtils.createApplication(application, true); endpointFactory.setAddress(path); endpointFactory.create(); } public void testEndpoint(int portNumber, String path, String message) { when() .get("http://localhost:" + portNumber + "/cxf" + path) .then() .statusCode(200) .content(equalTo(message)); } @Test public void verify_cxf_can_handle_two_registrations_on_same_path() throws LifecycleException { int portNumber = initialize(); addEndpoint("/another", "another"); addEndpoint("/hello", "hello"); testEndpoint(portNumber, "/another", "another"); testEndpoint(portNumber, "/hello", "hello"); try { addEndpoint("/hello", "illegal registration"); fail("ServiceConstructionException expected"); } catch (ServiceConstructionException e) { // ok, expected } testEndpoint(portNumber, "/another", "another"); testEndpoint(portNumber, "/hello", "hello"); }