Skip to content

Commit

Permalink
Fix compilation errors after remove redundant throws
Browse files Browse the repository at this point in the history
  • Loading branch information
klaren committed Feb 9, 2018
1 parent 7216ad9 commit b3b8ea4
Show file tree
Hide file tree
Showing 39 changed files with 142 additions and 280 deletions.
Expand Up @@ -35,34 +35,34 @@ public interface Neo4jPack
{ {
interface Packer interface Packer
{ {
void pack( String value ); void pack( String value ) throws IOException;


void pack( AnyValue value ) throws IOException; void pack( AnyValue value ) throws IOException;


void packStructHeader( int size, byte signature ); void packStructHeader( int size, byte signature ) throws IOException;


void packMapHeader( int size ); void packMapHeader( int size ) throws IOException;


void packListHeader( int size ); void packListHeader( int size ) throws IOException;


IOException consumeError(); IOException consumeError();


void flush(); void flush() throws IOException;
} }


interface Unpacker interface Unpacker
{ {
AnyValue unpack() throws IOException; AnyValue unpack() throws IOException;


String unpackString(); String unpackString() throws IOException;


MapValue unpackMap() throws IOException; MapValue unpackMap() throws IOException;


long unpackStructHeader(); long unpackStructHeader() throws IOException;


char unpackStructSignature(); char unpackStructSignature() throws IOException;


long unpackListHeader(); long unpackListHeader() throws IOException;


Neo4jError consumeError(); Neo4jError consumeError();
} }
Expand Down
Expand Up @@ -444,7 +444,6 @@ public void writeByteArray( byte[] value ) throws IOException


private static class Unpacker extends PackStream.Unpacker implements Neo4jPack.Unpacker private static class Unpacker extends PackStream.Unpacker implements Neo4jPack.Unpacker
{ {

private List<Neo4jError> errors = new ArrayList<>( 2 ); private List<Neo4jError> errors = new ArrayList<>( 2 );


Unpacker( PackInput input ) Unpacker( PackInput input )
Expand Down
Expand Up @@ -1903,22 +1903,15 @@ public void shouldCatchupRootWhenNodeHasTooNewGenerationWhileTraversingDownTree(
// a root catchup that records usage // a root catchup that records usage
Supplier<Root> rootCatchup = () -> Supplier<Root> rootCatchup = () ->
{ {
try triggered.setTrue();
{
triggered.setTrue();


// and set child generation to match pointer // and set child generation to match pointer
cursor.next( leftChild ); cursor.next( leftChild );
cursor.zapPage(); cursor.zapPage();
node.initializeLeaf( cursor, stableGeneration, unstableGeneration ); node.initializeLeaf( cursor, stableGeneration, unstableGeneration );


cursor.next( rootId ); cursor.next( rootId );
return new Root( rootId, generation ); return new Root( rootId, generation );
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
}; };


// when // when
Expand Down Expand Up @@ -1950,17 +1943,10 @@ public void shouldCatchupRootWhenNodeHasTooNewGenerationWhileTraversingLeaves()


Supplier<Root> rootCatchup = () -> Supplier<Root> rootCatchup = () ->
{ {
try // Use right child as new start over root to terminate test
{ cursor.next( rightChild );
// Use right child as new start over root to terminate test triggered.setTrue();
cursor.next( rightChild ); return new Root( cursor.getCurrentPageId(), TreeNode.generation( cursor ) );
triggered.setTrue();
return new Root( cursor.getCurrentPageId(), TreeNode.generation( cursor ) );
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
}; };


// a left leaf // a left leaf
Expand Down Expand Up @@ -2132,7 +2118,7 @@ private void checkpoint()
unstableGeneration++; unstableGeneration++;
} }


private void newRootFromSplit( StructurePropagation<KEY> split ) throws IOException private void newRootFromSplit( StructurePropagation<KEY> split )
{ {
assertTrue( split.hasRightKeyInsert ); assertTrue( split.hasRightKeyInsert );
long rootId = id.acquireNewId( stableGeneration, unstableGeneration ); long rootId = id.acquireNewId( stableGeneration, unstableGeneration );
Expand Down Expand Up @@ -2177,7 +2163,7 @@ private void remove( long key ) throws IOException
handleAfterChange(); handleAfterChange();
} }


private void handleAfterChange() throws IOException private void handleAfterChange()
{ {
if ( structurePropagation.hasRightKeyInsert ) if ( structurePropagation.hasRightKeyInsert )
{ {
Expand Down
Expand Up @@ -59,7 +59,6 @@
import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.api.exceptions.TransactionFailureException; import org.neo4j.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException; import org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException;
import org.neo4j.kernel.api.exceptions.schema.DropIndexFailureException;
import org.neo4j.kernel.api.explicitindex.AutoIndexing; import org.neo4j.kernel.api.explicitindex.AutoIndexing;
import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.txstate.ExplicitIndexTransactionState; import org.neo4j.kernel.api.txstate.ExplicitIndexTransactionState;
Expand Down Expand Up @@ -160,7 +159,7 @@ public class KernelTransactionImplementation implements KernelTransaction, TxSta
private Type type; private Type type;
private long transactionId; private long transactionId;
private long commitTime; private long commitTime;
private volatile int reuseCount; private volatile int reuseCount; // TODO: why volatile?
private volatile Map<String,Object> userMetaData; private volatile Map<String,Object> userMetaData;
private final Operations operations; private final Operations operations;


Expand Down Expand Up @@ -395,16 +394,8 @@ private void dropCreatedConstraintIndexes() throws TransactionFailureException
{ {
for ( IndexDescriptor createdConstraintIndex : txState().constraintIndexesCreatedInTx() ) for ( IndexDescriptor createdConstraintIndex : txState().constraintIndexesCreatedInTx() )
{ {
try // TODO logically, which statement should this operation be performed on?
{ constraintIndexCreator.dropUniquenessConstraintIndex( createdConstraintIndex );
// TODO logically, which statement should this operation be performed on?
constraintIndexCreator.dropUniquenessConstraintIndex( createdConstraintIndex );
}
catch ( DropIndexFailureException e )
{
throw new IllegalStateException( "Constraint index that was created in a transaction should be " +
"possible to drop during rollback of that transaction.", e );
}
} }
} }
} }
Expand Down
Expand Up @@ -21,10 +21,8 @@


import java.util.ArrayList; import java.util.ArrayList;


import org.neo4j.graphdb.ConstraintViolationException;
import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.schema.ConstraintDefinition; import org.neo4j.graphdb.schema.ConstraintDefinition;
import org.neo4j.internal.kernel.api.exceptions.KernelException;


public class NodePropertyUniqueConstraintCreator extends BaseNodeConstraintCreator public class NodePropertyUniqueConstraintCreator extends BaseNodeConstraintCreator
{ {
Expand All @@ -47,17 +45,9 @@ public final ConstraintDefinition create()
{ {
assertInUnterminatedTransaction(); assertInUnterminatedTransaction();


try IndexDefinitionImpl definition =
{ new IndexDefinitionImpl( actions, label, propertyKeys.toArray( new String[propertyKeys.size()] ),
IndexDefinitionImpl definition = true );
new IndexDefinitionImpl( actions, label, propertyKeys.toArray( new String[propertyKeys.size()] ), return actions.createPropertyUniquenessConstraint( definition );
true );
return actions.createPropertyUniquenessConstraint( definition );
}
catch ( KernelException e )
{
String userMessage = actions.getUserMessage( e );
throw new ConstraintViolationException( userMessage, e );
}
} }
} }
Expand Up @@ -68,25 +68,25 @@ public CommunityLockClient( LockManagerImpl manager )
{ {
this.manager = manager; this.manager = manager;


readReleaser = ( long key, LockResource lockResource ) -> readReleaser = ( key, lockResource ) ->
{ {
manager.releaseReadLock( lockResource, lockTransaction ); manager.releaseReadLock( lockResource, lockTransaction );
return false; return false;
}; };


writeReleaser = ( long key, LockResource lockResource ) -> writeReleaser = ( key, lockResource ) ->
{ {
manager.releaseWriteLock( lockResource, lockTransaction ); manager.releaseWriteLock( lockResource, lockTransaction );
return false; return false;
}; };


typeReadReleaser = ( int key, PrimitiveLongObjectMap<LockResource> value ) -> typeReadReleaser = ( key, value ) ->
{ {
value.visitEntries( readReleaser ); value.visitEntries( readReleaser );
return false; return false;
}; };


typeWriteReleaser = ( int key, PrimitiveLongObjectMap<LockResource> value ) -> typeWriteReleaser = ( key, value ) ->
{ {
value.visitEntries( writeReleaser ); value.visitEntries( writeReleaser );
return false; return false;
Expand Down
Expand Up @@ -48,7 +48,7 @@ public static TransactionalContextFactory create(
{ {
Supplier<GraphDatabaseQueryService> queryService = lazySingleton( spi::queryService ); Supplier<GraphDatabaseQueryService> queryService = lazySingleton( spi::queryService );
Neo4jTransactionalContext.Creator contextCreator = Neo4jTransactionalContext.Creator contextCreator =
( Supplier<Statement> statementSupplier, InternalTransaction tx, Statement initialStatement, ExecutingQuery executingQuery ) -> ( statementSupplier, tx, initialStatement, executingQuery ) ->
new Neo4jTransactionalContext( new Neo4jTransactionalContext(
queryService.get(), queryService.get(),
statementSupplier, statementSupplier,
Expand All @@ -72,7 +72,7 @@ public static TransactionalContextFactory create(
ThreadToStatementContextBridge txBridge = resolver.resolveDependency( ThreadToStatementContextBridge.class ); ThreadToStatementContextBridge txBridge = resolver.resolveDependency( ThreadToStatementContextBridge.class );
Guard guard = resolver.resolveDependency( Guard.class ); Guard guard = resolver.resolveDependency( Guard.class );
Neo4jTransactionalContext.Creator contextCreator = Neo4jTransactionalContext.Creator contextCreator =
( Supplier<Statement> statementSupplier, InternalTransaction tx, Statement initialStatement, ExecutingQuery executingQuery ) -> ( statementSupplier, tx, initialStatement, executingQuery ) ->
new Neo4jTransactionalContext( new Neo4jTransactionalContext(
queryService, queryService,
statementSupplier, statementSupplier,
Expand Down
Expand Up @@ -614,8 +614,7 @@ private <RECORD extends PrimitiveRecord> BiConsumer<InputEntityVisitor,RECORD> p
} }


final StorePropertyCursor cursor = new StorePropertyCursor( cursors, ignored -> {} ); final StorePropertyCursor cursor = new StorePropertyCursor( cursors, ignored -> {} );
return ( InputEntityVisitor entity, RECORD record ) -> return ( entity, record ) -> {
{
cursor.init( record.getNextProp(), LockService.NO_LOCK, AssertOpen.ALWAYS_OPEN ); cursor.init( record.getNextProp(), LockService.NO_LOCK, AssertOpen.ALWAYS_OPEN );
while ( cursor.next() ) while ( cursor.next() )
{ {
Expand Down
Expand Up @@ -82,28 +82,4 @@ public interface IndexImplementation extends Lifecycle
* @throws IOException depends on the implementation * @throws IOException depends on the implementation
*/ */
ResourceIterator<File> listStoreFiles() throws IOException; ResourceIterator<File> listStoreFiles() throws IOException;

/**
* Makes available index resource for recovery.
*/
@Override
void init();

/**
* Makes available index resource for online transaction processing.
*/
@Override
void start() throws Throwable;

/**
* Makes unavailable index resource from online transaction processing.
*/
@Override
void stop() throws Throwable;

/**
* Makes unavailable the index resource as a whole.
*/
@Override
void shutdown() throws Throwable;
} }
Expand Up @@ -150,10 +150,6 @@ public void close()
{ {
logger.awaitTermination(); logger.awaitTermination();
} }
catch ( InterruptedException e )
{
Thread.currentThread().interrupt();
}
finally finally
{ {
out.flush(); out.flush();
Expand Down
Expand Up @@ -150,17 +150,17 @@ private synchronized PrimitiveLongResourceIterator rangeSeekByString( String low


private synchronized PrimitiveLongResourceIterator rangeSeekByPrefix( String prefix ) private synchronized PrimitiveLongResourceIterator rangeSeekByPrefix( String prefix )
{ {
return stringSearch( ( String entry ) -> entry.startsWith( prefix ) ); return stringSearch( entry -> entry.startsWith( prefix ) );
} }


private synchronized PrimitiveLongResourceIterator containsString( String exactTerm ) private synchronized PrimitiveLongResourceIterator containsString( String exactTerm )
{ {
return stringSearch( ( String entry ) -> entry.contains( exactTerm ) ); return stringSearch( entry -> entry.contains( exactTerm ) );
} }


private PrimitiveLongResourceIterator endsWith( String suffix ) private PrimitiveLongResourceIterator endsWith( String suffix )
{ {
return stringSearch( ( String entry ) -> entry.endsWith( suffix ) ); return stringSearch( entry -> entry.endsWith( suffix ) );
} }


private synchronized PrimitiveLongResourceIterator scan() private synchronized PrimitiveLongResourceIterator scan()
Expand Down
Expand Up @@ -214,14 +214,7 @@ public void awaitingShutdownMustBlockUntilAllMessagesHaveBeenProcessed() throws
Future<?> awaitShutdownFuture = executor.submit( () -> Future<?> awaitShutdownFuture = executor.submit( () ->
{ {
awaitStartLatch.countDown(); awaitStartLatch.countDown();
try asyncEvents.awaitTermination();
{
asyncEvents.awaitTermination();
}
catch ( InterruptedException e )
{
throw new RuntimeException( e );
}
consumer.eventsProcessed.offer( specialShutdownObservedEvent ); consumer.eventsProcessed.offer( specialShutdownObservedEvent );
} ); } );


Expand Down
Expand Up @@ -20,13 +20,11 @@
package org.neo4j.server.modules; package org.neo4j.server.modules;


import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.util.List; import java.util.List;


import org.neo4j.concurrent.RecentK; import org.neo4j.concurrent.RecentK;
import org.neo4j.graphdb.DependencyResolver; import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.logging.Log;
import org.neo4j.logging.LogProvider; import org.neo4j.logging.LogProvider;
import org.neo4j.server.configuration.ServerSettings; import org.neo4j.server.configuration.ServerSettings;
import org.neo4j.server.plugins.PluginManager; import org.neo4j.server.plugins.PluginManager;
Expand All @@ -53,7 +51,6 @@ public class RESTApiModule implements ServerModule
private final WebServer webServer; private final WebServer webServer;
private DependencyResolver dependencyResolver; private DependencyResolver dependencyResolver;
private final LogProvider logProvider; private final LogProvider logProvider;
private final Log log;


private PluginManager plugins; private PluginManager plugins;


Expand All @@ -64,24 +61,16 @@ public RESTApiModule( WebServer webServer, Config config, DependencyResolver dep
this.config = config; this.config = config;
this.dependencyResolver = dependencyResolver; this.dependencyResolver = dependencyResolver;
this.logProvider = logProvider; this.logProvider = logProvider;
this.log = logProvider.getLog( getClass() );
} }


@Override @Override
public void start() public void start()
{ {
try URI restApiUri = restApiUri( );
{
URI restApiUri = restApiUri( );


webServer.addFilter( new CollectUserAgentFilter( clientNames() ), "/*" ); webServer.addFilter( new CollectUserAgentFilter( clientNames() ), "/*" );
webServer.addJAXRSClasses( getClassNames(), restApiUri.toString(), null ); webServer.addJAXRSClasses( getClassNames(), restApiUri.toString(), null );
loadPlugins(); loadPlugins();
}
catch ( URISyntaxException e )
{
log.warn( "Unable to mount REST API", e );
}
} }


/** /**
Expand Down Expand Up @@ -111,15 +100,8 @@ private List<String> getClassNames()
@Override @Override
public void stop() public void stop()
{ {
try webServer.removeJAXRSClasses( getClassNames(), restApiUri().toString() );
{ unloadPlugins();
webServer.removeJAXRSClasses( getClassNames(), restApiUri().toString() );
unloadPlugins();
}
catch ( URISyntaxException e )
{
log.warn( "Unable to unmount REST API", e );
}
} }


private URI restApiUri() private URI restApiUri()
Expand Down

0 comments on commit b3b8ea4

Please sign in to comment.