Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement servlet upgrade for ee10 and ee11 #12186

Merged
merged 10 commits into from
Sep 4, 2024

Conversation

lachlan-roberts
Copy link
Contributor

@lachlan-roberts lachlan-roberts commented Aug 21, 2024

Implement Servlet upgrade for ee10 and ee11 which is required for the TCK.

Replaces #10128

Signed-off-by: Lachlan Roberts <[email protected]>
@lachlan-roberts
Copy link
Contributor Author

The TCK fully passes after the changes in this branch.
See https://jenkins.webtide.net/job/tck/job/tck-servlet-arquillian/job/jetty-12-ee11/64/

@olamy
Copy link
Member

olamy commented Aug 22, 2024

The TCK fully passes after the changes in this branch. See https://jenkins.webtide.net/job/tck/job/tck-servlet-arquillian/job/jetty-12-ee11/64/

YEAHHHH

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be possible to do this without making HttpConnection public. We already have some upgrade related interfaces, so use them or create a new one to abstract away from the implementation.

@@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.server.internal;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this move is necessary?

Is it so that ServletAPIRequest can do:

        HttpConnection httpConnection = (HttpConnection)_servletContextRequest.getConnectionMetaData().getConnection();
        httpConnection.getParser().servletUpgrade();
        outputStream.flush(); // commit the 101 response
        httpConnection.getGenerator().servletUpgrade(); // tell the generator it can send data as-is

We already have interfaces: Connection.UpgradeFrom, Connection.UpgradeTo to abstract away from specific connection types. so can't you use them instead? Get those methods to flip the parser and generator states?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it so that ServletAPIRequest can do:

Yes, this is why it was necessary.

We already have interfaces: Connection.UpgradeFrom, Connection.UpgradeTo to abstract away from specific connection types. so can't you use them instead? Get those methods to flip the parser and generator states?

These interfaces are already implemented on HttpConnection, I think for the HTTP/2 upgrade.

So I think the options are (unless you have a better idea)

  1. make HttpConnection public
  2. create a new Upgrade interface and implement it on the HttpConnection
  3. add a new method to the Connection interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option 2

@lachlan-roberts lachlan-roberts requested a review from gregw August 27, 2024 07:58
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep HttpConnection internal

@lachlan-roberts lachlan-roberts requested a review from gregw August 29, 2024 02:50
@lachlan-roberts
Copy link
Contributor Author

@gregw nudge

@@ -596,7 +596,7 @@ public ComplianceViolation.Listener getComplianceViolationListener()
* <dl>
* <dt>org.eclipse.jetty.server.Server</dt><dd>The Jetty Server instance</dd>
* <dt>org.eclipse.jetty.server.HttpChannel</dt><dd>The HttpChannel for this request</dd>
* <dt>org.eclipse.jetty.server.HttpConnection</dt><dd>The HttpConnection or null if another transport is used</dd>
* <dt>org.eclipse.jetty.server.internal.HttpConnection</dt><dd>The HttpConnection or null if another transport is used</dd>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct (nor was it before). It is actually looking for Connection.class.getName()

Comment on lines 339 to 343
public void upgrade()
{
getParser().upgrade();
getGenerator().upgrade();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I've changed my mind about the naming here. This is not really upgrade, it would be more accurate to call these methods tunnel or openTunnel or startTunnel.

The description would be to convert the connection over which the current protocol us running to a tunnel, but without replacing the connection (as is done by our real upgrade mechanism). This can be used for upgrade within a connection, but it is not really an upgrade for this connection, as the connection remains and just tunnels data to/from its endpoint.

Signed-off-by: Lachlan Roberts <[email protected]>
@lachlan-roberts lachlan-roberts merged commit 8c5d5e8 into jetty-12.1.x Sep 4, 2024
10 checks passed
@lachlan-roberts lachlan-roberts deleted the jetty-12.1.x-servletUpgrade branch September 4, 2024 22:23
@olamy olamy mentioned this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants