title: Does jetty overwrite custom http status code ?
body: <p>I am trying to develop a rest api for my service wherein I set custom http status code depending on authorisation failure. But when I test it out using curl I am receiving 404 instead of 403. I am perplexed as to what might be causing this? Please help. </p>
  
  <p>This is what I see from curl output or swagger UI:</p>
  
  <pre><code>root@ubuntu:~# curl -X GET http://localhost:8082/mr/v1/topic/bhakk -v
  Note: Unnecessary use of -X or --request, GET is already inferred.
  *   Trying 127.0.0.1...
  * Connected to localhost (127.0.0.1) port 8082 (#0)
  &gt; GET /mr/v1/topic/bhakk HTTP/1.1
  &gt; Host: localhost:8082
  &gt; User-Agent: curl/7.47.0
  &gt; Accept: */*
  &gt;
  &lt; HTTP/1.1 404 Not Found
  &lt; Date: Mon, 07 May 2018 22:00:10 GMT
  &lt; Exception: serviceBlockedException
  &lt; Content-Type: application/vnd.kafka.v1+json
  &lt; Content-Length: 83
  &lt; Server: Jetty(9.2.z-SNAPSHOT)
  &lt;
  * Connection #0 to host localhost left intact
  {"error_code":40301,"message":"This service does not have access to the resource."}
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>    public Collection&lt;String&gt; list(@HeaderParam("x-nssvc-serviceid") String serviceID) {
          Date now = new java.util.Date();
          if (! ctx.getSecurityRestrictions().isServiceAllowed(uri, httpHeaders, "Describe", "Cluster", "kafka-cluster"))
            throw Errors.serviceBlockedException(ctx,httpServletResponse);
  
          List&lt;String&gt; topicsCopy = new ArrayList&lt;String&gt;(topics);
          for (Iterator&lt;String&gt; iterator = topicsCopy.iterator(); iterator.hasNext();) {
            String topic = iterator.next();
            if (! ctx.getSecurityRestrictions().hasAccess (serviceId, "Describe", "Topic", topic)) {
              iterator.remove();
            }
          }
  
          return topicsCopy;
        }
  
      public static RestException serviceBlockedException(Context ctx,HttpServletResponse httpServletResponse) {
          httpServletResponse.setHeader("Exception","serviceBlockedException");
          httpServletResponse.setStatus(Status.FORBIDDEN.getStatusCode()); &lt;----// here i am setting status code.
          return new RestNotFoundException(SERVICE_ID_BLOCKED_MESSAGE, SERVICE_ID_BLOCKED_ERROR_CODE);
        }
  </code></pre>