chesnokoff commented on code in PR #12634:
URL: https://github.com/apache/ignite/pull/12634#discussion_r2730556935


##########
modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java:
##########
@@ -163,63 +176,123 @@ void writeMessage(TcpDiscoveryAbstractMessage msg) 
throws IgniteCheckedException
      * @throws IgniteCheckedException If deserialization fails.
      */
     <T> T readMessage() throws IgniteCheckedException, IOException {
-        byte serMode = (byte)in.read();
+        return reader.readMessage();
+    }
 
-        if (JAVA_SERIALIZATION == serMode)
-            return U.unmarshal(spi.marshaller(), in, clsLdr);
+    /** Switches reader to fast mode after initial validated read. */
+    public void switchToFastReader() {
+        reader = fastReader;
+    }
 
-        try {
-            if (MESSAGE_SERIALIZATION != serMode) {

Review Comment:
   Initially `detectJavaObjectStreamHeader` was placed after `detectSslAlert`. 
The suggestion was to not make check for `serMode` after connection 
establishments.
   
   To do that we need to notify session that we do not need that checks. So now 
higher levels of code call `switchToFastReader` for notification and we change 
reader. As a result, we optimized one `if` check
   
   But on the other hand for me it looks like really small optimization because 
work with IO takes much more resources than one simple if. Moreover, it seems 
to break DIP because now higher levels of code have to know details about 
implementation of `TcpDiscoveryIoSession`



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

Reply via email to