    @Override
    public Response<Void> finishTransaction( RequestContext context, final boolean success )
    {
        try
        {
            return sendRequest( HaRequestType153.FINISH, context, new Serializer()
            {
                @Override
                public void write( ChannelBuffer buffer, ByteBuffer readBuffer ) throws IOException
                {
                    buffer.writeByte( success ? 1 : 0 );
                }
            }, VOID_DESERIALIZER );
        }
        catch ( UnableToResumeTransactionException e )
        {
            if ( !success )
            {
                /* Here we are in a state where the client failed while the request
                 * was processing on the server and the tx.finish() in the usual
                 * try-finally transaction block gets called, only to find that
                 * the transaction is already active... which is totally expected.
                 * The fact that the transaction is already active here shouldn't
                 * hide the original exception on the client, the exception which
                 * cause the client to fail while the request was processing on the master.
                 * This is effectively the use case of awaiting a lock that isn't granted
                 * within the lock read timeout period.
                 */
                return new Response<>( null, getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP );
            }
            throw e;
        }
    }

    @Override
    public Response<Void> finishTransaction( RequestContext context, final boolean success )
    {
        try
        {
            return sendRequest( HaRequestType153.FINISH, context, new Serializer()
            {
                @Override
                public void write( ChannelBuffer buffer, ByteBuffer readBuffer ) throws IOException
                {
                    buffer.writeByte( success ? 1 : 0 );
                }
            }, VOID_DESERIALIZER );
        }
        catch ( UnableToResumeTransactionException e )
        {
            if ( !success )
            {
                /* Here we are in a state where the client failed while the request
                 * was processing on the server and the tx.finish() in the usual
                 * try-finally transaction block gets called, only to find that
                 * the transaction is already active... which is totally expected.
                 * The fact that the transaction is already active here shouldn't
                 * hide the original exception on the client, the exception which
                 * cause the client to fail while the request was processing on the master.
                 * This is effectively the use case of awaiting a lock that isn't granted
                 * within the lock read timeout period.
                 */
                return new Response<Void>( null, getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP );
            }
            throw e;
        }
    }

Replace Generic With Diamond Response<Void> with Response<> in method public finishTransaction(context RequestContext, success boolean) : Response<Void> from class org.neo4j.kernel.ha.com.slave.MasterClient153


    @Override
    public Response<Void> finishTransaction( RequestContext context, final boolean success )
    {
        try
        {
            return sendRequest( HaRequestType17.FINISH, context, new Serializer()
            {
                @Override
                public void write( ChannelBuffer buffer, ByteBuffer readBuffer ) throws IOException
                {
                    buffer.writeByte( success ? 1 : 0 );
                }
            }, VOID_DESERIALIZER );
        }
        catch ( UnableToResumeTransactionException e )
        {
            if ( !success )
            {
                /* Here we are in a state where the client failed while the request
                 * was processing on the server and the tx.finish() in the usual
                 * try-finally transaction block gets called, only to find that
                 * the transaction is already active... which is totally expected.
                 * The fact that the transaction is already active here shouldn't
                 * hide the original exception on the client, the exception which
                 * cause the client to fail while the request was processing on the master.
                 * This is effectively the use case of awaiting a lock that isn't granted
                 * within the lock read timeout period.
                 */
                return new Response<>( null, getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP );
            }
            throw e;
        }
    }

    @Override
    public Response<Void> finishTransaction( RequestContext context, final boolean success )
    {
        try
        {
            return sendRequest( HaRequestType17.FINISH, context, new Serializer()
            {
                @Override
                public void write( ChannelBuffer buffer, ByteBuffer readBuffer ) throws IOException
                {
                    buffer.writeByte( success ? 1 : 0 );
                }
            }, VOID_DESERIALIZER );
        }
        catch ( UnableToResumeTransactionException e )
        {
            if ( !success )
            {
                /* Here we are in a state where the client failed while the request
                 * was processing on the server and the tx.finish() in the usual
                 * try-finally transaction block gets called, only to find that
                 * the transaction is already active... which is totally expected.
                 * The fact that the transaction is already active here shouldn't
                 * hide the original exception on the client, the exception which
                 * cause the client to fail while the request was processing on the master.
                 * This is effectively the use case of awaiting a lock that isn't granted
                 * within the lock read timeout period.
                 */
                return new Response<Void>( null, getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP );
            }
            throw e;
        }
    }

Replace Generic With Diamond Response<Void> with Response<> in method public finishTransaction(context RequestContext, success boolean) : Response<Void> from class org.neo4j.kernel.ha.com.slave.MasterClient17


    @Override
    public Response<Void> finishTransaction( RequestContext context, final boolean success )
    {
        try
        {
            return sendRequest( HaRequestType18.FINISH, context, new Serializer()
            {
                @Override
                public void write( ChannelBuffer buffer, ByteBuffer readBuffer ) throws IOException
                {
                    buffer.writeByte( success ? 1 : 0 );
                }
            }, VOID_DESERIALIZER );
        }
        catch ( UnableToResumeTransactionException e )
        {
            if ( !success )
            {
                /* Here we are in a state where the client failed while the request
                 * was processing on the server and the tx.finish() in the usual
                 * try-finally transaction block gets called, only to find that
                 * the transaction is already active... which is totally expected.
                 * The fact that the transaction is already active here shouldn't
                 * hide the original exception on the client, the exception which
                 * cause the client to fail while the request was processing on the master.
                 * This is effectively the use case of awaiting a lock that isn't granted
                 * within the lock read timeout period.
                 */
                return new Response<>( null, getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP );
            }
            throw e;
        }
    }

    @Override
    public Response<Void> finishTransaction( RequestContext context, final boolean success )
    {
        try
        {
            return sendRequest( HaRequestType18.FINISH, context, new Serializer()
            {
                @Override
                public void write( ChannelBuffer buffer, ByteBuffer readBuffer ) throws IOException
                {
                    buffer.writeByte( success ? 1 : 0 );
                }
            }, VOID_DESERIALIZER );
        }
        catch ( UnableToResumeTransactionException e )
        {
            if ( !success )
            {
                /* Here we are in a state where the client failed while the request
                 * was processing on the server and the tx.finish() in the usual
                 * try-finally transaction block gets called, only to find that
                 * the transaction is already active... which is totally expected.
                 * The fact that the transaction is already active here shouldn't
                 * hide the original exception on the client, the exception which
                 * cause the client to fail while the request was processing on the master.
                 * This is effectively the use case of awaiting a lock that isn't granted
                 * within the lock read timeout period.
                 */
                return new Response<Void>( null, getStoreId(), TransactionStream.EMPTY, ResourceReleaser.NO_OP );
            }
            throw e;
        }
    }

Replace Generic With Diamond Response<Void> with Response<> in method public finishTransaction(context RequestContext, success boolean) : Response<Void> from class org.neo4j.kernel.ha.com.slave.MasterClient18


        /**
         * @param except do not return any of the dbs found in this array
         * @return a slave in this cluster.
         * @throws IllegalStateException if no slave was found in this cluster.
         */
        public HighlyAvailableGraphDatabase getAnySlave( HighlyAvailableGraphDatabase... except )
        {
            Set<HighlyAvailableGraphDatabase> exceptSet = new HashSet<>( asList( except ) );
            for ( HighlyAvailableGraphDatabase graphDatabaseService : getAllMembers() )
            {
                if ( graphDatabaseService.getInstanceState().equals( "SLAVE" ) && !exceptSet.contains(
                        graphDatabaseService ) )
                {
                    return graphDatabaseService;
                }
            }

            throw new IllegalStateException( "No slave found in cluster " + name );
        }

        /**
         * @param except do not return any of the dbs found in this array
         * @return a slave in this cluster.
         * @throws IllegalStateException if no slave was found in this cluster.
         */
        public HighlyAvailableGraphDatabase getAnySlave( HighlyAvailableGraphDatabase... except )
        {
            Set<HighlyAvailableGraphDatabase> exceptSet = new HashSet<HighlyAvailableGraphDatabase>( asList( except ) );
            for ( HighlyAvailableGraphDatabase graphDatabaseService : getAllMembers() )
            {
                if ( graphDatabaseService.getInstanceState().equals( "SLAVE" ) && !exceptSet.contains(
                        graphDatabaseService ) )
                {
                    return graphDatabaseService;
                }
            }

            throw new IllegalStateException( "No slave found in cluster " + name );
        }

Replace Generic With Diamond HashSet<HighlyAvailableGraphDatabase> with HashSet<> in method public getAnySlave(except HighlyAvailableGraphDatabase...) : HighlyAvailableGraphDatabase from class org.neo4j.test.ha.ClusterManager.ManagedCluster


        public void sync( HighlyAvailableGraphDatabase... except )
        {
            Set<HighlyAvailableGraphDatabase> exceptSet = new HashSet<>( asList( except ) );
            for ( HighlyAvailableGraphDatabase db : getAllMembers() )
            {
                if ( !exceptSet.contains( db ) )
                {
                    db.getDependencyResolver().resolveDependency( UpdatePuller.class ).pullUpdates();
                }
            }
        }

        public void sync( HighlyAvailableGraphDatabase... except )
        {
            Set<HighlyAvailableGraphDatabase> exceptSet = new HashSet<HighlyAvailableGraphDatabase>( asList( except ) );
            for ( HighlyAvailableGraphDatabase db : getAllMembers() )
            {
                if ( !exceptSet.contains( db ) )
                {
                    db.getDependencyResolver().resolveDependency( UpdatePuller.class ).pullUpdates();
                }
            }
        }

