Skip to content

Commit 23e570a

Browse files
committed
Removed DriverClosedException
All usages changed back to IllegalStateException. This revert is done because we should first refine driver errors hierarchy and only then introduce specific exception types.
1 parent da96356 commit 23e570a

File tree

5 files changed

+14
-47
lines changed

5 files changed

+14
-47
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalDriver.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.neo4j.driver.v1.Logger;
2727
import org.neo4j.driver.v1.Logging;
2828
import org.neo4j.driver.v1.Session;
29-
import org.neo4j.driver.v1.exceptions.DriverClosedException;
3029

3130
import static java.lang.String.format;
3231

@@ -72,7 +71,7 @@ public final Session session( AccessMode mode )
7271
// For 1. this closeResources will take no effect as everything is already closed.
7372
// For 2. this closeResources will close the new connection pool just created to ensure no resource leak.
7473
closeResources();
75-
throw new DriverClosedException();
74+
throw driverCloseException();
7675
}
7776
return session;
7877
}
@@ -114,7 +113,12 @@ private void assertOpen()
114113
{
115114
if ( closed.get() )
116115
{
117-
throw new DriverClosedException();
116+
throw driverCloseException();
118117
}
119118
}
119+
120+
private static RuntimeException driverCloseException()
121+
{
122+
return new IllegalStateException( "This driver instance has already been closed" );
123+
}
120124
}

driver/src/main/java/org/neo4j/driver/internal/net/pooling/SocketConnectionPool.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.neo4j.driver.internal.util.Clock;
3232
import org.neo4j.driver.internal.util.Supplier;
3333
import org.neo4j.driver.v1.Logging;
34-
import org.neo4j.driver.v1.exceptions.DriverClosedException;
3534

3635
/**
3736
* The pool is designed to buffer certain amount of free sessions into session pool. When closing a session, we first
@@ -180,7 +179,7 @@ private void assertNotClosed()
180179
{
181180
if ( closed.get() )
182181
{
183-
throw new DriverClosedException( "Unable to use the connection pool" );
182+
throw new IllegalStateException( "Pool closed" );
184183
}
185184
}
186185

driver/src/main/java/org/neo4j/driver/v1/exceptions/DriverClosedException.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

driver/src/test/java/org/neo4j/driver/internal/net/pooling/SocketConnectionPoolTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.neo4j.driver.internal.util.Clock;
4343
import org.neo4j.driver.internal.util.FakeClock;
4444
import org.neo4j.driver.v1.Logging;
45-
import org.neo4j.driver.v1.exceptions.DriverClosedException;
4645

4746
import static java.util.Collections.newSetFromMap;
4847
import static org.hamcrest.Matchers.instanceOf;
@@ -268,7 +267,7 @@ public void closeWithConcurrentAcquisitionsEmptiesThePool() throws InterruptedEx
268267
catch ( Exception e )
269268
{
270269
assertThat( e, instanceOf( ExecutionException.class ) );
271-
assertThat( e.getCause(), instanceOf( DriverClosedException.class ) );
270+
assertThat( e.getCause(), instanceOf( IllegalStateException.class ) );
272271
}
273272
}
274273
executor.shutdownNow();

driver/src/test/java/org/neo4j/driver/v1/DriverCloseIT.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.logging.Level;
3030

3131
import org.neo4j.driver.internal.logging.ConsoleLogging;
32-
import org.neo4j.driver.v1.exceptions.DriverClosedException;
3332
import org.neo4j.driver.v1.util.StubServer;
3433
import org.neo4j.driver.v1.util.TestNeo4j;
3534

@@ -59,7 +58,7 @@ public void isEncryptedThrowsForClosedDriver()
5958
}
6059
catch ( Exception e )
6160
{
62-
assertThat( e, instanceOf( DriverClosedException.class ) );
61+
assertThat( e, instanceOf( IllegalStateException.class ) );
6362
}
6463
}
6564

@@ -77,7 +76,7 @@ public void sessionThrowsForClosedDriver()
7776
}
7877
catch ( Exception e )
7978
{
80-
assertThat( e, instanceOf( DriverClosedException.class ) );
79+
assertThat( e, instanceOf( IllegalStateException.class ) );
8180
}
8281
}
8382

@@ -95,7 +94,7 @@ public void sessionWithModeThrowsForClosedDriver()
9594
}
9695
catch ( Exception e )
9796
{
98-
assertThat( e, instanceOf( DriverClosedException.class ) );
97+
assertThat( e, instanceOf( IllegalStateException.class ) );
9998
}
10099
}
101100

@@ -136,7 +135,7 @@ public void useSessionAfterDriverIsClosed()
136135
}
137136
catch ( Exception e )
138137
{
139-
assertThat( e, instanceOf( DriverClosedException.class ) );
138+
assertThat( e, instanceOf( IllegalStateException.class ) );
140139
}
141140
}
142141
}
@@ -195,7 +194,7 @@ public void useSessionAfterDriverIsClosed() throws Exception
195194
}
196195
catch ( Exception e )
197196
{
198-
assertThat( e, instanceOf( DriverClosedException.class ) );
197+
assertThat( e, instanceOf( IllegalStateException.class ) );
199198
}
200199

201200
assertEquals( 0, readServer.exitStatus() );

0 commit comments

Comments
 (0)