diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/CursorException.java b/community/io/src/main/java/org/neo4j/io/pagecache/CursorException.java index 4b810f519ad39..7100bada42046 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/CursorException.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/CursorException.java @@ -22,8 +22,8 @@ import java.io.IOException; /** - * Thrown by {@link PageCursor#checkAndClearCursorError()} if an error condition has been set on the cursor with - * {@link PageCursor#setCursorError(String)}. + * Thrown by {@link PageCursor#checkAndClearCursorException()} if an error condition has been set on the cursor with + * {@link PageCursor#setCursorException(String)}. */ public class CursorException extends IOException { diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/PageCursor.java b/community/io/src/main/java/org/neo4j/io/pagecache/PageCursor.java index e899b263c198f..3f1936aff53b7 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/PageCursor.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/PageCursor.java @@ -302,7 +302,7 @@ public abstract class PageCursor implements AutoCloseable * Check if a cursor error has been set on this or any linked cursor, and if so, remove it from the cursor * and throw it as a {@link CursorException}. */ - public abstract void checkAndClearCursorError() throws CursorException; + public abstract void checkAndClearCursorException() throws CursorException; /** * Explicitly raise the out-of-bounds flag. @@ -314,19 +314,19 @@ public abstract class PageCursor implements AutoCloseable /** * Set an error condition on the cursor with the given message. *

- * This will make calls to {@link #checkAndClearCursorError()} throw a {@link CursorException} with the given + * This will make calls to {@link #checkAndClearCursorException()} throw a {@link CursorException} with the given * message, unless the error has gotten cleared by a {@link #shouldRetry()} call that returned {@code true}, * a call to {@link #next()} or {@link #next(long)}, or the cursor is closed. * - * @param message The message of the {@link CursorException} that {@link #checkAndClearCursorError()} will throw. + * @param message The message of the {@link CursorException} that {@link #checkAndClearCursorException()} will throw. */ - public abstract void setCursorError( String message ); + public abstract void setCursorException( String message ); /** * Unconditionally clear any error condition that has been set on this or any linked cursor, without throwing an * exception. */ - public abstract void clearCursorError(); + public abstract void clearCursorException(); /** * Open a new page cursor with the same pf_flags as this cursor, as if calling the {@link PagedFile#io(long, int)} diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/impl/CompositePageCursor.java b/community/io/src/main/java/org/neo4j/io/pagecache/impl/CompositePageCursor.java index 9dca3472f6971..c7268d073d462 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/impl/CompositePageCursor.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/impl/CompositePageCursor.java @@ -452,10 +452,10 @@ public boolean checkAndClearBoundsFlag() } @Override - public void checkAndClearCursorError() throws CursorException + public void checkAndClearCursorException() throws CursorException { - first.checkAndClearCursorError(); - second.checkAndClearCursorError(); + first.checkAndClearCursorException(); + second.checkAndClearCursorException(); } @Override @@ -465,16 +465,16 @@ public void raiseOutOfBounds() } @Override - public void setCursorError( String message ) + public void setCursorException( String message ) { - cursor( 0 ).setCursorError( message ); + cursor( 0 ).setCursorException( message ); } @Override - public void clearCursorError() + public void clearCursorException() { - first.clearCursorError(); - second.clearCursorError(); + first.clearCursorException(); + second.clearCursorException(); } @Override diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/impl/DelegatingPageCursor.java b/community/io/src/main/java/org/neo4j/io/pagecache/impl/DelegatingPageCursor.java index b70a0399a0178..bb143f6ea35f6 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/impl/DelegatingPageCursor.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/impl/DelegatingPageCursor.java @@ -138,9 +138,9 @@ public boolean checkAndClearBoundsFlag() } @Override - public void checkAndClearCursorError() throws CursorException + public void checkAndClearCursorException() throws CursorException { - delegate.checkAndClearCursorError(); + delegate.checkAndClearCursorException(); } @Override @@ -150,15 +150,15 @@ public void raiseOutOfBounds() } @Override - public void setCursorError( String message ) + public void setCursorException( String message ) { - delegate.setCursorError( message ); + delegate.setCursorException( message ); } @Override - public void clearCursorError() + public void clearCursorException() { - delegate.clearCursorError(); + delegate.clearCursorException(); } @Override diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnPageCursor.java b/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnPageCursor.java index b1ccbe01b0e28..26bdea2d1eb0f 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnPageCursor.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnPageCursor.java @@ -710,7 +710,7 @@ public boolean checkAndClearBoundsFlag() } @Override - public void checkAndClearCursorError() throws CursorException + public void checkAndClearCursorException() throws CursorException { MuninnPageCursor cursor = this; do @@ -734,7 +734,7 @@ public void checkAndClearCursorError() throws CursorException } @Override - public void clearCursorError() + public void clearCursorException() { clearCursorError( this ); } @@ -755,7 +755,7 @@ public void raiseOutOfBounds() } @Override - public void setCursorError( String message ) + public void setCursorException( String message ) { Objects.requireNonNull( message ); if ( usePreciseCursorErrorStackTraces ) diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnReadPageCursor.java b/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnReadPageCursor.java index 978b707ea5a65..114042bbbe269 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnReadPageCursor.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/MuninnReadPageCursor.java @@ -111,7 +111,7 @@ private void startRetry() throws IOException { setOffset( 0 ); checkAndClearBoundsFlag(); - clearCursorError(); + clearCursorException(); lockStamp = page.tryOptimisticReadLock(); // The page might have been evicted while we held the optimistic // read lock, so we need to check with page.pin that this is still diff --git a/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialReadPageCursor.java b/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialReadPageCursor.java index 7b06d078fbdb7..56e02a9e136be 100644 --- a/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialReadPageCursor.java +++ b/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialReadPageCursor.java @@ -388,7 +388,7 @@ private void resetDelegate() throws IOException delegate.shouldRetry(); delegate.setOffset( 0 ); delegate.checkAndClearBoundsFlag(); - delegate.clearCursorError(); + delegate.clearCursorException(); } @Override @@ -413,9 +413,9 @@ public boolean checkAndClearBoundsFlag() } @Override - public void checkAndClearCursorError() throws CursorException + public void checkAndClearCursorException() throws CursorException { - delegate.checkAndClearCursorError(); + delegate.checkAndClearCursorException(); } @Override @@ -425,15 +425,15 @@ public void raiseOutOfBounds() } @Override - public void setCursorError( String message ) + public void setCursorException( String message ) { - delegate.setCursorError( message ); + delegate.setCursorException( message ); } @Override - public void clearCursorError() + public void clearCursorException() { - delegate.clearCursorError(); + delegate.clearCursorException(); } @Override diff --git a/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialWritePageCursor.java b/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialWritePageCursor.java index 70b0d7e7d2840..78a1968193b3b 100644 --- a/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialWritePageCursor.java +++ b/community/io/src/test/java/org/neo4j/adversaries/pagecache/AdversarialWritePageCursor.java @@ -274,9 +274,9 @@ public boolean checkAndClearBoundsFlag() } @Override - public void checkAndClearCursorError() throws CursorException + public void checkAndClearCursorException() throws CursorException { - delegate.checkAndClearCursorError(); + delegate.checkAndClearCursorException(); } @Override @@ -286,15 +286,15 @@ public void raiseOutOfBounds() } @Override - public void setCursorError( String message ) + public void setCursorException( String message ) { - delegate.setCursorError( message ); + delegate.setCursorException( message ); } @Override - public void clearCursorError() + public void clearCursorException() { - delegate.clearCursorError(); + delegate.clearCursorException(); } @Override diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java b/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java index 3d376af2ff5bd..c70a7d707be4b 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java @@ -4152,7 +4152,7 @@ public void shouldRetryMustClearBoundsFlagIfLinkedCursorNeedsRetry() throws Exce } @Test - public void checkAndClearCursorErrorMustNotThrowIfNoErrorIsSet() throws Exception + public void checkAndClearCursorExceptionMustNotThrowIfNoExceptionIsSet() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ) ) @@ -4160,25 +4160,25 @@ public void checkAndClearCursorErrorMustNotThrowIfNoErrorIsSet() throws Exceptio try ( PageCursor cursor = pf.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } try ( PageCursor cursor = pf.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); //noinspection StatementWithEmptyBody do { // nothing } while ( cursor.shouldRetry() ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } } } @Test - public void checkAndClearCursorErrorMustThrowIfErrorIsSet() throws Exception + public void checkAndClearCursorExceptionMustThrowIfExceptionIsSet() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ) ) @@ -4187,8 +4187,8 @@ public void checkAndClearCursorErrorMustThrowIfErrorIsSet() throws Exception try ( PageCursor cursor = pf.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); - cursor.setCursorError( msg ); - cursor.checkAndClearCursorError(); + cursor.setCursorException( msg ); + cursor.checkAndClearCursorException(); fail( "checkAndClearError on write cursor should have thrown" ); } catch ( CursorException e ) @@ -4200,8 +4200,8 @@ public void checkAndClearCursorErrorMustThrowIfErrorIsSet() throws Exception try ( PageCursor cursor = pf.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); - cursor.setCursorError( msg ); - cursor.checkAndClearCursorError(); + cursor.setCursorException( msg ); + cursor.checkAndClearCursorException(); fail( "checkAndClearError on read cursor should have thrown" ); } catch ( CursorException e ) @@ -4212,7 +4212,7 @@ public void checkAndClearCursorErrorMustThrowIfErrorIsSet() throws Exception } @Test - public void checkAndClearCursorErrorMustClearErrorIfSet() throws Exception + public void checkAndClearCursorExceptionMustClearExceptionIfSet() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ) ) @@ -4220,37 +4220,37 @@ public void checkAndClearCursorErrorMustClearErrorIfSet() throws Exception try ( PageCursor cursor = pf.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); try { - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); fail( "checkAndClearError on write cursor should have thrown" ); } catch ( CursorException ignore ) { } - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } try ( PageCursor cursor = pf.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); try { - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); fail( "checkAndClearError on read cursor should have thrown" ); } catch ( CursorException ignore ) { } - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } } } @Test - public void nextMustClearCursorErrorIfSet() throws Exception + public void nextMustClearCursorExceptionIfSet() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ) ) @@ -4258,23 +4258,23 @@ public void nextMustClearCursorErrorIfSet() throws Exception try ( PageCursor cursor = pf.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next() ); - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); assertTrue( cursor.next() ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } try ( PageCursor cursor = pf.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); assertTrue( cursor.next() ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } } } @Test - public void nextWithIdMustClearCursorErrorIfSet() throws Exception + public void nextWithIdMustClearCursorExceptionIfSet() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ) ) @@ -4282,23 +4282,23 @@ public void nextWithIdMustClearCursorErrorIfSet() throws Exception try ( PageCursor cursor = pf.io( 0, PF_SHARED_WRITE_LOCK ) ) { assertTrue( cursor.next( 1 ) ); - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); assertTrue( cursor.next( 2 ) ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } try ( PageCursor cursor = pf.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next( 1 ) ); - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); assertTrue( cursor.next( 2 ) ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } } } @Test - public void shouldRetryMustClearCursorErrorIfItReturnsTrue() throws Exception + public void shouldRetryMustClearCursorExceptionIfItReturnsTrue() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4310,14 +4310,14 @@ public void shouldRetryMustClearCursorErrorIfItReturnsTrue() throws Exception assertTrue( reader.next() ); // now at page id 0 assertTrue( writer.next( 0 ) ); // invalidate the readers lock on page 0 assertTrue( writer.next() ); // move writer out of the way - reader.setCursorError( "boo" ); + reader.setCursorException( "boo" ); assertTrue( reader.shouldRetry() ); // this should clear the cursor error - reader.checkAndClearCursorError(); + reader.checkAndClearCursorException(); } } @Test - public void shouldRetryMustNotClearCursorErrorIfItReturnsFalse() throws Exception + public void shouldRetryMustNotClearCursorExceptionIfItReturnsFalse() throws Exception { File file = file( "a" ); generateFileWithRecords( file, recordCount, recordSize ); @@ -4328,14 +4328,14 @@ public void shouldRetryMustNotClearCursorErrorIfItReturnsFalse() throws Exceptio assertTrue( cursor.next() ); do { - cursor.setCursorError( "boo" ); + cursor.setCursorException( "boo" ); } while ( cursor.shouldRetry() ); // The last shouldRetry has obviously returned 'false' try { - cursor.checkAndClearCursorError(); - fail( "checkAndClearCursorError should have thrown" ); + cursor.checkAndClearCursorException(); + fail( "checkAndClearCursorException should have thrown" ); } catch ( CursorException ignore ) { @@ -4345,7 +4345,7 @@ public void shouldRetryMustNotClearCursorErrorIfItReturnsFalse() throws Exceptio } @Test - public void shouldRetryMustClearCursorErrorIfLinkedShouldRetryReturnsTrue() throws Exception + public void shouldRetryMustClearCursorExceptionIfLinkedShouldRetryReturnsTrue() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4361,15 +4361,15 @@ public void shouldRetryMustClearCursorErrorIfLinkedShouldRetryReturnsTrue() thro assertTrue( linkedReader.next() ); // linked reader now at page id 1 assertTrue( writer.next( 1 ) ); // invalidate linked readers lock assertTrue( writer.next() ); // move writer out of the way - reader.setCursorError( "boo" ); // raise cursor error on parent reader + reader.setCursorException( "boo" ); // raise cursor error on parent reader assertTrue( reader.shouldRetry() ); // we must retry because linked reader was invalidated - reader.checkAndClearCursorError(); // must not throw because shouldRetry returned true + reader.checkAndClearCursorException(); // must not throw because shouldRetry returned true } } } @Test - public void shouldRetryMustClearLinkedCursorErrorIfItReturnsTrue() throws Exception + public void shouldRetryMustClearLinkedCursorExceptionIfItReturnsTrue() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4383,17 +4383,17 @@ public void shouldRetryMustClearLinkedCursorErrorIfItReturnsTrue() throws Except try ( PageCursor linkedReader = reader.openLinkedCursor( 1 ) ) { assertTrue( linkedReader.next() ); // linked reader now at page id 1 - linkedReader.setCursorError( "boo" ); + linkedReader.setCursorException( "boo" ); assertTrue( writer.next( 0 ) ); // invalidate the read lock held by the parent reader assertTrue( reader.shouldRetry() ); // this should clear the linked cursor error - linkedReader.checkAndClearCursorError(); - reader.checkAndClearCursorError(); + linkedReader.checkAndClearCursorException(); + reader.checkAndClearCursorException(); } } } @Test - public void shouldRetryMustClearLinkedCursorErrorIfLinkedShouldRetryReturnsTrue() throws Exception + public void shouldRetryMustClearLinkedCursorExceptionIfLinkedShouldRetryReturnsTrue() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4407,17 +4407,17 @@ public void shouldRetryMustClearLinkedCursorErrorIfLinkedShouldRetryReturnsTrue( try ( PageCursor linkedReader = reader.openLinkedCursor( 1 ) ) { assertTrue( linkedReader.next() ); // linked reader now at page id 1 - linkedReader.setCursorError( "boo" ); + linkedReader.setCursorException( "boo" ); assertTrue( writer.next( 1 ) ); // invalidate the read lock held by the linked reader assertTrue( reader.shouldRetry() ); // this should clear the linked cursor error - linkedReader.checkAndClearCursorError(); - reader.checkAndClearCursorError(); + linkedReader.checkAndClearCursorException(); + reader.checkAndClearCursorException(); } } } @Test - public void shouldRetryMustNotClearCursorErrorIfBothItAndLinkedShouldRetryReturnsFalse() throws Exception + public void shouldRetryMustNotClearCursorExceptionIfBothItAndLinkedShouldRetryReturnsFalse() throws Exception { File file = file( "a" ); generateFileWithRecords( file, recordCount, recordSize ); @@ -4430,13 +4430,13 @@ public void shouldRetryMustNotClearCursorErrorIfBothItAndLinkedShouldRetryReturn assertTrue( linkedReader.next() ); do { - reader.setCursorError( "boo" ); + reader.setCursorException( "boo" ); } while ( reader.shouldRetry() ); try { - reader.checkAndClearCursorError(); - fail( "checkAndClearCursorError should have thrown" ); + reader.checkAndClearCursorException(); + fail( "checkAndClearCursorException should have thrown" ); } catch ( CursorException ignore ) { @@ -4446,7 +4446,7 @@ public void shouldRetryMustNotClearCursorErrorIfBothItAndLinkedShouldRetryReturn } @Test - public void shouldRetryMustNotClearLinkedCursorErrorIfBothItAndLinkedShouldRetryReturnsFalse() throws Exception + public void shouldRetryMustNotClearLinkedCursorExceptionIfBothItAndLinkedShouldRetryReturnsFalse() throws Exception { File file = file( "a" ); generateFileWithRecords( file, recordCount, recordSize ); @@ -4459,13 +4459,13 @@ public void shouldRetryMustNotClearLinkedCursorErrorIfBothItAndLinkedShouldRetry assertTrue( linkedReader.next() ); do { - linkedReader.setCursorError( "boo" ); + linkedReader.setCursorException( "boo" ); } while ( reader.shouldRetry() ); try { - reader.checkAndClearCursorError(); - fail( "checkAndClearCursorError should have thrown" ); + reader.checkAndClearCursorException(); + fail( "checkAndClearCursorException should have thrown" ); } catch ( CursorException ignore ) { @@ -4475,7 +4475,7 @@ public void shouldRetryMustNotClearLinkedCursorErrorIfBothItAndLinkedShouldRetry } @Test - public void checkAndClearCursorErrorMustThrowIfLinkedCursorHasErrorSet() throws Exception + public void checkAndClearCursorExceptionMustThrowIfLinkedCursorHasErrorSet() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4487,11 +4487,11 @@ public void checkAndClearCursorErrorMustThrowIfLinkedCursorHasErrorSet() throws try ( PageCursor linkedWriter = writer.openLinkedCursor( 1 ) ) { assertTrue( linkedWriter.next() ); - linkedWriter.setCursorError( msg ); + linkedWriter.setCursorException( msg ); try { - writer.checkAndClearCursorError(); - fail( "checkAndClearCursorError on writer should have thrown due to linked cursor error" ); + writer.checkAndClearCursorException(); + fail( "checkAndClearCursorException on writer should have thrown due to linked cursor error" ); } catch ( CursorException e ) { @@ -4504,11 +4504,11 @@ public void checkAndClearCursorErrorMustThrowIfLinkedCursorHasErrorSet() throws try ( PageCursor linkedReader = reader.openLinkedCursor( 1 ) ) { assertTrue( linkedReader.next() ); - linkedReader.setCursorError( msg ); + linkedReader.setCursorException( msg ); try { - reader.checkAndClearCursorError(); - fail( "checkAndClearCursorError on reader should have thrown due to linked cursor error" ); + reader.checkAndClearCursorException(); + fail( "checkAndClearCursorException on reader should have thrown due to linked cursor error" ); } catch ( CursorException e ) { @@ -4526,29 +4526,29 @@ public void checkAndClearCursorMustNotThrowIfErrorHasBeenSetButTheCursorHasBeenC { PageCursor writer = pf.io( 0, PF_SHARED_WRITE_LOCK ); assertTrue( writer.next() ); - writer.setCursorError( "boo" ); + writer.setCursorException( "boo" ); writer.close(); - writer.checkAndClearCursorError(); + writer.checkAndClearCursorException(); PageCursor reader = pf.io( 0, PF_SHARED_READ_LOCK ); assertTrue( reader.next() ); - reader.setCursorError( "boo" ); + reader.setCursorException( "boo" ); reader.close(); - reader.checkAndClearCursorError(); + reader.checkAndClearCursorException(); writer = pf.io( 0, PF_SHARED_WRITE_LOCK ); PageCursor linkedWriter = writer.openLinkedCursor( 1 ); assertTrue( linkedWriter.next() ); - linkedWriter.setCursorError( "boo" ); + linkedWriter.setCursorException( "boo" ); writer.close(); - linkedWriter.checkAndClearCursorError(); + linkedWriter.checkAndClearCursorException(); reader = pf.io( 0, PF_SHARED_READ_LOCK ); PageCursor linkedReader = reader.openLinkedCursor( 1 ); assertTrue( linkedReader.next() ); - linkedReader.setCursorError( "boo" ); + linkedReader.setCursorException( "boo" ); reader.close(); - linkedReader.checkAndClearCursorError(); + linkedReader.checkAndClearCursorException(); } } @@ -4587,7 +4587,7 @@ public void openingLinkedCursorOnClosedCursorMustThrow() throws Exception } @Test - public void settingNullCursorErrorMustThrow() throws Exception + public void settingNullCursorExceptionMustThrow() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4597,7 +4597,7 @@ public void settingNullCursorErrorMustThrow() throws Exception assertTrue( writer.next() ); try { - writer.setCursorError( null ); + writer.setCursorException( null ); fail( "setting null cursor error on write cursor should have thrown" ); } catch ( Exception e ) @@ -4608,7 +4608,7 @@ public void settingNullCursorErrorMustThrow() throws Exception assertTrue( reader.next() ); try { - reader.setCursorError( null ); + reader.setCursorException( null ); fail( "setting null cursor error in read cursor should have thrown" ); } catch ( Exception e ) @@ -4619,7 +4619,7 @@ public void settingNullCursorErrorMustThrow() throws Exception } @Test - public void clearCursorErrorMustUnsetErrorCondition() throws Exception + public void clearCursorExceptionMustUnsetErrorCondition() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4627,19 +4627,19 @@ public void clearCursorErrorMustUnsetErrorCondition() throws Exception PageCursor reader = pf.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( writer.next() ); - writer.setCursorError( "boo" ); - writer.clearCursorError(); - writer.checkAndClearCursorError(); + writer.setCursorException( "boo" ); + writer.clearCursorException(); + writer.checkAndClearCursorException(); assertTrue( reader.next() ); - reader.setCursorError( "boo" ); - reader.clearCursorError(); - reader.checkAndClearCursorError(); + reader.setCursorException( "boo" ); + reader.clearCursorException(); + reader.checkAndClearCursorException(); } } @Test - public void clearCursorErrorMustUnsetErrorConditionOnLinkedCursor() throws Exception + public void clearCursorExceptionMustUnsetErrorConditionOnLinkedCursor() throws Exception { getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); try ( PagedFile pf = pageCache.map( file( "a" ), filePageSize ); @@ -4649,16 +4649,16 @@ public void clearCursorErrorMustUnsetErrorConditionOnLinkedCursor() throws Excep assertTrue( writer.next() ); PageCursor linkedWriter = writer.openLinkedCursor( 1 ); assertTrue( linkedWriter.next() ); - linkedWriter.setCursorError( "boo" ); - writer.clearCursorError(); - writer.checkAndClearCursorError(); + linkedWriter.setCursorException( "boo" ); + writer.clearCursorException(); + writer.checkAndClearCursorException(); assertTrue( reader.next() ); PageCursor linkedReader = reader.openLinkedCursor( 1 ); assertTrue( linkedReader.next() ); - linkedReader.setCursorError( "boo" ); - reader.clearCursorError(); - reader.checkAndClearCursorError(); + linkedReader.setCursorException( "boo" ); + reader.clearCursorException(); + reader.checkAndClearCursorException(); } } diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/StubPageCursor.java b/community/io/src/test/java/org/neo4j/io/pagecache/StubPageCursor.java index f3a236dc6ed32..76d22fe364c4a 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/StubPageCursor.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/StubPageCursor.java @@ -139,7 +139,7 @@ public boolean checkAndClearBoundsFlag() } @Override - public void checkAndClearCursorError() throws CursorException + public void checkAndClearCursorException() throws CursorException { String message = this.cursorErrorMessage; if ( message != null ) @@ -155,13 +155,13 @@ public void raiseOutOfBounds() } @Override - public void setCursorError( String message ) + public void setCursorException( String message ) { this.cursorErrorMessage = message; } @Override - public void clearCursorError() + public void clearCursorException() { this.cursorErrorMessage = null; } diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/impl/CompositePageCursorTest.java b/community/io/src/test/java/org/neo4j/io/pagecache/impl/CompositePageCursorTest.java index 629696bf392bb..9565444d11d88 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/impl/CompositePageCursorTest.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/impl/CompositePageCursorTest.java @@ -1155,11 +1155,11 @@ public void setCursorErrorMustApplyToCursorAtCurrentOffset() throws Exception String firstMsg = "first boo"; String secondMsg = "second boo"; - cursor.setCursorError( firstMsg ); + cursor.setCursorException( firstMsg ); assertFalse( cursor.checkAndClearBoundsFlag() ); try { - first.checkAndClearCursorError(); + first.checkAndClearCursorException(); fail( "first checkAndClearCursorError should have thrown" ); } catch ( CursorException e ) @@ -1168,11 +1168,11 @@ public void setCursorErrorMustApplyToCursorAtCurrentOffset() throws Exception } cursor.setOffset( PAGE_SIZE ); - cursor.setCursorError( secondMsg ); + cursor.setCursorException( secondMsg ); assertFalse( cursor.checkAndClearBoundsFlag() ); try { - second.checkAndClearCursorError(); + second.checkAndClearCursorException(); fail( "second checkAndClearCursorError should have thrown" ); } catch ( CursorException e ) @@ -1185,17 +1185,17 @@ public void setCursorErrorMustApplyToCursorAtCurrentOffset() throws Exception public void checkAndClearCursorErrorMustNotThrowIfNoErrorsAreSet() throws Exception { PageCursor cursor = CompositePageCursor.compose( first, PAGE_SIZE, second, PAGE_SIZE ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } @Test public void checkAndClearCursorErrorMustThrowIfFirstCursorHasError() throws Exception { PageCursor cursor = CompositePageCursor.compose( first, PAGE_SIZE, second, PAGE_SIZE ); - first.setCursorError( "boo" ); + first.setCursorException( "boo" ); try { - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); fail( "composite cursor checkAndClearCursorError should have thrown" ); } catch ( CursorException e ) @@ -1208,10 +1208,10 @@ public void checkAndClearCursorErrorMustThrowIfFirstCursorHasError() throws Exce public void checkAndClearCursorErrorMustThrowIfSecondCursorHasError() throws Exception { PageCursor cursor = CompositePageCursor.compose( first, PAGE_SIZE, second, PAGE_SIZE ); - second.setCursorError( "boo" ); + second.setCursorException( "boo" ); try { - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); fail( "composite cursor checkAndClearCursorError should have thrown" ); } catch ( CursorException e ) @@ -1224,11 +1224,11 @@ public void checkAndClearCursorErrorMustThrowIfSecondCursorHasError() throws Exc public void checkAndClearCursorErrorWillOnlyCheckFirstCursorIfBothHaveErrorsSet() throws Exception { PageCursor cursor = CompositePageCursor.compose( first, PAGE_SIZE, second, PAGE_SIZE ); - first.setCursorError( "first boo" ); - second.setCursorError( "second boo" ); + first.setCursorException( "first boo" ); + second.setCursorException( "second boo" ); try { - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); fail( "composite cursor checkAndClearCursorError should have thrown" ); } catch ( CursorException e ) @@ -1237,7 +1237,7 @@ public void checkAndClearCursorErrorWillOnlyCheckFirstCursorIfBothHaveErrorsSet( } try { - second.checkAndClearCursorError(); + second.checkAndClearCursorException(); fail( "second cursor checkAndClearCursorError should have thrown" ); } catch ( CursorException e ) @@ -1250,13 +1250,13 @@ public void checkAndClearCursorErrorWillOnlyCheckFirstCursorIfBothHaveErrorsSet( public void clearCursorErrorMustClearBothCursors() throws Exception { PageCursor cursor = CompositePageCursor.compose( first, PAGE_SIZE, second, PAGE_SIZE ); - first.setCursorError( "first boo" ); - second.setCursorError( "second boo" ); - cursor.clearCursorError(); + first.setCursorException( "first boo" ); + second.setCursorException( "second boo" ); + cursor.clearCursorException(); // Now these must not throw - first.checkAndClearCursorError(); - second.checkAndClearCursorError(); - cursor.checkAndClearCursorError(); + first.checkAndClearCursorException(); + second.checkAndClearCursorException(); + cursor.checkAndClearCursorException(); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/DynamicRecordFormat.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/DynamicRecordFormat.java index cc2bd80de3a56..d0d40449c05e5 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/DynamicRecordFormat.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/DynamicRecordFormat.java @@ -69,7 +69,7 @@ public void read( DynamicRecord record, PageCursor cursor, RecordLoad mode, int { // We must have performed an inconsistent read, // because this many bytes cannot possibly fit in a record! - cursor.setCursorError( payloadTooBigErrorMessage( record, recordSize, nrOfBytes ) ); + cursor.setCursorException( payloadTooBigErrorMessage( record, recordSize, nrOfBytes ) ); return; } @@ -84,7 +84,7 @@ public void read( DynamicRecord record, PageCursor cursor, RecordLoad mode, int if ( longNextBlock != Record.NO_NEXT_BLOCK.intValue() && nrOfBytes < dataSize || nrOfBytes > dataSize ) { - cursor.setCursorError( illegalBlockSizeMessage( record, dataSize ) ); + cursor.setCursorException( illegalBlockSizeMessage( record, dataSize ) ); return; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/PropertyRecordFormat.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/PropertyRecordFormat.java index ec3eb6fdb981e..f32fb2ce44ca5 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/PropertyRecordFormat.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/standard/PropertyRecordFormat.java @@ -81,13 +81,13 @@ public void read( PropertyRecord record, PageCursor cursor, RecordLoad mode, int int numberOfBlocksUsed = type.calculateNumberOfBlocksUsed( block ); if ( numberOfBlocksUsed == PropertyType.BLOCKS_USED_FOR_BAD_TYPE_OR_ENCODING ) { - cursor.setCursorError( "Invalid type or encoding of property block: " + block + " (type = " + type + ")" ); + cursor.setCursorException( "Invalid type or encoding of property block: " + block + " (type = " + type + ")" ); return; } int additionalBlocks = numberOfBlocksUsed - 1; if ( additionalBlocks * 8 > RECORD_SIZE - (cursor.getOffset() - offsetAtBeginning ) ) { - cursor.setCursorError( "PropertyRecord claims to have more property blocks than can fit in a record" ); + cursor.setCursorException( "PropertyRecord claims to have more property blocks than can fit in a record" ); return; } while ( additionalBlocks --> 0 ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/record/RecordLoad.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/record/RecordLoad.java index 5287af091291f..1f0cb99c3a3ed 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/record/RecordLoad.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/record/RecordLoad.java @@ -77,7 +77,7 @@ public final void clearOrThrowCursorError( PageCursor cursor ) { try { - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); } catch ( CursorException e ) { @@ -88,7 +88,7 @@ public final void clearOrThrowCursorError( PageCursor cursor ) { // The CHECK and FORCE modes do not bother with reporting decoding errors... // ... but they must still clear them, since the page cursor may be reused to read other records - cursor.clearCursorError(); + cursor.clearCursorException(); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/CommonAbstractStoreBehaviourTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/CommonAbstractStoreBehaviourTest.java index aad21bff59478..a6baeb2744d17 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/CommonAbstractStoreBehaviourTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/CommonAbstractStoreBehaviourTest.java @@ -348,7 +348,7 @@ private void maybeSetCursorError( PageCursor cursor, long id ) { if ( cursorErrorOnRecord == id ) { - cursor.setCursorError( "boom" ); + cursor.setCursorException( "boom" ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatTest.java index 073ccee4119f3..ce9b7f5a857b9 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/RecordFormatTest.java @@ -222,7 +222,7 @@ private void readAndVerifyRecord( R written, R re } while ( cursor.shouldRetry() ); assertFalse( "Out-of-bounds when reading record " + written, cursor.checkAndClearBoundsFlag() ); - cursor.checkAndClearCursorError(); + cursor.checkAndClearCursorException(); // THEN if ( written.inUse() ) diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/BaseHighLimitRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/BaseHighLimitRecordFormat.java index 0664078ca1817..2a98d17b534a1 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/BaseHighLimitRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/BaseHighLimitRecordFormat.java @@ -106,7 +106,7 @@ public void read( RECORD record, PageCursor primaryCursor, RecordLoad mode, int // it may only be read as part of reading the primary unit. record.clear(); // Return and try again - primaryCursor.setCursorError( + primaryCursor.setCursorException( "Expected record to be the first unit in the chain, but record header says it's not" ); return; } @@ -123,7 +123,7 @@ public void read( RECORD record, PageCursor primaryCursor, RecordLoad mode, int // We must have made an inconsistent read of the secondary record unit reference. // No point in trying to read this. record.clear(); - primaryCursor.setCursorError( illegalSecondaryReferenceMessage( pageId ) ); + primaryCursor.setCursorException( illegalSecondaryReferenceMessage( pageId ) ); return; } secondaryCursor.setOffset( offset + HEADER_BYTE); diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/DynamicRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/DynamicRecordFormat.java index 6e4e3d76dc263..05681eeabc1b1 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/DynamicRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/DynamicRecordFormat.java @@ -72,7 +72,7 @@ public void read( DynamicRecord record, PageCursor cursor, RecordLoad mode, int int length = cursor.getShort() | cursor.getByte() << 16; if ( length > recordSize | length < 0 ) { - cursor.setCursorError( payloadLengthErrorMessage( record, recordSize, length ) ); + cursor.setCursorException( payloadLengthErrorMessage( record, recordSize, length ) ); return; } long next = cursor.getLong(); diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java index ac5f0771b0a19..8727a81006581 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java @@ -78,7 +78,7 @@ public void read( PropertyRecord record, PageCursor cursor, RecordLoad mode, int toAbsolute( Reference.decode( cursor ), recordId ) ); if ( (blockCount > record.getBlockCapacity()) | (RECORD_SIZE - (cursor.getOffset() - offset) < blockCount * Long.BYTES) ) { - cursor.setCursorError( "PropertyRecord claims to contain more blocks than can fit in a record" ); + cursor.setCursorException( "PropertyRecord claims to contain more blocks than can fit in a record" ); return; } while ( blockCount-- > 0 )