jsr369-experts@servlet-spec.java.net

[jsr369-experts] Re: [servlet-spec users] Re: Re: HttpServletRequest#getPushBuilder

From: Greg Wilkins <gregw_at_webtide.com>
Date: Tue, 31 Jan 2017 17:21:50 +1100

I thought we had discussed this before and in the end decided a noop
builder was desirable because of the intrinsic race condition that exists
with code like:

  if (request.isPushSupported())
  {
    PushBuilder builder = request.getPushBuilder();
    builder.path("/something.txt").push();
  }

Because push can be disabled at any time, there is a non obvious race in
the above code. If push is disabled by a settings frame after the
condition, then a NPE could result. I doubt many will actually write the
code:

  if (request.isPushSupported())
  {
    PushBuilder builder = request.getPushBuilder();
    if (builder !=null )
    {
      builder.path("/something.txt").push();
    }
  }

Note also that the final push can still end up being a noop if a settings
frame disables push while the builder is being used.

If we want the null return, then I think we need to remove isPushSupported,
so that the only valid code is:

  PushBuilder builder = request.getPushBuilder();
  if (builder !=null )
  {
    builder.path("/something.txt").push();
  }

cheers





On 31 January 2017 at 10:25, Edward Burns <edward.burns_at_oracle.com> wrote:

> >>>>> On Mon, 30 Jan 2017 15:18:57 -0800, Shing Wai Chan <
> shing.wai.chan_at_oracle.com> said:
>
> SW> If there is no objection, I will add default method to return null
> SW> and update the javadoc as shown below. Please respond by close of
> SW> business PST Thursday otherwise Ill specify the above the proposal.
>
> Looks good to me.
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | 26 business days until planned start of JSF 2.3 Final Approval Ballot
> | 16 business days until DevNexus 2017
> | 41 business days until JavaLand 2017
>



-- 
Greg Wilkins <gregw@webtide.com> CTO http://webtide.com