-
-
Notifications
You must be signed in to change notification settings - Fork 141
[JENKINS-54128] More efficient implementation of getLogFile that just uses the existing file when possible #118
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
Changes from all commits
58399b8
660583a
f8f429f
ba8691d
4a4256b
6293f9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,6 @@ | |
| import java.io.ByteArrayInputStream; | ||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.File; | ||
| import java.io.FileOutputStream; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
|
|
@@ -1019,7 +1018,7 @@ private final class NodePrintListener implements GraphListener.Synchronous { | |
| @Override public InputStream getLogInputStream() throws IOException { | ||
| // Inefficient but probably rarely used anyway. | ||
| ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| writeLogTo(getLogText()::writeLogTo, baos); | ||
| writeLogTo(getLogText()::writeRawLogTo, baos); | ||
| return new ByteArrayInputStream(baos.toByteArray()); | ||
| } | ||
|
|
||
|
|
@@ -1081,16 +1080,7 @@ private void writeLogTo(WriteMethod method, OutputStream os) throws IOException | |
| @Deprecated | ||
| @Override public File getLogFile() { | ||
| LOGGER.log(Level.WARNING, "Avoid calling getLogFile on " + this, new UnsupportedOperationException()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the number of existing callers, should we only log the stack trace at FINE level?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well…we only know about those callers because it is at
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this potentially going to generate a log of logspam though?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I don't see that (at least on current Jenkins master branch) that Run.getLogFile is deprecated, which makes it feel very odd to me that we're deprecated its override in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Potentially. Note that the log call code was already there—not touched by this PR.
Yup, on my to-do list.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? While it may be satisfying to simple signal "stop using this API" by making it log a warning every time, for a user this looks like the Workflow Job plugin was broken by the update that added the logging - we've seen this before with "cosmetic" log warnings. Just not great optics or user experience. Being able to point to deprecation of the extension point in core and an appropriate waiting period gives us more of a leg to stand on here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so what do I call instead? It does look removeable as a whole potentially as all it does is get a file name off it but not sure the full implications
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @timja Any log-related methods other than -String currentFile = build.getLogFile().getName();
+String currentFile = "log";
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will give it a go later on thanks 👍
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| try { | ||
| File f = File.createTempFile("deprecated", ".log", getRootDir()); | ||
| f.deleteOnExit(); | ||
| try (OutputStream os = new FileOutputStream(f)) { | ||
| getLogText().writeRawLogTo(0, os); | ||
| } | ||
| return f; | ||
| } catch (IOException x) { | ||
| throw new RuntimeException(x); | ||
| } | ||
| return LogStorage.of(asFlowExecutionOwner()).getLogFile(this, !isLogUpdated()); | ||
| } | ||
|
|
||
| static void alias() { | ||
|
|
||
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.
Yikes, caused by my changes in #114. Good catch!