Skip to content

[Dubbo-2.7.7] Fix problem: Rest Protocol can't work when use Tomcat 8.0.x as Web Container#6402

Merged
mercyblitz merged 1 commit intoapache:masterfrom
yiocio:master
Jul 8, 2020
Merged

[Dubbo-2.7.7] Fix problem: Rest Protocol can't work when use Tomcat 8.0.x as Web Container#6402
mercyblitz merged 1 commit intoapache:masterfrom
yiocio:master

Conversation

@yiocio
Copy link
Copy Markdown
Contributor

@yiocio yiocio commented Jul 1, 2020

What is the purpose of the change

fix the problem: Rest Protocol can't work when use Tomcat 8.0.x as Web Container which is described by issue #6399

Brief changelog

TomcatHttpServer.java

Verifying this change

When we start Tomcat server by program for embedded Tomcat with version 8.0.x

We can't set the connector by following steps:

  1. create a connector using the code: new Connector("org.apache.coyote.http11.Http11NioProtocol");
  2. set appropriate property for the created connector , eg: connector.setPort(url.getPort()), connector.setProperty("","");
  3. set the ready connector to tomcat , eg: tomcat.setConnector(connector);

We should set the connector as follow:

  1. got a connector by tomcat's method,pseudocode is : Connector connector = tomcat.getConnector();
  2. set appropriate property for the connector returned by tomcat , eg: connector.setPort(url.getPort()), connector.setProperty("","");

The point is the connector returned by tomcat would be added to service object which belong to tomcat, it's important for tomcat to start connector and listen on given port. But the key action is missed when using the first solution. one thing to note, the first solution is OK for tomcat with higher version(eg: 8.5.31). But, the second solution is compatible with all versions of Tomcat.

Additionally, we should create connector object by new Connector("HTTP/1.1") instead of new Connector("org.apache.coyote.http11.Http11NioProtocol"), because the first practice is more semantic. actually, org.apache.coyote.http11.Http11NioProtocol isn't protocol name, it just the name of implementation class for HTTP/1.1 protocol.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants