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

zhangliang 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 8ff70c695a9 Simplify generated logic of 
ShardingSphereSavepoint.savepointName (#31606)
8ff70c695a9 is described below

commit 8ff70c695a956619d508f20196bd179a65f655a9
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jun 6 18:02:54 2024 +0800

    Simplify generated logic of ShardingSphereSavepoint.savepointName (#31606)
---
 .../jdbc/core/savepoint/ShardingSphereSavepoint.java | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java
index d25f6dd68a9..5a039a32cdc 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/savepoint/ShardingSphereSavepoint.java
@@ -20,10 +20,10 @@ package 
org.apache.shardingsphere.driver.jdbc.core.savepoint;
 import lombok.Getter;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 
-import java.rmi.server.UID;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.Savepoint;
+import java.util.UUID;
 
 /**
  * ShardingSphere savepoint.
@@ -34,7 +34,7 @@ public final class ShardingSphereSavepoint implements 
Savepoint {
     private final String savepointName;
     
     public ShardingSphereSavepoint() {
-        savepointName = getUniqueId();
+        savepointName = UUID.randomUUID().toString().replaceAll("-", "_");
     }
     
     public ShardingSphereSavepoint(final String savepointName) throws 
SQLException {
@@ -42,22 +42,6 @@ public final class ShardingSphereSavepoint implements 
Savepoint {
         this.savepointName = savepointName;
     }
     
-    private String getUniqueId() {
-        String uidStr = new UID().toString();
-        int uidLength = uidStr.length();
-        StringBuilder safeString = new StringBuilder(uidLength + 1);
-        safeString.append('_');
-        for (int i = 0; i < uidLength; i++) {
-            char c = uidStr.charAt(i);
-            if (Character.isLetter(c) || Character.isDigit(c)) {
-                safeString.append(c);
-            } else {
-                safeString.append('_');
-            }
-        }
-        return safeString.toString();
-    }
-    
     @Override
     public int getSavepointId() throws SQLException {
         throw new SQLFeatureNotSupportedException("Only named savepoint are 
supported.");

Reply via email to