{"action":"created","issue":{"url":"https://api.github.com/repos/zandero/rest.vertx/issues/14","repository_url":"https://api.github.com/repos/zandero/rest.vertx","labels_url":"https://api.github.com/repos/zandero/rest.vertx/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/zandero/rest.vertx/issues/14/comments","events_url":"https://api.github.com/repos/zandero/rest.vertx/issues/14/events","html_url":"https://github.com/zandero/rest.vertx/issues/14","id":293511454,"number":14,"title":" rest.vertx is great, but i want to kone how to implement AsyncResult in restMethod","user":{"login":"xiaomomo","id":2564689,"avatar_url":"https://avatars0.githubusercontent.com/u/2564689?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaomomo","html_url":"https://github.com/xiaomomo","followers_url":"https://api.github.com/users/xiaomomo/followers","following_url":"https://api.github.com/users/xiaomomo/following{/other_user}","gists_url":"https://api.github.com/users/xiaomomo/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaomomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaomomo/subscriptions","organizations_url":"https://api.github.com/users/xiaomomo/orgs","repos_url":"https://api.github.com/users/xiaomomo/repos","events_url":"https://api.github.com/users/xiaomomo/events{/privacy}","received_events_url":"https://api.github.com/users/xiaomomo/received_events","type":"User","site_admin":false},"labels":[{"id":578817735,"url":"https://api.github.com/repos/zandero/rest.vertx/labels/duplicate","name":"duplicate","color":"cccccc","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-02-01T12:24:53Z","updated_at":"2018-02-06T03:10:19Z","closed_at":"2018-02-01T12:27:46Z","author_association":"NONE","body":"i want implement a async controller method like vertx.web \r\n\r\nhere is my code\r\n\r\n```\r\n@GET\r\n    @Path(\"/create\")\r\n    @Produces(MediaType.APPLICATION_JSON)\r\n    @ResponseWriter(VertxResponseWriter.class)\r\n    public Handler<Void> create(@Context RoutingContext context,\r\n                                @Context HttpServerResponse response,\r\n                                @Context Vertx vertx) {\r\n\r\n        System.out.println(Thread.currentThread().getName() + \"create start\");\r\n        context.request().getParam(\"id\");\r\n        SpaceDO spaceDO = new SpaceDO();\r\n        Handler<Void> result = res -> {\r\n            System.out.println(\"really return\");\r\n            response.setStatusCode(200)\r\n                    .putHeader(\"content-type\", \"application/json\")\r\n                    .end(\"vapsce return\");\r\n\r\n        };\r\n        spaceService.create(spaceDO, dbResult -> {\r\n            System.out.println(Thread.currentThread().getName() + \"async complete\");\r\n            result.handle(dbResult.result());\r\n        });\r\n        System.out.println(Thread.currentThread().getName() + \"create method end\");\r\n        return result;\r\n    }\r\n```\r\nbut the com.zandero.rest.RestRouter#produceResponse method end end response mandatory,and system invoke error: `java.lang.IllegalStateException: Response has already been written`\r\n\r\n```\r\nif (!response.ended()) {\r\n\t\t\tresponse.end();\r\n\t\t}\r\n```\r\nwhy do this, and could i comment that statement in some fork?\r\n"},"comment":{"url":"https://api.github.com/repos/zandero/rest.vertx/issues/comments/363296604","html_url":"https://github.com/zandero/rest.vertx/issues/14#issuecomment-363296604","issue_url":"https://api.github.com/repos/zandero/rest.vertx/issues/14","id":363296604,"user":{"login":"xiaomomo","id":2564689,"avatar_url":"https://avatars0.githubusercontent.com/u/2564689?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaomomo","html_url":"https://github.com/xiaomomo","followers_url":"https://api.github.com/users/xiaomomo/followers","following_url":"https://api.github.com/users/xiaomomo/following{/other_user}","gists_url":"https://api.github.com/users/xiaomomo/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaomomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaomomo/subscriptions","organizations_url":"https://api.github.com/users/xiaomomo/orgs","repos_url":"https://api.github.com/users/xiaomomo/repos","events_url":"https://api.github.com/users/xiaomomo/events{/privacy}","received_events_url":"https://api.github.com/users/xiaomomo/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T03:10:19Z","updated_at":"2018-02-06T03:10:19Z","author_association":"NONE","body":"sorry for my earlier describe bother you，i test your code in runtime, the code \r\n```\r\npublic class AsyncService {\r\n\r\n\tpublic void handle(Dummy dummy, Handler<AsyncResult<Dummy>> handler) throws InterruptedException {\r\n\r\n\t\tThread.sleep(1000L);\r\n\t\thandler.handle(Future.succeededFuture(dummy));\r\n\t\tSystem.out.println(Thread.currentThread().getName() + \" async service called \");\r\n\t}\r\n}\r\n```\r\nis execute synchronous and return  `{\"name\": \"async++\", \"value\": \"called++\"}`\r\n\r\nbut i want `AsyncService` execute async like this\r\n\r\n```\r\npublic class AsyncService {\r\n\r\n    public void handle(Dummy dummy, Handler<AsyncResult<Dummy>> handler) throws InterruptedException {\r\n\r\n        (new Thread(() -> {\r\n            try {\r\n                Thread.sleep(1000L);\r\n            } catch (InterruptedException e) {\r\n                e.printStackTrace();\r\n            }\r\n            handler.handle(Future.succeededFuture(dummy));\r\n        })).start();\r\n        System.out.println(Thread.currentThread().getName() + \" async service called \");\r\n    }\r\n}\r\n```\r\nin this time will return ` {\"name\": \"async\", \"value\": \"called\"}`\r\n\r\n"}}
{"actor":{"display_login":"xiaomomo"}}