Replace Generic With Diamond HashSet<HighlyAvailableGraphDatabase> with HashSet<> in method public sync(except HighlyAvailableGraphDatabase...) : void from class org.neo4j.test.ha.ClusterManager.ManagedCluster


        public HighlyAvailableGraphDatabase get()
        {
            if ( result == null )
            {
                try
                {
                    result = untilThen.get();
                }
                catch ( InterruptedException | ExecutionException e )
                {
                    throw new RuntimeException( e );
                }
                finally
                {
                    executor.shutdownNow();
                }
            }
            return (HighlyAvailableGraphDatabase) result;
        }

        public HighlyAvailableGraphDatabase get()
        {
            if ( result == null )
            {
                try
                {
                    result = untilThen.get();
                }
                catch ( InterruptedException e )
                {
                    throw new RuntimeException( e );
                }
                catch ( ExecutionException e )
                {
                    throw new RuntimeException( e );
                } finally
                {
                    executor.shutdownNow();
                }
            }
            return (HighlyAvailableGraphDatabase) result;
        }

Merge Catch [catch(InterruptedException e), catch(ExecutionException e)] to catch(InterruptedException|ExecutionException e) in method public get() : HighlyAvailableGraphDatabase from class org.neo4j.test.ha.ClusterManager.HighlyAvailableGraphDatabaseProxy


    /**
     * There must be a master available. Optionally exceptions, useful for when awaiting a
     * re-election of a different master.
     */
    public static Predicate<ManagedCluster> masterAvailable( HighlyAvailableGraphDatabase... except )
    {
        final Set<HighlyAvailableGraphDatabase> exceptSet = new HashSet<>( asList( except ) );
        return new Predicate<ClusterManager.ManagedCluster>()
        {
            @Override
            public boolean accept( ManagedCluster cluster )
            {
                for ( HighlyAvailableGraphDatabase graphDatabaseService : cluster.getAllMembers() )
                {
                    if ( !exceptSet.contains( graphDatabaseService ))
                    {
                        if ( graphDatabaseService.isMaster() )
                        {
                            return true;
                        }
                    }
                }
                return false;
            }

            @Override
            public String toString()
            {
                return "There's an available master";
            }
        };
    }

    /**
     * There must be a master available. Optionally exceptions, useful for when awaiting a
     * re-election of a different master.
     */
    public static Predicate<ManagedCluster> masterAvailable( HighlyAvailableGraphDatabase... except )
    {
        final Set<HighlyAvailableGraphDatabase> exceptSet = new HashSet<HighlyAvailableGraphDatabase>( asList( except ) );
        return new Predicate<ClusterManager.ManagedCluster>()
        {
            @Override
            public boolean accept( ManagedCluster cluster )
            {
                for ( HighlyAvailableGraphDatabase graphDatabaseService : cluster.getAllMembers() )
                {
                    if ( !exceptSet.contains( graphDatabaseService ))
                    {
                        if ( graphDatabaseService.isMaster() )
                        {
                            return true;
                        }
                    }
                }
                return false;
            }

            @Override
            public String toString()
            {
                return "There's an available master";
            }
        };
    }

Replace Generic With Diamond HashSet<HighlyAvailableGraphDatabase> with HashSet<> in method public masterAvailable(except HighlyAvailableGraphDatabase...) : Predicate<ManagedCluster> from class org.neo4j.test.ha.ClusterManager


    @Override
    public void update( Iterable<NodePropertyUpdate> updates ) throws IOException
    {
        super.update( new FilteringIterable<>( updates, ruleMatchingUpdates ) );
    }

    @Override
    public void update( Iterable<NodePropertyUpdate> updates ) throws IOException
    {
        super.update( new FilteringIterable<NodePropertyUpdate>( updates, ruleMatchingUpdates ) );
    }

Replace Generic With Diamond FilteringIterable<NodePropertyUpdate> with FilteringIterable<> in method public update(updates Iterable<NodePropertyUpdate>) : void from class org.neo4j.kernel.impl.api.index.RuleUpdateFilterIndexProxy


        @Override
        public void dropIndexDefinitions( Label label, String propertyKey )
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            try ( StatementState state = ctxProvider.statementForWriting() )
            {
                long labelId = context.keyReadOperations().labelGetForName( state, label.name() );
                long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, propertyKey );

                if ( labelId != KeyReadOperations.NO_SUCH_LABEL && propertyKeyId != KeyReadOperations
                        .NO_SUCH_PROPERTY_KEY )
                {
                    context.schemaWriteOperations().indexDrop( state,
                            context.schemaReadOperations().indexesGetForLabelAndPropertyKey( state, labelId,
                                    propertyKeyId ) );
                }
            }
            catch ( SchemaKernelException e )
            {
                throw new ConstraintViolationException( String.format(
                        "Unable to drop index on label `%s` for property %s.", label.name(), propertyKey ), e );
            }
        }

        @Override
        public void dropIndexDefinitions( Label label, String propertyKey )
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            StatementState state = ctxProvider.statementForWriting();
            try
            {
                long labelId = context.keyReadOperations().labelGetForName( state, label.name() );
                long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, propertyKey );

                if(labelId != KeyReadOperations.NO_SUCH_LABEL && propertyKeyId != KeyReadOperations.NO_SUCH_PROPERTY_KEY )
                {
                    context.schemaWriteOperations().indexDrop( state,
                            context.schemaReadOperations().indexesGetForLabelAndPropertyKey( state, labelId, propertyKeyId ) );
                }
            }
            catch ( SchemaKernelException e )
            {
                throw new ConstraintViolationException( String.format(
                        "Unable to drop index on label `%s` for property %s.", label.name(), propertyKey ), e );
            }
            finally
            {
                state.close();
            }
        }

Try With Resources try(StatementState state=ctxProvider.statementForWriting()) in method public dropIndexDefinitions(label Label, propertyKey String) : void from class org.neo4j.kernel.SchemaImpl.GDBSchemaActions


        @Override
        public ConstraintDefinition createPropertyUniquenessConstraint( Label label, String propertyKey )
                throws SchemaKernelException
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            try ( StatementState state = ctxProvider.statementForWriting() )
            {
                long labelId = context.keyWriteOperations().labelGetOrCreateForName( state, label.name() );
                long propertyKeyId = context.keyWriteOperations().propertyKeyGetOrCreateForName( state, propertyKey );
                context.schemaWriteOperations().uniquenessConstraintCreate( state, labelId, propertyKeyId );
                return new PropertyUniqueConstraintDefinition( this, label, propertyKey );
            }
        }

        @Override
        public ConstraintDefinition createPropertyUniquenessConstraint( Label label, String propertyKey )
                throws SchemaKernelException
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            StatementState state = ctxProvider.statementForWriting();
            try
            {
                long labelId = context.keyWriteOperations().labelGetOrCreateForName( state, label.name() );
                long propertyKeyId = context.keyWriteOperations().propertyKeyGetOrCreateForName( state, propertyKey );
                context.schemaWriteOperations().uniquenessConstraintCreate( state, labelId, propertyKeyId );
                return new PropertyUniqueConstraintDefinition( this, label, propertyKey );
            }
            finally
            {
                state.close();
            }
        }

Try With Resources try(StatementState state=ctxProvider.statementForWriting()) in method public createPropertyUniquenessConstraint(label Label, propertyKey String) : ConstraintDefinition from class org.neo4j.kernel.SchemaImpl.GDBSchemaActions


        @Override
        public void dropPropertyUniquenessConstraint( Label label, String propertyKey )
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            try ( StatementState state = ctxProvider.statementForWriting() )
            {
                long labelId = context.keyWriteOperations().labelGetOrCreateForName( state, label.name() );
                long propertyKeyId = context.keyWriteOperations().propertyKeyGetOrCreateForName( state, propertyKey );
                UniquenessConstraint constraint = new UniquenessConstraint( labelId, propertyKeyId );
                context.schemaWriteOperations().constraintDrop( state, constraint );
            }
            catch ( SchemaKernelException e )
            {
                throw new ThisShouldNotHappenError( "Mattias", "Unable to drop property unique constraint" );
            }
        }

        @Override
        public void dropPropertyUniquenessConstraint( Label label, String propertyKey )
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            StatementState state = ctxProvider.statementForWriting();
            try
            {
                long labelId = context.keyWriteOperations().labelGetOrCreateForName( state, label.name() );
                long propertyKeyId = context.keyWriteOperations().propertyKeyGetOrCreateForName( state, propertyKey );
                UniquenessConstraint constraint = new UniquenessConstraint( labelId, propertyKeyId );
                context.schemaWriteOperations().constraintDrop( state, constraint );
            }
            catch ( SchemaKernelException e )
            {
                throw new ThisShouldNotHappenError( "Mattias", "Unable to drop property unique constraint" );
            }
            finally
            {
                state.close();
            }
        }

