Correctly check for model compatibility The major versions must match The last two minor versions should be supported
See issue OPENNLP-906 Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/66336833 Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/66336833 Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/66336833 Branch: refs/heads/parser_regression Commit: 66336833dbcff38eb7c26595ccc15f7260450cba Parents: 67ffda9 Author: Jörn Kottmann <[email protected]> Authored: Sat Dec 31 19:32:48 2016 +0100 Committer: Jörn Kottmann <[email protected]> Committed: Sat Dec 31 19:56:14 2016 +0100 ---------------------------------------------------------------------- .../src/main/java/opennlp/tools/util/model/BaseModel.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/opennlp/blob/66336833/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java ---------------------------------------------------------------------- diff --git a/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java b/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java index fdae63a..5fcd1da 100644 --- a/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java +++ b/opennlp-tools/src/main/java/opennlp/tools/util/model/BaseModel.java @@ -419,14 +419,11 @@ public abstract class BaseModel implements ArtifactProvider, Serializable { // Version check is only performed if current version is not the dev/debug version if (!Version.currentVersion().equals(Version.DEV_VERSION)) { // Major and minor version must match, revision might be + // this check allows for the use of models of n minor release behind current minor release if (Version.currentVersion().getMajor() != version.getMajor() || - Version.currentVersion().getMinor() != version.getMinor()) { - //this check allows for the use of models one minor release behind current minor release - if (Version.currentVersion().getMajor() == version.getMajor() && (Version.currentVersion().getMinor() - 2) - != version.getMinor()) { + Version.currentVersion().getMinor() - 2 > version.getMinor()) { throw new InvalidFormatException("Model version " + version + " is not supported by this (" + Version.currentVersion() +") version of OpenNLP!"); - } } // Reject loading a snapshot model with a non-snapshot version
