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/04/12 06:43:27 UTC

[shardingsphere] branch master updated: Revise code style in PostgreSQLException (#25137)

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 1533b52e838 Revise code style in PostgreSQLException (#25137)
1533b52e838 is described below

commit 1533b52e8380f2efb612fa55c087da54786f151e
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Wed Apr 12 14:43:18 2023 +0800

    Revise code style in PostgreSQLException (#25137)
---
 .../postgresql/exception/PostgreSQLException.java  | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 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 8a0f18d1604..653f7d090b5 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
@@ -23,8 +23,13 @@ import org.apache.shardingsphere.infra.util.exception.external.sql.vendor.Vendor
 import java.sql.SQLException;
 import java.text.MessageFormat;
 
+/**
+ * Replacement for {@link org.postgresql.util.PSQLException}.
+ */
 @Getter
-public class PostgreSQLException extends SQLException {
+public final class PostgreSQLException extends SQLException {
+    
+    private static final long serialVersionUID = -593592349806424431L;
     
     private final ServerErrorMessage serverErrorMessage;
     
@@ -40,11 +45,11 @@ public class PostgreSQLException extends SQLException {
     
     @Getter
     public static class ServerErrorMessage {
-    
+        
         private final String severity;
-    
+        
         private final String sqlState;
-    
+        
         private final String message;
         
         public ServerErrorMessage(final String severity, final VendorError vendorError, final Object... reasonArgs) {
@@ -52,22 +57,20 @@ public class PostgreSQLException extends SQLException {
             this.sqlState = vendorError.getSqlState().getValue();
             this.message = String.format(vendorError.getReason(), reasonArgs);
         }
-    
+        
         @Override
         public String toString() {
             StringBuilder totalMessage = new StringBuilder();
-            if (severity != null) {
+            if (null != severity) {
                 totalMessage.append(severity).append(": ");
             }
-            if (message != null) {
+            if (null != message) {
                 totalMessage.append(message);
             }
-            if (sqlState != null) {
+            if (null != sqlState) {
                 totalMessage.append("\n  ").append(MessageFormat.format("Server SQLState: {0}", sqlState));
             }
-        
             return totalMessage.toString();
         }
     }
-    
 }