Skip to content
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

Define OutputStreamTaskListener & close BufferedBuildListener #294

Merged

Conversation

jglick
Copy link
Member

@jglick jglick commented Jul 13, 2023

Logging improvements needed for jenkinsci/workflow-durable-task-step-plugin#323.

@jglick jglick marked this pull request as draft July 13, 2023 22:46
@jglick jglick requested review from dwnusbaum and a team July 13, 2023 22:46
jglick added a commit to jglick/workflow-durable-task-step-plugin that referenced this pull request Jul 27, 2023
@jglick jglick marked this pull request as ready for review July 28, 2023 20:47
Comment on lines +63 to +67
Logger.getLogger(OutputStreamTaskListener.class.getName()).warning(() -> "Unexpected PrintStream subclass " + ps.getClass().getName() + " which might override write(…); error handling is degraded unless OutputStreamTaskListener is used: " + listener.getClass().getName());
return ps;
}
if (Runtime.version().compareToIgnoreOptional(Runtime.Version.parse("17")) >= 0) {
Logger.getLogger(OutputStreamTaskListener.class.getName()).warning(() -> "On Java 17+ error handling is degraded unless OutputStreamTaskListener is used: " + listener.getClass().getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a stack trace to these messages? Otherwise I don't really see how a Jenkins developer would be able to track down the problematic code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is just with the named class. A stack trace would not really add anything important.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the interesting thing is where that class is being used, right? E.g. If I see StreamTaskListener this message is unhelpful. Or do you only think this will only happen for custom listener implementations where the class name makes the use site obvious?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only happen for custom TaskListener implementations (this is for Pipeline builds where StreamTaskListener should not be used), and the use site is beside the point—either the class implements the new interface or it does not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only happen for custom TaskListener implementations (this is for Pipeline builds where StreamTaskListener should not be used)

Ok, probably fine then.

either the class implements the new interface or it does not.

Sure, but it was not obvious to me what classes we would expect here. If StreamTaskListener or LogTaskListener is possible then the message is not helpful and my concern was that it might cause confusing log spam. For example if we hit https://github.com/jenkinsci/workflow-durable-task-step-plugin/blob/1f55bd46852f56767bd2d664fa055deaa98c88cf/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/DurableTaskStep.java#L433 (seems like an obscure case) then is this warning reachable and would it be logged repeatedly? It isn't obvious to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case probably, but something is already pretty broken then. The warning could be limited to classes defined in plugins, and/or for that error handler we could make a special implementation. I can file a follow-up to refine a little bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it does not seem particularly important given your explanation, it just wasn't totally clear to me what kinds of scenarios we should anticipate.

@jglick jglick merged commit 4b91043 into jenkinsci:master Jul 28, 2023
14 checks passed
@jglick jglick deleted the OutputStreamTaskListener-JENKINS-52165 branch July 28, 2023 21:43
jglick added a commit to jglick/workflow-durable-task-step-plugin that referenced this pull request Jul 28, 2023
import org.kohsuke.accmod.restrictions.Beta;

/**
* {@link TaskListener} which can directly return an {@link OutputStream} not wrapped in a {@link PrintStream}.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants