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

Use appropriate connector instance based on protocol #263

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

prakhar10
Copy link
Member

This is to fix #242

@cla-bot cla-bot bot added the cla-signed label Feb 21, 2024
@prakhar10
Copy link
Member Author

@mosabua @ebyhr I'm not really sure how such cases are being handled in Trino repo, but i can take a look. If there are any suggestions please let me know.

@mosabua
Copy link
Member

mosabua commented Mar 6, 2024

Can you fix the test as requested @prakhar10

@prakhar10
Copy link
Member Author

Can you fix the test as requested @prakhar10

Sorry for the delay, got busy with something else. I'll fix this in a couple of days.

@prakhar10 prakhar10 force-pushed the switch-protocol branch 2 times, most recently from cfa3cd4 to 32df8a6 Compare March 13, 2024 13:28
.mapToInt(HttpConnectorFactory::getPort)
.mapToInt(connector -> {
if (connector instanceof HttpsConnectorFactory httpsConnectorFactory) {
return httpsConnectorFactory.getPort();
Copy link
Member

Choose a reason for hiding this comment

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

The implementation of getPort() method looks same between HttpsConnectorFactory and HttpConnectorFactory. Why do we need to differentiate them?

Copy link
Member

Choose a reason for hiding this comment

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

I looked at porting this to the new class now and also this code. Honestly I share the questions from @ebyhr and I am not sure at all why this change would do anything. I looked the the source of the two factory classes as well and the https one just extends the http one and there is no modification or change or so for the port.

So if this change really resolves the issues.. I dont know why. Thoughts @prakhar10 ?

return httpsConnectorFactory.getPort();
}
return ((HttpConnectorFactory) connector).getPort();
})
Copy link
Member

Choose a reason for hiding this comment

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

We should ensure the retrieved port is unique. The subsequent findFirst() & orElseThrow() needs fix.

@mosabua
Copy link
Member

mosabua commented Apr 2, 2024

Should we just use the changes from #294 with the test from this PR and improve in this PR as next step? Could you do that @prakhar10 ?

@prakhar10
Copy link
Member Author

Should we just use the changes from #294 with the test from this PR and improve in this PR as next step? Could you do that @prakhar10 ?

Sure @mosabua , but I believe we started off with a similar change and with reviews we've come to this code that I have currently in this PR.

But if it helps and if everyone agrees I can bring in the code changes from that PR into this one and we can take it forward.

@mosabua
Copy link
Member

mosabua commented Apr 3, 2024

Should we just use the changes from #294 with the test from this PR and improve in this PR as next step? Could you do that @prakhar10 ?

Sure @mosabua , but I believe we started off with a similar change and with reviews we've come to this code that I have currently in this PR.

But if it helps and if everyone agrees I can bring in the code changes from that PR into this one and we can take it forward.

Ideally we just address the outstanding comments from @ebyhr ... and ensure the test works as expected. I really think we need to get this merged for the next release.

@ebyhr
Copy link
Member

ebyhr commented Apr 3, 2024

By the way, test isn't mandatory in my opinion. This is pretty small change and will be removed when migrating to Airlift.

@ebyhr
Copy link
Member

ebyhr commented Apr 12, 2024

Could you rebase on main to resolve conflicts?

@prakhar10
Copy link
Member Author

Could you rebase on main to resolve conflicts?

Looks like this file does not exist anymore in the main branch, do we need this PR then @ebyhr ?

@ebyhr
Copy link
Member

ebyhr commented Apr 15, 2024

@prakhar10 Please take a look at HaGatewayProviderModule:

private int getApplicationPort()
{
Stream<ConnectorFactory> connectors =
configuration.getServerFactory() instanceof DefaultServerFactory
? ((DefaultServerFactory) configuration.getServerFactory())
.getApplicationConnectors().stream()
: Stream.of((SimpleServerFactory) configuration.getServerFactory())
.map(SimpleServerFactory::getConnector);
return connectors
.filter(connector -> connector.getClass().isAssignableFrom(HttpConnectorFactory.class))
.map(connector -> (HttpConnectorFactory) connector)
.mapToInt(HttpConnectorFactory::getPort)
.findFirst()
.orElseThrow(IllegalStateException::new);
}

@mosabua
Copy link
Member

mosabua commented Apr 30, 2024

@prakhar10 are you going to move this change over to the new module? Even potentially without test .. just so we can get this merged and maybe ship as part of the 8 release?

@willmostly
Copy link
Contributor

Hi @prakhar10 , do you need any assistance with this?

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

Successfully merging this pull request may close these issues.

Can't access application after configure SSL
4 participants