Divyansh200102 commented on code in PR #5421:
URL: https://github.com/apache/shenyu/pull/5421#discussion_r1467585106
##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java:
##########
@@ -29,9 +30,32 @@
* The type shenyu client register repository factory.
*/
public final class ShenyuClientRegisterRepositoryFactory {
-
+
private static final Map<String, ShenyuClientRegisterRepository>
REPOSITORY_MAP = new ConcurrentHashMap<>();
-
+
+ /**
+ * Get the REPOSITORY_MAP.
+ *
+ * @return the REPOSITORY_MAP
+ */
+ //getter
+ public static Map<String, ShenyuClientRegisterRepository>
getRepositoryMap() {
+ return Collections.unmodifiableMap(REPOSITORY_MAP);
+ }
+
+ /**
+ * Sets the repository map with the provided map of
ShenyuClientRegisterRepository instances.
+ * Clears the existing repository map and adds all entries from the
provided map.
+ *
+ * @param repositoryMap The map containing ShenyuClientRegisterRepository
instances,
+ * where each entry's key is the repository type
identifier.
+ */
+ // Setter for testing purposes
Review Comment:
I was trying to use call `getRepositoryMap().clear();` but I am facing this
error `Immutable object cannot be modified` even though I am using the getter
so to fix this I read somewhere it can be fixed using setter along with getter
to create a new map `ConcurrentHashMap<>()` for testing purposes but that also
didin't end up working. It's also the same for the .put() in
`getRepositoryMap()).put("someType", repositoryMock)` @moremind
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]