Skip to content

Fix logger name in HalFormsAdaptingResponseBodyAdvice #2479

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

Conversation

jkschneider
Copy link
Contributor

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 14, 2025
@@ -42,7 +41,7 @@
class HalFormsAdaptingResponseBodyAdvice<T extends RepresentationModel<T>>
implements ResponseBodyAdvice<RepresentationModel<T>> {

private static final Logger logger = LoggerFactory.getLogger(RequestResponseBodyMethodProcessor.class);
private static final Logger logger = LoggerFactory.getLogger(HalFormsAdaptingResponseBodyAdvice.class);
Copy link
Member

Choose a reason for hiding this comment

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

This one is useful.

@@ -47,7 +47,7 @@ class RepositoryRestExceptionHandlerUnitTests {
@BeforeAll
public static void silenceLog() {

logger = (Logger) LoggerFactory.getLogger(RepositoryRestExceptionHandler.class);
logger = (Logger) LoggerFactory.getLogger(RepositoryRestExceptionHandlerUnitTests.class);
Copy link
Member

Choose a reason for hiding this comment

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

This one is not useful as it accomplishes something else. The recipe would benefit from considering tests and where (method or class body) the logger is actually obtained.

@odrotbohm odrotbohm closed this in 6f20a57 May 20, 2025
odrotbohm pushed a commit that referenced this pull request May 20, 2025
odrotbohm pushed a commit that referenced this pull request May 20, 2025
odrotbohm pushed a commit that referenced this pull request May 20, 2025
@odrotbohm odrotbohm changed the title refactor: Loggers should be named for their enclosing classes Fix logger name in HalFormsAdaptingResponseBodyAdvice May 20, 2025
@odrotbohm
Copy link
Member

I've partially applied the changes in the PR. As Mark pointed out, generally assuming you'd always want to obtain a logger for the same class might not hold true in edge cases, such as the one in our tests here. Thanks, nonetheless!

@odrotbohm odrotbohm removed the status: waiting-for-triage An issue we've not yet triaged label May 20, 2025
@odrotbohm odrotbohm added this to the 4.3.13 (2024.0.13) milestone May 20, 2025
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.

4 participants