Try With Resources try(StatementState state=ctxProvider.statementForWriting()) in method public dropPropertyUniquenessConstraint(label Label, propertyKey String) : void from class org.neo4j.kernel.SchemaImpl.GDBSchemaActions


        @Override
        public String getUserMessage( KernelException e )
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            try ( StatementState state = ctxProvider.statementForReading() )
            {
                return e.getUserMessage( new StatementTokenNameLookup( state, context.keyReadOperations() ) );
            }
        }

        @Override
        public String getUserMessage( KernelException e )
        {
            StatementOperationParts context = ctxProvider.getCtxForWriting();
            StatementState state = ctxProvider.statementForReading();
            try
            {
                return e.getUserMessage( new StatementTokenNameLookup( state, context.keyReadOperations() ) );
            }
            finally
            {
                state.close();
            }
        }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getUserMessage(e KernelException) : String from class org.neo4j.kernel.SchemaImpl.GDBSchemaActions


    @Override
    public Iterable<IndexDefinition> getIndexes( final Label label )
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        try ( StatementState state = ctxProvider.statementForReading() )
        {
            List<IndexDefinition> definitions = new ArrayList<>();
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );

            if ( labelId == KeyReadOperations.NO_SUCH_LABEL )
            {
                return emptyList();
            }

            addDefinitions( definitions, context, state, context.schemaReadOperations().indexesGetForLabel( state,
                    labelId ), false );
            addDefinitions( definitions, context, state, context.schemaReadOperations().uniqueIndexesGetForLabel(
                    state, labelId ), true );
            return definitions;
        }
    }

    @Override
    public Iterable<IndexDefinition> getIndexes( final Label label )
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        StatementState state = ctxProvider.statementForReading();
        try
        {
            List<IndexDefinition> definitions = new ArrayList<>();
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );

            if(labelId == KeyReadOperations.NO_SUCH_LABEL)
            {
                return emptyList();
            }

            addDefinitions( definitions, context, state, context.schemaReadOperations().indexesGetForLabel( state,
                    labelId ), false );
            addDefinitions( definitions, context, state, context.schemaReadOperations().uniqueIndexesGetForLabel(
                    state, labelId ), true );
            return definitions;
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getIndexes(label Label) : Iterable<IndexDefinition> from class org.neo4j.kernel.SchemaImpl


    @Override
    public Iterable<IndexDefinition> getIndexes()
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        try ( StatementState state = ctxProvider.statementForReading() )
        {
            List<IndexDefinition> definitions = new ArrayList<>();
            addDefinitions( definitions, context, state, context.schemaReadOperations().indexesGetAll( state ), false );
            addDefinitions( definitions, context, state, context.schemaReadOperations().uniqueIndexesGetAll( state ),
                    true );
            return definitions;
        }
    }

    @Override
    public Iterable<IndexDefinition> getIndexes()
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        StatementState state = ctxProvider.statementForReading();
        try
        {
            List<IndexDefinition> definitions = new ArrayList<>();
            addDefinitions( definitions, context, state, context.schemaReadOperations().indexesGetAll( state ), false );
            addDefinitions( definitions, context, state, context.schemaReadOperations().uniqueIndexesGetAll( state ), true );
            return definitions;
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getIndexes() : Iterable<IndexDefinition> from class org.neo4j.kernel.SchemaImpl


    @Override
    public IndexState getIndexState( final IndexDefinition index )
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        String propertyKey = single( index.getPropertyKeys() );
        SchemaReadOperations schemaReading = context.schemaReadOperations();
        try ( StatementState state = ctxProvider.statementForReading() )
        {
            long labelId = context.keyReadOperations().labelGetForName( state, index.getLabel().name() );
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, propertyKey );

            if ( labelId == KeyReadOperations.NO_SUCH_LABEL )
            {
                throw new NotFoundException( format( "Label %s not found", index.getLabel().name() ) );
            }

            if ( propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                throw new NotFoundException( format( "Property key %s not found", propertyKey ) );
            }

            IndexDescriptor descriptor =
                    schemaReading.indexesGetForLabelAndPropertyKey( state, labelId, propertyKeyId );
            InternalIndexState indexState = schemaReading.indexGetState( state, descriptor );
            switch ( indexState )
            {
                case POPULATING:
                    return POPULATING;
                case ONLINE:
                    return ONLINE;
                case FAILED:
                    return FAILED;
                default:
                    throw new IllegalArgumentException( String.format( "Illegal index state %s", indexState ) );
            }
        }
        catch ( SchemaRuleNotFoundException | IndexNotFoundKernelException e )
        {
            throw new NotFoundException( format( "No index for label %s on property %s",
                    index.getLabel().name(), propertyKey ) );
        }
    }

    @Override
    public IndexState getIndexState( final IndexDefinition index )
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        String propertyKey = single( index.getPropertyKeys() );
        StatementState state = ctxProvider.statementForReading();
        SchemaReadOperations schemaReading = context.schemaReadOperations();
        try
        {
            long labelId = context.keyReadOperations().labelGetForName( state, index.getLabel().name() );
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, propertyKey );

            if(labelId == KeyReadOperations.NO_SUCH_LABEL)
            {
                throw new NotFoundException( format( "Label %s not found", index.getLabel().name() ) );
            }

            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                throw new NotFoundException( format( "Property key %s not found", propertyKey ) );
            }

            IndexDescriptor descriptor =
                    schemaReading.indexesGetForLabelAndPropertyKey( state, labelId, propertyKeyId );
            InternalIndexState indexState = schemaReading.indexGetState( state, descriptor );
            switch ( indexState )
            {
            case POPULATING:
                return POPULATING;
            case ONLINE:
                return ONLINE;
            case FAILED:
                return FAILED;
            default:
                throw new IllegalArgumentException( String.format( "Illegal index state %s", indexState ) );
            }
        }
        catch ( SchemaRuleNotFoundException | IndexNotFoundKernelException e )
        {
            throw new NotFoundException( format( "No index for label %s on property %s",
                                                 index.getLabel().name(), propertyKey ) );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getIndexState(index IndexDefinition) : IndexState from class org.neo4j.kernel.SchemaImpl


    @Override
    public String getIndexFailure( IndexDefinition index )
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        String propertyKey = single( index.getPropertyKeys() );
        try ( StatementState state = ctxProvider.statementForReading() )
        {
            long labelId = context.keyReadOperations().labelGetForName( state, index.getLabel().name() );
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, propertyKey );

            if ( labelId == KeyReadOperations.NO_SUCH_LABEL )
            {
                throw new NotFoundException( format( "Label %s not found", index.getLabel().name() ) );
            }

            if ( propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                throw new NotFoundException( format( "Property key %s not found", propertyKey ) );
            }

            IndexDescriptor indexId = context.schemaReadOperations().indexesGetForLabelAndPropertyKey( state,
                    labelId, propertyKeyId );
            return context.schemaReadOperations().indexGetFailure( state, indexId );
        }
        catch ( SchemaRuleNotFoundException | IndexNotFoundKernelException e )
        {
            throw new NotFoundException( format( "No index for label %s on property %s",
                    index.getLabel().name(), propertyKey ) );
        }
    }

    @Override
    public String getIndexFailure( IndexDefinition index )
    {
        assertInTransaction();

        StatementOperationParts context = ctxProvider.getCtxForReading();
        StatementState state = ctxProvider.statementForReading();
        String propertyKey = single( index.getPropertyKeys() );
        try
        {
            long labelId = context.keyReadOperations().labelGetForName( state, index.getLabel().name() );
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, propertyKey );

            if(labelId == KeyReadOperations.NO_SUCH_LABEL)
            {
                throw new NotFoundException( format( "Label %s not found", index.getLabel().name() ) );
            }

            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                throw new NotFoundException( format( "Property key %s not found", propertyKey ) );
            }

            IndexDescriptor indexId = context.schemaReadOperations().indexesGetForLabelAndPropertyKey( state, labelId, propertyKeyId );
            return context.schemaReadOperations().indexGetFailure( state, indexId );
        }
        catch ( SchemaRuleNotFoundException | IndexNotFoundKernelException e )
        {
            throw new NotFoundException( format( "No index for label %s on property %s",
                                                 index.getLabel().name(), propertyKey ) );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getIndexFailure(index IndexDefinition) : String from class org.neo4j.kernel.SchemaImpl


    @Override
    public Iterable<ConstraintDefinition> getConstraints()
    {
        assertInTransaction();

        final StatementOperationParts context = ctxProvider.getCtxForReading();
        try ( StatementState state = ctxProvider.statementForReading() )
        {
            Iterator<UniquenessConstraint> constraints = context.schemaReadOperations().constraintsGetAll( state );
            return asConstraintDefinitions( context, state, constraints );
        }
    }

    @Override
    public Iterable<ConstraintDefinition> getConstraints()
    {
        assertInTransaction();

        final StatementOperationParts context = ctxProvider.getCtxForReading();
        StatementState state = ctxProvider.statementForReading();
        try
        {
            Iterator<UniquenessConstraint> constraints = context.schemaReadOperations().constraintsGetAll( state );
            return asConstraintDefinitions( context, state, constraints );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getConstraints() : Iterable<ConstraintDefinition> from class org.neo4j.kernel.SchemaImpl


    @Override
    public Iterable<ConstraintDefinition> getConstraints( final Label label )
    {
        assertInTransaction();

        final StatementOperationParts context = ctxProvider.getCtxForReading();
        try ( StatementState state = ctxProvider.statementForReading() )
        {
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );
            if ( labelId == KeyReadOperations.NO_SUCH_LABEL )
            {
                return emptyList();
            }
            Iterator<UniquenessConstraint> constraints = context.schemaReadOperations().constraintsGetForLabel(
                    state, labelId );
            return asConstraintDefinitions( context, state, constraints );
        }
    }

    @Override
    public Iterable<ConstraintDefinition> getConstraints( final Label label )
    {
        assertInTransaction();

        final StatementOperationParts context = ctxProvider.getCtxForReading();
        StatementState state = ctxProvider.statementForReading();
        try
        {
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );
            if(labelId == KeyReadOperations.NO_SUCH_LABEL)
            {
                return emptyList();
            }
            Iterator<UniquenessConstraint> constraints = context.schemaReadOperations().constraintsGetForLabel(
                    state, labelId );
            return asConstraintDefinitions( context, state, constraints );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=ctxProvider.statementForReading()) in method public getConstraints(label Label) : Iterable<ConstraintDefinition> from class org.neo4j.kernel.SchemaImpl


    @Override
    public void delete()
    {
        StatementOperationParts context = statementCtxProvider.getCtxForWriting();
        try ( StatementState state = statementCtxProvider.statementForWriting() )
        {
            context.entityWriteOperations().nodeDelete( state, getId() );
        }
    }

    @Override
    public void delete()
    {
        StatementOperationParts context = statementCtxProvider.getCtxForWriting();
        StatementState state = statementCtxProvider.statementForWriting();
        try
        {
            context.entityWriteOperations().nodeDelete( state, getId() );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForWriting()) in method public delete() : void from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public Object removeProperty( String key ) throws NotFoundException
    {
        StatementOperationParts context = statementCtxProvider.getCtxForWriting();
        try ( StatementState state = statementCtxProvider.statementForWriting() )
        {
            long propertyKeyId = context.keyWriteOperations().propertyKeyGetOrCreateForName( state, key );
            return context.entityWriteOperations().nodeRemoveProperty( state, nodeId, propertyKeyId ).value( null );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            throw new ThisShouldNotHappenError( "Stefan/Jake", "A property key id disappeared under our feet" );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        catch ( SchemaKernelException e )
        {
            // TODO: Maybe throw more context-specific error than just IllegalArgument
            throw new IllegalArgumentException( e );
        }
    }

    @Override
    public Object removeProperty( String key ) throws NotFoundException
    {
        StatementOperationParts context = statementCtxProvider.getCtxForWriting();
        StatementState state = statementCtxProvider.statementForWriting();
        try
        {
            long propertyKeyId = context.keyWriteOperations().propertyKeyGetOrCreateForName( state, key );
            return context.entityWriteOperations().nodeRemoveProperty( state, nodeId, propertyKeyId ).value( null );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            throw new ThisShouldNotHappenError( "Stefan/Jake", "A property key id disappeared under our feet" );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        catch ( SchemaKernelException e )
        {
            // TODO: Maybe throw more context-specific error than just IllegalArgument
            throw new IllegalArgumentException( e );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForWriting()) in method public removeProperty(key String) : Object from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public Object getProperty( String key, Object defaultValue )
    {
        // TODO: Push this check to getPropertyKeyId
        // ^^^^^ actually, if the key is null, we could fail before getting the statement context...
        if ( null == key )
            throw new IllegalArgumentException( "(null) property key is not allowed" );

        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        try ( StatementState state = statementCtxProvider.statementForReading() )
        {
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, key );
            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                return defaultValue;
            }
            return context.entityReadOperations().nodeGetProperty( state, nodeId, propertyKeyId ).value( defaultValue );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            return defaultValue;
        }
    }

    @Override
    public Object getProperty( String key, Object defaultValue )
    {
        // TODO: Push this check to getPropertyKeyId
        // ^^^^^ actually, if the key is null, we could fail before getting the statement context...
        if ( null == key )
            throw new IllegalArgumentException( "(null) property key is not allowed" );

        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        StatementState state = statementCtxProvider.statementForReading();
        try
        {
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, key );
            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                return defaultValue;
            }
            return context.entityReadOperations().nodeGetProperty( state, nodeId, propertyKeyId ).value(defaultValue);
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            return defaultValue;
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForReading()) in method public getProperty(key String, defaultValue Object) : Object from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public Iterable<Object> getPropertyValues()
    {
        final StatementOperationParts context = statementCtxProvider.getCtxForReading();
        try ( StatementState state = statementCtxProvider.statementForReading() )
        {
            return asSet( map( new Function<Property, Object>()
            {
                @Override
                public Object apply( Property prop )
                {
                    try
                    {
                        return prop.value();
                    }
                    catch ( PropertyNotFoundException e )
                    {
                        throw new ThisShouldNotHappenError( "Jake",
                                "Property key retrieved through kernel API should exist." );
                    }
                }
            }, context.entityReadOperations().nodeGetAllProperties( state, getId() ) ) );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( "Node not found", e );
        }
    }

    @Override
    public Iterable<Object> getPropertyValues()
    {
        final StatementOperationParts context = statementCtxProvider.getCtxForReading();
        StatementState state = statementCtxProvider.statementForReading();
        try
        {
            return asSet( map( new Function<Property,Object>() {
                @Override
                public Object apply( Property prop )
                {
                    try
                    {
                        return prop.value();
                    }
                    catch ( PropertyNotFoundException e )
                    {
                        throw new ThisShouldNotHappenError( "Jake",
                                "Property key retrieved through kernel API should exist." );
                    }
                }
            }, context.entityReadOperations().nodeGetAllProperties( state, getId() )));
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( "Node not found", e );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForReading()) in method public getPropertyValues() : Iterable<Object> from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public Iterable<String> getPropertyKeys()
    {
        final StatementOperationParts context = statementCtxProvider.getCtxForReading();
        try ( StatementState state = statementCtxProvider.statementForReading() )
        {
            List<String> keys = new ArrayList<>();
            PrimitiveLongIterator keyIds = context.entityReadOperations().nodeGetPropertyKeys( state, getId() );
            while ( keyIds.hasNext() )
            {
                keys.add( context.keyReadOperations().propertyKeyGetName( state, keyIds.next() ) );
            }
            return keys;
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( "Node not found", e );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            throw new ThisShouldNotHappenError( "Jake",
                    "Property key retrieved through kernel API should exist." );
        }
    }

    @Override
    public Iterable<String> getPropertyKeys()
    {
        final StatementOperationParts context = statementCtxProvider.getCtxForReading();
        final StatementState state = statementCtxProvider.statementForReading();
        try
        {
            List<String> keys = new ArrayList<>();
            PrimitiveLongIterator keyIds = context.entityReadOperations().nodeGetPropertyKeys( state, getId() );
            while ( keyIds.hasNext() )
            {
                keys.add( context.keyReadOperations().propertyKeyGetName( state, keyIds.next() ) );
            }
            return keys;
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( "Node not found", e );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            throw new ThisShouldNotHappenError( "Jake",
                    "Property key retrieved through kernel API should exist." );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForReading()) in method public getPropertyKeys() : Iterable<String> from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public Object getProperty( String key ) throws NotFoundException
    {
        // TODO: Push this check to getPropertyKeyId
        // ^^^^^ actually, if the key is null, we could fail before getting the statement context...
        if ( null == key )
            throw new IllegalArgumentException( "(null) property key is not allowed" );

        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        try ( StatementState state = statementCtxProvider.statementForReading() )
        {
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, key );
            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                return false;
            }
            return context.entityReadOperations().nodeGetProperty( state, nodeId, propertyKeyId ).value();
        }
        catch ( EntityNotFoundException | PropertyKeyIdNotFoundException | PropertyNotFoundException e )
        {
            throw new NotFoundException( e );
        }
    }

    @Override
    public Object getProperty( String key ) throws NotFoundException
    {
        // TODO: Push this check to getPropertyKeyId
        // ^^^^^ actually, if the key is null, we could fail before getting the statement context...
        if ( null == key )
            throw new IllegalArgumentException( "(null) property key is not allowed" );

        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        StatementState state = statementCtxProvider.statementForReading();
        try
        {
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, key );
            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                return false;
            }
            return context.entityReadOperations().nodeGetProperty( state, nodeId, propertyKeyId ).value();
        }
        catch ( EntityNotFoundException | PropertyKeyIdNotFoundException | PropertyNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForReading()) in method public getProperty(key String) : Object from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public boolean hasProperty( String key )
    {
        if ( null == key )
            return false;

        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        try ( StatementState state = statementCtxProvider.statementForReading() )
        {
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, key );
            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                return false;
            }
            return context.entityReadOperations().nodeHasProperty( state, nodeId, propertyKeyId );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            return false;
        }
    }

    @Override
    public boolean hasProperty( String key )
    {
        if ( null == key )
            return false;

        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        StatementState state = statementCtxProvider.statementForReading();
        try
        {
            long propertyKeyId = context.keyReadOperations().propertyKeyGetForName( state, key );
            if(propertyKeyId == KeyReadOperations.NO_SUCH_PROPERTY_KEY )
            {
                return false;
            }
            return context.entityReadOperations().nodeHasProperty( state, nodeId, propertyKeyId );
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( e );
        }
        catch ( PropertyKeyIdNotFoundException e )
        {
            return false;
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForReading()) in method public hasProperty(key String) : boolean from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public void removeLabel( Label label )
    {
        StatementOperationParts context = statementCtxProvider.getCtxForWriting();
        try ( StatementState state = statementCtxProvider.statementForWriting() )
        {
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );
            if(labelId != KeyReadOperations.NO_SUCH_LABEL)
            {
                context.entityWriteOperations().nodeRemoveLabel( state, getId(), labelId );
            }
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( "No node with id " + getId() + " found.", e );
        }
    }

    @Override
    public void removeLabel( Label label )
    {
        StatementOperationParts context = statementCtxProvider.getCtxForWriting();
        StatementState state = statementCtxProvider.statementForWriting();
        try
        {
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );
            if(labelId != KeyReadOperations.NO_SUCH_LABEL)
            {
                context.entityWriteOperations().nodeRemoveLabel( state, getId(), labelId );
            }
        }
        catch ( EntityNotFoundException e )
        {
            throw new NotFoundException( "No node with id " + getId() + " found.", e );
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForWriting()) in method public removeLabel(label Label) : void from class org.neo4j.kernel.impl.core.NodeProxy


    @Override
    public boolean hasLabel( Label label )
    {
        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        try ( StatementState state = statementCtxProvider.statementForReading() )
        {
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );

            return labelId != KeyReadOperations.NO_SUCH_LABEL &&
                   context.entityReadOperations().nodeHasLabel( state, getId(), labelId );
        }
        catch ( EntityNotFoundException e )
        {
            return false;
        }
    }

    @Override
    public boolean hasLabel( Label label )
    {
        StatementOperationParts context = statementCtxProvider.getCtxForReading();
        StatementState state = statementCtxProvider.statementForReading();
        try
        {
            long labelId = context.keyReadOperations().labelGetForName( state, label.name() );

            return labelId != KeyReadOperations.NO_SUCH_LABEL &&
                   context.entityReadOperations().nodeHasLabel( state, getId(), labelId );
        }
        catch ( EntityNotFoundException e )
        {
            return false;
        }
        finally
        {
            state.close();
        }
    }

