You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2023/05/14 13:50:35 UTC

[shardingsphere] branch master updated: Fix sonar issue of PostgreSQLException (#25662)

This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new bb8ec637053 Fix sonar issue of PostgreSQLException (#25662)
bb8ec637053 is described below

commit bb8ec637053edcaefe588331be19d01a207005a7
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 14 21:50:29 2023 +0800

    Fix sonar issue of PostgreSQLException (#25662)
---
 .../dialect/postgresql/exception/PostgreSQLException.java | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/exception/PostgreSQLException.java b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/exception/PostgreSQLException.java
index 653f7d090b5..04ac8fe0ec5 100644
--- a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/exception/PostgreSQLException.java
+++ b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/exception/PostgreSQLException.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.dialect.postgresql.exception;
 import lombok.Getter;
 import org.apache.shardingsphere.infra.util.exception.external.sql.vendor.VendorError;
 
+import java.io.Serializable;
 import java.sql.SQLException;
 import java.text.MessageFormat;
 
@@ -44,7 +45,9 @@ public final class PostgreSQLException extends SQLException {
     }
     
     @Getter
-    public static class ServerErrorMessage {
+    public static class ServerErrorMessage implements Serializable {
+        
+        private static final long serialVersionUID = -2823942573556507523L;
         
         private final String severity;
         
@@ -60,17 +63,17 @@ public final class PostgreSQLException extends SQLException {
         
         @Override
         public String toString() {
-            StringBuilder totalMessage = new StringBuilder();
+            StringBuilder result = new StringBuilder();
             if (null != severity) {
-                totalMessage.append(severity).append(": ");
+                result.append(severity).append(": ");
             }
             if (null != message) {
-                totalMessage.append(message);
+                result.append(message);
             }
             if (null != sqlState) {
-                totalMessage.append("\n  ").append(MessageFormat.format("Server SQLState: {0}", sqlState));
+                result.append("\n  ").append(MessageFormat.format("Server SQLState: {0}", sqlState));
             }
-            return totalMessage.toString();
+            return result.toString();
         }
     }
 }