-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
RingBufferLogHandler.records
could leak records
#6018
Conversation
assertFalse(lr.handler.getView().contains(r4)); | ||
assertTrue(lr.handler.getView().contains(r5)); | ||
assertTrue(lr.handler.getView().contains(r6)); | ||
assertThat(lr.handler.getView(), contains(r6, r5, r1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strengthening test to assert order as well.
This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback. Thanks! |
System log no longer works after this change: |
As @PierreBtz points out in jenkinsci/support-core-plugin#324 (review), if someone set up a custom logger that recorded messages from Pipeline components, it could temporarily hold on to
GroovyClassLoader
s from completed builds, which is not something we want as these might be quite large; seems preferable to let log messages be dropped under extreme memory pressure conditions. Perhaps it is possible to usePhantomReference
to replace a record with its formatted equivalent just before collection but this seems like overengineering.Note that in both the core and plugin cases, it is not exactly correct to hold a list of unformatted
LogRecord
s at all, when they are not going to be immediately written to some log sink. For example code like thiswould send messages like
to a log file, but display
in a GUI display. Unfortunately there is no way to know for sure if the sub-
INFO
record is going to ever be formatted, so formatting eagerly inpublish
would usually be wasteful just in order to properly handle log messages from code using this antipattern (log record parameters whosetoString
depends on mutable state).I am also cleaning up some concurrency code that looked dubious in f999510 and more so in #5772. Since accesses to
start
andsize
aresynchronized
, why use additional constructs? Perhaps this made sense when returning a lazily evaluated list, though I am not convinced its implementation was ever correct. Simpler and clearer to just construct a concrete list of results if and whengetView
is called, which is done for example injenkins/core/src/main/resources/hudson/logging/LogRecorder/index.jelly
Line 34 in 71117cc
Proposed changelog entries
Maintainer checklist
Before the changes are marked as
ready-for-merge
:Proposed changelog entries
are correctupgrade-guide-needed
label is set and there is aProposed upgrade guidelines
section in the PR title. (example)lts-candidate
to be considered (see query).