Try With Resources try(StatementState state=statementCtxProvider.statementForReading()) in method public hasLabel(label Label) : boolean from class org.neo4j.kernel.impl.core.NodeProxy


    private <FAILURE extends Exception> StoreScan<FAILURE> visitNodes( PrimitiveLongPredicate propertyKeyPredicate,
                                                                       PrimitiveLongPredicate labelPredicate,
                                                                       Visitor<NodePropertyUpdate, FAILURE> visitor )
    {
        // Create a processor that for each accepted node (containing the desired label) looks through its properties,
        // getting the desired one (if any) and feeds to the index manipulator.
        LabelsReference labelsReference = new LabelsReference();
        final RecordStore.Processor<FAILURE> processor = new NodeIndexingProcessor<>( propertyStore,
                propertyKeyPredicate,
                labelsReference, visitor );

        // Run the processor for the nodes containing the given label.
        // TODO When we've got a decent way of getting nodes with a label, use that instead.
        final Predicate<NodeRecord> predicate = new NodeLabelFilterPredicate( nodeStore, labelPredicate,
                labelsReference );

        // Run the processor, be sure that the predicate filters out removed nodes by checking in-use
        return new ProcessStoreScan<>( processor, predicate );
    }

    private <FAILURE extends Exception> StoreScan<FAILURE> visitNodes( PrimitiveLongPredicate propertyKeyPredicate,
                                                                       PrimitiveLongPredicate labelPredicate,
                                                                       Visitor<NodePropertyUpdate, FAILURE> visitor )
    {
        // Create a processor that for each accepted node (containing the desired label) looks through its properties,
        // getting the desired one (if any) and feeds to the index manipulator.
        LabelsReference labelsReference = new LabelsReference();
        final RecordStore.Processor<FAILURE> processor = new NodeIndexingProcessor<FAILURE>( propertyStore,
                propertyKeyPredicate,
                labelsReference, visitor );

        // Run the processor for the nodes containing the given label.
        // TODO When we've got a decent way of getting nodes with a label, use that instead.
        final Predicate<NodeRecord> predicate = new NodeLabelFilterPredicate( nodeStore, labelPredicate,
                labelsReference );

        // Run the processor, be sure that the predicate filters out removed nodes by checking in-use
        return new ProcessStoreScan<FAILURE>( processor, predicate );
    }

