Oscar Scholten created CXF-6636:
-----------------------------------
Summary: creating second server on same path destroys original
server
Key: CXF-6636
URL: https://issues.apache.org/jira/browse/CXF-6636
Project: CXF
Issue Type: Bug
Affects Versions: 3.1.3, 3.0.6
Reporter: Oscar Scholten
Priority: Minor
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.
{code}
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");
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)