Repository: mesos Updated Branches: refs/heads/master 9a6e0065f -> 8a6e9fe03
Ignore overflow components in version parsing. Review: https://reviews.apache.org/r/37669 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8a6e9fe0 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8a6e9fe0 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8a6e9fe0 Branch: refs/heads/master Commit: 8a6e9fe035cafd36b1451f9349a17e8c18e2a02d Parents: 9a6e006 Author: haosdent huang <[email protected]> Authored: Sat Aug 29 12:12:49 2015 -0700 Committer: Timothy Chen <[email protected]> Committed: Sat Aug 29 12:12:50 2015 -0700 ---------------------------------------------------------------------- .../3rdparty/stout/include/stout/version.hpp | 14 ++++++++++---- .../libprocess/3rdparty/stout/tests/version_tests.cpp | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/8a6e9fe0/3rdparty/libprocess/3rdparty/stout/include/stout/version.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/version.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/version.hpp index 5101084..1faddb9 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/version.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/version.hpp @@ -18,6 +18,8 @@ #include <string> #include <vector> +#include <glog/logging.h> + #include <stout/error.hpp> #include <stout/numify.hpp> #include <stout/stringify.hpp> @@ -52,14 +54,18 @@ struct Version strings::split(strings::split(s, "-")[0], "."); if (split.size() > maxComponents) { - return Error("Version string has " + stringify(split.size()) + - " components; maximum " + stringify(maxComponents) + - " components allowed"); + LOG(WARNING) << "Version string has " << split.size() << " components; " + << "only " << maxComponents << " components will be " + << "recognized, the rest will be ignored."; } int components[maxComponents] = {0}; + size_t componentSize = maxComponents; + if (split.size() < maxComponents) { + componentSize = split.size(); + } - for (size_t i = 0; i < split.size(); i++) { + for (size_t i = 0; i < componentSize; i++) { Try<int> result = numify<int>(split[i]); if (result.isError()) { return Error("Invalid version component '" + split[i] + "': " + http://git-wip-us.apache.org/repos/asf/mesos/blob/8a6e9fe0/3rdparty/libprocess/3rdparty/stout/tests/version_tests.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/tests/version_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/version_tests.cpp index e8f8358..e48bda1 100644 --- a/3rdparty/libprocess/3rdparty/stout/tests/version_tests.cpp +++ b/3rdparty/libprocess/3rdparty/stout/tests/version_tests.cpp @@ -57,10 +57,15 @@ TEST(VersionTest, Parse) EXPECT_EQ(version4.get(), version1.get()); EXPECT_EQ(stringify(version4.get()), "1.20.3"); + // Ignore additional components following "X.Y.Z". + Try<Version> version5 = Version::parse("1.20.3.fc22"); + EXPECT_SOME(version5); + EXPECT_EQ(version5.get(), version1.get()); + EXPECT_EQ(stringify(version5.get()), "1.20.3"); + EXPECT_ERROR(Version::parse("0.a.b")); EXPECT_ERROR(Version::parse("")); EXPECT_ERROR(Version::parse("a")); EXPECT_ERROR(Version::parse("1.")); EXPECT_ERROR(Version::parse(".1.2")); - EXPECT_ERROR(Version::parse("0.1.2.3")); }