Replace Generic With Diamond NodeIndexingProcessor<FAILURE> with NodeIndexingProcessor<> in method private visitNodes(propertyKeyPredicate PrimitiveLongPredicate, labelPredicate PrimitiveLongPredicate, visitor Visitor<NodePropertyUpdate,FAILURE>) : StoreScan<FAILURE> from class org.neo4j.kernel.impl.nioneo.xa.NeoStoreIndexStoreView


    @Test @Ignore("2013-07-01 AT This should probably be removed")
    public void readOnlyStatementContextLifecycleShouldBeThreadSafe() throws Exception
    {
        // GIVEN
        GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
        KernelAPI kernel = db.getDependencyResolver().resolveDependency( KernelAPI.class );
        DoubleLatch latch = new DoubleLatch( 10 );
        List<Worker> workers = new ArrayList<>();
        for ( int i = 0; i < latch.getNumberOfContestants(); i++ )
        {
            workers.add( new Worker( kernel, latch ) );
        }
        latch.awaitFinish();

        // WHEN

        // THEN
        for ( Worker worker : workers )
        {
            if ( worker.failure != null )
            {
                throw new RuntimeException( "Worker failed", worker.failure );
            }
        }
        db.shutdown();
    }

    @Test @Ignore("2013-07-01 AT This should probably be removed")
    public void readOnlyStatementContextLifecycleShouldBeThreadSafe() throws Exception
    {
        // GIVEN
        GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
        KernelAPI kernel = db.getDependencyResolver().resolveDependency( KernelAPI.class );
        DoubleLatch latch = new DoubleLatch( 10 );
        List<Worker> workers = new ArrayList<Worker>();
        for ( int i = 0; i < latch.getNumberOfContestants(); i++ )
        {
            workers.add( new Worker( kernel, latch ) );
        }
        latch.awaitFinish();

        // WHEN

        // THEN
        for ( Worker worker : workers )
        {
            if ( worker.failure != null )
            {
                throw new RuntimeException( "Worker failed", worker.failure );
            }
        }
        db.shutdown();
    }

Replace Generic With Diamond ArrayList<Worker> with ArrayList<> in method public readOnlyStatementContextLifecycleShouldBeThreadSafe() : void from class org.neo4j.kernel.impl.api.KernelTest


    @Test
    public void shouldBeAbleToCancelPopulationJob() throws Exception
    {
        // GIVEN
        createNode( map( name, "Mattias" ), FIRST );
        IndexPopulator populator = mock( IndexPopulator.class );
        FlippableIndexProxy index = mock( FlippableIndexProxy.class );
        IndexStoreView storeView = mock( IndexStoreView.class );
        ControlledStoreScan storeScan = new ControlledStoreScan();
        when( storeView.visitNodesWithPropertyAndLabel( any( IndexDescriptor.class ),
                Matchers.<Visitor<NodePropertyUpdate, RuntimeException>>any() ) ).thenReturn( storeScan );

        final IndexPopulationJob job = newIndexPopulationJob( FIRST, name, populator, index, storeView,
                StringLogger.DEV_NULL );

        OtherThreadExecutor<Void> populationJobRunner = new OtherThreadExecutor<>(
                "Population job test runner", null );
        Future<Void> runFuture = populationJobRunner.executeDontWait( new WorkerCommand<Void, Void>()
        {
            @Override
            public Void doWork( Void state )
            {
                job.run();
                return null;
            }
        } );

        storeScan.latch.awaitStart();
        job.cancel().get();
        storeScan.latch.awaitFinish();

        // WHEN
        runFuture.get();

        // THEN
        verify( populator, times( 1 ) ).close( false );
        verify( index, times( 0 ) ).flip( Matchers.<Callable<Void>>any(), Matchers.<FailedIndexProxyFactory>any() );
    }

    @Test
    public void shouldBeAbleToCancelPopulationJob() throws Exception
    {
        // GIVEN
        createNode( map( name, "Mattias" ), FIRST );
        IndexPopulator populator = mock( IndexPopulator.class );
        FlippableIndexProxy index = mock( FlippableIndexProxy.class );
        IndexStoreView storeView = mock( IndexStoreView.class );
        ControlledStoreScan storeScan = new ControlledStoreScan();
        when( storeView.visitNodesWithPropertyAndLabel( any( IndexDescriptor.class ),
                Matchers.<Visitor<NodePropertyUpdate, RuntimeException>>any() ) ).thenReturn( storeScan );

        final IndexPopulationJob job = newIndexPopulationJob( FIRST, name, populator, index, storeView,
                StringLogger.DEV_NULL );

        OtherThreadExecutor<Void> populationJobRunner = new OtherThreadExecutor<Void>(
                "Population job test runner", null );
        Future<Void> runFuture = populationJobRunner.executeDontWait( new WorkerCommand<Void, Void>()
        {
            @Override
            public Void doWork( Void state )
            {
                job.run();
                return null;
            }
        } );

        storeScan.latch.awaitStart();
        job.cancel().get();
        storeScan.latch.awaitFinish();

        // WHEN
        runFuture.get();

        // THEN
        verify( populator, times( 1 ) ).close( false );
        verify( index, times( 0 ) ).flip( Matchers.<Callable<Void>>any(), Matchers.<FailedIndexProxyFactory>any() );
    }

