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

feat: Bring back vaadin servlet mapping behind feature flag #14694

Conversation

MarcinVaadin
Copy link
Member

Description

As there is a need to support custom servlet mapping after it has been removed (#14602) - it has been bring back behind feature flag.

Fixes #14641

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

Artur- and others added 2 commits September 28, 2022 13:22
@github-actions
Copy link

github-actions bot commented Sep 29, 2022

Unit Test Results

   978 files  +23     978 suites  +23   50m 25s ⏱️ - 3m 31s
6 082 tests ±  0  6 028 ✔️ ±  0  54 💤 ±0  0 ±0 
6 378 runs  +41  6 315 ✔️ +40  63 💤 +1  0 ±0 

Results for commit 2c0ab6a. ± Comparison against base commit dc00ef1.

♻️ This comment has been updated with latest results.

@vaadin-bot vaadin-bot added +1.0.0 and removed +0.1.0 labels Sep 30, 2022
MarcinVaadin and others added 2 commits September 30, 2022 14:07
…sUtil.java

Co-authored-by: sonatype-lift[bot] <37194012+sonatype-lift[bot]@users.noreply.github.com>
…ervlet-behind-feature-flag' into feature/14641-bring-back-vaadinServlet-behind-feature-flag
@mshabarov mshabarov self-requested a review October 3, 2022 11:05
MarcinVaadin and others added 3 commits October 3, 2022 15:51
For sake of Quarcus and other non-spring applications JSR356_PATH_MAPPING_LENGTH has been moved to general Atmosphere init parameters in PushRequestHandler

Co-authored-by: Marco Collovati <marco@vaadin.com>
@sonarcloud
Copy link

sonarcloud bot commented Oct 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@@ -58,6 +58,9 @@
public class VaadinServletConfiguration {

static final String VAADIN_SERVLET_MAPPING = "/vaadinServlet/*";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can VAADIN_SERVLET_MAPPING be removed?

if (rootMapping
&& isPushServletMappingEnabled(context.getEnvironment())) {
// in the case of root mapping, push requests should go to
// /vaadinServlet/pushUrl
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// /vaadinServlet/pushUrl
// /VAADIN/push/pushUrl

.replace("/*", "");
customPushUrl = customPushUrl.replaceFirst("context://", "/");
customPushUrl = customPushUrl.replaceFirst(Pattern.quote(mapping),
""); // if workaround "/vaadinServlet/myCustomUrl" used
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
""); // if workaround "/vaadinServlet/myCustomUrl" used
""); // if workaround "/VAADIN/push/myCustomUrl" used

@@ -0,0 +1,4 @@
server.port=8888
vaadin.exclude-urls=/swagger-ui/**
vaadin.pushServletMapping=true
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd propose "nonRootPushServletMapping" (or vice versa - "pushRootServletMapping", true by default) as a name for this parameter, because "pushServletMapping" doesn't tell much about its meaning. Also, not "pushServletMapping=false" doesn't make sense, since mapping is always there.

@@ -84,7 +84,7 @@ public ServletRegistrationBean<SpringServlet> servletRegistrationBean(
String pushRegistrationPath;

if (rootMapping) {
mapping = VaadinServletConfiguration.VAADIN_SERVLET_MAPPING;
mapping = VaadinServletConfiguration.VAADIN_SERVLET_PUSH_MAPPING;
Copy link
Contributor

Choose a reason for hiding this comment

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

mapping is used here not for push endpoint, but for SpringServlet registration, which is fine.
Apart from Push, it is fine to have /vaadinServlet mapped spring servlet.
We only talk about mapping path for JSR356_MAPPING_PATH, it should be changed, not the spring servlet.
Or I terribly missed something.

Copy link
Contributor

Choose a reason for hiding this comment

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

So in my opinion you should change pushRegistrationPath to include /VAADIN/push in case of root mapping, but not mapping itself.

protected boolean isPushServletMappingEnabled(Environment environment) {
if (SpringUtil.isSpringBoot()) {
try {
return (boolean) Class.forName(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we have to do this? Isn't VaadinConfigurationProperties instance available in the context where the method isPushServletMappingEnabled is needed?

makeContextRelative(mapping.replace("*", "")));
}

mapping = VaadinServletConfiguration.VAADIN_SERVLET_PUSH_MAPPING;
Copy link
Contributor

Choose a reason for hiding this comment

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

mapping should be "/vaadinServlet", because it corresponds to the servlet, not to the push registration.
pushRegistrationPath should be modified.

Comment on lines +103 to +106
if (configurationProperties.isPushServletMapping()) {
initParameters.put(ApplicationConfig.JSR356_MAPPING_PATH,
mapping.replace("/*", ""));
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did I understand correctly that if I've set a custom vaadin url mapping (e.g. /ui/*), the mapping for PUSH will be the on /ui/* and not on /ui/VAADIN/push?
If so, the AJP reverse proxy configuration will still have the same problem of missing a dedicate path for websockets

Copy link
Contributor

@mshabarov mshabarov Oct 7, 2022

Choose a reason for hiding this comment

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

Yes, it would be /ui/* and it was so in the past even with /vaadinServlet. So seems like if someone uses AJP with non root url mapping, this fix wouldn't work (as it wouldn't work even with old code with /vaadinServlet).

Copy link
Contributor

Choose a reason for hiding this comment

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

What if we add VAADIN/push always when this new parameter is turned on?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, it seems more consistent to me

@MarcinVaadin
Copy link
Member Author

Closing a PR due to approach change. New PR will be created.

@MarcinVaadin MarcinVaadin deleted the feature/14641-bring-back-vaadinServlet-behind-feature-flag branch October 7, 2022 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Websocket in combination with AJP broken behind reverse-proxy in 23.2.
5 participants