ChinmaySKulkarni commented on a change in pull request #676: PHOENIX-5636: 
Improve the error message when client connects to server with higher major 
version
URL: https://github.com/apache/phoenix/pull/676#discussion_r377849710
 
 

 ##########
 File path: phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
 ##########
 @@ -122,22 +123,29 @@
             ColumnFamilyDescriptorBuilder.KEEP_DELETED_CELLS,
             ColumnFamilyDescriptorBuilder.REPLICATION_SCOPE);
 
-    public static boolean areClientAndServerCompatible(long 
serverHBaseAndPhoenixVersion) {
+    public static boolean areClientAndServerCompatible(long 
serverHBaseAndPhoenixVersion, StringBuilder buf) {
         // As of 3.0, we allow a client and server to differ for the minor 
version.
         // Care has to be taken to upgrade the server before the client, as 
otherwise
         // the client may call expressions that don't yet exist on the server.
         // Differing by the patch version has always been allowed.
         // Only differing by the major version is not allowed.
-        return 
areClientAndServerCompatible(MetaDataUtil.decodePhoenixVersion(serverHBaseAndPhoenixVersion),
 MetaDataProtocol.PHOENIX_MAJOR_VERSION, 
MetaDataProtocol.PHOENIX_MINOR_VERSION);
+        return 
areClientAndServerCompatible(MetaDataUtil.decodePhoenixVersion(serverHBaseAndPhoenixVersion),
 MetaDataProtocol.PHOENIX_MAJOR_VERSION, 
MetaDataProtocol.PHOENIX_MINOR_VERSION, buf);
     }
 
     // Default scope for testing
-    static boolean areClientAndServerCompatible(int serverVersion, int 
clientMajorVersion, int clientMinorVersion) {
+    static boolean areClientAndServerCompatible(int serverVersion, int 
clientMajorVersion, int clientMinorVersion, StringBuilder buf) {
         // A server and client with the same major and minor version number 
must be compatible.
         // So it's important that we roll the PHOENIX_MAJOR_VERSION or 
PHOENIX_MINOR_VERSION
         // when we make an incompatible change.
-        return VersionUtil.encodeMinPatchVersion(clientMajorVersion, 
clientMinorVersion) <= serverVersion && // Minor major and minor cannot be 
ahead of server
-                VersionUtil.encodeMaxMinorVersion(clientMajorVersion) >= 
serverVersion; // Major version must at least be up to server version
+        boolean isCompatible = true;
+        if (!(VersionUtil.encodeMinPatchVersion(clientMajorVersion, 
clientMinorVersion) <= serverVersion)) {
+            isCompatible = false;
+            buf.append(SQLExceptionCode.OUTDATED_JARS.getErrorCode());
+        } else if (!(VersionUtil.encodeMaxMinorVersion(clientMajorVersion) >= 
serverVersion)) {
 
 Review comment:
   same here. Change `!>=` to `<`

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


With regards,
Apache Git Services

Reply via email to