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

String tag = settings.getString(sessionID, logonTagSetting);
String[] split = tag.split("=", 2);
StringField stringField = new StringField(Integer.valueOf(split[0]), split[1]);
StringField stringField = new StringField(Integer.parseInt(split[0]), split[1]);
Copy link
Author

@abhishekraha abhishekraha Oct 3, 2025

Choose a reason for hiding this comment

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

removed redundant auto-boxing

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

}

public class RedundantHandlerException extends RuntimeException {
public static class RedundantHandlerException extends RuntimeException {
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

}

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

try {
DatabaseEntry sequenceKey = new DatabaseEntry();
EntryBinding sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class);
EntryBinding<Integer> sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class);
Copy link
Author

Choose a reason for hiding this comment

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

Making variable type safe at source instead of doing type-casting everytime it is used

for (int index = 0; ; index++) {
try {
final String protocolKey = Initiator.SETTING_SOCKET_CONNECT_PROTOCOL
+ (index == 0 ? "" : Integer.toString(index));
Copy link
Author

Choose a reason for hiding this comment

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

every Integer.toString(index) will create a new object.
reducing innecessary garbage creation

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