Skip to content

Commit

Permalink
Added ability to turn version checking off (https://issues.redhat.com…
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Nov 3, 2023
1 parent 6eadd72 commit de32a8f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/manual/protocols.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ address chosen will be:
| jgroups.use.jdk_logger | If true, the JDK logger (`java.util.logging.Logger`) will be used
| jgroups.log_class | The fully qualified name of a class implementing a logger to be used. See <<Logging>> for details.
| jgroups.msg.default_headers | System prop for defining the default number of headers in a Message (default: 4).
| jgroups.version.check | Whether or not to check the version of received messages and discard them if the versions
don't match. Default: true (version check is enabled).

|===============

Expand Down
2 changes: 2 additions & 0 deletions src/org/jgroups/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public final class Global {
public static final String USE_JDK_LOGGER="jgroups.use.jdk_logger"; // forces use of the JDK logger
public static final String LOG_CLASS="jgroups.log_class"; // class of preferred logger

public static final String VERSION_CHECK="jgroups.version.check"; // used to disable/enable version checking

/** System prop for defining the default number of headers in a Message */
public static final String DEFAULT_HEADERS="jgroups.msg.default_headers";

Expand Down
10 changes: 6 additions & 4 deletions src/org/jgroups/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Version {
public static final String VERSION_PROPERTY = "jgroups.version";
public static final String CODENAME = "jgroups.codename";
private static final Pattern VERSION_REGEXP = Pattern.compile("((\\d+)\\.(\\d+)\\.(\\d+).*)");

private static boolean VERSION_CHECK = true; // version checking is enabled by default


static {
Expand Down Expand Up @@ -82,7 +82,9 @@ public class Version {
catch(Exception e) {
throw new IllegalStateException(String.format("failed parsing %s (%s correct?)", ver, VERSION_FILE), e);
}

String s=Util.getProperty(Global.VERSION_CHECK);
if(s != null)
VERSION_CHECK=Boolean.parseBoolean(s);
}

public static short getMajor() {return major;}
Expand Down Expand Up @@ -169,7 +171,7 @@ public static short[] decode(short version) {
* @return
*/
public static boolean isBinaryCompatible(short ver) {
if(version == ver)
if(!VERSION_CHECK || version == ver)
return true;
short tmp_major=(short)((ver & MAJOR_MASK) >> MAJOR_SHIFT);
short tmp_minor=(short)((ver & MINOR_MASK) >> MINOR_SHIFT);
Expand All @@ -178,7 +180,7 @@ public static boolean isBinaryCompatible(short ver) {


public static boolean isBinaryCompatible(short ver1, short ver2) {
if(ver1 == ver2)
if(!VERSION_CHECK || ver1 == ver2)
return true;
short[] tmp=decode(ver1);
short tmp_major=tmp[0], tmp_minor=tmp[1];
Expand Down

0 comments on commit de32a8f

Please sign in to comment.