{"action":"created","comment":{"url":"https://api.github.com/repos/dropwizard/dropwizard/pulls/comments/31082082","id":31082082,"diff_hunk":"@@ -0,0 +1,83 @@\n+package io.dropwizard.benchmarks.jersey;\n+\n+import com.google.common.collect.Iterators;\n+import io.dropwizard.jersey.validation.ConstraintMessage;\n+import org.hibernate.validator.constraints.NotEmpty;\n+import org.openjdk.jmh.annotations.*;\n+import org.openjdk.jmh.runner.Runner;\n+import org.openjdk.jmh.runner.options.OptionsBuilder;\n+\n+import javax.validation.ConstraintViolation;\n+import javax.validation.Valid;\n+import javax.validation.Validation;\n+import javax.validation.Validator;\n+import javax.validation.executable.ExecutableValidator;\n+import javax.ws.rs.HeaderParam;\n+import java.util.Set;\n+import java.util.concurrent.TimeUnit;\n+\n+import static org.apache.commons.lang3.reflect.MethodUtils.getAccessibleMethod;\n+\n+@BenchmarkMode(Mode.AverageTime)\n+@OutputTimeUnit(TimeUnit.NANOSECONDS)\n+@State(Scope.Benchmark)\n+public class ConstraintViolationBenchmark {\n+\n+    private ConstraintViolation<ConstraintViolationBenchmark> paramViolation;\n+    private ConstraintViolation<ConstraintViolationBenchmark> objViolation;\n+\n+    public String paramFunc(@HeaderParam(\"cheese\") @NotEmpty String secretSauce) {\n+        return secretSauce;\n+    }\n+\n+    public String objectFunc(@Valid Foo foo) {\n+        return foo.toString();\n+    }\n+\n+    public class Foo {\n+        @NotEmpty\n+        private String bar;\n+    }\n+\n+    @Setup\n+    public void prepare() {\n+        final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();\n+        final ExecutableValidator execValidator = validator.forExecutables();\n+\n+        Set<ConstraintViolation<ConstraintViolationBenchmark>> paramViolations =\n+            execValidator.validateParameters(\n+                this,\n+                getAccessibleMethod(getClass(), \"paramFunc\", String.class),\n+                new Object[]{\"\"} // the parameter value\n+            );\n+        paramViolation = Iterators.getOnlyElement(paramViolations.iterator());","path":"dropwizard-benchmarks/src/main/java/io/dropwizard/benchmarks/jersey/ConstraintViolationBenchmark.java","position":53,"original_position":53,"commit_id":"7fc6e6878bab687e63c33611e057516c68869c67","original_commit_id":"7fc6e6878bab687e63c33611e057516c68869c67","user":{"login":"arteam","id":1717632,"avatar_url":"https://avatars.githubusercontent.com/u/1717632?v=3","gravatar_id":"","url":"https://api.github.com/users/arteam","html_url":"https://github.com/arteam","followers_url":"https://api.github.com/users/arteam/followers","following_url":"https://api.github.com/users/arteam/following{/other_user}","gists_url":"https://api.github.com/users/arteam/gists{/gist_id}","starred_url":"https://api.github.com/users/arteam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arteam/subscriptions","organizations_url":"https://api.github.com/users/arteam/orgs","repos_url":"https://api.github.com/users/arteam/repos","events_url":"https://api.github.com/users/arteam/events{/privacy}","received_events_url":"https://api.github.com/users/arteam/received_events","type":"User","site_admin":false},"body":"I think it's safe just to call `iterator.next`, because we know that the violation is exist.","created_at":"2015-05-26T21:32:13Z","updated_at":"2015-05-26T21:32:13Z","html_url":"https://github.com/dropwizard/dropwizard/pull/1039#discussion_r31082082","pull_request_url":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039","_links":{"self":{"href":"https://api.github.com/repos/dropwizard/dropwizard/pulls/comments/31082082"},"html":{"href":"https://github.com/dropwizard/dropwizard/pull/1039#discussion_r31082082"},"pull_request":{"href":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039"}}},"pull_request":{"url":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039","id":35044532,"html_url":"https://github.com/dropwizard/dropwizard/pull/1039","diff_url":"https://github.com/dropwizard/dropwizard/pull/1039.diff","patch_url":"https://github.com/dropwizard/dropwizard/pull/1039.patch","issue_url":"https://api.github.com/repos/dropwizard/dropwizard/issues/1039","number":1039,"state":"open","locked":false,"title":"Descriptive constraint violation messages","user":{"login":"nickbabcock","id":2106129,"avatar_url":"https://avatars.githubusercontent.com/u/2106129?v=3","gravatar_id":"","url":"https://api.github.com/users/nickbabcock","html_url":"https://github.com/nickbabcock","followers_url":"https://api.github.com/users/nickbabcock/followers","following_url":"https://api.github.com/users/nickbabcock/following{/other_user}","gists_url":"https://api.github.com/users/nickbabcock/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbabcock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbabcock/subscriptions","organizations_url":"https://api.github.com/users/nickbabcock/orgs","repos_url":"https://api.github.com/users/nickbabcock/repos","events_url":"https://api.github.com/users/nickbabcock/events{/privacy}","received_events_url":"https://api.github.com/users/nickbabcock/received_events","type":"User","site_admin":false},"body":"This pull requests attempts to return user friendly error messages when constraints are violated either in the response or the request.\r\n\r\nSo instead of error messages of\r\n\r\n```json\r\n{\"errors\":[\"blazer.arg0.name may not be empty\"]}\r\n```\r\nand\r\n\r\n```json\r\n{\"errors\":[\"blaze.<return value> length must be between 0 and 3\"]}\r\n```\r\nmore user friendly error messages are returned\r\n\r\n```json\r\n{\"errors\":[\"query param name may not be empty\"]}\r\n```\r\n```json\r\n{\"errors\":[\"server response length must be between 0 and 3\"]}\r\n```\r\n\r\nThis pull request isn't done, so don't merge (hardly any documentation and I didn't completely mull over edge cases). As it happens, I'll be off the grid for the next couple weeks, but I wanted to get some eyes on the code (hence the pull request), but if someone is extremely enthusiastic they can carry this pull request the rest of the way, else I'll pick off where I left off and incorporate any suggestions in the pull request.\r\n\r\nThe code isn't fast, concise, documented, or complete -- but it passes all the test cases I wrote for it :smile:\r\n\r\nOpinions wanted!","created_at":"2015-05-08T20:36:20Z","updated_at":"2015-05-26T21:32:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"708c37746227b70d3c7e404bb224519fd5977eaf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039/commits","review_comments_url":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039/comments","review_comment_url":"https://api.github.com/repos/dropwizard/dropwizard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dropwizard/dropwizard/issues/1039/comments","statuses_url":"https://api.github.com/repos/dropwizard/dropwizard/statuses/7fc6e6878bab687e63c33611e057516c68869c67","head":{"label":"nickbabcock:constraint-messages","ref":"constraint-messages","sha":"7fc6e6878bab687e63c33611e057516c68869c67","user":{"login":"nickbabcock","id":2106129,"avatar_url":"https://avatars.githubusercontent.com/u/2106129?v=3","gravatar_id":"","url":"https://api.github.com/users/nickbabcock","html_url":"https://github.com/nickbabcock","followers_url":"https://api.github.com/users/nickbabcock/followers","following_url":"https://api.github.com/users/nickbabcock/following{/other_user}","gists_url":"https://api.github.com/users/nickbabcock/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbabcock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbabcock/subscriptions","organizations_url":"https://api.github.com/users/nickbabcock/orgs","repos_url":"https://api.github.com/users/nickbabcock/repos","events_url":"https://api.github.com/users/nickbabcock/events{/privacy}","received_events_url":"https://api.github.com/users/nickbabcock/received_events","type":"User","site_admin":false},"repo":{"id":18115354,"name":"dropwizard","full_name":"nickbabcock/dropwizard","owner":{"login":"nickbabcock","id":2106129,"avatar_url":"https://avatars.githubusercontent.com/u/2106129?v=3","gravatar_id":"","url":"https://api.github.com/users/nickbabcock","html_url":"https://github.com/nickbabcock","followers_url":"https://api.github.com/users/nickbabcock/followers","following_url":"https://api.github.com/users/nickbabcock/following{/other_user}","gists_url":"https://api.github.com/users/nickbabcock/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbabcock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbabcock/subscriptions","organizations_url":"https://api.github.com/users/nickbabcock/orgs","repos_url":"https://api.github.com/users/nickbabcock/repos","events_url":"https://api.github.com/users/nickbabcock/events{/privacy}","received_events_url":"https://api.github.com/users/nickbabcock/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickbabcock/dropwizard","description":"A damn simple library for building production-ready RESTful web services.","fork":true,"url":"https://api.github.com/repos/nickbabcock/dropwizard","forks_url":"https://api.github.com/repos/nickbabcock/dropwizard/forks","keys_url":"https://api.github.com/repos/nickbabcock/dropwizard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickbabcock/dropwizard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickbabcock/dropwizard/teams","hooks_url":"https://api.github.com/repos/nickbabcock/dropwizard/hooks","issue_events_url":"https://api.github.com/repos/nickbabcock/dropwizard/issues/events{/number}","events_url":"https://api.github.com/repos/nickbabcock/dropwizard/events","assignees_url":"https://api.github.com/repos/nickbabcock/dropwizard/assignees{/user}","branches_url":"https://api.github.com/repos/nickbabcock/dropwizard/branches{/branch}","tags_url":"https://api.github.com/repos/nickbabcock/dropwizard/tags","blobs_url":"https://api.github.com/repos/nickbabcock/dropwizard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickbabcock/dropwizard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickbabcock/dropwizard/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickbabcock/dropwizard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickbabcock/dropwizard/statuses/{sha}","languages_url":"https://api.github.com/repos/nickbabcock/dropwizard/languages","stargazers_url":"https://api.github.com/repos/nickbabcock/dropwizard/stargazers","contributors_url":"https://api.github.com/repos/nickbabcock/dropwizard/contributors","subscribers_url":"https://api.github.com/repos/nickbabcock/dropwizard/subscribers","subscription_url":"https://api.github.com/repos/nickbabcock/dropwizard/subscription","commits_url":"https://api.github.com/repos/nickbabcock/dropwizard/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickbabcock/dropwizard/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickbabcock/dropwizard/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickbabcock/dropwizard/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickbabcock/dropwizard/contents/{+path}","compare_url":"https://api.github.com/repos/nickbabcock/dropwizard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickbabcock/dropwizard/merges","archive_url":"https://api.github.com/repos/nickbabcock/dropwizard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickbabcock/dropwizard/downloads","issues_url":"https://api.github.com/repos/nickbabcock/dropwizard/issues{/number}","pulls_url":"https://api.github.com/repos/nickbabcock/dropwizard/pulls{/number}","milestones_url":"https://api.github.com/repos/nickbabcock/dropwizard/milestones{/number}","notifications_url":"https://api.github.com/repos/nickbabcock/dropwizard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickbabcock/dropwizard/labels{/name}","releases_url":"https://api.github.com/repos/nickbabcock/dropwizard/releases{/id}","created_at":"2014-03-25T20:24:18Z","updated_at":"2015-04-17T18:15:07Z","pushed_at":"2015-05-26T19:17:53Z","git_url":"git://github.com/nickbabcock/dropwizard.git","ssh_url":"git@github.com:nickbabcock/dropwizard.git","clone_url":"https://github.com/nickbabcock/dropwizard.git","svn_url":"https://github.com/nickbabcock/dropwizard","homepage":"http://www.dropwizard.io","size":6476,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dropwizard:master","ref":"master","sha":"601b279456f354135dd23ba54a18a0aa85f3cb38","user":{"login":"dropwizard","id":5478557,"avatar_url":"https://avatars.githubusercontent.com/u/5478557?v=3","gravatar_id":"","url":"https://api.github.com/users/dropwizard","html_url":"https://github.com/dropwizard","followers_url":"https://api.github.com/users/dropwizard/followers","following_url":"https://api.github.com/users/dropwizard/following{/other_user}","gists_url":"https://api.github.com/users/dropwizard/gists{/gist_id}","starred_url":"https://api.github.com/users/dropwizard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dropwizard/subscriptions","organizations_url":"https://api.github.com/users/dropwizard/orgs","repos_url":"https://api.github.com/users/dropwizard/repos","events_url":"https://api.github.com/users/dropwizard/events{/privacy}","received_events_url":"https://api.github.com/users/dropwizard/received_events","type":"Organization","site_admin":false},"repo":{"id":1272129,"name":"dropwizard","full_name":"dropwizard/dropwizard","owner":{"login":"dropwizard","id":5478557,"avatar_url":"https://avatars.githubusercontent.com/u/5478557?v=3","gravatar_id":"","url":"https://api.github.com/users/dropwizard","html_url":"https://github.com/dropwizard","followers_url":"https://api.github.com/users/dropwizard/followers","following_url":"https://api.github.com/users/dropwizard/following{/other_user}","gists_url":"https://api.github.com/users/dropwizard/gists{/gist_id}","starred_url":"https://api.github.com/users/dropwizard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dropwizard/subscriptions","organizations_url":"https://api.github.com/users/dropwizard/orgs","repos_url":"https://api.github.com/users/dropwizard/repos","events_url":"https://api.github.com/users/dropwizard/events{/privacy}","received_events_url":"https://api.github.com/users/dropwizard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dropwizard/dropwizard","description":"A damn simple library for building production-ready RESTful web services.","fork":false,"url":"https://api.github.com/repos/dropwizard/dropwizard","forks_url":"https://api.github.com/repos/dropwizard/dropwizard/forks","keys_url":"https://api.github.com/repos/dropwizard/dropwizard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dropwizard/dropwizard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dropwizard/dropwizard/teams","hooks_url":"https://api.github.com/repos/dropwizard/dropwizard/hooks","issue_events_url":"https://api.github.com/repos/dropwizard/dropwizard/issues/events{/number}","events_url":"https://api.github.com/repos/dropwizard/dropwizard/events","assignees_url":"https://api.github.com/repos/dropwizard/dropwizard/assignees{/user}","branches_url":"https://api.github.com/repos/dropwizard/dropwizard/branches{/branch}","tags_url":"https://api.github.com/repos/dropwizard/dropwizard/tags","blobs_url":"https://api.github.com/repos/dropwizard/dropwizard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dropwizard/dropwizard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dropwizard/dropwizard/git/refs{/sha}","trees_url":"https://api.github.com/repos/dropwizard/dropwizard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dropwizard/dropwizard/statuses/{sha}","languages_url":"https://api.github.com/repos/dropwizard/dropwizard/languages","stargazers_url":"https://api.github.com/repos/dropwizard/dropwizard/stargazers","contributors_url":"https://api.github.com/repos/dropwizard/dropwizard/contributors","subscribers_url":"https://api.github.com/repos/dropwizard/dropwizard/subscribers","subscription_url":"https://api.github.com/repos/dropwizard/dropwizard/subscription","commits_url":"https://api.github.com/repos/dropwizard/dropwizard/commits{/sha}","git_commits_url":"https://api.github.com/repos/dropwizard/dropwizard/git/commits{/sha}","comments_url":"https://api.github.com/repos/dropwizard/dropwizard/comments{/number}","issue_comment_url":"https://api.github.com/repos/dropwizard/dropwizard/issues/comments{/number}","contents_url":"https://api.github.com/repos/dropwizard/dropwizard/contents/{+path}","compare_url":"https://api.github.com/repos/dropwizard/dropwizard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dropwizard/dropwizard/merges","archive_url":"https://api.github.com/repos/dropwizard/dropwizard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dropwizard/dropwizard/downloads","issues_url":"https://api.github.com/repos/dropwizard/dropwizard/issues{/number}","pulls_url":"https://api.github.com/repos/dropwizard/dropwizard/pulls{/number}","milestones_url":"https://api.github.com/repos/dropwizard/dropwizard/milestones{/number}","notifications_url":"https://api.github.com/repos/dropwizard/dropwizard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dropwizard/dropwizard/labels{/name}","releases_url":"https://api.github.com/repos/dropwizard/dropwizard/releases{/id}","created_at":"2011-01-19T19:52:29Z","updated_at":"2015-05-26T17:17:45Z","pushed_at":"2015-05-26T21:03:26Z","git_url":"git://github.com/dropwizard/dropwizard.git","ssh_url":"git@github.com:dropwizard/dropwizard.git","clone_url":"https://github.com/dropwizard/dropwizard.git","svn_url":"https://github.com/dropwizard/dropwizard","homepage":"http://www.dropwizard.io","size":30107,"stargazers_count":3317,"watchers_count":3317,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1376,"mirror_url":null,"open_issues_count":47,"forks":1376,"open_issues":47,"watchers":3317,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039"},"html":{"href":"https://github.com/dropwizard/dropwizard/pull/1039"},"issue":{"href":"https://api.github.com/repos/dropwizard/dropwizard/issues/1039"},"comments":{"href":"https://api.github.com/repos/dropwizard/dropwizard/issues/1039/comments"},"review_comments":{"href":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039/comments"},"review_comment":{"href":"https://api.github.com/repos/dropwizard/dropwizard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dropwizard/dropwizard/pulls/1039/commits"},"statuses":{"href":"https://api.github.com/repos/dropwizard/dropwizard/statuses/7fc6e6878bab687e63c33611e057516c68869c67"}}}}