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

Add StaplerResponseWrapper #73

Merged
merged 2 commits into from
May 23, 2016
Merged

Add StaplerResponseWrapper #73

merged 2 commits into from
May 23, 2016

Conversation

kzantow
Copy link
Contributor

@kzantow kzantow commented Apr 22, 2016

... for wrapping functionality downstream if needed (e.g. capturing output by overriding getWriter()).

@reviewbybees esp. @jglick

@ghost
Copy link

ghost commented Apr 22, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@kzantow kzantow changed the title Add StaplerRequestWrapper Add StaplerResponseWrapper Apr 22, 2016
needed (e.g. capturing output by overriding getWriter())
@svanoort
Copy link
Member

🐝 - pretty straightforward

public abstract class StaplerResponseWrapper implements StaplerResponse {
private final StaplerResponse wrapped;

public StaplerResponseWrapper(StaplerResponse wrapped) {
Copy link
Member

Choose a reason for hiding this comment

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

🐜 but not a bad idea to put a @NotNull to enforce non-nullity of the wrapped response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but you might need to override getWrapped() to get a StaplerResponse by some other means (I've had to do this in the HttpServletResponseWrapper world before), and having a null wrapped member variable is valid in that case.

Copy link
Member

Choose a reason for hiding this comment

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

@kzantow Wouldn't it make more sense to just extend StaplerResponse in that case? You're not really using the wrapper then.

Copy link
Contributor Author

@kzantow kzantow Apr 27, 2016

Choose a reason for hiding this comment

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

You'd still need to forward all the calls to some StaplerResponse somewhere. Let's say you wanted to @Inject StaplerResponse into something with a "larger scope" in a DI system, you couldn't set the current response and you'd have to provide a wrapper, for example, to look it up from a ThreadLocal variable every time.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... okay I can see that case. On considering again, I think getWrapped() would be the right place to put NotNull, not on initialization.

@andresrc
Copy link

🐝

@kzantow
Copy link
Contributor Author

kzantow commented May 23, 2016

@svanoort 's comment addressed

@svanoort
Copy link
Member

🐝

@rsandell rsandell merged commit 4014323 into jenkinsci:master May 23, 2016
@oleg-nenashev
Copy link
Member

LGTM

@daniel-beck daniel-beck mentioned this pull request Dec 22, 2016
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.

6 participants