Skip to content

Conversation

abhishekraha
Copy link

@abhishekraha abhishekraha commented Oct 3, 2025

Changes :

  1. Refactored code to remove unwanted object creation
  2. Changed inner class to be static to avoid mem leakage
  3. IntelliJ remove/regroup-imports and indentation
  4. grammatical fixes

eventFileName = prefix + "event.log";

File directory = new File(messagesFileName).getParentFile();
if (!directory.exists()) {
Copy link
Author

Choose a reason for hiding this comment

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

redundant check as directory.mkdir() has exists check inbuilt

}

private class Invoker {
private static class Invoker {
Copy link
Author

Choose a reason for hiding this comment

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

non-static inner class will unnecessarily carry a reference to the outer class

if (sniHostName != null) {
SSLParameters sslParameters = sslEngine.getSSLParameters();
sslParameters.setServerNames(Arrays.asList(new SNIHostName(sniHostName)));
sslParameters.setServerNames(Collections.singletonList(new SNIHostName(sniHostName)));
Copy link
Author

Choose a reason for hiding this comment

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

Arrays.asList(new SNIHostName(sniHostName)) - creates 2 objects

  1. new SNIHostName(sniHostName)
  2. Array object when we do Arrays.asList

Collections.singletonList(new SNIHostName(sniHostName)) - creates 1 object of SNIHostName and wraps it in the Collection obeject

Copy link
Member

Choose a reason for hiding this comment

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

Will check the other points, but this code is called typically only once. Good point, though.

Copy link
Member

@chrjohn chrjohn left a comment

Choose a reason for hiding this comment

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

Please roll back the import changes.

@abhishekraha
Copy link
Author

Please roll back the import changes.

done.

out of curiosity - is the intention that we only import the classes that are required and not the whole package because importing is a compile time task and I don't think it has any latency implications.

@abhishekraha abhishekraha requested a review from chrjohn October 4, 2025 17:07
@chrjohn
Copy link
Member

chrjohn commented Oct 5, 2025

out of curiosity - is the intention that we only import the classes that are required and not the whole package because importing is a compile time task and I don't think it has any latency implications.

The intention is simply that one uses IntelliJ, another uses Eclipse, a third Netbeans and either has its own taste of how imports should be organized (unless you configure it the same for all IDEs).

@abhishekraha
Copy link
Author

out of curiosity - is the intention that we only import the classes that are required and not the whole package because importing is a compile time task and I don't think it has any latency implications.

The intention is simply that one uses IntelliJ, another uses Eclipse, a third Netbeans and either has its own taste of how imports should be organized (unless you configure it the same for all IDEs).

Got it. Thanks

I've reverted the import changes.

I didn't get much time after this initial one where my changes were around non-critical execution path which were called once maybe twice in the life cycle
I'll probably try to contribute to things that are more important in my next PR

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