{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/hawkbit/pulls/comments/122964770","pull_request_review_id":45123684,"id":122964770,"diff_hunk":"@@ -84,88 +74,50 @@\n      *            the thrown and catched exception\n      * @throws Throwable\n      */\n-    @AfterThrowing(pointcut = \"( execution( * org.springframework.transaction..*.*(..)) \"\n-            + \" || execution( * org.eclipse.hawkbit.repository.*.*(..)) )\", throwing = \"ex\")\n+    @AfterThrowing(pointcut = \"execution( * org.eclipse.hawkbit.repository.jpa.*Management.*(..))\", throwing = \"ex\")\n     // Exception for squid:S00112, squid:S1162\n     // It is a AspectJ proxy which deals with exceptions.\n     @SuppressWarnings({ \"squid:S00112\", \"squid:S1162\" })\n     public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {\n \n-        LOG.trace(\"exception occured\", ex);\n-        Exception translatedAccessException = translateEclipseLinkExceptionIfPossible(ex);\n-\n-        if (translatedAccessException == null && ex instanceof TransactionSystemException) {\n-            final TransactionSystemException systemException = (TransactionSystemException) ex;\n-            translatedAccessException = translateEclipseLinkExceptionIfPossible(\n-                    (Exception) systemException.getOriginalException());\n+        // Workarround for EclipseLink pre-update where it does not throw\n+        // ConstraintViolationException correctly in case of existing entity\n+        // update\n+        if (ex instanceof TransactionSystemException) {\n+            throw findConstraintViolationException(ex);\n         }\n \n-        if (translatedAccessException == null) {\n-            translatedAccessException = ex;\n-        }\n+        Exception mappingException = ex;\n \n-        Exception mappingException = translatedAccessException;\n-\n-        LOG.trace(\"translated excpetion is\", translatedAccessException);\n         for (final Class<?> mappedEx : MAPPED_EXCEPTION_ORDER) {\n \n-            if (mappedEx.isAssignableFrom(translatedAccessException.getClass())) {\n+            if (mappedEx.isAssignableFrom(ex.getClass())) {\n                 if (!EXCEPTION_MAPPING.containsKey(mappedEx.getName())) {\n                     LOG.error(\"there is no mapping configured for exception class {}\", mappedEx.getName());\n                     mappingException = new GenericSpServerException(ex);\n                 } else {\n                     mappingException = (Exception) Class.forName(EXCEPTION_MAPPING.get(mappedEx.getName()))\n                             .getConstructor(Throwable.class).newInstance(ex);\n                 }\n+                LOG.trace(\"mapped exception {} to {}\", ex.getClass(), mappingException.getClass());\n                 break;\n             }\n         }\n \n-        LOG.trace(\"mapped exception {} to {}\", translatedAccessException.getClass(), mappingException.getClass());\n         throw mappingException;\n     }\n \n-    private DataAccessException translateEclipseLinkExceptionIfPossible(final Exception exception) {\n-        final DataAccessException translatedAccessException = jpaVendorAdapter.getJpaDialect()\n-                .translateExceptionIfPossible((RuntimeException) exception);\n-        return translateSQLStateExceptionIfPossible(translatedAccessException);\n-\n-    }\n-\n-    /**\n-     * There is no EclipseLinkExceptionTranslator. So we have to check and\n-     * translate the exception by the sql error code. Luckily, there we can use\n-     * {@link SQLStateSQLExceptionTranslator} if we can get a\n-     * {@link SQLException}.\n-     *\n-     * @param accessException\n-     *            the base access exception from jpa\n-     * @return the translated accessException\n-     */\n-    private DataAccessException translateSQLStateExceptionIfPossible(final DataAccessException accessException) {\n-        if (!(accessException instanceof JpaSystemException)) {\n-            return accessException;\n-        }\n-\n-        final SQLException ex = findSqlException((JpaSystemException) accessException);\n-\n-        if (ex == null) {\n-            return accessException;\n-        }\n-\n-        return sqlStateExceptionTranslator.translate(null, null, ex);\n-    }\n-\n-    private static SQLException findSqlException(final JpaSystemException jpaSystemException) {\n-        Throwable exception = jpaSystemException.getCause();\n-        while (exception != null) {\n+    private static Exception findConstraintViolationException(final Exception rex) {\n+        Throwable exception = rex;\n+        do {\n             final Throwable cause = exception.getCause();\n-            if (cause instanceof SQLException) {\n-                return (SQLException) cause;\n+            if (cause instanceof javax.validation.ConstraintViolationException) {\n+                return (Exception) cause;\n             }\n             exception = cause;\n-        }\n-        return null;\n+        } while (exception != null);\n+\n+        return rex;","path":"hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/aspects/ExceptionMappingAspectHandler.java","position":137,"original_position":137,"commit_id":"6600b9aeaca4169b44543fd88fd15838bbc2c084","original_commit_id":"6600b9aeaca4169b44543fd88fd15838bbc2c084","user":{"login":"SirWayne","id":6340898,"avatar_url":"https://avatars2.githubusercontent.com/u/6340898?v=3","gravatar_id":"","url":"https://api.github.com/users/SirWayne","html_url":"https://github.com/SirWayne","followers_url":"https://api.github.com/users/SirWayne/followers","following_url":"https://api.github.com/users/SirWayne/following{/other_user}","gists_url":"https://api.github.com/users/SirWayne/gists{/gist_id}","starred_url":"https://api.github.com/users/SirWayne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SirWayne/subscriptions","organizations_url":"https://api.github.com/users/SirWayne/orgs","repos_url":"https://api.github.com/users/SirWayne/repos","events_url":"https://api.github.com/users/SirWayne/events{/privacy}","received_events_url":"https://api.github.com/users/SirWayne/received_events","type":"User","site_admin":false},"body":"Is this intended not return a null value? So the `TransactionSystemException` is always thrown and will not translated.","created_at":"2017-06-20T12:47:51Z","updated_at":"2017-06-20T12:47:51Z","html_url":"https://github.com/eclipse/hawkbit/pull/546#discussion_r122964770","pull_request_url":"https://api.github.com/repos/eclipse/hawkbit/pulls/546","_links":{"self":{"href":"https://api.github.com/repos/eclipse/hawkbit/pulls/comments/122964770"},"html":{"href":"https://github.com/eclipse/hawkbit/pull/546#discussion_r122964770"},"pull_request":{"href":"https://api.github.com/repos/eclipse/hawkbit/pulls/546"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/hawkbit/pulls/546","id":126480503,"html_url":"https://github.com/eclipse/hawkbit/pull/546","diff_url":"https://github.com/eclipse/hawkbit/pull/546.diff","patch_url":"https://github.com/eclipse/hawkbit/pull/546.patch","issue_url":"https://api.github.com/repos/eclipse/hawkbit/issues/546","number":546,"state":"open","locked":false,"title":"Fix exception handling on repository","user":{"login":"kaizimmerm","id":9153035,"avatar_url":"https://avatars1.githubusercontent.com/u/9153035?v=3","gravatar_id":"","url":"https://api.github.com/users/kaizimmerm","html_url":"https://github.com/kaizimmerm","followers_url":"https://api.github.com/users/kaizimmerm/followers","following_url":"https://api.github.com/users/kaizimmerm/following{/other_user}","gists_url":"https://api.github.com/users/kaizimmerm/gists{/gist_id}","starred_url":"https://api.github.com/users/kaizimmerm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaizimmerm/subscriptions","organizations_url":"https://api.github.com/users/kaizimmerm/orgs","repos_url":"https://api.github.com/users/kaizimmerm/repos","events_url":"https://api.github.com/users/kaizimmerm/events{/privacy}","received_events_url":"https://api.github.com/users/kaizimmerm/received_events","type":"User","site_admin":false},"body":"Fixed several issues and worked a bit on API documentation:\r\n\r\n* Fixed issue where repository on update operations does not throw ConstraintViolation (as on create) if bean violates a constraint after update.\r\n* Fixed issue where assignDs operations do not throw spring exceptions as expected but native EclipseLink or MySQL exceptions.\r\n* Fixed deadlock on JDBC connections in high load scenarios.\r\n* Added constraint documentation on builders for target and added a few more test as well (should be done for the other entities in similar fashion later on).\r\n\r\nPiggy backed a small changed on mgmt API into the request: add \"modules\" link to DS resource.","created_at":"2017-06-20T09:00:15Z","updated_at":"2017-06-20T12:47:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"36539092f8a96394a51dbff4e183c56fcb8cff99","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/hawkbit/pulls/546/commits","review_comments_url":"https://api.github.com/repos/eclipse/hawkbit/pulls/546/comments","review_comment_url":"https://api.github.com/repos/eclipse/hawkbit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/hawkbit/issues/546/comments","statuses_url":"https://api.github.com/repos/eclipse/hawkbit/statuses/6600b9aeaca4169b44543fd88fd15838bbc2c084","head":{"label":"bsinno:fix_constraint_rest_api_error","ref":"fix_constraint_rest_api_error","sha":"6600b9aeaca4169b44543fd88fd15838bbc2c084","user":{"login":"bsinno","id":9215699,"avatar_url":"https://avatars0.githubusercontent.com/u/9215699?v=3","gravatar_id":"","url":"https://api.github.com/users/bsinno","html_url":"https://github.com/bsinno","followers_url":"https://api.github.com/users/bsinno/followers","following_url":"https://api.github.com/users/bsinno/following{/other_user}","gists_url":"https://api.github.com/users/bsinno/gists{/gist_id}","starred_url":"https://api.github.com/users/bsinno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsinno/subscriptions","organizations_url":"https://api.github.com/users/bsinno/orgs","repos_url":"https://api.github.com/users/bsinno/repos","events_url":"https://api.github.com/users/bsinno/events{/privacy}","received_events_url":"https://api.github.com/users/bsinno/received_events","type":"Organization","site_admin":false},"repo":{"id":50108079,"name":"hawkbit","full_name":"bsinno/hawkbit","owner":{"login":"bsinno","id":9215699,"avatar_url":"https://avatars0.githubusercontent.com/u/9215699?v=3","gravatar_id":"","url":"https://api.github.com/users/bsinno","html_url":"https://github.com/bsinno","followers_url":"https://api.github.com/users/bsinno/followers","following_url":"https://api.github.com/users/bsinno/following{/other_user}","gists_url":"https://api.github.com/users/bsinno/gists{/gist_id}","starred_url":"https://api.github.com/users/bsinno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsinno/subscriptions","organizations_url":"https://api.github.com/users/bsinno/orgs","repos_url":"https://api.github.com/users/bsinno/repos","events_url":"https://api.github.com/users/bsinno/events{/privacy}","received_events_url":"https://api.github.com/users/bsinno/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bsinno/hawkbit","description":null,"fork":true,"url":"https://api.github.com/repos/bsinno/hawkbit","forks_url":"https://api.github.com/repos/bsinno/hawkbit/forks","keys_url":"https://api.github.com/repos/bsinno/hawkbit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bsinno/hawkbit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bsinno/hawkbit/teams","hooks_url":"https://api.github.com/repos/bsinno/hawkbit/hooks","issue_events_url":"https://api.github.com/repos/bsinno/hawkbit/issues/events{/number}","events_url":"https://api.github.com/repos/bsinno/hawkbit/events","assignees_url":"https://api.github.com/repos/bsinno/hawkbit/assignees{/user}","branches_url":"https://api.github.com/repos/bsinno/hawkbit/branches{/branch}","tags_url":"https://api.github.com/repos/bsinno/hawkbit/tags","blobs_url":"https://api.github.com/repos/bsinno/hawkbit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bsinno/hawkbit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bsinno/hawkbit/git/refs{/sha}","trees_url":"https://api.github.com/repos/bsinno/hawkbit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bsinno/hawkbit/statuses/{sha}","languages_url":"https://api.github.com/repos/bsinno/hawkbit/languages","stargazers_url":"https://api.github.com/repos/bsinno/hawkbit/stargazers","contributors_url":"https://api.github.com/repos/bsinno/hawkbit/contributors","subscribers_url":"https://api.github.com/repos/bsinno/hawkbit/subscribers","subscription_url":"https://api.github.com/repos/bsinno/hawkbit/subscription","commits_url":"https://api.github.com/repos/bsinno/hawkbit/commits{/sha}","git_commits_url":"https://api.github.com/repos/bsinno/hawkbit/git/commits{/sha}","comments_url":"https://api.github.com/repos/bsinno/hawkbit/comments{/number}","issue_comment_url":"https://api.github.com/repos/bsinno/hawkbit/issues/comments{/number}","contents_url":"https://api.github.com/repos/bsinno/hawkbit/contents/{+path}","compare_url":"https://api.github.com/repos/bsinno/hawkbit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bsinno/hawkbit/merges","archive_url":"https://api.github.com/repos/bsinno/hawkbit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bsinno/hawkbit/downloads","issues_url":"https://api.github.com/repos/bsinno/hawkbit/issues{/number}","pulls_url":"https://api.github.com/repos/bsinno/hawkbit/pulls{/number}","milestones_url":"https://api.github.com/repos/bsinno/hawkbit/milestones{/number}","notifications_url":"https://api.github.com/repos/bsinno/hawkbit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bsinno/hawkbit/labels{/name}","releases_url":"https://api.github.com/repos/bsinno/hawkbit/releases{/id}","deployments_url":"https://api.github.com/repos/bsinno/hawkbit/deployments","created_at":"2016-01-21T13:05:15Z","updated_at":"2017-03-09T11:48:20Z","pushed_at":"2017-06-20T12:16:27Z","git_url":"git://github.com/bsinno/hawkbit.git","ssh_url":"git@github.com:bsinno/hawkbit.git","clone_url":"https://github.com/bsinno/hawkbit.git","svn_url":"https://github.com/bsinno/hawkbit","homepage":null,"size":15800,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":5,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"3b5f12b7a477e1ee75b397b49c1e88902c9f60bd","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars2.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":45860898,"name":"hawkbit","full_name":"eclipse/hawkbit","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars2.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/hawkbit","description":"Eclipse hawkBit™","fork":false,"url":"https://api.github.com/repos/eclipse/hawkbit","forks_url":"https://api.github.com/repos/eclipse/hawkbit/forks","keys_url":"https://api.github.com/repos/eclipse/hawkbit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/hawkbit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/hawkbit/teams","hooks_url":"https://api.github.com/repos/eclipse/hawkbit/hooks","issue_events_url":"https://api.github.com/repos/eclipse/hawkbit/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/hawkbit/events","assignees_url":"https://api.github.com/repos/eclipse/hawkbit/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/hawkbit/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/hawkbit/tags","blobs_url":"https://api.github.com/repos/eclipse/hawkbit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/hawkbit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/hawkbit/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/hawkbit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/hawkbit/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/hawkbit/languages","stargazers_url":"https://api.github.com/repos/eclipse/hawkbit/stargazers","contributors_url":"https://api.github.com/repos/eclipse/hawkbit/contributors","subscribers_url":"https://api.github.com/repos/eclipse/hawkbit/subscribers","subscription_url":"https://api.github.com/repos/eclipse/hawkbit/subscription","commits_url":"https://api.github.com/repos/eclipse/hawkbit/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/hawkbit/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/hawkbit/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/hawkbit/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/hawkbit/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/hawkbit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/hawkbit/merges","archive_url":"https://api.github.com/repos/eclipse/hawkbit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/hawkbit/downloads","issues_url":"https://api.github.com/repos/eclipse/hawkbit/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/hawkbit/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/hawkbit/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/hawkbit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/hawkbit/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/hawkbit/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/hawkbit/deployments","created_at":"2015-11-09T19:19:06Z","updated_at":"2017-05-29T06:56:54Z","pushed_at":"2017-06-20T12:16:28Z","git_url":"git://github.com/eclipse/hawkbit.git","ssh_url":"git@github.com:eclipse/hawkbit.git","clone_url":"https://github.com/eclipse/hawkbit.git","svn_url":"https://github.com/eclipse/hawkbit","homepage":"https://projects.eclipse.org/projects/iot.hawkbit","size":15707,"stargazers_count":72,"watchers_count":72,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":23,"forks":22,"open_issues":23,"watchers":72,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/hawkbit/pulls/546"},"html":{"href":"https://github.com/eclipse/hawkbit/pull/546"},"issue":{"href":"https://api.github.com/repos/eclipse/hawkbit/issues/546"},"comments":{"href":"https://api.github.com/repos/eclipse/hawkbit/issues/546/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/hawkbit/pulls/546/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/hawkbit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/hawkbit/pulls/546/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/hawkbit/statuses/6600b9aeaca4169b44543fd88fd15838bbc2c084"}}}}
{"actor":{"display_login":"SirWayne"}}