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

Improve documentation of nullability on LoggingEvent interface #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hermannm
Copy link

I recently worked with the SLF4J LoggingEvent interface, and found myself having to dig through the DefaultLoggingEvent implementation to see which methods on LoggingEvent could actually return null. I saw that there is an existing docstring documenting the nullability of LoggingEvent.getMarkers(), but none for the other methods. I figured it would be useful to document this on all methods, to make the interface contract clearer.

The existing LoggingEvent.getMarkers() docstring duplicated its text in the main doc and in @return. This seemed redundant to me, but if you prefer this format I'll change over to it.

I figured that for a small change like this it would be easiest to submit a PR directly, so I didn't go through the mailing list/bug report. But I'll do that if you prefer strictly following the contributor guidelines.

@hermannm hermannm force-pushed the document-nullable-logging-event-fields branch from 8d551b7 to d3e1c8c Compare December 27, 2024 01:01
@ppkarwasz
Copy link
Contributor

It would be probably useful to annotate SLF4J with JSpecify. Unlike all the previous nullability annotations, JSpecify is actually supported by a long list of vendors and it is becoming the de facto standard.
Spring also decided to migrate to JSpecify (see spring-projects/spring-framework#28797).

@hermannm
Copy link
Author

It would be probably useful to annotate SLF4J with JSpecify. Unlike all the previous nullability annotations, JSpecify is actually supported by a long list of vendors and it is becoming the de facto standard. Spring also decided to migrate to JSpecify (see spring-projects/spring-framework#28797).

Agreed that JSpecify would be better! But adopting that seems like a greater effort, that should be a project-wide decision (correct me if I'm wrong). Until we decide to adopt JSpecify, I thought it would be useful to at least document nullability like this.

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

Successfully merging this pull request may close these issues.

2 participants