Permalink
Browse files

Move version check into Version itself.

  • Loading branch information...
Francisco Borges
Francisco Borges committed Nov 19, 2012
1 parent ad5bdf7 commit b95b0435d2cbadfd122f0274621ad87ad0330d97
@@ -36,7 +36,7 @@
int getIncrementingVersion();
- int[] getCompatibleVersionList();
+ boolean isCompatible(int v);
String getNettyVersion();
}
@@ -68,7 +68,7 @@ public VersionImpl(final String versionName,
this.nettyVersion = nettyVersion;
- this.compatibleVersionList = compatibleVersionList;
+ this.compatibleVersionList = Arrays.copyOf(compatibleVersionList, compatibleVersionList.length);
}
// Version implementation ------------------------------------------
@@ -123,9 +123,16 @@ public String getNettyVersion()
return nettyVersion;
}
- public int[] getCompatibleVersionList()
+ public boolean isCompatible(int version)
{
- return compatibleVersionList;
+ for (int element : compatibleVersionList)
+ {
+ if (element == version)
+ {
+ return true;
+ }
+ }
+ return false;
}
@Override
@@ -28,9 +28,9 @@
import org.hornetq.core.protocol.core.impl.wireformat.ReattachSessionMessage;
import org.hornetq.core.protocol.core.impl.wireformat.ReattachSessionResponseMessage;
import org.hornetq.core.security.HornetQPrincipal;
-import org.hornetq.core.server.HornetQServerLogger;
import org.hornetq.core.server.HornetQMessageBundle;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.HornetQServerLogger;
import org.hornetq.core.server.ServerSession;
import org.hornetq.core.version.Version;
@@ -111,18 +111,7 @@ private void handleCreateSession(final CreateSessionMessage request)
try
{
Version version = server.getVersion();
- int[] compatibleList = version.getCompatibleVersionList();
- boolean isCompatibleClient = false;
- for (int element : compatibleList)
- {
- if (element == request.getVersion())
- {
- isCompatibleClient = true;
- break;
- }
- }
-
- if (!isCompatibleClient)
+ if (!version.isCompatible(request.getVersion()))
{
HornetQServerLogger.LOGGER.incompatibleVersion(request.getVersion(), connection.getRemoteAddress(), version.getFullVersion());
throw HornetQMessageBundle.BUNDLE.incompatibleCLientServer();

0 comments on commit b95b043

Please sign in to comment.