summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2019-06-13 09:52:54 +0200
committerDavid Ostrovsky <david@ostrovsky.org>2019-06-16 18:01:29 +0200
commit98b13a9809f366b57f269bcbb03c44af865e7089 (patch)
tree2d6e82f26345f6852625619ad587420c3a80b60a
parent45182fea5507334437bee5cc1d1ed5b23e5b6ba2 (diff)
MysqlAccountPatchReviewStore: Fix duplicate key detection
The detection code is checking against SQL error code, even though the SQL state is retrieved from the SQLException. As the consequence, duplicate key state is not detected and primary key violation error is reported during REST API call. To rectify, retrieve the error code number from the SQL exception to correctly detect duplicate key error. This approach is also based on gwtorm code that is also using SQLException#getErrorCode() method. Bug: Issue 10664 Change-Id: I678419a84af287edd8d121bddd2d11c2ed72eefe
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java
index 7cf28ffee5..6b49404828 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java
@@ -36,7 +36,7 @@ public class MysqlAccountPatchReviewStore extends JdbcAccountPatchReviewStore {
@Override
public OrmException convertError(String op, SQLException err) {
- switch (getSQLStateInt(err)) {
+ switch (err.getErrorCode()) {
case 1022: // ER_DUP_KEY
case 1062: // ER_DUP_ENTRY
case 1169: // ER_DUP_UNIQUE;