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

earthchen pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new b7d52c39ac fix: AbstractMetadataReport MemoryOverflow (#15987)
b7d52c39ac is described below

commit b7d52c39ac35527e331282945f3e8fe20fc0dd61
Author: xiao.lu <[email protected]>
AuthorDate: Mon Jan 12 18:32:07 2026 +0800

    fix: AbstractMetadataReport MemoryOverflow (#15987)
    
    * fix: AbstractMetadataReport MemoryOverflow
    
    * style: Format the metadata identifier code
    
    * test: Add identifiers to repeat test cases
    
    * test: Fixed the null value issue in the test cases
    
    ---------
    
    Co-authored-by: heliang <[email protected]>
---
 .../BaseApplicationMetadataIdentifier.java         | 19 ++++++++++
 .../identifier/BaseServiceMetadataIdentifier.java  | 23 +++++++++++++
 .../report/identifier/MetadataIdentifier.java      | 15 ++++++++
 .../identifier/ServiceMetadataIdentifier.java      | 15 ++++++++
 .../identifier/SubscriberMetadataIdentifier.java   | 21 ++++++++++++
 .../report/identifier/MetadataIdentifierTest.java  | 15 ++++++--
 .../identifier/ServiceMetadataIdentifierTest.java  | 40 ++++++++++++++++++++++
 .../SubscriberMetadataIdentifierTest.java          | 34 ++++++++++++++++++
 8 files changed, 180 insertions(+), 2 deletions(-)

diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseApplicationMetadataIdentifier.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseApplicationMetadataIdentifier.java
index 3838e43926..a7a60b0fe6 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseApplicationMetadataIdentifier.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseApplicationMetadataIdentifier.java
@@ -16,6 +16,8 @@
  */
 package org.apache.dubbo.metadata.report.identifier;
 
+import java.util.Objects;
+
 import static org.apache.dubbo.metadata.MetadataConstants.DEFAULT_PATH_TAG;
 
 /**
@@ -45,4 +47,21 @@ public class BaseApplicationMetadataIdentifier {
         String prefix = KeyTypeEnum.PATH.build(pathTag, application);
         return KeyTypeEnum.PATH.build(prefix, params);
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof BaseApplicationMetadataIdentifier)) return false;
+        BaseApplicationMetadataIdentifier that = 
(BaseApplicationMetadataIdentifier) o;
+        return Objects.equals(application, that.application);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(application);
+    }
+
+    @Override
+    public String toString() {
+        return "BaseApplicationMetadataIdentifier{" + "application='" + 
application + '\'' + '}';
+    }
 }
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseServiceMetadataIdentifier.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseServiceMetadataIdentifier.java
index 8b755151a6..3585c18567 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseServiceMetadataIdentifier.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/BaseServiceMetadataIdentifier.java
@@ -18,6 +18,8 @@ package org.apache.dubbo.metadata.report.identifier;
 
 import org.apache.dubbo.common.URL;
 
+import java.util.Objects;
+
 import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
 import static org.apache.dubbo.metadata.MetadataConstants.DEFAULT_PATH_TAG;
 
@@ -59,4 +61,25 @@ public class BaseServiceMetadataIdentifier {
         }
         return URL.encode(serviceInterface);
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof BaseServiceMetadataIdentifier)) return false;
+        BaseServiceMetadataIdentifier that = (BaseServiceMetadataIdentifier) o;
+        return Objects.equals(serviceInterface, that.serviceInterface)
+                && Objects.equals(version, that.version)
+                && Objects.equals(group, that.group)
+                && Objects.equals(side, that.side);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(serviceInterface, version, group, side);
+    }
+
+    @Override
+    public String toString() {
+        return "BaseServiceMetadataIdentifier{" + "serviceInterface='" + 
serviceInterface + '\'' + ", version='"
+                + version + '\'' + ", group='" + group + '\'' + ", side='" + 
side + '\'' + '}';
+    }
 }
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java
index b5501ae6a3..9ebf7efc42 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java
@@ -18,6 +18,8 @@ package org.apache.dubbo.metadata.report.identifier;
 
 import org.apache.dubbo.common.URL;
 
+import java.util.Objects;
+
 /**
  * The MetadataIdentifier is used to store method descriptor.
  * <p>
@@ -99,6 +101,19 @@ public class MetadataIdentifier extends 
BaseServiceMetadataIdentifier implements
         return serviceInterface != null ? URL.buildKey(serviceInterface, 
getGroup(), getVersion()) : null;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof MetadataIdentifier)) return false;
+        if (!super.equals(o)) return false;
+        MetadataIdentifier that = (MetadataIdentifier) o;
+        return Objects.equals(application, that.application);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(), application);
+    }
+
     @Override
     public String toString() {
         return "MetadataIdentifier{" + "application='"
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
index ce11a8abda..e475e065a2 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
@@ -18,6 +18,8 @@ package org.apache.dubbo.metadata.report.identifier;
 
 import org.apache.dubbo.common.URL;
 
+import java.util.Objects;
+
 import static org.apache.dubbo.metadata.MetadataConstants.KEY_REVISION_PREFIX;
 
 /**
@@ -67,6 +69,19 @@ public class ServiceMetadataIdentifier extends 
BaseServiceMetadataIdentifier imp
         this.protocol = protocol;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof ServiceMetadataIdentifier)) return false;
+        if (!super.equals(o)) return false;
+        ServiceMetadataIdentifier that = (ServiceMetadataIdentifier) o;
+        return Objects.equals(revision, that.revision) && 
Objects.equals(protocol, that.protocol);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(), revision, protocol);
+    }
+
     @Override
     public String toString() {
         return "ServiceMetadataIdentifier{" + "revision='"
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifier.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifier.java
index 12993f66f1..b060169d53 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifier.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifier.java
@@ -18,6 +18,8 @@ package org.apache.dubbo.metadata.report.identifier;
 
 import org.apache.dubbo.common.URL;
 
+import java.util.Objects;
+
 import static org.apache.dubbo.common.constants.CommonConstants.REVISION_KEY;
 
 /**
@@ -62,4 +64,23 @@ public class SubscriberMetadataIdentifier extends 
BaseApplicationMetadataIdentif
     public void setRevision(String revision) {
         this.revision = revision;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof SubscriberMetadataIdentifier)) return false;
+        if (!super.equals(o)) return false;
+        SubscriberMetadataIdentifier that = (SubscriberMetadataIdentifier) o;
+        return Objects.equals(revision, that.revision);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(), revision);
+    }
+
+    @Override
+    public String toString() {
+        return "SubscriberMetadataIdentifier{" + "revision='" + revision + 
'\'' + ", application='" + application + '\''
+                + '}';
+    }
 }
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java
 
b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java
index 476623e4ea..3bcb48380b 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java
@@ -18,6 +18,8 @@ package org.apache.dubbo.metadata.report.identifier;
 
 import org.apache.dubbo.metadata.MetadataConstants;
 
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -41,8 +43,8 @@ class MetadataIdentifierTest {
                 providerMetadataIdentifier.getUniqueKey(KeyTypeEnum.PATH),
                 "metadata" + PATH_SEPARATOR + interfaceName + PATH_SEPARATOR
                         + (version == null ? "" : (version + PATH_SEPARATOR))
-                        + (group == null ? "" : (group + PATH_SEPARATOR)) + 
PROVIDER_SIDE
-                        + PATH_SEPARATOR + application);
+                        + (group == null ? "" : (group + PATH_SEPARATOR)) + 
PROVIDER_SIDE + PATH_SEPARATOR
+                        + application);
         Assertions.assertEquals(
                 
providerMetadataIdentifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY),
                 interfaceName
@@ -55,4 +57,13 @@ class MetadataIdentifierTest {
                         + MetadataConstants.KEY_SEPARATOR
                         + application);
     }
+
+    @Test
+    void testPutDuplicateIdentifier() {
+        ConcurrentHashMap<MetadataIdentifier, Object> map = new 
ConcurrentHashMap<>();
+        map.put(new MetadataIdentifier("com.ServiceInterface", "1.0.0", 
"gray", "consumer", "testApp"), new Object());
+        map.put(new MetadataIdentifier("com.ServiceInterface", "1.0.0", 
"gray", "consumer", "testApp"), new Object());
+        map.put(new MetadataIdentifier("com.ServiceInterface", "1.0.0", 
"gray", "consumer", "testApp"), new Object());
+        Assertions.assertEquals(map.size(), 1);
+    }
 }
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifierTest.java
 
b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifierTest.java
new file mode 100644
index 0000000000..450f0801bf
--- /dev/null
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifierTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.dubbo.metadata.report.identifier;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class ServiceMetadataIdentifierTest {
+
+    @Test
+    void testPutDuplicateIdentifier() {
+        ConcurrentHashMap<ServiceMetadataIdentifier, Object> map = new 
ConcurrentHashMap<>();
+        map.put(
+                new ServiceMetadataIdentifier("com.ServiceInterface", "1.0.0", 
"gray", "consumer", "testApp", "dubbo"),
+                new Object());
+        map.put(
+                new ServiceMetadataIdentifier("com.ServiceInterface", "1.0.0", 
"gray", "consumer", "testApp", "dubbo"),
+                new Object());
+        map.put(
+                new ServiceMetadataIdentifier("com.ServiceInterface", "1.0.0", 
"gray", "consumer", "testApp", "dubbo"),
+                new Object());
+        Assertions.assertEquals(map.size(), 1);
+    }
+}
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifierTest.java
 
b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifierTest.java
new file mode 100644
index 0000000000..588c8dde75
--- /dev/null
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/SubscriberMetadataIdentifierTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.dubbo.metadata.report.identifier;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class SubscriberMetadataIdentifierTest {
+
+    @Test
+    void testPutDuplicateIdentifier() {
+        ConcurrentHashMap<SubscriberMetadataIdentifier, Object> map = new 
ConcurrentHashMap<>();
+        map.put(new SubscriberMetadataIdentifier("testApp", "1.0.0"), new 
Object());
+        map.put(new SubscriberMetadataIdentifier("testApp", "1.0.0"), new 
Object());
+        map.put(new SubscriberMetadataIdentifier("testApp", "1.0.0"), new 
Object());
+        Assertions.assertEquals(map.size(), 1);
+    }
+}

Reply via email to