Skip to content

Dropwizard EndPoints are not logged when Atmosphere is included. #46

@zscott

Description

@zscott

When Atmosphere is enabled Jersey clones an anonymous class extending DropwizardResourceConfig causing it to become an instance of the more generic DefaultResourceConfig which has the effect of not displaying the configured endpoints on startup.

Lines 789-803 of com.sun.jersey.server.impl.application.WebApplicationImpl.java

    Class<?>[] components = ServiceFinder.find("jersey-server-components").toClassArray();
    if (components.length > 0) {
        if (LOGGER.isLoggable(Level.INFO)) {
            StringBuilder b = new StringBuilder();
            b.append("Adding the following classes declared in META-INF/services/jersey-server-components to the resource configuration:");
            for (Class c : components)
                b.append('\n').append("  ").append(c);
            LOGGER.log(Level.INFO, b.toString());
        }

        this.resourceConfig = rc.clone();
        this.resourceConfig.getClasses().addAll(Arrays.asList(components));
    } else {
        this.resourceConfig = rc;
    }

Before adding Atmosphere to my project components.length was 0. With Atmosphere added to the project one component called org.atmosphere.jersey.AtmosphereResourceConfigurator is returned by ServiceFinder.find("jersey-server-components") causing:

this.resourceConfig = rc.clone();

to be executed rather than:

this.resourceConfig = rc;

The passed-in Dropwizard resource config is an anonymous class declared in Environment:

Lines 89-100 of com.yammer.dropwizard.config.Environment:

    this.config = new DropwizardResourceConfig(false) {
        @Override
        public void validate() {
            super.validate();
            logResources();
            logProviders();
            logHealthChecks();
            logManagedObjects();
            logEndpoints();
            logTasks();
        }
    };

When this anonymous class is cloned by Jersey it becomes an instance of:

com.sun.jersey.api.core.DefaultResourceConfig.

Subsequently, when validate() is called it is the DefaultResourceConfig implementation of validate() that is called not the overridden implementation declared in com.yammer.dropwizard.config.Environment, therefore logResources(), logProviders(), etc. are never called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions