private void configureTrace(final ContainerResponseWriter crw) { final TraceInformation ti = (TraceInformation) request.getProperties().get(TraceInformation.class.getName()); setContainerResponseWriter( new ContainerResponseWriter() { public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse response) throws IOException { ti.addTraceHeaders(); return crw.writeStatusAndHeaders(contentLength, response); } public void finish() throws IOException { crw.finish(); } }); }