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: use superclass of VadinServlet/Request if possible #9699

Merged
merged 2 commits into from
Mar 4, 2021

Conversation

stbischof
Copy link
Contributor

@stbischof stbischof commented Dec 20, 2020

I cases you are not using the VaadinServletService because you ship your own own (Servlet-based) VaadinService.

Then you are, at the moment, not able to use fundamental classes like VaadinServlet. This is because they use your VaadinServletService. But you are not using any methods of VaadinServletService because VaadinService is enough. So I suggest to use superclasses if possible.

VaadinServletRequestneeds a VaadinServletService

    @Override
    public VaadinServletService getService() {
        return vaadinService;
    }

If you have your own VaadinService implementation you can't rely on VaadinServletRequest
ant an the moment you cant use a lot of classes like VaadinServlet, PushRequestHandler, StreamResourceHandler, WebComponentBootstrapHandler

@stbischof stbischof force-pushed the ServletRequestWrapper branch 5 times, most recently from 8754129 to 4803667 Compare December 21, 2020 02:10
@@ -16,6 +16,8 @@
package com.vaadin.flow.server.communication;

import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestWrapper;
Copy link
Collaborator

Choose a reason for hiding this comment

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

CRITICAL Remove this unused import 'javax.servlet.ServletRequestWrapper'. rule

Copy link
Contributor

@pleku pleku left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and sorry for the long delay with the review, but this PR basically shows how reluctant people are to comment on PRs that don't explain why changes are proposed. There is no issue open that would explain why this is needed so you need to start with that.

Secondly many of the changes seem like invalid and, sorry for being direct but, a waste of time. Please help me understand why this would be valuable. If not, I think we'll just have to say no thanks this time - I hope you understand.

Copy link
Contributor

@pleku pleku left a comment

Choose a reason for hiding this comment

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

If we we're to allow having your own VaadinService then it would be good if there was some sort of test in the project that would make it so that this feature is not accidentally broken.

Now that the reasoning behind the PR is clear, the next question would be about the added value and use case - why do you want to use your own VaadinService ?

(edit: this type of discussions would be better to have in an issue before starting the implementation)

@stbischof
Copy link
Contributor Author

stbischof commented Feb 9, 2021

Because of your OSGi approach is not the way how I would expect to handle OSGi and Vaadin. It is kind of "Works with OSGi" and will fit most of people. But really working with Services is in a deep way would look other.

And your OSGi bundles also have the wrong license.

If you allow others to having an own VaadinService i will add test that force and check ClassCastExceptions.

@pleku
Copy link
Contributor

pleku commented Feb 10, 2021

Because of your OSGi approach is not the way how I would expect to handle OSGi and Vaadin. It is kind of "Works with OSGi" and will fit most of people. But really working with Services is in a deep way would look other.

I take it you mean with this that there would be a better way for this to work by utilizing declarative services in OSGi. I think this is a direction that we would want to take too and would gladly accept those contributions, but this direction should be taken by first discussing and agreeing on the steps in issues before jumping into implementation - it will be more smooth that way as then we know what is incoming and are more likely to help you get it in instead of need to start by questioning that "why is this code needed". From our perspective, we have to start that way as we're promising to maintain the code for 15 years to users who need that.

And your OSGi bundles also have the wrong license.

Just to be sure - do you mean the commercial license in vaadin/osgi or something else ?

If you allow others to having an own VaadinService i will add test that force and check ClassCastExceptions.

I don't have any objections to this now that I understand the goal. Though, I would rather work together to improve our OSGi support for all instead of enabling people to build their own support. We're gladly willing to give out licenses to those who contribute to it.

@stbischof
Copy link
Contributor Author

stbischof commented Feb 10, 2021

I broken all my contribution in the moment where i had seen that you moved the osgi part to commercial license in vaadin/osgi.
Also parts that had been under the normal license.

Because this was just an private interest a commercial license would not be an option for me and some guyes with the same interests. I will discuss this with them.

@pleku pleku changed the title use superclass of VadinServlet/Request if possible feat: use superclass of VadinServlet/Request if possible Feb 17, 2021
@pleku
Copy link
Contributor

pleku commented Feb 17, 2021

To clarify to myself for later times, this is still waiting for a test to be added that would prevent breaking the "feature" that easily.

