You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniel Kulp (JIRA)" <ji...@apache.org> on 2017/03/28 16:14:41 UTC
[jira] [Updated] (CXF-6636) creating second server on same path
destroys original server
[ https://issues.apache.org/jira/browse/CXF-6636?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp updated CXF-6636:
-----------------------------
Component/s: Transports
> 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
> Components: Transports
> Affects Versions: 3.0.6, 3.1.3
> Reporter: Oscar Scholten
>
> 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.15#6346)