pivotal-jbarrett commented on a change in pull request #5905:
URL: https://github.com/apache/geode/pull/5905#discussion_r561407046



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java
##########
@@ -111,37 +89,76 @@
  * @since GemFire 5.7
  */
 
-public class CommandInitializer {
+public class CommandInitializer implements CommandRegistry {
 
-  @Immutable
-  static final Map<KnownVersion, Map<Integer, Command>> ALL_COMMANDS = 
initializeAllCommands();
+  @Deprecated
+  @MakeNotStatic
+  static final CommandInitializer instance = new CommandInitializer();
 
   /**
-   * Register a new command with the system.
+   * Gets legacy singleton instance.
+   *
+   * @deprecated Efforts should be made to get and instance from the cache or 
other object.
    *
-   * @param messageType - An ordinal for this message. This must be something 
defined in MessageType
-   *        that has not already been allocated to a different command.
-   * @param versionToNewCommand The command to register, for different 
versions. The key is the
-   *        earliest version for which this command class is valid (starting 
with GFE_57). The value
-   *        is the command object for clients starting with that version.
+   * @return legacy singleton instance. Instance is not immutable.
    */
-  public static void registerCommand(int messageType,
+  @Deprecated
+  public static CommandInitializer getDefaultInstance() {
+    return instance;
+  }
+
+  final Map<KnownVersion, Map<Integer, Command>> 
unmodifiableRegisteredCommands;
+  final LinkedHashMap<KnownVersion, ConcurrentMap<Integer, Command>> 
modifiableRegisteredCommands;

Review comment:
       Ah... to maintain the contract that the maps returned by the 
`get(Version)` method are immutable views. The previous implementation made the 
outer map immutable but not the inner map so the caller could technically 
mutate the map causing who knows what issues. Now the only way to mutate is 
through `register`, which mutates the backing maps but keeps the immutable 
wrappers intact. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to