@stbischof stbischof force-pushed the ServletRequestWrapper branch 2 times, most recently from 6246f58 to c4070f7 Compare February 18, 2021 10:57
@stbischof
Copy link
Contributor Author

i added the wished tests: OtherImplementationsTest.java

@pleku
Copy link
Contributor

pleku commented Feb 18, 2021

The build failed due to unrelated build agent issues, I'll retrigger it tomorrow and take a look at the test.

@stbischof
Copy link
Contributor Author

stbischof commented Feb 24, 2021

@pleku Could you please retrigger it?

@stbischof
Copy link
Contributor Author

forced push to trigger rerun of tests, (last one also did not finished

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
Copy link
Contributor

@pleku pleku left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay, I was on winter vacation last week ⛷️

Only couple of small comments and then this would be 🟢


public class OtherImplementationsTest {
@Test
public void StaticFileServer_Constructor_uses_VadinService()
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking nit: typoed Vaadin here and c/p the error to other method names too ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed into Vaadin


import com.vaadin.flow.server.communication.PushRequestHandler;

public class OtherImplementationsTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

I get the test, but at a glance probably most developers will not. Please change the name to CustomVaadinServiceImplementationTest and maybe add a comment line "Makes sure that a custom vaadin service that is not vaadin servlet service can be used in when desired".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, Thx

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
@pleku pleku enabled auto-merge (squash) March 4, 2021 08:37
@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 7 issues

  • CRITICAL 2 critical
  • MAJOR 1 major
  • MINOR 4 minor

Watch the comments in this conversation to review them.

5 extra issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. MAJOR VaadinService.java#L426: Rename "instantiator" which hides the field declared at line 193. rule
  2. MINOR VaadinService.java#L429: Remove this use of "init"; it is deprecated. rule
  3. MINOR VaadinService.java#L443: Remove this use of "init"; it is deprecated. rule
  4. MINOR VaadinServlet.java#L194: Remove the declaration of thrown exception 'javax.servlet.ServletException', as it cannot be thrown from method's body. rule
  5. MINOR VaadinServlet.java#L543: Replace this lambda with a method reference. rule

@pleku pleku merged commit c581668 into vaadin:master Mar 4, 2021
@Legioth
Copy link
Member

Legioth commented Apr 14, 2021

This change causes massive backwards binary compatibility issues with e.g. add-ons compiled against older versions of Vaadin. This happens because method invocations in bytecode are tied to the method return type and not only the method name and parameter types.

I would suggest reverting to avoid those issues.

Furthermore, I don't even understand the whole point of making this change. If you want to use a custom service implementation together with VaadinServlet, then why wouldn't you extend VaadinServletService instead of the generic VaadinService class?

@Legioth
Copy link
Member

Legioth commented Apr 15, 2021

To further elaborate on my previous message, the point is that VaadinServlet and VaadinServletService should really be seen as a single unit that just happens to be split up into two separate classes because Java doesn't offer multiple inheritance.

They're not supposed to be separated from each other. A proper separation would require more thorough architectural considerations rather than only tweaking some return types that happened to get in the way when trying to do something that you're not supposed to even try.

@pleku
Copy link
Contributor

pleku commented Apr 26, 2021

I don't know why the bot has added the label Released with Platform 19.0.0 as it is not true - @ZheSun88 ?

pleku added a commit that referenced this pull request Apr 26, 2021
…ssible (#9699)"

This reverts commit c581668, except
intentionally leaves out part in PushHandler which accepts VaadinService
and the protected API introduced to StaticFileServer to get a StaticFileServer
resource, so it may be overridden to use something else than VaadinServletService.
@ZheSun88
Copy link
Contributor

ZheSun88 commented Apr 26, 2021

Thanks@pleku , there was a wrong tag in platform repo, so the bot caught the wrong flow release for V19.0.0. i have fixed the issue.

@vaadin vaadin deleted a comment from vaadin-bot Apr 26, 2021
pleku added a commit that referenced this pull request Apr 27, 2021
…)" (#10812)

This reverts commit c581668, except
intentionally leaves out part of the protected API introduced to StaticFileServer to get a StaticFileServer
resource, so it may be overridden to use something else than VaadinServletService.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants