<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi.<br>
    </p>
    <p>The mailing-list on sourceforge (<a
        class="moz-txt-link-abbreviated"
        href="mailto:resteasy-developers@lists.sourceforge.net"><a class="moz-txt-link-abbreviated" href="mailto:resteasy-developers@lists.sourceforge.net">resteasy-developers@lists.sourceforge.net</a></a>)
      has been deprecated. Forwarding to correct mailing list (
      <a class="moz-txt-link-abbreviated" href="mailto:resteasy-dev@lists.jboss.org">resteasy-dev@lists.jboss.org</a> ).<br>
    </p>
    <p>Yes, "A 304 response cannot contain a message-body", see <a
        class="moz-txt-link-freetext"
        href="https://tools.ietf.org/html/rfc7232#section-4.1"><a class="moz-txt-link-freetext" href="https://tools.ietf.org/html/rfc7232#section-4.1">https://tools.ietf.org/html/rfc7232#section-4.1</a></a><br>
    </p>
    <div class="moz-forward-container">Sean, can you sent example of
      your end-point and client part? I tried to use this endpoint and
      client. It works as I expected. Any NPE is thrown:<br>
      <br>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <pre style="background-color:#ffffff;color:#000000;font-family:'Source Code Pro';font-size:10.5pt;"><span style="color:#808000;">@GET
</span><span style="color:#808000;">@Path</span>(<span style="color:#008000;font-weight:bold;">"nothing"</span>)
<span style="color:#808000;">@Produces</span>(<span style="color:#008000;font-weight:bold;">"application/octet-stream"</span>)
<span style="color:#000080;font-weight:bold;">public </span>InputStream nothing() {
    <span style="color:#000080;font-weight:bold;">if </span>(<span style="color:#000080;font-weight:bold;">true</span>) {
        <span style="color:#000080;font-weight:bold;">throw new </span>WebApplicationException(<span style="color:#0000ff;">304</span>);
    }
    <span style="color:#000080;font-weight:bold;">return new </span>ByteArrayInputStream(<span style="color:#008000;font-weight:bold;">"hello"</span>.getBytes());
}

-----------------------------------------------------------------------------------

<meta http-equiv="content-type" content="text/html; charset=utf-8">Response response = <span style="color:#660e7a;font-style:italic;">client</span>.target(generateURL(<span style="color:#008000;font-weight:bold;">"/nothing"</span>)).request().get();
<span style="color:#000080;font-weight:bold;">int </span>code = response.getStatus();
<span style="color:#000080;font-weight:bold;">if </span>(code == <span style="color:#0000ff;">200</span>) {
    InputStream is = response.readEntity(InputStream.<span style="color:#000080;font-weight:bold;">class</span>);
    Assert.<span style="font-style:italic;">assertEquals</span>(<span style="color:#008000;font-weight:bold;">"hello"</span>, TestUtil.<span style="font-style:italic;">readString</span>(is));
}
<span style="color:#000080;font-weight:bold;">if </span>(code == <span style="color:#0000ff;">304</span>) {
    <span style="color:#000080;font-weight:bold;">try </span>{
        response.readEntity(InputStream.<span style="color:#000080;font-weight:bold;">class</span>);
        Assert.<span style="font-style:italic;">fail</span>(<span style="color:#008000;font-weight:bold;">"ProcessingException was not thrown"</span>);
    } <span style="color:#000080;font-weight:bold;">catch </span>(ProcessingException e) {
        <span style="color:#808080;font-style:italic;">// expected exception
</span><span style="color:#808080;font-style:italic;">    </span>}
}
response.close();<pre style="background-color:#ffffff;color:#000000;font-family:'Source Code Pro';font-size:10.5pt;"></pre></pre>


But I found some performance issue with 304. If I use this end-point:
<meta http-equiv="content-type" content="text/html; charset=utf-8"><pre style="background-color:#ffffff;color:#000000;font-family:'Source Code Pro';font-size:10.5pt;"><span style="color:#808000;">@GET
</span><span style="color:#808000;">@Path</span>(<span style="color:#008000;font-weight:bold;">"nothing"</span>)
<span style="color:#000080;font-weight:bold;">public </span>Response nothing()
{
   <span style="color:#000080;font-weight:bold;">return </span>Response.<span style="font-style:italic;">status</span>(<span style="color:#0000ff;">304</span>).entity(<span style="color:#008000;font-weight:bold;">"test"</span>).build();
}</pre>
In WildFly, body is erased in
      Undertow (AFAIK), but RESTEasy could do this too. Check for 304 can be implemented here:

<a class="moz-txt-link-freetext" href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ServerResponseWriter.java#L50">https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ServerResponseWriter.java#L50</a>

      

      Now, interceptors are applied to these kinds of responses. This is
      not necessary and it may not be optimal for performance. Alessio,
      Ron, WDYT?

      

      

      Marek

      

      -------- Forwarded Message --------
      <table class="moz-email-headers-table" border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
            </th>
            <td>[Resteasy-developers] Proper handling of NotModified/304</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
            <td>Fri, 10 Jun 2016 10:50:03 -0400</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
            <td>Sean Dawson <a class="moz-txt-link-rfc2396E" href="mailto:sean.dawson2014@gmail.com">&lt;sean.dawson2014@gmail.com&gt;</a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">To: </th>
            <td>resteasy-devel.
              <a class="moz-txt-link-rfc2396E" href="mailto:resteasy-developers@lists.sourceforge.net">&lt;resteasy-developers@lists.sourceforge.net&gt;</a></td>
          </tr>
        </tbody>
      </table>
      

      

      <div dir="ltr">
        <div>

        </div>
        <div>I posted this on users but I'm thinking it's a RestEasy bug
          at this point.</div>
        <div>

        </div>
        <div>The code seems to buffer the entity and then throw a
          processing exception if the status is bad.</div>
        <div>

        </div>
        <div>In the case of 304, no body is provided (and this seems to
          be correct according to the standard).  I have found no way
          server side to return anything but null as the entity.  So
          attempting to buffer it on a 304 just seems plain incorrect
          (and results in an NPE).</div>
        <div>

        </div>
        <div>Am I missing something?</div>
        <div>

        </div>
        <div>Setting the custom header on the response does work - but
          I'm not sure that'll make it back to the client when it passes
          through servers that usually strip those out.</div>
        <div>

        </div>
      </div>
    </div>
  


</body></html>