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

Logger and string usage warning fix #689

Conversation

SampathKumarAmex
Copy link
Contributor

Description

  • Removed the string concatenation from logger statement which has the placeholder
  • start doesn't need to be initialised outside. IDE was showing warning for this. So, removed the variable declaration and used it inline

Motivation and Context

  • Fixing a minor issue in logging (i.e. using {} and concatenation together)
  • Fixed the warning on variable declaration

How Has This Been Tested?

n/a

Note:-
I can add unit test for log statement using external dependency LogCaptor. Please leave the preference in comment. I will add the below test in the separate PR. Thanks!

@Test
    public void testStringFromFileConstructorLogger() {
        LogCaptor logCaptor = LogCaptor.forClass(StringFromFile.class);
        new StringFromFile();
        assertThat(logCaptor.getDebugLogs().get(0),
                containsString("++++++++ Construct org.apache.jmeter.functions.StringFromFile@"));
    }

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

@asfgit asfgit closed this in 51507ea Jan 4, 2022
@FSchumacher
Copy link
Contributor

Thanks for the PR.

I don't think we need to check the log messages for correctness in unit tests.

@SampathKumarAmex
Copy link
Contributor Author

I don't think we need to check the log messages for correctness in unit tests.

OK, that was proposal for the next PR.

Change 1:-

Actually, this PR addresses the unnecessary concatenation + present in the log statement.

Before change:-

log.debug("++++++++ Construct {}" + this);

After change:-

log.debug("++++++++ Construct {}", this);

Change 2:-
The second minor change is to move the String declaration to inline to fix the IDE warning.

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