TestFilterServlet.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:fili 作者:
/**
 * An endpoint at /fail.
 *
 * @param uriInfo  The URI info of the request
 * @param asyncResponse  The response to respond to
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/fail")
public void getFail(@Context UriInfo uriInfo, @Suspended AsyncResponse asyncResponse) {

    // Process stream
    StreamingOutput stream = new StreamingOutput() {
        @Override
        public void write(OutputStream os) throws IOException {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ignore) {
                // Ignore
            }
            throw new IOException();
        }
    };

    // pass stream handler as response
    javax.ws.rs.core.Response rsp = javax.ws.rs.core.Response.ok(stream).build();
    asyncResponse.resume(rsp);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号