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
{
void pack( String value );
void pack( String 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();

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

interface Unpacker
{
AnyValue unpack() throws IOException;

String unpackString();
String unpackString() 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();
}
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 List<Neo4jError> errors = new ArrayList<>( 2 );

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

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

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

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

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

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

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

private void handleAfterChange() throws IOException
private void handleAfterChange()
{
if ( structurePropagation.hasRightKeyInsert )
{
Expand Down
Expand Up @@ -59,7 +59,6 @@
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.api.exceptions.TransactionFailureException;
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.schema.index.IndexDescriptor;
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 long transactionId;
private long commitTime;
private volatile int reuseCount;
private volatile int reuseCount; // TODO: why volatile?
private volatile Map<String,Object> userMetaData;
private final Operations operations;

Expand Down Expand Up @@ -395,16 +394,8 @@ private void dropCreatedConstraintIndexes() throws TransactionFailureException
{
for ( IndexDescriptor createdConstraintIndex : txState().constraintIndexesCreatedInTx() )
{
try
{
// 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 );
}
// TODO logically, which statement should this operation be performed on?
constraintIndexCreator.dropUniquenessConstraintIndex( createdConstraintIndex );
}
}
}
Expand Down
Expand Up @@ -21,10 +21,8 @@

import java.util.ArrayList;

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

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

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

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

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

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

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

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 );
while ( cursor.next() )
{
Expand Down
Expand Up @@ -82,28 +82,4 @@ public interface IndexImplementation extends Lifecycle
* @throws IOException depends on the implementation
*/
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();
}
catch ( InterruptedException e )
{
Thread.currentThread().interrupt();
}
finally
{
out.flush();
Expand Down
Expand Up @@ -150,17 +150,17 @@ private synchronized PrimitiveLongResourceIterator rangeSeekByString( String low

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 )
{
return stringSearch( ( String entry ) -> entry.contains( exactTerm ) );
return stringSearch( entry -> entry.contains( exactTerm ) );
}

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

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

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

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

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

private PluginManager plugins;

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

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

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

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

private URI restApiUri()
Expand Down

0 comments on commit b3b8ea4

Please sign in to comment.