Skip to content

Commit 60ef87d

Browse files
committed
Removed unused methods from ConnectionPool
Methods `#purge(BoltServerAddress)` and `#hasAddress(BoltServerAddress)` were only used in tests. Now they are gone.
1 parent 010f784 commit 60ef87d

File tree

4 files changed

+2
-79
lines changed

4 files changed

+2
-79
lines changed

driver/src/main/java/org/neo4j/driver/internal/async/pool/ConnectionPoolImpl.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,6 @@ public CompletionStage<Connection> acquire( BoltServerAddress address )
9292
} );
9393
}
9494

95-
@Override
96-
public void purge( BoltServerAddress address )
97-
{
98-
log.info( "Purging connections towards %s", address );
99-
100-
// purge active connections
101-
activeChannelTracker.purge( address );
102-
103-
// purge idle connections in the pool and pool itself
104-
ChannelPool pool = pools.remove( address );
105-
if ( pool != null )
106-
{
107-
pool.close();
108-
}
109-
}
110-
11195
@Override
11296
public void retainAll( Set<BoltServerAddress> addressesToRetain )
11397
{
@@ -124,20 +108,15 @@ public void retainAll( Set<BoltServerAddress> addressesToRetain )
124108
ChannelPool pool = pools.remove( address );
125109
if ( pool != null )
126110
{
127-
log.info( "Purging idle connections towards %s", address );
111+
log.info( "Closing connection pool towards %s, it has no active connections " +
112+
"and is not in the routing table", address );
128113
pool.close();
129114
}
130115
}
131116
}
132117
}
133118
}
134119

135-
@Override
136-
public boolean hasAddress( BoltServerAddress address )
137-
{
138-
return pools.containsKey( address );
139-
}
140-
141120
@Override
142121
public int activeConnections( BoltServerAddress address )
143122
{

driver/src/main/java/org/neo4j/driver/internal/spi/ConnectionPool.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ public interface ConnectionPool
2727
{
2828
CompletionStage<Connection> acquire( BoltServerAddress address );
2929

30-
void purge( BoltServerAddress address );
31-
3230
void retainAll( Set<BoltServerAddress> addressesToRetain );
3331

34-
boolean hasAddress( BoltServerAddress address );
35-
3632
int activeConnections( BoltServerAddress address );
3733

3834
CompletionStage<Void> close();

driver/src/test/java/org/neo4j/driver/internal/async/pool/ConnectionPoolImplTest.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
import static java.util.Collections.singleton;
4747
import static org.hamcrest.Matchers.instanceOf;
4848
import static org.hamcrest.Matchers.startsWith;
49-
import static org.junit.Assert.assertEquals;
50-
import static org.junit.Assert.assertFalse;
5149
import static org.junit.Assert.assertNotNull;
5250
import static org.junit.Assert.assertNull;
5351
import static org.junit.Assert.assertThat;
@@ -138,44 +136,6 @@ public void shouldFailToAcquireWhenPoolClosed()
138136
}
139137
}
140138

141-
@Test
142-
public void shouldPurgeAddressWithConnections()
143-
{
144-
Connection connection1 = await( pool.acquire( neo4j.address() ) );
145-
Connection connection2 = await( pool.acquire( neo4j.address() ) );
146-
Connection connection3 = await( pool.acquire( neo4j.address() ) );
147-
148-
assertNotNull( connection1 );
149-
assertNotNull( connection2 );
150-
assertNotNull( connection3 );
151-
152-
assertEquals( 3, pool.activeConnections( neo4j.address() ) );
153-
154-
pool.purge( neo4j.address() );
155-
156-
assertEquals( 0, pool.activeConnections( neo4j.address() ) );
157-
}
158-
159-
@Test
160-
public void shouldPurgeAddressWithoutConnections()
161-
{
162-
assertEquals( 0, pool.activeConnections( neo4j.address() ) );
163-
164-
pool.purge( neo4j.address() );
165-
166-
assertEquals( 0, pool.activeConnections( neo4j.address() ) );
167-
}
168-
169-
@Test
170-
public void shouldCheckIfPoolHasAddress()
171-
{
172-
assertFalse( pool.hasAddress( neo4j.address() ) );
173-
174-
await( pool.acquire( neo4j.address() ) );
175-
176-
assertTrue( pool.hasAddress( neo4j.address() ) );
177-
}
178-
179139
@Test
180140
public void shouldNotCloseWhenClosed()
181141
{

driver/src/test/java/org/neo4j/driver/internal/util/FailingConnectionDriverFactory.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,12 @@ public CompletionStage<Connection> acquire( BoltServerAddress address )
7070
.thenApply( connection -> new FailingConnection( connection, nextRunFailure ) );
7171
}
7272

73-
@Override
74-
public void purge( BoltServerAddress address )
75-
{
76-
delegate.purge( address );
77-
}
78-
7973
@Override
8074
public void retainAll( Set<BoltServerAddress> addressesToRetain )
8175
{
8276
delegate.retainAll( addressesToRetain );
8377
}
8478

85-
@Override
86-
public boolean hasAddress( BoltServerAddress address )
87-
{
88-
return delegate.hasAddress( address );
89-
}
90-
9179
@Override
9280
public int activeConnections( BoltServerAddress address )
9381
{

0 commit comments

Comments
 (0)