Replace Generic With Diamond OtherThreadExecutor<Void> with OtherThreadExecutor<> in method public shouldBeAbleToCancelPopulationJob() : void from class org.neo4j.kernel.impl.api.index.IndexPopulationJobTest


        @Override
        public Iterator<NodePropertyUpdate> iterator()
        {
            return new ArrayIterator<>( updates );
        }

        @Override
        public Iterator<NodePropertyUpdate> iterator()
        {
            return new ArrayIterator<NodePropertyUpdate>( updates );
        }

Replace Generic With Diamond ArrayIterator<NodePropertyUpdate> with ArrayIterator<> in method public iterator() : Iterator<NodePropertyUpdate> from class org.neo4j.kernel.impl.api.index.IndexingServiceTest.DataUpdates


    @Before
    public void setUpNeoStore() throws Exception
    {
        log = Logger
                .getLogger( "org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog/"
                        + "nioneo_logical.log" );
        level = log.getLevel();
        log.setLevel( Level.OFF );
        log = Logger
                .getLogger( "org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource" );
        log.setLevel( Level.OFF );
        propertyKeyTokens = new HashMap<>();

        StoreFactory sf = new StoreFactory( new Config( Collections.<String, String>emptyMap(),
                GraphDatabaseSettings.class ), new DefaultIdGeneratorFactory(),
                new DefaultWindowPoolFactory(), fileSystem, StringLogger.DEV_NULL, null );
        sf.createNeoStore( file( "neo" ) ).close();

        ds = newNeoStore();
        xaCon = ds.getXaConnection();
        logBaseFileName = ds.getXaContainer().getLogicalLog().getBaseFileName();
    }

    @Before
    public void setUpNeoStore() throws Exception
    {
        log = Logger
                .getLogger( "org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog/"
                        + "nioneo_logical.log" );
        level = log.getLevel();
        log.setLevel( Level.OFF );
        log = Logger
                .getLogger( "org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource" );
        log.setLevel( Level.OFF );
        propertyKeyTokens = new HashMap<String, Token>();

        StoreFactory sf = new StoreFactory( new Config( Collections.<String, String>emptyMap(),
                GraphDatabaseSettings.class ), new DefaultIdGeneratorFactory(),
                new DefaultWindowPoolFactory(), fileSystem, StringLogger.DEV_NULL, null );
        sf.createNeoStore( file( "neo" ) ).close();

        ds = newNeoStore();
        xaCon = ds.getXaConnection();
        logBaseFileName = ds.getXaContainer().getLogicalLog().getBaseFileName();
    }

Replace Generic With Diamond HashMap<String,Token> with HashMap<> in method public setUpNeoStore() : void from class org.neo4j.kernel.impl.nioneo.store.TestXa


    private List<String> itemsAsList( DefaultComboBoxModel<String> model )
    {
        List<String> list = new ArrayList<>( model.getSize() );
        for ( int i = 0; i < model.getSize(); i++ )
        {
            list.add( model.getElementAt( i ) );
        }
        return list;
    }

    private List<String> itemsAsList( DefaultComboBoxModel<String> model )
    {
        List<String> list = new ArrayList<String>( model.getSize() );
        for ( int i = 0; i < model.getSize(); i++ )
        {
            list.add( model.getElementAt( i ) );
        }
        return list;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method private itemsAsList(model DefaultComboBoxModel<String>) : List<String> from class org.neo4j.desktop.ui.MainWindow


    private Iterator<Path> uniquenessFiltered( Iterator<Path> paths )
    {
        return new FilteringIterator<>( paths, uniquenessPredicate );
    }

    private Iterator<Path> uniquenessFiltered( Iterator<Path> paths )
    {
        return new FilteringIterator<Path>( paths, uniquenessPredicate );
    }

Replace Generic With Diamond FilteringIterator<Path> with FilteringIterator<> in method private uniquenessFiltered(paths Iterator<Path>) : Iterator<Path> from class org.neo4j.kernel.impl.traversal.BidirectionalTraverserIterator


    private <T> T[] getList( String name, GraphDatabaseAPI graphDb,
            Converter<T> converter ) throws BadInputException
    {
        Object value = data.get( name );
        if ( value == null ) return null;
        List<T> result = new ArrayList<>();
        if ( value instanceof Object[] )
        {
            for ( Object element : (Object[]) value )
            {
                result.add( converter.convert( graphDb, element ) );
            }
        }
        else if ( value instanceof Iterable<?> )
        {
            for ( Object element : (Iterable<?>) value )
            {
                result.add( converter.convert( graphDb, element ) );
            }
        }
        else
        {
            throw new BadInputException( name + " is not a list" );
        }
        return result.toArray( converter.newArray( result.size() ) );
    }

    private <T> T[] getList( String name, GraphDatabaseAPI graphDb,
            Converter<T> converter ) throws BadInputException
    {
        Object value = data.get( name );
        if ( value == null ) return null;
        List<T> result = new ArrayList<T>();
        if ( value instanceof Object[] )
        {
            for ( Object element : (Object[]) value )
            {
                result.add( converter.convert( graphDb, element ) );
            }
        }
        else if ( value instanceof Iterable<?> )
        {
            for ( Object element : (Iterable<?>) value )
            {
                result.add( converter.convert( graphDb, element ) );
            }
        }
        else
        {
            throw new BadInputException( name + " is not a list" );
        }
        return result.toArray( converter.newArray( result.size() ) );
    }

Replace Generic With Diamond ArrayList<T> with ArrayList<> in method private getList(name String, graphDb GraphDatabaseAPI, converter Converter<T>) : T[] from class org.neo4j.server.plugins.ParameterList


    @Test
    public void shouldHandleSets() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithSet" );
        List<String> strings = Arrays.asList( "aaa", "bbb", "aaa" );
        Map<String, Object> params = MapUtil.map( "strings", strings );

        PluginFunctionalTestHelper.makePostMap( methodUri, params );

        Set<String> stringsSet = new HashSet<>( strings );

        assertThat( FunctionalTestPlugin.stringSet, is( stringsSet ) );
    }

    @Test
    public void shouldHandleSets() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithSet" );
        List<String> strings = Arrays.asList( "aaa", "bbb", "aaa" );
        Map<String, Object> params = MapUtil.map( "strings", strings );

        PluginFunctionalTestHelper.makePostMap( methodUri, params );

        Set<String> stringsSet = new HashSet<String>( strings );

        assertThat( FunctionalTestPlugin.stringSet, is( stringsSet ) );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public shouldHandleSets() : void from class org.neo4j.server.plugins.PluginFunctionalTest


    @Test
    public void shouldHandleJsonLists() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithList" );
        List<String> strings = Arrays.asList( "aaa", "bbb", "aaa" );
        Map<String, Object> params = MapUtil.map( "strings", strings );

        PluginFunctionalTestHelper.makePostMap( methodUri, params );

        List<String> stringsList = new ArrayList<>( strings );

        assertThat( FunctionalTestPlugin.stringList, is( stringsList ) );
    }

    @Test
    public void shouldHandleJsonLists() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithList" );
        List<String> strings = Arrays.asList( "aaa", "bbb", "aaa" );
        Map<String, Object> params = MapUtil.map( "strings", strings );

        PluginFunctionalTestHelper.makePostMap( methodUri, params );

        List<String> stringsList = new ArrayList<String>( strings );

        assertThat( FunctionalTestPlugin.stringList, is( stringsList ) );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public shouldHandleJsonLists() : void from class org.neo4j.server.plugins.PluginFunctionalTest


    @Test
    public void shouldHandleUrlEncodedLists() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithList" );

        String postBody = "strings[]=aaa&strings[]=bbb&strings[]=ccc";

        RestRequest.req().post( methodUri ,postBody,MediaType.APPLICATION_FORM_URLENCODED_TYPE);

        List<String> strings = Arrays.asList( "aaa", "bbb", "ccc" );

        List<String> stringsList = new ArrayList<>( strings );

        assertThat( FunctionalTestPlugin.stringList, is( stringsList ) );
    }

    @Test
    public void shouldHandleUrlEncodedLists() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithList" );

        String postBody = "strings[]=aaa&strings[]=bbb&strings[]=ccc";

        RestRequest.req().post( methodUri ,postBody,MediaType.APPLICATION_FORM_URLENCODED_TYPE);

        List<String> strings = Arrays.asList( "aaa", "bbb", "ccc" );

        List<String> stringsList = new ArrayList<String>( strings );

        assertThat( FunctionalTestPlugin.stringList, is( stringsList ) );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public shouldHandleUrlEncodedLists() : void from class org.neo4j.server.plugins.PluginFunctionalTest


    @Test
    public void shouldHandleUrlEncodedListsAndInt() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithListAndInt" );

        String postBody = "strings[]=aaa&strings[]=bbb&strings[]=ccc&count=3";

        RestRequest.req().post(methodUri,postBody,MediaType.APPLICATION_FORM_URLENCODED_TYPE);

        List<String> strings = Arrays.asList( "aaa", "bbb", "ccc" );

        List<String> stringsList = new ArrayList<>( strings );

        assertThat( FunctionalTestPlugin.stringList, is( stringsList ) );
        assertThat( FunctionalTestPlugin._integer, is( 3 ) );
    }

    @Test
    public void shouldHandleUrlEncodedListsAndInt() throws Exception
    {
        String methodUri = getPluginMethodUri( functionalTestHelper.dataUri(), "methodWithListAndInt" );

        String postBody = "strings[]=aaa&strings[]=bbb&strings[]=ccc&count=3";

        RestRequest.req().post(methodUri,postBody,MediaType.APPLICATION_FORM_URLENCODED_TYPE);

        List<String> strings = Arrays.asList( "aaa", "bbb", "ccc" );

        List<String> stringsList = new ArrayList<String>( strings );

        assertThat( FunctionalTestPlugin.stringList, is( stringsList ) );
        assertThat( FunctionalTestPlugin._integer, is( 3 ) );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public shouldHandleUrlEncodedListsAndInt() : void from class org.neo4j.server.plugins.PluginFunctionalTest


    public Map<String, Object> getNodeProperties( long nodeId )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Node node = database.getGraph().getNodeById( nodeId );
            Map<String, Object> allProperties = new HashMap<>();
            for ( String propertyKey : node.getPropertyKeys() )
            {
                allProperties.put( propertyKey, node.getProperty( propertyKey ) );
            }
            tx.success();
            return allProperties;
        }
        finally
        {
            tx.finish();
        }
    }

    public Map<String, Object> getNodeProperties( long nodeId )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Node node = database.getGraph().getNodeById( nodeId );
            Map<String, Object> allProperties = new HashMap<String, Object>();
            for ( String propertyKey : node.getPropertyKeys() )
            {
                allProperties.put( propertyKey, node.getProperty( propertyKey ) );
            }
            tx.success();
            return allProperties;
        }
        finally
        {
            tx.finish();
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public getNodeProperties(nodeId long) : Map<String,Object> from class org.neo4j.server.rest.domain.GraphDbHelper


    public Map<String, Object> getRelationshipProperties( long relationshipId )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Relationship relationship = database.getGraph().getRelationshipById( relationshipId );
            Map<String, Object> allProperties = new HashMap<>();
            for ( String propertyKey : relationship.getPropertyKeys() )
            {
                allProperties.put( propertyKey, relationship.getProperty( propertyKey ) );
            }
            tx.success();
            return allProperties;
        }
        finally
        {
            tx.finish();
        }
    }

    public Map<String, Object> getRelationshipProperties( long relationshipId )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Relationship relationship = database.getGraph().getRelationshipById( relationshipId );
            Map<String, Object> allProperties = new HashMap<String, Object>();
            for ( String propertyKey : relationship.getPropertyKeys() )
            {
                allProperties.put( propertyKey, relationship.getProperty( propertyKey ) );
            }
            tx.success();
            return allProperties;
        }
        finally
        {
            tx.finish();
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public getRelationshipProperties(relationshipId long) : Map<String,Object> from class org.neo4j.server.rest.domain.GraphDbHelper


    public Collection<Long> queryIndexedNodes( String indexName, String key, Object value )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Collection<Long> result = new ArrayList<>();
            for ( Node node : database.getNodeIndex( indexName ).query( key, value ) )
            {
                result.add( node.getId() );
            }
            tx.success();
            return result;
        }
        finally
        {
            tx.finish();
        }
    }

    public Collection<Long> queryIndexedNodes( String indexName, String key, Object value )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Collection<Long> result = new ArrayList<Long>();
            for ( Node node : database.getNodeIndex( indexName ).query( key, value ) )
            {
                result.add( node.getId() );
            }
            tx.success();
            return result;
        }
        finally
        {
            tx.finish();
        }
    }

