From 84be1e660b8fcfbcb5645c464436fb85c7d4818e Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 18 Sep 2024 15:15:04 -0700 Subject: [PATCH] Mute the minor version warning https://github.com/protocolbuffers/protobuf/issues/18096 PiperOrigin-RevId: 676149826 --- .../com/google/protobuf/RuntimeVersion.java | 7 ------- .../com/google/protobuf/RuntimeVersionTest.java | 17 ----------------- .../protobuf/internal/runtime_version_test.py | 16 ---------------- python/google/protobuf/runtime_version.py | 8 -------- 4 files changed, 48 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/RuntimeVersion.java b/java/core/src/main/java/com/google/protobuf/RuntimeVersion.java index ca39049e9ce69..dbf2b3abe5d1f 100644 --- a/java/core/src/main/java/com/google/protobuf/RuntimeVersion.java +++ b/java/core/src/main/java/com/google/protobuf/RuntimeVersion.java @@ -118,13 +118,6 @@ private static void validateProtobufGencodeVersionImpl( "Detected incompatible Protobuf Gencode/Runtime versions when loading %s: gencode %s," + " runtime %s. Runtime version cannot be older than the linked gencode version.", location, gencodeVersionString, VERSION_STRING)); - } else if ((MINOR > minor || PATCH > patch) && minorWarningLoggedCount < MAX_WARNING_COUNT) { - logger.warning( - String.format( - " Protobuf gencode version %s is older than the runtime version %s at %s. Please" - + " avoid checked-in Protobuf gencode that can be obsolete.", - gencodeVersionString, VERSION_STRING, location)); - minorWarningLoggedCount++; } // Check that runtime version suffix is the same as the gencode version suffix. diff --git a/java/core/src/test/java/com/google/protobuf/RuntimeVersionTest.java b/java/core/src/test/java/com/google/protobuf/RuntimeVersionTest.java index e2fae7d219321..1714ce42ed0a5 100644 --- a/java/core/src/test/java/com/google/protobuf/RuntimeVersionTest.java +++ b/java/core/src/test/java/com/google/protobuf/RuntimeVersionTest.java @@ -146,23 +146,6 @@ public void versionValidation_differentVesionSuffixDisallowed() { + " testing.Foo"); } - @Test - public void versionValidation_warnOlderGencodeVersion() { - TestUtil.TestLogHandler logHandler = new TestUtil.TestLogHandler(); - Logger logger = Logger.getLogger(RuntimeVersion.class.getName()); - logger.addHandler(logHandler); - RuntimeVersion.validateProtobufGencodeVersion( - RuntimeVersion.DOMAIN, - RuntimeVersion.MAJOR, - RuntimeVersion.MINOR - 1, - RuntimeVersion.PATCH, - RuntimeVersion.SUFFIX, - "dummy"); - assertThat(logHandler.getStoredLogRecords()).hasSize(1); - assertThat(logHandler.getStoredLogRecords().get(0).getMessage()) - .contains("Please avoid checked-in Protobuf gencode that can be obsolete."); - } - @Test public void versionValidation_gencodeOneMajorVersionOlderWarning() { TestUtil.TestLogHandler logHandler = new TestUtil.TestLogHandler(); diff --git a/python/google/protobuf/internal/runtime_version_test.py b/python/google/protobuf/internal/runtime_version_test.py index fcede1430a5a8..5e96c91aa4207 100644 --- a/python/google/protobuf/internal/runtime_version_test.py +++ b/python/google/protobuf/internal/runtime_version_test.py @@ -118,22 +118,6 @@ def test_different_suffix_disallowed(self): 'foo.proto', ) - def test_gencode_older_than_runtime_version_warning(self): - with self.assertWarnsRegex( - Warning, - expected_regex=( - 'Please avoid checked-in Protobuf gencode that can be obsolete.' - ), - ): - runtime_version.ValidateProtobufRuntimeVersion( - runtime_version.DOMAIN, - runtime_version.MAJOR, - runtime_version.MINOR - 1, - runtime_version.PATCH, - runtime_version.SUFFIX, - 'foo.proto', - ) - def test_gencode_one_major_version_older_warning(self): with self.assertWarnsRegex( Warning, expected_regex='is exactly one major version older' diff --git a/python/google/protobuf/runtime_version.py b/python/google/protobuf/runtime_version.py index a4d096a640328..20733b2859cb3 100644 --- a/python/google/protobuf/runtime_version.py +++ b/python/google/protobuf/runtime_version.py @@ -115,14 +115,6 @@ def ValidateProtobufRuntimeVersion( f' {location}: gencode {gen_version} runtime {version}. Runtime version' f' cannot be older than the linked gencode version. {error_prompt}' ) - elif MINOR > gen_minor or PATCH > gen_patch: - if _warning_count < _MAX_WARNING_COUNT: - warnings.warn( - 'Protobuf gencode version %s is older than the runtime version %s at' - ' %s. Please avoid checked-in Protobuf gencode that can be obsolete.' - % (gen_version, version, location) - ) - _warning_count += 1 if gen_suffix != SUFFIX: _ReportVersionError(