Skip to content

Commit 95706eb

Browse files
committed
Merge pull request #129 from neo4j/1.0-failures-on-commit
Test for and handle failures on commit
2 parents 12dfe1a + 727b9c6 commit 95706eb

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

driver/src/main/java/org/neo4j/driver/internal/connector/socket/SocketResponseHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ private int statsValue( Value stats, String name )
176176
public void handleIgnoredMessage()
177177
{
178178
StreamCollector collector = collectors.remove();
179-
collector.done();
179+
if (collector != null)
180+
{
181+
collector.done();
182+
}
180183
}
181184

182185
@Override

driver/src/test/java/org/neo4j/driver/v1/integration/ErrorIT.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.neo4j.driver.v1.integration;
2020

21+
import java.util.UUID;
22+
2123
import org.junit.Rule;
2224
import org.junit.Test;
2325
import org.junit.rules.ExpectedException;
@@ -123,4 +125,31 @@ public void shouldExplainConnectionError() throws Throwable
123125
}
124126
}
125127

128+
@Test
129+
public void shouldHandleFailureAtCommitTime() throws Throwable
130+
{
131+
String label = UUID.randomUUID().toString(); // avoid clashes with other tests
132+
133+
// given
134+
Transaction tx = session.beginTransaction();
135+
tx.run( "CREATE CONSTRAINT ON (a:`" + label + "`) ASSERT a.name IS UNIQUE" );
136+
tx.success();
137+
tx.close();
138+
139+
// and
140+
tx = session.beginTransaction();
141+
tx.run( "CREATE INDEX ON :`" + label + "`(name)" );
142+
tx.success();
143+
144+
// then expect
145+
exception.expect( ClientException.class );
146+
exception.expectMessage( "Label '" + label + "' and property 'name' have a unique " +
147+
"constraint defined on them, so an index is already created that matches this." );
148+
149+
// when
150+
tx.close();
151+
152+
}
153+
154+
126155
}

0 commit comments

Comments
 (0)