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

terrymanu 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 e8bba8cde0e Refactor MCPSessionIdentity (#39175)
e8bba8cde0e is described below

commit e8bba8cde0ee38bf162e0a8df0008ea06a840f1b
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jul 18 12:19:25 2026 +0800

    Refactor MCPSessionIdentity (#39175)
    
    * Refactor MCPSessionIdentity
    
    * Refactor MCPSessionIdentity
    
    * Refactor MCPSessionIdentity
---
 .../shardingsphere/mcp/api/MCPRequestContext.java  |  2 +-
 .../mcp/api/session/MCPSessionIdentity.java        | 10 +----
 .../mcp/api/session/MCPSessionIdentityTest.java    | 44 ----------------------
 3 files changed, 3 insertions(+), 53 deletions(-)

diff --git 
a/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/MCPRequestContext.java
 
b/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/MCPRequestContext.java
index 21feb072a0d..a39f5e5bc8f 100644
--- 
a/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/MCPRequestContext.java
+++ 
b/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/MCPRequestContext.java
@@ -28,7 +28,7 @@ import 
org.apache.shardingsphere.mcp.api.transport.MCPTransportType;
 public interface MCPRequestContext {
     
     /**
-     * Get the identity snapshot of the current MCP session.
+     * Get the identity of the current MCP session.
      *
      * <p>The identity always contains the MCP session identifier. Trusted 
HTTP attribution is optional and does not represent authentication or 
authorization.</p>
      *
diff --git 
a/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentity.java
 
b/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentity.java
index 026c7576640..1f2a83fe4f9 100644
--- 
a/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentity.java
+++ 
b/mcp/api/src/main/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentity.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.mcp.api.session;
 
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 
 import java.util.Map;
 
@@ -27,6 +28,7 @@ import java.util.Map;
  * <p>The session identifier is always present. Subject, source and attributes 
are optional trusted attribution captured when the session is initialized.
  * Attribution does not represent authentication or authorization.</p>
  */
+@RequiredArgsConstructor
 @Getter
 public final class MCPSessionIdentity {
     
@@ -37,12 +39,4 @@ public final class MCPSessionIdentity {
     private final String source;
     
     private final Map<String, String> attributes;
-    
-    public MCPSessionIdentity(final String sessionId, final String subject, 
final String source, final Map<String, String> attributes) {
-        this.sessionId = sessionId;
-        this.subject = subject;
-        this.source = source;
-        this.attributes = Map.copyOf(attributes);
-    }
-    
 }
diff --git 
a/mcp/api/src/test/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentityTest.java
 
b/mcp/api/src/test/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentityTest.java
deleted file mode 100644
index 30bdc8332cc..00000000000
--- 
a/mcp/api/src/test/java/org/apache/shardingsphere/mcp/api/session/MCPSessionIdentityTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mcp.api.session;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class MCPSessionIdentityTest {
-    
-    @Test
-    void assertAttributesSnapshot() {
-        Map<String, String> attributes = new HashMap<>(Map.of("region", 
"ap-south"));
-        MCPSessionIdentity identity = new MCPSessionIdentity("session-1", 
"subject", "gateway", attributes);
-        attributes.put("region", "eu-west");
-        assertThat(identity.getAttributes(), is(Map.of("region", "ap-south")));
-    }
-    
-    @Test
-    void assertAttributesImmutable() {
-        Map<String, String> actual = new MCPSessionIdentity("session-1", 
"subject", "gateway", Map.of("region", "ap-south")).getAttributes();
-        assertThrows(UnsupportedOperationException.class, () -> 
actual.put("region", "eu-west"));
-    }
-}

Reply via email to