Replace Generic With Diamond ArrayList<Long> with ArrayList<> in method public queryIndexedNodes(indexName String, key String, value Object) : Collection<Long> from class org.neo4j.server.rest.domain.GraphDbHelper


    public Collection<Long> getIndexedNodes( String indexName, String key, Object value )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Collection<Long> result = new ArrayList<>();
            for ( Node node : database.getNodeIndex( indexName ).get( key, value ) )
            {
                result.add( node.getId() );
            }
            tx.success();
            return result;
        }
        finally
        {
            tx.finish();
        }
    }

    public Collection<Long> getIndexedNodes( String indexName, String key, Object value )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Collection<Long> result = new ArrayList<Long>();
            for ( Node node : database.getNodeIndex( indexName ).get( key, value ) )
            {
                result.add( node.getId() );
            }
            tx.success();
            return result;
        }
        finally
        {
            tx.finish();
        }
    }

Replace Generic With Diamond ArrayList<Long> with ArrayList<> in method public getIndexedNodes(indexName String, key String, value Object) : Collection<Long> from class org.neo4j.server.rest.domain.GraphDbHelper


    public Collection<Long> getIndexedRelationships( String indexName, String key, Object value )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Collection<Long> result = new ArrayList<>();
            for ( Relationship relationship : database.getRelationshipIndex( indexName ).get( key, value ) )
            {
                result.add( relationship.getId() );
            }
            tx.success();
            return result;
        }
        finally
        {
            tx.finish();
        }
    }

    public Collection<Long> getIndexedRelationships( String indexName, String key, Object value )
    {
        Transaction tx = database.getGraph().beginTx();
        try
        {
            Collection<Long> result = new ArrayList<Long>();
            for ( Relationship relationship : database.getRelationshipIndex( indexName ).get( key, value ) )
            {
                result.add( relationship.getId() );
            }
            tx.success();
            return result;
        }
        finally
        {
            tx.finish();
        }
    }

Replace Generic With Diamond ArrayList<Long> with ArrayList<> in method public getIndexedRelationships(indexName String, key String, value Object) : Collection<Long> from class org.neo4j.server.rest.domain.GraphDbHelper


    private void addError( Neo4jError error )
    {
        if ( errors == null )
        {
            errors = new LinkedList<>();
        }
        errors.add( error );
    }

    private void addError( Neo4jError error )
    {
        if ( errors == null )
        {
            errors = new LinkedList<Neo4jError>();
        }
        errors.add( error );
    }

Replace Generic With Diamond LinkedList<Neo4jError> with LinkedList<> in method private addError(error Neo4jError) : void from class org.neo4j.server.rest.transactional.StatementDeserializer


    private boolean beginsWithCorrectTokens() throws IOException
    {
        List<JsonToken> expectedTokens = asList( START_OBJECT, FIELD_NAME, START_ARRAY );
        String expectedField = "statements";

        List<JsonToken> foundTokens = new ArrayList<>();

        for ( int i = 0; i < expectedTokens.size(); i++ )
        {
            JsonToken token = input.nextToken();
            if ( i == 0 && token == null )
            {
                return false;
            }
            if ( token == FIELD_NAME && !expectedField.equals( input.getText() ) )
            {
                addError( new Neo4jError(
                        StatusCode.INVALID_REQUEST_FORMAT,
                        new DeserializationException( String.format( "Unable to deserialize request. " +
                                                                     "Expected first field to be '%s', but was '%s'.",
                                                                     expectedField, input.getText() ) ) ) );
                return false;
            }
            foundTokens.add( token );
        }
        if ( !expectedTokens.equals( foundTokens ) )
        {
            addError( new Neo4jError(
                    StatusCode.INVALID_REQUEST_FORMAT,
                    new DeserializationException( String.format( "Unable to deserialize request. " +
                            "Expected %s, found %s.", expectedTokens, foundTokens ) ) ) );
            return false;
        }
        return true;
    }

    private boolean beginsWithCorrectTokens() throws IOException
    {
        List<JsonToken> expectedTokens = asList( START_OBJECT, FIELD_NAME, START_ARRAY );
        String expectedField = "statements";

        List<JsonToken> foundTokens = new ArrayList<JsonToken>();

        for ( int i = 0; i < expectedTokens.size(); i++ )
        {
            JsonToken token = input.nextToken();
            if ( i == 0 && token == null )
            {
                return false;
            }
            if ( token == FIELD_NAME && !expectedField.equals( input.getText() ) )
            {
                addError( new Neo4jError(
                        StatusCode.INVALID_REQUEST_FORMAT,
                        new DeserializationException( String.format( "Unable to deserialize request. " +
                                                                     "Expected first field to be '%s', but was '%s'.",
                                                                     expectedField, input.getText() ) ) ) );
                return false;
            }
            foundTokens.add( token );
        }
        if ( !expectedTokens.equals( foundTokens ) )
        {
            addError( new Neo4jError(
                    StatusCode.INVALID_REQUEST_FORMAT,
                    new DeserializationException( String.format( "Unable to deserialize request. " +
                            "Expected %s, found %s.", expectedTokens, foundTokens ) ) ) );
            return false;
        }
        return true;
    }

Replace Generic With Diamond ArrayList<JsonToken> with ArrayList<> in method private beginsWithCorrectTokens() : boolean from class org.neo4j.server.rest.transactional.StatementDeserializer


    public void execute( StatementDeserializer statements, ExecutionResultSerializer output )
    {
        List<Neo4jError> errors = new LinkedList<>();
        try
        {
            output.transactionCommitUri( uriScheme.txCommitUri( id ) );
            ensureActiveTransaction();
            execute( statements, output, errors );
        }
        catch ( InternalBeginTransactionError e )
        {
            errors.add( e.toNeo4jError() );
        }
        finally
        {
            output.errors( errors );
            output.finish();
        }
    }

    public void execute( StatementDeserializer statements, ExecutionResultSerializer output )
    {
        List<Neo4jError> errors = new LinkedList<Neo4jError>();
        try
        {
            output.transactionCommitUri( uriScheme.txCommitUri( id ) );
            ensureActiveTransaction();
            execute( statements, output, errors );
        }
        catch ( InternalBeginTransactionError e )
        {
            errors.add( e.toNeo4jError() );
        }
        finally
        {
            output.errors( errors );
            output.finish();
        }
    }

