Skip to content

Why does not tomcat throw an exception when server.start failed with a socket binding error. #3236

@chickenlj

Description

@chickenlj

Why does not tomcat throw an exception when server.start failed with a socket binding error.

https://github.com/apache/incubator-dubbo/blob/master/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java#L71

I do see the exception stack printed on the Console, whereas no exception was thrown in here:

try {
            tomcat.start();
        } catch (LifecycleException e) {
            throw new IllegalStateException("Failed to start tomcat server at " + url.getAddress(), e);
        } catch (Exception ee) {
            throw new IllegalStateException(e);
        }

This behavior will cause a tomcat based HTTP service being registered unexpectedly to the Registry even after the binding has failed.

@Override
    public <T> Exporter<T> export(final Invoker<T> originInvoker) throws RpcException {
         ... ...
        // socket binding exception extected
        final ExporterChangeableWrapper<T> exporter = doLocalExport(originInvoker, providerUrl);
        ... ... 
        // url to registry
        final Registry registry = getRegistry(originInvoker);
        register(registryUrl, registeredProviderUrl);
         
        return new DestroyableExporter<>(exporter);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugBugs to being fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions