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

Fixing connection cleanup in case of mass connection breaking. #2614

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.tinkerpop.gremlin.util.TimeUtil;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -663,18 +664,19 @@ public String getPoolInfo(final Connection connectionToCallout) {

private void appendConnections(final StringBuilder sb, final Connection connectionToCallout,
final List<Connection> connections) {
final int connectionCount = connections.size();
for (int ix = 0; ix < connectionCount; ix++) {
final Connection c = connections.get(ix);
if (c.equals(connectionToCallout))
final Iterator<Connection> it = connections.iterator();
Copy link
Contributor

@kenhuuu kenhuuu May 22, 2024

Choose a reason for hiding this comment

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

Minor nit: There aren't any tests for this PR, but this might be ok since appendConnections is only used for logging. But seeing as how we are now dependent on the CopyOnWriteArrayList's iterator behavior, we might want to add a small comment and maybe even explicitly declare connections as a CopyOnWriteArrayList<Connection> rather than just a List<Connection>.

while(it.hasNext()) {
final Connection c = it.next();
if (c.equals(connectionToCallout)) {
sb.append("==> ");
else
}
else {
sb.append("> ");

}
sb.append(c.getConnectionInfo(false));

if (ix < connectionCount - 1)
if (it.hasNext()) {
sb.append(System.lineSeparator());
}
}
}

Expand Down
Loading