Replace Generic With Diamond LinkedList<Neo4jError> with LinkedList<> in method public execute(statements StatementDeserializer, output ExecutionResultSerializer) : void from class org.neo4j.server.rest.transactional.TransactionHandle


    public void commit( StatementDeserializer statements, ExecutionResultSerializer output )
    {
        List<Neo4jError> errors = new LinkedList<>();
        try
        {
            ensureActiveTransaction();
            commit( statements, output, errors );
        }
        catch ( InternalBeginTransactionError e )
        {
            errors.add( e.toNeo4jError() );
        }
        finally
        {
            output.errors( errors );
            output.finish();
        }
    }

    public void commit( StatementDeserializer statements, ExecutionResultSerializer output )
    {
        List<Neo4jError> errors = new LinkedList<Neo4jError>();
        try
        {
            ensureActiveTransaction();
            commit( statements, output, errors );
        }
        catch ( InternalBeginTransactionError e )
        {
            errors.add( e.toNeo4jError() );
        }
        finally
        {
            output.errors( errors );
            output.finish();
        }
    }

Replace Generic With Diamond LinkedList<Neo4jError> with LinkedList<> in method public commit(statements StatementDeserializer, output ExecutionResultSerializer) : void from class org.neo4j.server.rest.transactional.TransactionHandle


    public void rollback( ExecutionResultSerializer output )
    {
        List<Neo4jError> errors = new LinkedList<>();
        try
        {
            ensureActiveTransaction();
            rollback( errors );
        }
        catch ( InternalBeginTransactionError e )
        {
            errors.add( e.toNeo4jError() );
        }
        finally
        {
            output.errors( errors );
            output.finish();
        }
    }

    public void rollback( ExecutionResultSerializer output )
    {
        List<Neo4jError> errors = new LinkedList<Neo4jError>();
        try
        {
            ensureActiveTransaction();
            rollback( errors );
        }
        catch ( InternalBeginTransactionError e )
        {
            errors.add( e.toNeo4jError() );
        }
        finally
        {
            output.errors( errors );
            output.finish();
        }
    }

Replace Generic With Diamond LinkedList<Neo4jError> with LinkedList<> in method public rollback(output ExecutionResultSerializer) : void from class org.neo4j.server.rest.transactional.TransactionHandle


            @Override
            protected boolean matchesSafely( Iterable<Neo4jError> item )
            {
                Set<StatusCode> actualErrorCodes = new HashSet<>();
                for ( Neo4jError neo4jError : item )
                {
                    actualErrorCodes.add( neo4jError.getStatusCode() );
                }
                return expectedErrorsCodes.equals( actualErrorCodes );
            }

            @Override
            protected boolean matchesSafely( Iterable<Neo4jError> item )
            {
                Set<StatusCode> actualErrorCodes = new HashSet<StatusCode>();
                for ( Neo4jError neo4jError : item )
                {
                    actualErrorCodes.add( neo4jError.getStatusCode() );
                }
                return expectedErrorsCodes.equals( actualErrorCodes );
            }

Replace Generic With Diamond HashSet<StatusCode> with HashSet<> in method protected matchesSafely(item Iterable<Neo4jError>) : boolean from class org.neo4j.server.rest.transactional.TransactionHandleTest.hasErrors.new TypeSafeMatcher<Iterable<Neo4jError>>


        public Builder withHeaders( Map<String, String> newHeaders )
        {
            HashMap<String, String> combined = new HashMap<>();
            combined.putAll( newHeaders );
            combined.putAll( headers );
            return new Builder( combined, baseUri );
        }

        public Builder withHeaders( Map<String, String> newHeaders )
        {
            HashMap<String, String> combined = new HashMap<String, String>();
            combined.putAll( newHeaders );
            combined.putAll( headers );
            return new Builder( combined, baseUri );
        }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public withHeaders(newHeaders Map<String,String>) : Builder from class org.neo4j.test.server.HTTP.Builder


    private Map<String, String> getDefaultParams()
    {
        Map<String, String> params = new HashMap<>();
        params.put( "neostore.nodestore.db.mapped_memory", "20M" );
        params.put( "neostore.propertystore.db.mapped_memory", "90M" );
        params.put( "neostore.propertystore.db.index.mapped_memory", "1M" );
        params.put( "neostore.propertystore.db.index.keys.mapped_memory", "1M" );
        params.put( "neostore.propertystore.db.strings.mapped_memory", "130M" );
        params.put( "neostore.propertystore.db.arrays.mapped_memory", "130M" );
        params.put( "neostore.relationshipstore.db.mapped_memory", "50M" );
        return params;
    }

    private Map<String, String> getDefaultParams()
    {
        Map<String, String> params = new HashMap<String, String>();
        params.put( "neostore.nodestore.db.mapped_memory", "20M" );
        params.put( "neostore.propertystore.db.mapped_memory", "90M" );
        params.put( "neostore.propertystore.db.index.mapped_memory", "1M" );
        params.put( "neostore.propertystore.db.index.keys.mapped_memory", "1M" );
        params.put( "neostore.propertystore.db.strings.mapped_memory", "130M" );
        params.put( "neostore.propertystore.db.arrays.mapped_memory", "130M" );
        params.put( "neostore.relationshipstore.db.mapped_memory", "50M" );
        return params;
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method private getDefaultParams() : Map<String,String> from class org.neo4j.unsafe.batchinsert.BatchInserterImpl


    private IndexRule[] getIndexesNeedingPopulation()
    {
        List<IndexRule> indexesNeedingPopulation = new ArrayList<>();
        for ( SchemaRule rule : schemaCache.getSchemaRules() )
        {
            if ( rule.getKind().isIndex() )
            {
                IndexRule indexRule = (IndexRule) rule;
                SchemaIndexProvider provider =
                        schemaIndexProviders.apply( indexRule.getProviderDescriptor() );
                if ( provider.getInitialState( indexRule.getId() ) != InternalIndexState.FAILED )
                {
                    indexesNeedingPopulation.add( indexRule );
                }
            }
        }
        return indexesNeedingPopulation.toArray( new IndexRule[indexesNeedingPopulation.size()] );
    }

    private IndexRule[] getIndexesNeedingPopulation()
    {
        List<IndexRule> indexesNeedingPopulation = new ArrayList<IndexRule>();
        for ( SchemaRule rule : schemaCache.getSchemaRules() )
        {
            if ( rule.getKind().isIndex() )
            {
                IndexRule indexRule = (IndexRule) rule;
                SchemaIndexProvider provider =
                        schemaIndexProviders.apply( indexRule.getProviderDescriptor() );
                if ( provider.getInitialState( indexRule.getId() ) != InternalIndexState.FAILED )
                {
                    indexesNeedingPopulation.add( indexRule );
                }
            }
        }
        return indexesNeedingPopulation.toArray( new IndexRule[indexesNeedingPopulation.size()] );
    }

Replace Generic With Diamond ArrayList<IndexRule> with ArrayList<> in method private getIndexesNeedingPopulation() : IndexRule[] from class org.neo4j.unsafe.batchinsert.BatchInserterImpl


    @Override
    public Iterable<Long> getRelationshipIds( long nodeId )
    {
        NodeRecord nodeRecord = getNodeRecord( nodeId );
        long nextRel = nodeRecord.getNextRel();
        List<Long> ids = new ArrayList<>();
        while ( nextRel != Record.NO_NEXT_RELATIONSHIP.intValue() )
        {
            RelationshipRecord relRecord = getRelationshipRecord( nextRel );
            ids.add( relRecord.getId() );
            long firstNode = relRecord.getFirstNode();
            long secondNode = relRecord.getSecondNode();
            if ( firstNode == nodeId )
            {
                nextRel = relRecord.getFirstNextRel();
            }
            else if ( secondNode == nodeId )
            {
                nextRel = relRecord.getSecondNextRel();
            }
            else
            {
                throw new InvalidRecordException( "Node[" + nodeId +
                                                  "] not part of firstNode[" + firstNode +
                                                  "] or secondNode[" + secondNode + "]" );
            }
        }
        return ids;
    }

    @Override
    public Iterable<Long> getRelationshipIds( long nodeId )
    {
        NodeRecord nodeRecord = getNodeRecord( nodeId );
        long nextRel = nodeRecord.getNextRel();
        List<Long> ids = new ArrayList<Long>();
        while ( nextRel != Record.NO_NEXT_RELATIONSHIP.intValue() )
        {
            RelationshipRecord relRecord = getRelationshipRecord( nextRel );
            ids.add( relRecord.getId() );
            long firstNode = relRecord.getFirstNode();
            long secondNode = relRecord.getSecondNode();
            if ( firstNode == nodeId )
            {
                nextRel = relRecord.getFirstNextRel();
            }
            else if ( secondNode == nodeId )
            {
                nextRel = relRecord.getSecondNextRel();
            }
            else
            {
                throw new InvalidRecordException( "Node[" + nodeId +
                                                  "] not part of firstNode[" + firstNode +
                                                  "] or secondNode[" + secondNode + "]" );
            }
        }
        return ids;
    }

Replace Generic With Diamond ArrayList<Long> with ArrayList<> in method public getRelationshipIds(nodeId long) : Iterable<Long> from class org.neo4j.unsafe.batchinsert.BatchInserterImpl