Skip to content

Change pre-22 poison pill to only log once per affected message type. #21754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test case that clearly shows the logging per specific type.
  • Loading branch information
esrauchg committed May 15, 2025
commit 31fed58cb844a67b49a350433a8c7ea37bd26de1
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,10 @@ public Message getDefaultInstanceForType() {
return null;
}
}
var msg = new TestMessage1();

class TestMessage2 extends TestMessage1 {}

TestMessage1 msg = new TestMessage1();
msg.makeExtensionsImmutable();
List<LogRecord> logs = logHandler.getStoredLogRecords();
assertThat(logs).hasSize(1);
Expand All @@ -2054,6 +2057,14 @@ public Message getDefaultInstanceForType() {
// Subsequent calls for the same type do not log again.
msg.makeExtensionsImmutable();
assertThat(logs).hasSize(1);

// A call on a second type does log for that type.
TestMessage2 msg2 = new TestMessage2();
msg2.makeExtensionsImmutable();
assertThat(logs).hasSize(2);
// And not again (only once per type).
msg2.makeExtensionsImmutable();
assertThat(logs).hasSize(2);
}

@Test
Expand Down
Loading