    @Test
    public void pullUpdatesShellAppPullsUpdates() throws Throwable
    {
        File root = TargetDirectory.forTest( getClass() ).cleanDirectory( "pullUpdatesShellAppPullsUpdates" );
        Map<Integer, Map<String, String>> instanceConfig = new HashMap<>();
        for (int i = 1; i <= 2; i++)
        {
            Map<String, String> thisInstance =
                    MapUtil.stringMap( ShellSettings.remote_shell_port.name(), "" + (SHELL_PORT + i) );
            instanceConfig.put( i, thisInstance );
        }
        ClusterManager clusterManager = new ClusterManager( clusterOfSize( 2 ), root, MapUtil.stringMap(
                HaSettings.pull_interval.name(), "0",
                HaSettings.tx_push_factor.name(), "0" ,
                ShellSettings.remote_shell_enabled.name(), "true"
                ), instanceConfig );
        clusterManager.start();
        cluster = clusterManager.getDefaultCluster();

        long commonNodeId = createNodeOnMaster();

        setProperty( cluster.getMaster(), commonNodeId, 1 );
        callPullUpdatesViaShell( 2 );
        HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
        Transaction transaction = slave.beginTx();
        try
        {
            assertEquals( 1, slave.getNodeById(commonNodeId).getProperty( "i" ) );
        }
        finally
        {
            transaction.finish();
        }
    }

    @Test
    public void pullUpdatesShellAppPullsUpdates() throws Throwable
    {
        File root = TargetDirectory.forTest( getClass() ).cleanDirectory( "pullUpdatesShellAppPullsUpdates" );
        Map<Integer, Map<String, String>> instanceConfig = new HashMap<Integer, Map<String, String>>();
        for (int i = 1; i <= 2; i++)
        {
            Map<String, String> thisInstance =
                    MapUtil.stringMap( ShellSettings.remote_shell_port.name(), "" + (SHELL_PORT + i) );
            instanceConfig.put( i, thisInstance );
        }
        ClusterManager clusterManager = new ClusterManager( clusterOfSize( 2 ), root, MapUtil.stringMap(
                HaSettings.pull_interval.name(), "0",
                HaSettings.tx_push_factor.name(), "0" ,
                ShellSettings.remote_shell_enabled.name(), "true"
                ), instanceConfig );
        clusterManager.start();
        cluster = clusterManager.getDefaultCluster();

        long commonNodeId = createNodeOnMaster();

        setProperty( cluster.getMaster(), commonNodeId, 1 );
        callPullUpdatesViaShell( 2 );
        HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
        Transaction transaction = slave.beginTx();
        try
        {
            assertEquals( 1, slave.getNodeById(commonNodeId).getProperty( "i" ) );
        }
        finally
        {
            transaction.finish();
        }
    }

Replace Generic With Diamond HashMap<Integer,Map<String,String>> with HashMap<> in method public pullUpdatesShellAppPullsUpdates() : void from class org.neo4j.ha.TestPullUpdates


    private String commitToSchemaState( String key, String value ) throws TransactionFailureException
    {
        try ( KernelTransaction transaction = kernel.newTransaction() )
        {
            String result = getOrCreateFromState( transaction, key, value );
            transaction.success();
            return result;
        }
    }

    private String commitToSchemaState( String key, String value ) throws TransactionFailureException
    {
        KernelTransaction transaction = kernel.newTransaction();
        boolean success = false;
        try
        {
            String result = getOrCreateFromState( transaction, key, value );
            success = true;
            return result;
        }
        finally
        {
            kernel.finish( transaction, success );
        }
    }

Try With Resources try(KernelTransaction transaction=kernel.newTransaction()) in method private commitToSchemaState(key String, value String) : String from class org.neo4j.kernel.impl.api.KernelSchemaStateFlushingTest


    @Override
    public synchronized int getOrCreate( String name )
    {
        KernelAPI kernel = kernelProvider.instance();
        try ( KernelTransaction transaction = kernel.newTransaction() )
        {
            int id = createKey( transaction.getTransactionRecordState(), name );
            transaction.success();
            return id;
        }
        catch ( TransactionFailureException e )
        {
            throw new org.neo4j.graphdb.TransactionFailureException(
                    "Failure to rollback after creating token failed", e );
        }
    }

    @Override
    public synchronized int getOrCreate( String name )
    {
        KernelAPI kernel = kernelProvider.instance();
        KernelTransaction transaction = kernel.newTransaction();
        boolean success = false;
        try
        {
            int id = createKey( transaction.getTransactionRecordState(), name );
            success = true;
            return id;
        }
        finally
        {
            if ( !success )
            {
                try
                {
                    kernel.finish( transaction, success );
                }
                catch ( TransactionFailureException e )
                {
                    throw new org.neo4j.graphdb.TransactionFailureException(
                            "Failure to rollback after creating token failed", e );
                }
            }
        }
    }

Try With Resources try(KernelTransaction transaction=kernel.newTransaction()) in method public getOrCreate(name String) : int from class org.neo4j.kernel.impl.core.IsolatedTransactionTokenCreator


    @Override
    public List<WindowPoolStats> getAllWindowPoolStats()
    {
        List<WindowPoolStats> list = new ArrayList<>();
        list.add( nameStore.getWindowPoolStats() );
        list.add( getWindowPoolStats() );
        return list;
    }

    @Override
    public List<WindowPoolStats> getAllWindowPoolStats()
    {
        List<WindowPoolStats> list = new ArrayList<WindowPoolStats>();
        list.add( nameStore.getWindowPoolStats() );
        list.add( getWindowPoolStats() );
        return list;
    }

Replace Generic With Diamond ArrayList<WindowPoolStats> with ArrayList<> in method public getAllWindowPoolStats() : List<WindowPoolStats> from class org.neo4j.kernel.impl.nioneo.store.TokenStore


        private void verifyRelationshipIdsReused()
        {
            try ( Transaction transaction = database.beginTx() )
            {
                Node node1 = database.createNode();
                Node node2 = database.createNode();
                Relationship relationship1 = node1.createRelationshipTo( node2, withName( "REUSE" ) );
                assertEquals( 0, relationship1.getId() );
                transaction.success();
            }
        }

        private void verifyRelationshipIdsReused()
        {
            Transaction transaction = database.beginTx();
            try
            {
                Node node1 = database.createNode();
                Node node2 = database.createNode();
                Relationship relationship1 = node1.createRelationshipTo( node2, withName( "REUSE" ) );
                assertEquals( 0, relationship1.getId() );
                transaction.success();
            }
            finally
            {
                transaction.finish();
            }
        }

Try With Resources try(Transaction transaction=database.beginTx()) in method private verifyRelationshipIdsReused() : void from class org.neo4j.kernel.impl.storemigration.StoreMigratorIT.DatabaseContentVerifier


    private void assertNuDuplicates( Token[] tokens )
    {
        Set<String> visited = new HashSet<>();
        for ( Token token : tokens )
        {
            assertTrue( visited.add( token.name() ) );
        }
    }

    private void assertNuDuplicates( Token[] tokens )
    {
        Set<String> visited = new HashSet<String>();
        for ( Token token : tokens )
        {
            assertTrue( visited.add( token.name() ) );
        }
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method private assertNuDuplicates(tokens Token[]) : void from class org.neo4j.kernel.impl.storemigration.StoreMigratorIT


    private void stopServicesAndHandleBranchedStore( BranchedDataPolicy branchPolicy ) throws Throwable
    {
        List<Class> services = new ArrayList<>( Arrays.asList( SERVICES_TO_RESTART_FOR_STORE_COPY ) );
        Collections.reverse( services );
        for ( Class<Lifecycle> serviceClass : services )
        {
            resolver.resolveDependency( serviceClass ).stop();
        }

        branchPolicy.handle( config.get( InternalAbstractGraphDatabase.Configuration.store_dir ) );
    }

    private void stopServicesAndHandleBranchedStore( BranchedDataPolicy branchPolicy ) throws Throwable
    {
        List<Class> services = new ArrayList<Class>( Arrays.asList( SERVICES_TO_RESTART_FOR_STORE_COPY ) );
        Collections.reverse( services );
        for ( Class<Lifecycle> serviceClass : services )
        {
            resolver.resolveDependency( serviceClass ).stop();
        }

        branchPolicy.handle( config.get( InternalAbstractGraphDatabase.Configuration.store_dir ) );
    }

Replace Generic With Diamond ArrayList<Class> with ArrayList<> in method private stopServicesAndHandleBranchedStore(branchPolicy BranchedDataPolicy) : void from class org.neo4j.kernel.ha.cluster.SwitchToSlave


    private Map<String, String> determineSystemProperties()
    {
        Map<String, String> relevantSysProps = new HashMap<>();
        Properties sysProps = System.getProperties();
        Enumeration sysPropsNames = sysProps.propertyNames();
        while ( sysPropsNames.hasMoreElements() )
        {
            String sysPropName = (String) sysPropsNames.nextElement();
            if ( sysPropName.startsWith( UDC_PROPERTY_PREFIX ) || sysPropName.startsWith( OS_PROPERTY_PREFIX ) )
            {
                String propertyValue = sysProps.getProperty( sysPropName );
                relevantSysProps.put( removeUdcPrefix( sysPropName ), sanitizeUdcProperty( propertyValue ) );
            }
        }
        return relevantSysProps;
    }

    private Map<String, String> determineSystemProperties()
    {
        Map<String, String> relevantSysProps = new HashMap<String, String>();
        Properties sysProps = System.getProperties();
        Enumeration sysPropsNames = sysProps.propertyNames();
        while ( sysPropsNames.hasMoreElements() )
        {
            String sysPropName = (String) sysPropsNames.nextElement();
            if ( sysPropName.startsWith( UDC_PROPERTY_PREFIX ) || sysPropName.startsWith( OS_PROPERTY_PREFIX ) )
            {
                String propertyValue = sysProps.getProperty( sysPropName );
                relevantSysProps.put( removeUdcPrefix( sysPropName ), sanitizeUdcProperty( propertyValue ) );
            }
        }
        return relevantSysProps;
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method private determineSystemProperties() : Map<String,String> from class org.neo4j.ext.udc.impl.DefaultUdcInformationCollector


    private void blockUntilServerAvailable( final URL url ) throws Exception
    {
        final CountDownLatch latch = new CountDownLatch( 1 );
        final PointerTo<Boolean> flag = new PointerTo<>( false );

        Thread t = new Thread( new Runnable()
        {
            @Override
            public void run()
            {
                while ( !flag.getValue() )
                {
                    try
                    {
                        HttpGet httpget = new HttpGet( url.toURI() );
                        httpget.addHeader( "Accept", "application/json" );
                        DefaultHttpClient client = new DefaultHttpClient();
                        client.execute( httpget );

                        // If we get here, the server's ready
                        flag.setValue( true );
                        latch.countDown();
                    }
                    catch ( Exception e )
                    {
                        throw new RuntimeException( e );
                    }
                }
            }
        } );

        t.run();

        latch.await( 1000, TimeUnit.MILLISECONDS );

        t.join();
    }

    private void blockUntilServerAvailable( final URL url ) throws Exception
    {
        final CountDownLatch latch = new CountDownLatch( 1 );
        final PointerTo<Boolean> flag = new PointerTo<Boolean>( false );

        Thread t = new Thread( new Runnable()
        {
            @Override
            public void run()
            {
                while ( !flag.getValue() )
                {
                    try
                    {
                        HttpGet httpget = new HttpGet( url.toURI() );
                        httpget.addHeader( "Accept", "application/json" );
                        DefaultHttpClient client = new DefaultHttpClient();
                        client.execute( httpget );

                        // If we get here, the server's ready
                        flag.setValue( true );
                        latch.countDown();
                    }
                    catch ( Exception e )
                    {
                        throw new RuntimeException( e );
                    }
                }
            }
        } );

        t.run();

        latch.await( 1000, TimeUnit.MILLISECONDS );

        t.join();
    }

Replace Generic With Diamond PointerTo<Boolean> with PointerTo<> in method private blockUntilServerAvailable(url URL) : void from class org.neo4j.ext.udc.impl.UdcExtensionImplTest


        private Map<String, String> addVitalConfig( Map<String, String> dbConfiguration )
        {
            return stringMap( new HashMap<>( dbConfiguration ),
                    GraphDatabaseSettings.keep_logical_logs.name(), Settings.TRUE );
        }

        private Map<String, String> addVitalConfig( Map<String, String> dbConfiguration )
        {
            return stringMap( new HashMap<String, String>( dbConfiguration ),
                    GraphDatabaseSettings.keep_logical_logs.name(), Settings.TRUE );
        }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method private addVitalConfig(dbConfiguration Map<String,String>) : Map<String,String> from class org.neo4j.test.AbstractSubProcessTestBase.Bootstrapper


    @Test
    public void use_cypher_periodic_commit() throws Exception
    {
        File file = File.createTempFile( "file", "csv", null );
        try ( PrintWriter writer = new PrintWriter( file ) )
        {
            String url = file.toURI().toURL().toString().replace("\\", "\\\\");
            writer.println("1,2,3");
            writer.println("4,5,6");

            // WHEN
            executeCommand( "USING PERIODIC COMMIT 100 LOAD CSV FROM '" + url + "' AS line CREATE ();" );
        }
        catch ( ShellException e )
        {
            // THEN NOT
            fail( "Failed to execute PERIODIC COMMIT query" );
        }
        finally
        {
            file.delete();
        }
    }

    @Test
    public void use_cypher_periodic_commit() throws Exception
    {
        try
        {
            // WHEN
            executeCommand( "USING PERIODIC COMMIT 100 CREATE n;" );
        }
        catch ( ShellException e )
        {
            // THEN NOT
            fail( "Failed to execute PERIODIC COMMIT query" );
        }
    }

Try With Resources try(PrintWriter writer=new PrintWriter(file)) in method public use_cypher_periodic_commit() : void from class org.neo4j.shell.TestApps


            public void run()
            {

                try(Transaction tx = getGraphDb().beginTx())
                {
                    node1.setProperty( "key", "new" );
                    rel1.setProperty( "key", "new" );
                    node1.createRelationshipTo( node2,
                        DynamicRelationshipType.withName( "TEST" ) );
                    assertPropertyEqual( node1, "key", "new" );
                    assertPropertyEqual( rel1, "key", "new" );
                    assertRelationshipCount( node1, 2 );
                    assertRelationshipCount( node2, 2 );
                    latch1.countDown();
                    latch2.await();
                    assertPropertyEqual( node1, "key", "new" );
                    assertPropertyEqual( rel1, "key", "new" );
                    assertRelationshipCount( node1, 2 );
                    assertRelationshipCount( node2, 2 );
                    // no tx.success();
                }
                catch ( Exception e )
                {
                    e.printStackTrace();
                    Thread.interrupted();
                    t1Exception.set( e );
                }
                finally
                {
                    try
                    {
                        assertPropertyEqual( node1, "key", "old" );
                        assertPropertyEqual( rel1, "key", "old" );
                        assertRelationshipCount( node1, 1 );
                        assertRelationshipCount( node2, 1 );
                    }
                    catch(Exception e)
                    {
                        t1Exception.compareAndSet( null, e );
                    }
                }
            }

            public void run()
            {
                Transaction tx = getGraphDb().beginTx();
                try
                {
                    node1.setProperty( "key", "new" );
                    rel1.setProperty( "key", "new" );
                    node1.createRelationshipTo( node2,
                        DynamicRelationshipType.withName( "TEST" ) );
                    assertPropertyEqual( node1, "key", "new" );
                    assertPropertyEqual( rel1, "key", "new" );
                    assertRelationshipCount( node1, 2 );
                    assertRelationshipCount( node2, 2 );
                    latch1.countDown();
                    latch2.await();
                    assertPropertyEqual( node1, "key", "new" );
                    assertPropertyEqual( rel1, "key", "new" );
                    assertRelationshipCount( node1, 2 );
                    assertRelationshipCount( node2, 2 );
                    // no tx.success();
                }
                catch ( InterruptedException e )
                {
                    e.printStackTrace();
                    Thread.interrupted();
                }
                finally
                {
                    tx.finish();
                    assertPropertyEqual( node1, "key", "old" );
                    assertPropertyEqual( rel1, "key", "old" );
                    assertRelationshipCount( node1, 1 );
                    assertRelationshipCount( node2, 1 );
                }
            }

Try With Resources try(Transaction tx=getGraphDb().beginTx()) in method public run() : void from class org.neo4j.kernel.impl.core.TestIsolationBasic.testSimpleTransactionIsolation.t1.new Thread.new Runnable


        private void enlist()
        {
            try
            {
                XAResource xaResource = connection.getXaResource();
                if ( !tx.enlistResource( xaResource ) )
                {
                    throw new ResourceAcquisitionFailedException( xaResource );
                }

                TransactionEventsSyncHook hook = syncHookFactory.create();
                if ( hook != null )
                {
                    tx.registerSynchronization( hook );
                }
            }
            catch ( RollbackException | SystemException re )
            {
                throw new ResourceAcquisitionFailedException( re );
            }
        }

        private void enlist()
        {
            try
            {
                XAResource xaResource = connection.getXaResource();
                if ( !tx.enlistResource( xaResource ) )
                {
                    throw new ResourceAcquisitionFailedException( xaResource );
                }

                TransactionEventsSyncHook hook = syncHookFactory.create();
                if ( hook != null )
                {
                    tx.registerSynchronization( hook );
                }
            }
            catch ( RollbackException re )
            {
                throw new ResourceAcquisitionFailedException( re );
            }
            catch ( SystemException se )
            {
                throw new ResourceAcquisitionFailedException( se );
            }
        }

Merge Catch [catch(RollbackException re), catch(SystemException se)] to catch(RollbackException|SystemException re) in method private enlist() : void from class org.neo4j.kernel.impl.persistence.PersistenceManager.ResourceHolder


    private ResourceHolder createResource( Transaction tx )
    {
        try
        {
            XaConnection xaConnection = persistenceSource.getXaDataSource().getXaConnection();
            NeoStoreTransaction resource = persistenceSource.createTransaction( xaConnection );
            ResourceHolder result = new ResourceHolder( syncHookFactory, tx, xaConnection, resource );

            TransactionState state = transactionManager.getTransactionState();
            tx.registerSynchronization( new ResourceCleanupHook( tx, state, result ) );
            return result;
        }
        catch ( RollbackException | SystemException e )
        {
            throw new ResourceAcquisitionFailedException( e );
        }
    }

    private ResourceHolder createResource( Transaction tx )
    {
        try
        {
            XaConnection xaConnection = persistenceSource.getXaDataSource().getXaConnection();
            NeoStoreTransaction resource = persistenceSource.createTransaction( xaConnection );
            ResourceHolder result = new ResourceHolder( syncHookFactory, tx, xaConnection, resource );

            TransactionState state = transactionManager.getTransactionState();
            tx.registerSynchronization( new ResourceCleanupHook( tx, state, result ) );
            return result;
        }
        catch ( RollbackException e )
        {
            throw new ResourceAcquisitionFailedException( e );
        }
        catch ( SystemException e )
        {
            throw new ResourceAcquisitionFailedException( e );
        }
    }

Merge Catch [catch(RollbackException e), catch(SystemException e)] to catch(RollbackException|SystemException e) in method private createResource(tx Transaction) : ResourceHolder from class org.neo4j.kernel.impl.persistence.PersistenceManager


    private List<Long> getAllNodes( String propertyValue ) throws IOException
    {
        try ( IndexReader reader = accessor.newReader() )
        {
            List<Long> list = new LinkedList<>();
            for ( PrimitiveLongIterator iterator = reader.lookup( propertyValue ); iterator.hasNext(); )
            {
                list.add( iterator.next() );
            }
            Collections.sort( list );
            return list;
        }
    }

    private List<Long> getAllNodes( String propertyValue ) throws IOException
    {
        IndexReader reader = accessor.newReader();
        try
        {
            List<Long> list = new LinkedList<>();
            for ( PrimitiveLongIterator iterator = reader.lookup( propertyValue ); iterator.hasNext(); )
            {
                list.add( iterator.next() );
            }
            Collections.sort( list );
            return list;
        }
        finally
        {
            reader.close();
        }
    }

Try With Resources try(IndexReader reader=accessor.newReader()) in method private getAllNodes(propertyValue String) : List<Long> from class org.neo4j.kernel.api.index.UniqueIndexAccessorCompatibility


    private void loadDatabaseTuningProperties( File configFile ) throws ConfigurationException
    {
        String databaseTuningPropertyFileLocation = serverConfiguration.getString( DB_TUNING_PROPERTY_FILE_KEY );

        if ( databaseTuningPropertyFileLocation == null )
        {
            if ( propertyFileDirectoryContainsDBTuningFile() )
            {
                databaseTuningPropertyFileLocation = new File( propertyFileDirectory, NEO4J_PROPERTIES_FILENAME ).getAbsolutePath();
                log.info( "No database tuning file explicitly set, defaulting to [%s]",
                        databaseTuningPropertyFileLocation );
            }
            else
            {
                log.info(
                        "No database tuning properties (org.neo4j.server.db.tuning.properties) found in [%s], using defaults.",
                        configFile.getPath() );
                return;
            }
        }

        File databaseTuningPropertyFile = new File( databaseTuningPropertyFileLocation );

        if ( !databaseTuningPropertyFile.exists() )
        {
            log.warn( "The specified file for database performance tuning properties [%s] does not exist.",
                    databaseTuningPropertyFileLocation );
            return;
        }

        try
        {
            databaseTuningProperties = MapUtil.load(databaseTuningPropertyFile);
        }
        catch( IOException e )
        {
            databaseTuningProperties = new HashMap<>();
        }
    }

    private void loadDatabaseTuningProperties( File configFile ) throws ConfigurationException
    {
        String databaseTuningPropertyFileLocation = serverConfiguration.getString( DB_TUNING_PROPERTY_FILE_KEY );

        if ( databaseTuningPropertyFileLocation == null )
        {
            if ( propertyFileDirectoryContainsDBTuningFile() )
            {
                databaseTuningPropertyFileLocation = new File( propertyFileDirectory, NEO4J_PROPERTIES_FILENAME ).getAbsolutePath();
                log.info( "No database tuning file explicitly set, defaulting to [%s]",
                        databaseTuningPropertyFileLocation );
            }
            else
            {
                log.info(
                        "No database tuning properties (org.neo4j.server.db.tuning.properties) found in [%s], using defaults.",
                        configFile.getPath() );
                return;
            }
        }

        File databaseTuningPropertyFile = new File( databaseTuningPropertyFileLocation );

        if ( !databaseTuningPropertyFile.exists() )
        {
            log.warn( "The specified file for database performance tuning properties [%s] does not exist.",
                    databaseTuningPropertyFileLocation );
            return;
        }

        try
        {
            databaseTuningProperties = MapUtil.load(databaseTuningPropertyFile);
        }
        catch( IOException e )
        {
            databaseTuningProperties = new HashMap<String, String>();
        }
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method private loadDatabaseTuningProperties(configFile File) : void from class org.neo4j.server.configuration.PropertyFileConfigurator


    private Iterable<Person> onlyFriend( Iterable<RankedPerson> rankedFriends )
    {
        ArrayList<Person> retVal = new ArrayList<>();
        for ( RankedPerson person : rankedFriends )
        {
            retVal.add( person.getPerson() );
        }
        return retVal;
    }

    private Iterable<Person> onlyFriend( Iterable<RankedPerson> rankedFriends )
    {
        ArrayList<Person> retVal = new ArrayList<Person>();
        for ( RankedPerson person : rankedFriends )
        {
            retVal.add( person.getPerson() );
        }
        return retVal;
    }

Replace Generic With Diamond ArrayList<Person> with ArrayList<> in method private onlyFriend(rankedFriends Iterable<RankedPerson>) : Iterable<Person> from class org.neo4j.examples.socnet.Person


    private static long setRecord( FileSystemAbstraction fileSystem, File neoStore, int position, long value )
    {
        try ( FileChannel channel = fileSystem.open( neoStore, "rw" ) )
        {
            channel.position( RECORD_SIZE*position+1/*inUse*/ );
            ByteBuffer buffer = ByteBuffer.allocate( 8 );
            channel.read( buffer );
            buffer.flip();
            long previous = buffer.getLong();
            channel.position( RECORD_SIZE*position+1/*inUse*/ );
            buffer.clear();
            buffer.putLong( value ).flip();
            channel.write( buffer );
            return previous;
        }
        catch ( IOException e )
        {
            throw new RuntimeException( e );
        }
    }

    /**
     * Sets the version for the given neostore file in {@code storeDir}.
     * @param storeDir the store dir to locate the neostore file in.
     * @param version the version to set.
     * @return the previous version before writing.
     */
    public static long setVersion( FileSystemAbstraction fileSystem, File storeDir, long version )
    {
        FileChannel channel = null;
        try
        {
            channel = fileSystem.open( new File( storeDir, NeoStore.DEFAULT_NAME ), "rw" );
            channel.position( RECORD_SIZE*2+1/*inUse*/ );
            ByteBuffer buffer = ByteBuffer.allocate( 8 );
            channel.read( buffer );
            buffer.flip();
            long previous = buffer.getLong();
            channel.position( RECORD_SIZE*2+1/*inUse*/ );
            buffer.clear();
            buffer.putLong( version ).flip();
            channel.write( buffer );
            return previous;
        }
        catch ( IOException e )
        {
            throw new RuntimeException( e );
        }
        finally
        {
            try
            {
                if ( channel != null ) channel.close();
            }
            catch ( IOException e )
            {
                throw new RuntimeException( e );
            }
        }
    }

Try With Resources try(FileChannel channel=fileSystem.open(neoStore,"rw")) in method private setRecord(fileSystem FileSystemAbstraction, neoStore File, position int, value long) : long from class org.neo4j.kernel.impl.nioneo.store.NeoStore


    private static long getRecord( FileSystemAbstraction fs, File neoStore, int recordPosition )
    {
        try ( FileChannel channel = fs.open( neoStore, "r" ) )
        {
            /*
             * We have to check size, because the store version
             * field was introduced with 1.5, so if there is a non-clean
             * shutdown we may have a buffer underflow.
             */
            if ( recordPosition > 3 && channel.size() < RECORD_SIZE * 5 )
            {
                return -1;
            }
            channel.position( RECORD_SIZE * recordPosition + 1/*inUse*/);
            ByteBuffer buffer = ByteBuffer.allocate( 8 );
            channel.read( buffer );
            buffer.flip();
            return buffer.getLong();
        }
        catch ( IOException e )
        {
            throw new RuntimeException( e );
        }
    }

    private static long getRecord( FileSystemAbstraction fs, File neoStore, long recordPosition )
    {
        FileChannel channel = null;
        try
        {
            channel = fs.open( neoStore, "r" );
            /*
             * We have to check size, because the store version
             * field was introduced with 1.5, so if there is a non-clean
             * shutdown we may have a buffer underflow.
             */
            if ( recordPosition > 3 && channel.size() < RECORD_SIZE * 5 )
            {
                return -1;
            }
            channel.position( RECORD_SIZE * recordPosition + 1/*inUse*/);
            ByteBuffer buffer = ByteBuffer.allocate( 8 );
            channel.read( buffer );
            buffer.flip();
            return buffer.getLong();
        }
        catch ( IOException e )
        {
            throw new RuntimeException( e );
        }
        finally
        {
            try
            {
                if ( channel != null )
                    channel.close();
            }
            catch ( IOException e )
            {
                throw new RuntimeException( e );
            }
        }
    }

Try With Resources try(FileChannel channel=fs.open(neoStore,"r")) in method private getRecord(fs FileSystemAbstraction, neoStore File, recordPosition int) : long from class org.neo4j.kernel.impl.nioneo.store.NeoStore


    private void setStoreVersionTrailer( File targetStoreFileName, String versionTrailer ) throws IOException
    {
        byte[] trailer = UTF8.encode( versionTrailer );
        long fileSize = 0;
        try ( FileChannel fileChannel = fs.open( targetStoreFileName, "rw" ) )
        {
            fileSize = fileChannel.size();
            fileChannel.position( fileChannel.size()-trailer.length );
            fileChannel.write( ByteBuffer.wrap( trailer ) );
        }
        catch ( IllegalArgumentException e )
        {
            throw new IllegalArgumentException( "size:" + fileSize + ", trailer:" + trailer.length +
                    " for " + targetStoreFileName );
        }
    }

    private void setStoreVersionTrailer( File targetStoreFileName, String versionTrailer ) throws IOException
    {
        FileChannel fileChannel = fs.open( targetStoreFileName, "rw" );
        try
        {
            byte[] trailer = UTF8.encode( versionTrailer );
            fileChannel.position( fileChannel.size()-trailer.length );
            fileChannel.write( ByteBuffer.wrap( trailer ) );
        }
        finally
        {
            fileChannel.close();
        }
    }

Try With Resources try(FileChannel fileChannel=fs.open(targetStoreFileName,"rw")) in method private setStoreVersionTrailer(targetStoreFileName File, versionTrailer String) : void from class org.neo4j.kernel.impl.storemigration.legacystore.LegacyStore


    @Test
    public void shouldUpgradeAutomaticallyOnDatabaseStartup() throws IOException
    {
        prepareSampleLegacyDatabase( fileSystem, workingDirectory );

        assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );

        HashMap<String, String> params = new HashMap<>();
        params.put( GraphDatabaseSettings.allow_store_upgrade.name(), "true" );

        GraphDatabaseService database = new GraphDatabaseFactory()
                .newEmbeddedDatabaseBuilder( workingDirectory.getPath() ).setConfig( params ).newGraphDatabase();
        database.shutdown();

        assertTrue( "Some store files did not have the correct version",
                allStoreFilesHaveVersion( fileSystem, workingDirectory, ALL_STORES_VERSION ) );
    }

    @Test
    public void shouldUpgradeAutomaticallyOnDatabaseStartup() throws IOException
    {
        prepareSampleLegacyDatabase( fileSystem, workingDirectory );

        assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );

        HashMap<String, String> params = new HashMap<String, String>();
        params.put( GraphDatabaseSettings.allow_store_upgrade.name(), "true" );

        GraphDatabaseService database = new GraphDatabaseFactory()
                .newEmbeddedDatabaseBuilder( workingDirectory.getPath() ).setConfig( params ).newGraphDatabase();
        database.shutdown();

        assertTrue( "Some store files did not have the correct version",
                allStoreFilesHaveVersion( fileSystem, workingDirectory, ALL_STORES_VERSION ) );
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public shouldUpgradeAutomaticallyOnDatabaseStartup() : void from class org.neo4j.kernel.impl.storemigration.StoreUpgradeIntegrationTest


    @Test
    public void shouldAbortOnNonCleanlyShutdown() throws Throwable
    {
        prepareSampleLegacyDatabase( fileSystem, workingDirectory );

        assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );
        StoreUpgraderTestIT.truncateAllFiles( fileSystem, workingDirectory );
        // Now everything has lost the version info

        Map<String, String> params = new HashMap<>();
        params.put( GraphDatabaseSettings.allow_store_upgrade.name(), "true" );

        try
        {
            new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(
                    workingDirectory.getPath()).setConfig( params ).newGraphDatabase();
            fail( "Should have been unable to start upgrade on old version" );
        }
        catch ( RuntimeException e )
        {
            assertThat( Exceptions.rootCause( e ), Matchers.instanceOf(
                    StoreUpgrader.UpgradingStoreVersionNotFoundException.class ) );
        }
    }

    @Test
    public void shouldAbortOnNonCleanlyShutdown() throws Throwable
    {
        prepareSampleLegacyDatabase( fileSystem, workingDirectory );

        assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );
        StoreUpgraderTestIT.truncateAllFiles( fileSystem, workingDirectory );
        // Now everything has lost the version info

        Map<String, String> params = new HashMap<String, String>();
        params.put( GraphDatabaseSettings.allow_store_upgrade.name(), "true" );

        try
        {
            new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(
                    workingDirectory.getPath()).setConfig( params ).newGraphDatabase();
            fail( "Should have been unable to start upgrade on old version" );
        }
        catch ( RuntimeException e )
        {
            assertThat( Exceptions.rootCause( e ), Matchers.instanceOf(
                    StoreUpgrader.UpgradingStoreVersionNotFoundException.class ) );
        }
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public shouldAbortOnNonCleanlyShutdown() : void from class org.neo4j.kernel.impl.storemigration.StoreUpgradeIntegrationTest


    @Test
    public void shouldAbortOnCorruptStore() throws IOException
    {
        prepareSampleLegacyDatabase( fileSystem, workingDirectory );

        assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );
        truncateFile(fileSystem, new File( workingDirectory,
                "neostore.propertystore.db.index.keys" ),
                "StringPropertyStore " + LEGACY_VERSION );

        Map<String, String> params = new HashMap<>();
        params.put( GraphDatabaseSettings.allow_store_upgrade.name(), "true" );

        try
        {
            GraphDatabaseService database = new GraphDatabaseFactory()
                    .newEmbeddedDatabaseBuilder( workingDirectory.getPath() ).setConfig( params ).newGraphDatabase();
            fail( "Should have been unable to start upgrade on old version" );
        }
        catch ( RuntimeException e )
        {
            assertThat( Exceptions.rootCause( e ), Matchers.instanceOf( UnableToUpgradeException.class ) );
        }
    }

    @Test
    public void shouldAbortOnCorruptStore() throws IOException
    {
        prepareSampleLegacyDatabase( fileSystem, workingDirectory );

        assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );
        truncateFile(fileSystem, new File( workingDirectory,
                "neostore.propertystore.db.index.keys" ),
                "StringPropertyStore " + LEGACY_VERSION );

        Map<String, String> params = new HashMap<String, String>();
        params.put( GraphDatabaseSettings.allow_store_upgrade.name(), "true" );

        try
        {
            GraphDatabaseService database = new GraphDatabaseFactory()
                    .newEmbeddedDatabaseBuilder( workingDirectory.getPath() ).setConfig( params ).newGraphDatabase();
            fail( "Should have been unable to start upgrade on old version" );
        }
        catch ( RuntimeException e )
        {
            assertThat( Exceptions.rootCause( e ), Matchers.instanceOf( UnableToUpgradeException.class ) );
        }
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public shouldAbortOnCorruptStore() : void from class org.neo4j.kernel.impl.storemigration.StoreUpgradeIntegrationTest


    public Map<String, String> getParams()
    {
        return new HashMap<>( this.params );
    }

    public Map<String, String> getParams()
    {
        return new HashMap<String, String>( this.params );
    }

Replace Generic With Diamond HashMap<String,String> with HashMap<> in method public getParams() : Map<String,String> from class org.neo4j.kernel.configuration.Config


    /**
     * Replace the current set of configuration parameters with another one.
     */
    public synchronized void applyChanges( Map<String, String> newConfiguration )
    {
        newConfiguration = migrator.apply( newConfiguration, log );

        // Make sure all changes are valid
        validator.validate( newConfiguration );

        // Figure out what changed
        if ( listeners.isEmpty() )
        {
            // Make the change
            params.clear();
            params.putAll( newConfiguration );
        }
        else
        {
            List<ConfigurationChange> configurationChanges = new ArrayList<>();
            for ( Map.Entry<String, String> stringStringEntry : newConfiguration.entrySet() )
            {
                String oldValue = params.get( stringStringEntry.getKey() );
                String newValue = stringStringEntry.getValue();
                if ( !(oldValue == null && newValue == null) &&
                        (oldValue == null || newValue == null || !oldValue.equals( newValue )) )
                {
                    configurationChanges.add( new ConfigurationChange( stringStringEntry.getKey(), oldValue,
                            newValue ) );
                }
            }

            // Make the change
            params.clear();
            params.putAll( newConfiguration );

            // Notify listeners
            for ( ConfigurationChangeListener listener : listeners )
            {
                listener.notifyConfigurationChanges( configurationChanges );
            }
        }
    }

    /**
     * Replace the current set of configuration parameters with another one.
     */
    public synchronized void applyChanges( Map<String, String> newConfiguration )
    {
        newConfiguration = migrator.apply( newConfiguration, log );

        // Make sure all changes are valid
        validator.validate( newConfiguration );

        // Figure out what changed
        if ( listeners.isEmpty() )
        {
            // Make the change
            params.clear();
            params.putAll( newConfiguration );
        }
        else
        {
            List<ConfigurationChange> configurationChanges = new ArrayList<ConfigurationChange>();
            for ( Map.Entry<String, String> stringStringEntry : newConfiguration.entrySet() )
            {
                String oldValue = params.get( stringStringEntry.getKey() );
                String newValue = stringStringEntry.getValue();
                if ( !(oldValue == null && newValue == null) &&
                        (oldValue == null || newValue == null || !oldValue.equals( newValue )) )
                {
                    configurationChanges.add( new ConfigurationChange( stringStringEntry.getKey(), oldValue,
                            newValue ) );
                }
            }

            // Make the change
            params.clear();
            params.putAll( newConfiguration );

            // Notify listeners
            for ( ConfigurationChangeListener listener : listeners )
            {
                listener.notifyConfigurationChanges( configurationChanges );
            }
        }
    }

Replace Generic With Diamond ArrayList<ConfigurationChange> with ArrayList<> in method public applyChanges(newConfiguration Map<String,String>) : void from class org.neo4j.kernel.configuration.Config


    @SuppressWarnings("rawtypes")
    private Map<String, Setting<?>> getSettingsFrom( Iterable<Class<?>> settingsClasses )
    {
        Map<String, Setting<?>> settings = new HashMap<>();
        for ( Class<?> clazz : settingsClasses )
        {
            for ( Pair<Field, Setting> field : fieldHarvester.findStatic( clazz, Setting.class ) )
            {
                settings.put( field.other().name(), field.other() );
            }
        }
        return settings;
    }

    @SuppressWarnings("rawtypes")
    private Map<String, Setting<?>> getSettingsFrom( Iterable<Class<?>> settingsClasses )
    {
        Map<String, Setting<?>> settings = new HashMap<String, Setting<?>>();
        for ( Class<?> clazz : settingsClasses )
        {
            for ( Pair<Field, Setting> field : fieldHarvester.findStatic( clazz, Setting.class ) )
            {
                settings.put( field.other().name(), field.other() );
            }
        }
        return settings;
    }

Replace Generic With Diamond HashMap<String,Setting<?>> with HashMap<> in method private getSettingsFrom(settingsClasses Iterable<Class<?>>) : Map<String,Setting<?>> from class org.neo4j.kernel.configuration.ConfigurationValidator


    @Override
    public Iterable<AdvertisableService> getServices()
    {
        List<AdvertisableService> toReturn = new ArrayList<>( 3 );
        toReturn.add( new ConsoleService( null, null, null ) );
        toReturn.add( new JmxService( null, null ) );
        toReturn.add( new MonitorService( null, null ) );

        return toReturn;
    }

    @Override
    public Iterable<AdvertisableService> getServices()
    {
        List<AdvertisableService> toReturn = new ArrayList<AdvertisableService>( 3 );
        toReturn.add( new ConsoleService( null, null, null ) );
        toReturn.add( new JmxService( null, null ) );
        toReturn.add( new MonitorService( null, null ) );

        return toReturn;
    }

Replace Generic With Diamond ArrayList<AdvertisableService> with ArrayList<> in method public getServices() : Iterable<AdvertisableService> from class org.neo4j.server.CommunityNeoServer


    @Test
    public void makeSureDbIsOnlyReadable()
    {
        // when
        try (Transaction tx = graphDb.beginTx())
        {
            graphDb.createNode();

            fail("expected exception");
        }
        // then
        catch ( ReadOnlyDbException e )
        {
            // ok
        }
    }

    @Test
    public void makeSureDbIsOnlyReadable()
    {
        Transaction tx = graphDb.beginTx();
        // when
        try
        {
            graphDb.createNode();

            fail("expected exception");
        }
        // then
        catch ( ReadOnlyDbException e )
        {
            // ok
        }
        finally
        {
            tx.finish();
        }
    }

Try With Resources try(Transaction tx=graphDb.beginTx()) in method public makeSureDbIsOnlyReadable() : void from class org.neo4j.examples.ReadOnlyDocTest


    @Name( GET_CONNECTED_NODES )
    @PluginTarget( Node.class )
    public Iterable<Node> getAllConnectedNodes( @Source Node start )
    {
        ArrayList<Node> nodes = new ArrayList<>();
        try ( Transaction tx = start.getGraphDatabase().beginTx() )
        {
            for ( Relationship rel : start.getRelationships() )
            {
                nodes.add( rel.getOtherNode( start ) );
            }

            tx.success();
        }
        return nodes;
    }

    @Name( GET_CONNECTED_NODES )
    @PluginTarget( Node.class )
    public Iterable<Node> getAllConnectedNodes( @Source Node start )
    {
        ArrayList<Node> nodes = new ArrayList<>();
        Transaction tx = start.getGraphDatabase().beginTx();
        try
        {
            for ( Relationship rel : start.getRelationships() )
            {
                nodes.add( rel.getOtherNode( start ) );
            }

            tx.success();
        }
        finally
        {
            tx.finish();
        }
        return nodes;
    }

Try With Resources try(Transaction tx=start.getGraphDatabase().beginTx()) in method public getAllConnectedNodes(start Node) : Iterable<Node> from class org.neo4j.server.plugins.FunctionalTestPlugin


    @PluginTarget( Node.class )
    public Iterable<Relationship> getRelationshipsBetween( final @Source Node start,
            final @Parameter( name = "other" ) Node end )
    {
        List<Relationship> result = new ArrayList<>();
        try ( Transaction tx = start.getGraphDatabase().beginTx() )
        {
            for ( Relationship relationship : start.getRelationships() )
            {
                if ( relationship.getOtherNode( start ).equals( end ) )
                {
                    result.add( relationship );
                }
            }
            tx.success();
        }
        return result;
    }

    @PluginTarget( Node.class )
    public Iterable<Relationship> getRelationshipsBetween( final @Source Node start,
            final @Parameter( name = "other" ) Node end )
    {
        List<Relationship> result = new ArrayList<>();
        Transaction tx = start.getGraphDatabase().beginTx();
        try
        {
            for ( Relationship relationship : start.getRelationships() )
            {
                if ( relationship.getOtherNode( start ).equals( end ) )
                {
                    result.add( relationship );
                }
            }
        }
        finally
        {
            tx.finish();
        }
        return result;
    }

Try With Resources try(Transaction tx=start.getGraphDatabase().beginTx()) in method public getRelationshipsBetween(start Node, end Node) : Iterable<Relationship> from class org.neo4j.server.plugins.FunctionalTestPlugin


    @PluginTarget( Node.class )
    public Iterable<Relationship> createRelationships( @Source Node start,
            @Parameter( name = "type" ) RelationshipType type, @Parameter( name = "nodes" ) Iterable<Node> nodes )
    {
        List<Relationship> result = new ArrayList<>();
        try ( Transaction tx = start.getGraphDatabase().beginTx() )
        {
            for ( Node end : nodes )
            {
                result.add( start.createRelationshipTo( end, type ) );
            }
            tx.success();
        }
        return result;
    }

    @PluginTarget( Node.class )
    public Iterable<Relationship> createRelationships( @Source Node start,
            @Parameter( name = "type" ) RelationshipType type, @Parameter( name = "nodes" ) Iterable<Node> nodes )
    {
        List<Relationship> result = new ArrayList<>();
        Transaction tx = start.getGraphDatabase().beginTx();
        try
        {
            for ( Node end : nodes )
            {
                result.add( start.createRelationshipTo( end, type ) );
            }
            tx.success();
        }
        finally
        {
            tx.finish();
        }
        return result;
    }

Try With Resources try(Transaction tx=start.getGraphDatabase().beginTx()) in method public createRelationships(start Node, type RelationshipType, nodes Iterable<Node>) : Iterable<Relationship> from class org.neo4j.server.plugins.FunctionalTestPlugin


    @PluginTarget( Node.class )
    public Node getThisNodeOrById( @Source Node start, @Parameter( name = "id", optional = true ) Long id )
    {
        optional = id;

        if ( id == null )
        {
            return start;
        }

        try ( Transaction tx = start.getGraphDatabase().beginTx() )
        {
            Node node = start.getGraphDatabase().getNodeById( id );

            tx.success();
            return node;
        }
    }

    @PluginTarget( Node.class )
    public Node getThisNodeOrById( @Source Node start, @Parameter( name = "id", optional = true ) Long id )
    {
        optional = id;

        if ( id == null )
        {
            return start;
        }

        Transaction tx = start.getGraphDatabase().beginTx();
        try
        {
            Node node = start.getGraphDatabase().getNodeById( id );

            tx.success();
            return node;
        }
        finally
        {
            tx.finish();
        }
    }

Try With Resources try(Transaction tx=start.getGraphDatabase().beginTx()) in method public getThisNodeOrById(start Node, id Long) : Node from class org.neo4j.server.plugins.FunctionalTestPlugin


    @PluginTarget( GraphDatabaseService.class )
    public Node createNode( @Source GraphDatabaseService db )
    {
        try ( Transaction tx = db.beginTx() )
        {
            Node node = db.createNode();

            tx.success();
            return node;
        }
    }

    @PluginTarget( GraphDatabaseService.class )
    public Node createNode( @Source GraphDatabaseService db )
    {
        Transaction tx = db.beginTx();
        try
        {
            Node node = db.createNode();

            tx.success();
            return node;
        }
        finally
        {
            tx.finish();
        }
    }

Try With Resources try(Transaction tx=db.beginTx()) in method public createNode(db GraphDatabaseService) : Node from class org.neo4j.server.plugins.FunctionalTestPlugin


    @PluginTarget( GraphDatabaseService.class )
    public Node methodWithIntParam( @Source GraphDatabaseService db, @Parameter( name = "id", optional = false ) int id )
    {
        try ( Transaction tx = db.beginTx() )
        {
            Node node = db.getNodeById( id );

            tx.success();
            return node;
        }
    }

    @PluginTarget( GraphDatabaseService.class )
    public Node methodWithIntParam( @Source GraphDatabaseService db, @Parameter( name = "id", optional = false ) int id )
    {
        Transaction tx = db.beginTx();
        try
        {
            Node node = db.getNodeById( id );

            tx.success();
            return node;
        }
        finally
        {
            tx.finish();
        }
    }

Try With Resources try(Transaction tx=db.beginTx()) in method public methodWithIntParam(db GraphDatabaseService, id int) : Node from class org.neo4j.server.plugins.FunctionalTestPlugin


    @PluginTarget( Relationship.class )
    public Iterable<Node> methodOnRelationship( @Source Relationship rel )
    {
        try ( Transaction tx = rel.getGraphDatabase().beginTx() )
        {
            List<Node> nodes = Arrays.asList( rel.getNodes() );

            tx.success();
            return nodes;
        }
    }

    @PluginTarget( Relationship.class )
    public Iterable<Node> methodOnRelationship( @Source Relationship rel )
    {
        Transaction tx = rel.getGraphDatabase().beginTx();
        try
        {
            List<Node> nodes = Arrays.asList( rel.getNodes() );

            tx.success();
            return nodes;
        }
        finally
        {
            tx.finish();
        }
    }

Try With Resources try(Transaction tx=rel.getGraphDatabase().beginTx()) in method public methodOnRelationship(rel Relationship) : Iterable<Node> from class org.neo4j.server.plugins.FunctionalTestPlugin


    @Override
    public Response setNodeProperty( ForceMode force, long
            nodeId, String key, String body )
    {
        try (Transaction transaction = graph.beginTx())
        {
            Response response = restfulGraphDatabase.setNodeProperty( force, nodeId, key, body );
            if (response.getStatus() < 300)
            {
                transaction.success();
            }
            return response;
        }
    }

    @Override
    public Response setNodeProperty( ForceMode force, long
            nodeId, String key, String body )
    {
        Transaction transaction = graph.beginTx();
        try
        {
            Response response = restfulGraphDatabase.setNodeProperty( force, nodeId, key, body );
            transaction.success();
            return response;
        }
        finally
        {
            transaction.finish();
        }
    }

Try With Resources try(Transaction transaction=graph.beginTx()) in method public setNodeProperty(force ForceMode, nodeId long, key String, body String) : Response from class org.neo4j.server.rest.web.TransactionWrappingRestfulGraphDatabase


    @Test
    public void shouldGetCorrectTransactionDataUponCommit()
    {
        // Create new data, nothing modified, just added/created
        ExpectedTransactionData expectedData = new ExpectedTransactionData();
        VerifyingTransactionEventHandler handler = new VerifyingTransactionEventHandler( expectedData );
        GraphDatabaseService db = dbRule.getGraphDatabaseService();
        db.registerTransactionEventHandler( handler );
        Node node1 = null, node2, node3 = null;
        Relationship rel1 = null, rel2 = null;
        try
        {
            try ( Transaction tx = db.beginTx() )
            {
                node1 = db.createNode();
                expectedData.expectedCreatedNodes.add( node1 );

                node2 = db.createNode();
                expectedData.expectedCreatedNodes.add( node2 );

                rel1 = node1.createRelationshipTo( node2, RelTypes.TXEVENT );
                expectedData.expectedCreatedRelationships.add( rel1 );

                node1.setProperty( "name", "Mattias" );
                expectedData.assignedProperty( node1, "name", "Mattias", null );

                node1.setProperty( "last name", "Persson" );
                expectedData.assignedProperty( node1, "last name", "Persson", null );

                node1.setProperty( "counter", 10 );
                expectedData.assignedProperty( node1, "counter", 10, null );

                rel1.setProperty( "description", "A description" );
                expectedData.assignedProperty( rel1, "description",
                        "A description", null );

                rel1.setProperty( "number", 4.5D );
                expectedData.assignedProperty( rel1, "number", 4.5D, null );

                node3 = db.createNode();
                expectedData.expectedCreatedNodes.add( node3 );
                rel2 = node3.createRelationshipTo( node2, RelTypes.TXEVENT );
                expectedData.expectedCreatedRelationships.add( rel2 );

                node3.setProperty( "name", "Node 3" );
                expectedData.assignedProperty( node3, "name", "Node 3", null );
                tx.success();
            }

            assertTrue( "Should have been invoked", handler.hasBeenCalled() );
            if ( handler.failure() != null )
            {
                throw new RuntimeException( handler.failure() );
            }
        }
        finally
        {
            db.unregisterTransactionEventHandler( handler );
        }

        // Use the above data and modify it, change properties, delete stuff
        expectedData = new ExpectedTransactionData();
        handler = new VerifyingTransactionEventHandler( expectedData );
        db.registerTransactionEventHandler( handler );
        try
        {
            try ( Transaction tx = db.beginTx() )
            {
                Node newNode = db.createNode();
                expectedData.expectedCreatedNodes.add( newNode );

                Node tempNode = db.createNode();
                Relationship tempRel = tempNode.createRelationshipTo( node1,
                        RelTypes.TXEVENT );
                tempNode.setProperty( "something", "Some value" );
                tempRel.setProperty( "someproperty", 101010 );
                tempNode.removeProperty( "nothing" );

                node3.setProperty( "test", "hello" );
                node3.setProperty( "name", "No name" );
                node3.delete();
                expectedData.expectedDeletedNodes.add( node3 );
                expectedData.removedProperty( node3, "name", null, "Node 3" );

                node1.setProperty( "new name", "A name" );
                node1.setProperty( "new name", "A better name" );
                expectedData.assignedProperty( node1, "new name", "A better name",
                        null );
                node1.setProperty( "name", "Nothing" );
                node1.setProperty( "name", "Mattias Persson" );
                expectedData.assignedProperty( node1, "name", "Mattias Persson",
                        "Mattias" );
                node1.removeProperty( "counter" );
                expectedData.removedProperty( node1, "counter", null, 10 );
                node1.removeProperty( "last name" );
                node1.setProperty( "last name", "Hi" );
                expectedData.assignedProperty( node1, "last name", "Hi", "Persson" );

                rel2.delete();
                expectedData.expectedDeletedRelationships.add( rel2 );

                rel1.removeProperty( "number" );
                expectedData.removedProperty( rel1, "number", null, 4.5D );
                rel1.setProperty( "description", "Ignored" );
                rel1.setProperty( "description", "New" );
                expectedData.assignedProperty( rel1, "description", "New",
                        "A description" );

                tempRel.delete();
                tempNode.delete();
                tx.success();
            }

            assertTrue( "Should have been invoked", handler.hasBeenCalled() );
            if ( handler.failure() != null )
            {
                throw new RuntimeException( handler.failure() );
            }
        }
        finally
        {
            db.unregisterTransactionEventHandler( handler );
        }
    }

    @Test
    public void shouldGetCorrectTransactionDataUponCommit()
    {
        // Create new data, nothing modified, just added/created
        ExpectedTransactionData expectedData = new ExpectedTransactionData();
        VerifyingTransactionEventHandler handler = new VerifyingTransactionEventHandler(
                expectedData );
        getGraphDb().registerTransactionEventHandler( handler );
        newTransaction();
        Node node1 = null, node2, node3 = null;
        Relationship rel1 = null, rel2 = null;
        try
        {
            node1 = getGraphDb().createNode();
            expectedData.expectedCreatedNodes.add( node1 );

            node2 = getGraphDb().createNode();
            expectedData.expectedCreatedNodes.add( node2 );

            rel1 = node1.createRelationshipTo( node2, RelTypes.TXEVENT );
            expectedData.expectedCreatedRelationships.add( rel1 );

            node1.setProperty( "name", "Mattias" );
            expectedData.assignedProperty( node1, "name", "Mattias", null );

            node1.setProperty( "last name", "Persson" );
            expectedData.assignedProperty( node1, "last name", "Persson", null );

            node1.setProperty( "counter", 10 );
            expectedData.assignedProperty( node1, "counter", 10, null );

            rel1.setProperty( "description", "A description" );
            expectedData.assignedProperty( rel1, "description",
                    "A description", null );

            rel1.setProperty( "number", 4.5D );
            expectedData.assignedProperty( rel1, "number", 4.5D, null );

            node3 = getGraphDb().createNode();
            expectedData.expectedCreatedNodes.add( node3 );
            rel2 = node3.createRelationshipTo( node2, RelTypes.TXEVENT );
            expectedData.expectedCreatedRelationships.add( rel2 );

            node3.setProperty( "name", "Node 3" );
            expectedData.assignedProperty( node3, "name", "Node 3", null );

            newTransaction();
            assertTrue( "Should have been invoked", handler.hasBeenCalled() );
            if ( handler.failure() != null )
            {
                throw new RuntimeException( handler.failure() );
            }
        }
        finally
        {
            getGraphDb().unregisterTransactionEventHandler( handler );
        }

        // Use the above data and modify it, change properties, delete stuff
        expectedData = new ExpectedTransactionData();
        handler = new VerifyingTransactionEventHandler( expectedData );
        getGraphDb().registerTransactionEventHandler( handler );
        newTransaction();
        try
        {
            Node newNode = getGraphDb().createNode();
            expectedData.expectedCreatedNodes.add( newNode );

            Node tempNode = getGraphDb().createNode();
            Relationship tempRel = tempNode.createRelationshipTo( node1,
                    RelTypes.TXEVENT );
            tempNode.setProperty( "something", "Some value" );
            tempRel.setProperty( "someproperty", 101010 );
            tempNode.removeProperty( "nothing" );

            node3.setProperty( "test", "hello" );
            node3.setProperty( "name", "No name" );
            node3.delete();
            expectedData.expectedDeletedNodes.add( node3 );
            expectedData.removedProperty( node3, "name", null, "Node 3" );

            node1.setProperty( "new name", "A name" );
            node1.setProperty( "new name", "A better name" );
            expectedData.assignedProperty( node1, "new name", "A better name",
                    null );
            node1.setProperty( "name", "Nothing" );
            node1.setProperty( "name", "Mattias Persson" );
            expectedData.assignedProperty( node1, "name", "Mattias Persson",
                    "Mattias" );
            node1.removeProperty( "counter" );
            expectedData.removedProperty( node1, "counter", null, 10 );
            node1.removeProperty( "last name" );
            node1.setProperty( "last name", "Hi" );
            expectedData.assignedProperty( node1, "last name", "Hi", "Persson" );

            rel2.delete();
            expectedData.expectedDeletedRelationships.add( rel2 );

            rel1.removeProperty( "number" );
            expectedData.removedProperty( rel1, "number", null, 4.5D );
            rel1.setProperty( "description", "Ignored" );
            rel1.setProperty( "description", "New" );
            expectedData.assignedProperty( rel1, "description", "New",
                    "A description" );

            tempRel.delete();
            tempNode.delete();

            newTransaction();
            assertTrue( "Should have been invoked", handler.hasBeenCalled() );
            if ( handler.failure() != null )
            {
                throw new RuntimeException( handler.failure() );
            }
        }
        finally
        {
            getGraphDb().unregisterTransactionEventHandler( handler );
        }
    }

Try With Resources try(Transaction tx=db.beginTx()) in method public shouldGetCorrectTransactionDataUponCommit() : void from class org.neo4j.kernel.impl.event.TestTransactionEvents


    public static void assertLogContains( FileSystemAbstraction fileSystem, String logPath,
            LogEntry ... expectedEntries ) throws IOException
    {
        ByteBuffer buffer = ByteBuffer.allocateDirect( 9 + Xid.MAXGTRIDSIZE
                + Xid.MAXBQUALSIZE * 10 );
        try ( FileChannel fileChannel = fileSystem.open( new File( logPath ), "r" ) )
        {
            // Always a header
            LogIoUtils.readLogHeader( buffer, fileChannel, true );

            // Read all log entries
            List<LogEntry> entries = new ArrayList<>(  );
            CommandFactory cmdFactory = new CommandFactory();
            LogEntry entry;
            while ( (entry = LogIoUtils.readEntry( buffer, fileChannel, cmdFactory )) != null )
            {
                entries.add( entry );
            }

            // Assert entries are what we expected
            for(int entryNo=0;entryNo < expectedEntries.length; entryNo++)
            {
                LogEntry expectedEntry = expectedEntries[entryNo];
                if(entries.size() <= entryNo)
                {
                    fail("Log ended prematurely. Expected to find '" + expectedEntry.toString() + "' as log entry number "+entryNo+", instead there were no more log entries." );
                }

                LogEntry actualEntry = entries.get( entryNo );

                assertThat( "Unexpected entry at entry number " + entryNo, actualEntry, is( expectedEntry ) );
            }

            // And assert log does not contain more entries
            assertThat( "The log contained more entries than we expected!", entries.size(), is( expectedEntries.length ) );
        }
    }

    public static void assertLogContains( FileSystemAbstraction fileSystem, String logPath,
            LogEntry ... expectedEntries ) throws IOException
    {
        FileChannel fileChannel = fileSystem.open( new File( logPath ), "r" );
        ByteBuffer buffer = ByteBuffer.allocateDirect( 9 + Xid.MAXGTRIDSIZE
                + Xid.MAXBQUALSIZE * 10 );

        try {
            // Always a header
            LogIoUtils.readLogHeader( buffer, fileChannel, true );

            // Read all log entries
            List<LogEntry> entries = new ArrayList<LogEntry>(  );
            CommandFactory cmdFactory = new CommandFactory();
            LogEntry entry;
            while ( (entry = LogIoUtils.readEntry( buffer, fileChannel, cmdFactory )) != null )
            {
                entries.add( entry );
            }

            // Assert entries are what we expected
            for(int entryNo=0;entryNo < expectedEntries.length; entryNo++)
            {
                LogEntry expectedEntry = expectedEntries[entryNo];
                if(entries.size() <= entryNo)
                {
                    fail("Log ended prematurely. Expected to find '" + expectedEntry.toString() + "' as log entry number "+entryNo+", instead there were no more log entries." );
                }

                LogEntry actualEntry = entries.get( entryNo );

                assertThat( "Unexpected entry at entry number " + entryNo, actualEntry, is( expectedEntry ) );
            }

            // And assert log does not contain more entries
            assertThat( "The log contained more entries than we expected!", entries.size(), is( expectedEntries.length ) );
        } finally {
            fileChannel.close();
        }
    }

Try With Resources try(FileChannel fileChannel=fileSystem.open(new File(logPath),"r")) in method public assertLogContains(fileSystem FileSystemAbstraction, logPath String, expectedEntries LogEntry...) : void from class org.neo4j.test.LogTestUtils


    private void checkDataConsistencyWithMaster( Master master, NeoStoreXaDataSource nioneoDataSource )
    {
        long myLastCommittedTx = nioneoDataSource.getLastCommittedTxId();
        Pair<Integer, Long> myMaster;
        try
        {
            myMaster = nioneoDataSource.getMasterForCommittedTx( myLastCommittedTx );
        }
        catch ( NoSuchLogVersionException e )
        {
            msgLog.logMessage(
                    "Logical log file for txId "
                            + myLastCommittedTx
                            + " missing [version="
                            + e.getVersion()
                            + "]. If this is startup then it will be recovered later, " +
                            "otherwise it might be a problem." );
            return;
        }
        catch ( IOException e )
        {
            msgLog.logMessage( "Failed to get master ID for txId " + myLastCommittedTx + ".", e );
            return;
        }
        catch ( Exception e )
        {
            throw new BranchedDataException( "Exception while getting master ID for txId "
                    + myLastCommittedTx + ".", e );
        }

        HandshakeResult handshake;
        try ( Response<HandshakeResult> response = master.handshake( myLastCommittedTx, nioneoDataSource.getStoreId() ) )
        {
            handshake = response.response();
            requestContextFactory.setEpoch( handshake.epoch() );
        }
        catch ( RuntimeException e )
        {
            // Checked exceptions will be wrapped as the cause if this was a serialized
            // server-side exception
            if ( e.getCause() instanceof MissingLogDataException )
            {
                /*
                 * This means the master was unable to find a log entry for the txid we just asked. This
                 * probably means the thing we asked for is too old or too new. Anyway, since it doesn't
                 * have the tx it is better if we just throw our store away and ask for a new copy. Next
                 * time around it shouldn't have to even pass from here.
                 */
                throw new StoreOutOfDateException( "The master is missing the log required to complete the " +
                        "consistency check", e.getCause() );
            }
            throw e;
        }

        if ( myMaster.first() != XaLogicalLog.MASTER_ID_REPRESENTING_NO_MASTER &&
                (myMaster.first() != handshake.txAuthor() || myMaster.other() != handshake.txChecksum()) )
        {
            String msg = "Branched data, I (machineId:" + config.get( ClusterSettings.server_id ) + ") think machineId for" +
                    " txId (" +
                    myLastCommittedTx + ") is " + myMaster + ", but master (machineId:" +
                    getServerId( availableMasterId ) + ") says that it's " + handshake;
            throw new BranchedDataException( msg );
        }
        msgLog.logMessage( "Master id for last committed tx ok with highestTxId=" +
                myLastCommittedTx + " with masterId=" + myMaster, true );
    }

    private void checkDataConsistencyWithMaster( Master master, NeoStoreXaDataSource nioneoDataSource )
    {
        long myLastCommittedTx = nioneoDataSource.getLastCommittedTxId();
        Pair<Integer, Long> myMaster;
        try
        {
            myMaster = nioneoDataSource.getMasterForCommittedTx( myLastCommittedTx );
        }
        catch ( NoSuchLogVersionException e )
        {
            msgLog.logMessage(
                    "Logical log file for txId "
                            + myLastCommittedTx
                            + " missing [version="
                            + e.getVersion()
                            + "]. If this is startup then it will be recovered later, " +
                            "otherwise it might be a problem." );
            return;
        }
        catch ( IOException e )
        {
            msgLog.logMessage( "Failed to get master ID for txId " + myLastCommittedTx + ".", e );
            return;
        }
        catch ( Exception e )
        {
            throw new BranchedDataException( "Exception while getting master ID for txId "
                    + myLastCommittedTx + ".", e );
        }

        Response<Pair<Integer, Long>> response = null;
        Pair<Integer, Long> mastersMaster;
        try
        {
            response = master.getMasterIdForCommittedTx( myLastCommittedTx, nioneoDataSource.getStoreId() );
            mastersMaster = response.response();
        }
        catch ( RuntimeException e )
        {
            // Checked exceptions will be wrapped as the cause if this was a serialized
            // server-side exception
            if ( e.getCause() instanceof MissingLogDataException )
            {
                /*
                 * This means the master was unable to find a log entry for the txid we just asked. This
                 * probably means the thing we asked for is too old or too new. Anyway, since it doesn't
                 * have the tx it is better if we just throw our store away and ask for a new copy. Next
                 * time around it shouldn't have to even pass from here.
                 */
                throw new StoreOutOfDateException( "The master is missing the log required to complete the " +
                        "consistency check", e.getCause() );
            }
            throw e;
        }
        finally
        {
            if ( response != null )
            {
                response.close();
            }
        }

        if ( myMaster.first() != XaLogicalLog.MASTER_ID_REPRESENTING_NO_MASTER
                && !myMaster.equals( mastersMaster ) )
        {
            String msg = "Branched data, I (machineId:" + config.get( ClusterSettings.server_id ) + ") think machineId for" +
                    " txId (" +
                    myLastCommittedTx + ") is " + myMaster + ", but master (machineId:" +
                    getServerId( availableMasterId ) + ") says that it's " + mastersMaster;
            throw new BranchedDataException( msg );
        }
        msgLog.logMessage( "Master id for last committed tx ok with highestTxId=" +
                myLastCommittedTx + " with masterId=" + myMaster, true );
    }

Try With Resources try(Response<HandshakeResult> response=master.handshake(myLastCommittedTx,nioneoDataSource.getStoreId())) in method private checkDataConsistencyWithMaster(master Master, nioneoDataSource NeoStoreXaDataSource) : void from class org.neo4j.kernel.ha.cluster.HighAvailabilityModeSwitcher


        @Override
        public synchronized long nextId()
        {
            long nextId = nextLocalId();
            if ( nextId == VALUE_REPRESENTING_NULL )
            {
                // If we don't have anymore grabbed ids from master, grab a bunch
                try ( Response<IdAllocation> response =
                        master.allocateIds( requestContextFactory.newRequestContext(), idType ) )
                {
                    IdAllocation allocation = response.response();
                    logger.info( "Received id allocation " + allocation + " from master " + master + " for " + idType );
                    nextId = storeLocally( allocation );
                }
            }
            return nextId;
        }

        @Override
        public synchronized long nextId()
        {
            long nextId = nextLocalId();
            if ( nextId == VALUE_REPRESENTING_NULL )
            {
                // If we don't have anymore grabbed ids from master, grab a bunch
                Response<IdAllocation> response = master.allocateIds( idType );
                try
                {
                    IdAllocation allocation = response.response();
                    logger.info( "Received id allocation " + allocation + " from master " + master + " for " + idType );
                    nextId = storeLocally( allocation );
                }
                finally
                {
                    response.close();
                }
            }
            return nextId;
        }

Try With Resources try(Response<IdAllocation> response=master.allocateIds(requestContextFactory.newRequestContext(),idType)) in method public nextId() : long from class org.neo4j.kernel.ha.id.HaIdGeneratorFactory.SlaveIdGenerator


    @POST
    @Path( PATH_NODE_LABELS )
    public Response addNodeLabel( @HeaderParam( HEADER_TRANSACTION ) ForceMode force,
                                  @PathParam( "nodeId" ) long nodeId,
                                  String body )
    {
        try
        {
            Object rawInput = input.readValue( body );
            if ( rawInput instanceof String )
            {
                ArrayList<String> s = new ArrayList<>();
                s.add((String) rawInput);
                actions( force ).addLabelToNode( nodeId, s );
            }
            else if(rawInput instanceof Collection)
            {
                actions( force ).addLabelToNode( nodeId, (Collection<String>) rawInput );
            }
            else
            {
                throw new BadInputException( format( "Label name must be a string. Got: '%s'", rawInput ) );
            }
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( ArrayStoreException ase )
        {
            return generateBadRequestDueToMangledJsonResponse( body );
        }
        catch ( NodeNotFoundException e )
        {
            return output.notFound( e );
        }
        return nothing();
    }

    @POST
    @Path( PATH_NODE_LABELS )
    public Response addNodeLabel( @HeaderParam( HEADER_TRANSACTION ) ForceMode force,
                                  @PathParam( "nodeId" ) long nodeId,
                                  String body )
    {
        try
        {
            Object rawInput = input.readValue( body );
            if ( rawInput instanceof String )
            {
                ArrayList<String> s = new ArrayList<String>();
                s.add((String) rawInput);
                actions( force ).addLabelToNode( nodeId, s );
            }
            else if(rawInput instanceof Collection)
            {
                actions( force ).addLabelToNode( nodeId, (Collection<String>) rawInput );
            }
            else
            {
                throw new BadInputException( format( "Label name must be a string. Got: '%s'", rawInput ) );
            }
        }
        catch ( BadInputException e )
        {
            return output.badRequest( e );
        }
        catch ( ArrayStoreException ase )
        {
            return generateBadRequestDueToMangledJsonResponse( body );
        }
        catch ( NodeNotFoundException e )
        {
            return output.notFound( e );
        }
        return nothing();
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public addNodeLabel(force ForceMode, nodeId long, body String) : Response from class org.neo4j.server.rest.web.RestfulGraphDatabase


    private void addRelationshipsBetweenNodes()
    {
        Set<Node> newNodes = new HashSet<>();
        for ( Node node : nodes.values() )
        {
            for ( Relationship relationship : node.getRelationships() )
            {
                if ( !relationships.containsKey( relationship.getId() ) )
                {
                    continue;
                }

                final Node other = relationship.getOtherNode( node );
                if ( nodes.containsKey( other.getId() ) || newNodes.contains( other ) )
                {
                    continue;
                }
                newNodes.add( other );
            }
        }
        for ( Node node : newNodes )
        {
            add( node );
        }
    }

    private void addRelationshipsBetweenNodes()
    {
        Set<Node> newNodes = new HashSet<Node>();
        for ( Node node : nodes.values() )
        {
            for ( Relationship relationship : node.getRelationships() )
            {
                if ( !relationships.containsKey( relationship.getId() ) )
                {
                    continue;
                }

                final Node other = relationship.getOtherNode( node );
                if ( nodes.containsKey( other.getId() ) || newNodes.contains( other ) )
                {
                    continue;
                }
                newNodes.add( other );
            }
        }
        for ( Node node : newNodes )
        {
            add( node );
        }
    }

Replace Generic With Diamond HashSet<Node> with HashSet<> in method private addRelationshipsBetweenNodes() : void from class org.neo4j.cypher.export.CypherResultSubGraph


    protected String replaceAlias( String line, Session session )
    {
	    boolean changed = true;
	    Set<String> appNames = new HashSet<>();
	    while ( changed )
	    {
	        changed = false;
    	    String appName = AppCommandParser.parseOutAppName( line );
            String alias = session.getAlias( appName );
    	    if ( alias != null && appNames.add( alias ) )
    	    {
    	        changed = true;
    	        line = alias + line.substring( appName.length() );
    	    }
	    }
	    return line;
    }

    protected String replaceAlias( String line, Session session )
    {
	    boolean changed = true;
	    Set<String> appNames = new HashSet<String>();
	    while ( changed )
	    {
	        changed = false;
    	    String appName = AppCommandParser.parseOutAppName( line );
            String alias = session.getAlias( appName );
    	    if ( alias != null && appNames.add( alias ) )
    	    {
    	        changed = true;
    	        line = alias + line.substring( appName.length() );
    	    }
	    }
	    return line;
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method protected replaceAlias(line String, session Session) : String from class org.neo4j.shell.impl.AbstractAppServer


    private static List<String> quote( List<String> candidates )
    {
        List<String> result = new ArrayList<>();
        for ( String candidate : candidates )
        {
            candidate = candidate.replaceAll( " ", "\\\\ " );
            result.add( candidate );
        }
        return result;
    }

    private static List<String> quote( List<String> candidates )
    {
        List<String> result = new ArrayList<String>();
        for ( String candidate : candidates )
        {
            candidate = candidate.replaceAll( " ", "\\\\ " );
            result.add( candidate );
        }
        return result;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method private quote(candidates List<String>) : List<String> from class org.neo4j.shell.impl.AbstractAppServer


    @Test
    public void testMore()
    {
        BatchInserter graphDb = newBatchInserter();
        long startNode = graphDb.createNode( properties );
        long endNodes[] = new long[25];
        Set<Long> rels = new HashSet<>();
        for ( int i = 0; i < 25; i++ )
        {
            endNodes[i] = graphDb.createNode( properties );
            rels.add( graphDb.createRelationship( startNode, endNodes[i],
                relTypeArray[i % 5], properties ) );
        }
        for ( BatchRelationship rel : graphDb.getRelationships( startNode ) )
        {
            assertTrue( rels.contains( rel.getId() ) );
            assertEquals( rel.getStartNode(), startNode );
        }
        graphDb.setNodeProperties( startNode, properties );
        graphDb.shutdown();
    }

    @Test
    public void testMore()
    {
        BatchInserter graphDb = newBatchInserter();
        long startNode = graphDb.createNode( properties );
        long endNodes[] = new long[25];
        Set<Long> rels = new HashSet<Long>();
        for ( int i = 0; i < 25; i++ )
        {
            endNodes[i] = graphDb.createNode( properties );
            rels.add( graphDb.createRelationship( startNode, endNodes[i],
                relTypeArray[i % 5], properties ) );
        }
        for ( BatchRelationship rel : graphDb.getRelationships( startNode ) )
        {
            assertTrue( rels.contains( rel.getId() ) );
            assertEquals( rel.getStartNode(), startNode );
        }
        graphDb.setNodeProperties( startNode, properties );
        graphDb.shutdown();
    }

Replace Generic With Diamond HashSet<Long> with HashSet<> in method public testMore() : void from class org.neo4j.unsafe.batchinsert.TestBatchInsert


    private void createTransaction( GraphDatabaseAPI db )
    {
        try (Transaction tx = db.beginTx())
        {
            db.createNode();
            tx.success();
        }
        catch ( RuntimeException e )
        {
            e.printStackTrace();
            throw e;
        }
    }

    private void createTransaction( GraphDatabaseAPI db )
    {
        Transaction tx = db.beginTx();
        try
        {
            db.createNode();
            tx.success();
        }
        catch ( RuntimeException e )
        {
            e.printStackTrace();
            throw e;
        }
        finally
        {
            tx.finish();
        }
    }

Try With Resources try(Transaction tx=db.beginTx()) in method private createTransaction(db GraphDatabaseAPI) : void from class org.neo4j.kernel.ha.TxPushStrategyConfigIT


                public Node call() throws Exception
                {
                    try ( Transaction tx = graphDb.beginTx() )
                    {
                        final Node node = graphDb.createNode();
                        // Acquire lock
                        tx.acquireWriteLock( commonNode );
                        Index<Node> index = graphDb.index().forNodes( "uuids" );
                        final Node existing = index.get( "uuid", uuid ).getSingle();
                        if ( existing != null )
                        {
                            throw new RuntimeException( "Node already exists" );
                        }
                        node.setProperty( "uuid", uuid );
                        index.add( node, "uuid", uuid );
                        tx.success();
                        return node;
                    }
                }

                public Node call() throws Exception
                {
                    Transaction tx = graphDb.beginTx();
                    try
                    {
                        final Node node = graphDb.createNode();
                        // Acquire lock
                        tx.acquireWriteLock( commonNode );
                        Index<Node> index = graphDb.index().forNodes( "uuids" );
                        final Node existing = index.get( "uuid", uuid ).getSingle();
                        if ( existing != null )
                        {
                            throw new RuntimeException( "Node already exists" );
                        }
                        node.setProperty( "uuid", uuid );
                        index.add( node, "uuid", uuid );
                        tx.success();
                        return node;
                    }
                    finally
                    {
                        tx.finish();
                    }
                }

Try With Resources try(Transaction tx=graphDb.beginTx()) in method public call() : Node from class org.neo4j.index.IndexConstraintsTest.testMultipleCreate.submit.new Callable<Node>


    private void awaitPropagation( int i, long nodeId, ClusterManager.ManagedCluster cluster ) throws Exception
    {
        long endTime = currentTimeMillis() + PULL_INTERVAL * 20;
        boolean ok = false;
        while ( !ok && currentTimeMillis() < endTime )
        {
            ok = true;
            for ( HighlyAvailableGraphDatabase db : cluster.getAllMembers() )
            {
                try ( Transaction tx = db.beginTx() )
                {

                    Number value = (Number)db.getNodeById(nodeId).getProperty( "i", null );
                    if ( value == null || value.intValue() != i )
                    {
                        ok = false;
                    }
                }
                catch( NotFoundException e )
                {
                    ok=false;
                }
            }
            if ( !ok )
            {
                powerNap();
            }
        }
        assertTrue( "Change wasn't propagated by pulling updates", ok );
    }

    private void awaitPropagation( int i, long nodeId, ClusterManager.ManagedCluster cluster ) throws Exception
    {
        long endTime = currentTimeMillis() + PULL_INTERVAL * 20;
        boolean ok = false;
        while ( !ok && currentTimeMillis() < endTime )
        {
            ok = true;
            for ( HighlyAvailableGraphDatabase db : cluster.getAllMembers() )
            {
                try
                {
                    Number value = (Number)db.getNodeById(nodeId).getProperty( "i", null );
                    if ( value == null || value.intValue() != i )
                    {
                        ok = false;
                    }
                }
                catch(NotFoundException e)
                {
                    ok=false;
                }
            }
            if ( !ok )
            {
                powerNap();
            }
        }
        assertTrue( "Change wasn't propagated by pulling updates", ok );
    }

Try With Resources try(Transaction tx=db.beginTx()) in method private awaitPropagation(i int, nodeId long, cluster ClusterManager.ManagedCluster) : void from class org.neo4j.ha.TestPullUpdates


    @Test
    public void graph()
    {
        engine.execute( "CREATE (n:Person {name:\"Adam\"});" );
        Block block = Block.getBlock( Arrays.asList( "// graph:xyz" ) );
        assertThat( block.type, sameInstance( BlockType.GRAPH ) );
        String output;
        try (Transaction transaction = database.beginTx())
        {
            output = block.process( state );
            transaction.success();
        }
        assertThat(
                output,
                allOf( startsWith( "[\"dot\"" ), containsString( "Adam" ),
                        containsString( "cypherdoc-xyz" ),
                        containsString( ".svg" ), containsString( "neoviz" ) ) );
    }

    @Test
    public void graph()
    {
        engine.execute( "CREATE (n:Person {name:\"Adam\"});" );
        Block block = Block.getBlock( Arrays.asList( "// graph:xyz" ) );
        assertThat( block.type, sameInstance( BlockType.GRAPH ) );
        Transaction transaction = database.beginTx();
        String output;
        try
        {
            output = block.process( state );
        }
        finally
        {
            transaction.finish();
        }
        assertThat(
                output,
                allOf( startsWith( "[\"dot\"" ), containsString( "Adam" ),
                        containsString( "cypherdoc-xyz" ),
                        containsString( ".svg" ), containsString( "neoviz" ) ) );
    }

Try With Resources try(Transaction transaction=database.beginTx()) in method public graph() : void from class org.neo4j.doc.cypherdoc.BlockTest


    @Test
    public void graphWithoutId()
    {
        engine.execute( "CREATE (n:Person {name:\"Adam\"});" );
        Block block = Block.getBlock( Arrays.asList( "//graph" ) );
        assertThat( block.type, sameInstance( BlockType.GRAPH ) );
        String output;
        try (Transaction transaction = database.beginTx())
        {
            output = block.process( state );
            transaction.success();
        }
        assertThat(
                output,
                allOf( startsWith( "[\"dot\"" ), containsString( "Adam" ), containsString( "cypherdoc--" ),
                        containsString( ".svg" ), containsString( "neoviz" ) ) );
    }

    @Test
    public void graphWithoutId()
    {
        engine.execute( "CREATE (n:Person {name:\"Adam\"});" );
        Block block = Block.getBlock( Arrays.asList( "//graph" ) );
        assertThat( block.type, sameInstance( BlockType.GRAPH ) );
        Transaction transaction = database.beginTx();
        String output;
        try
        {
            output = block.process( state );
        }
        finally
        {
            transaction.finish();
        }
        assertThat(
                output,
                allOf( startsWith( "[\"dot\"" ), containsString( "Adam" ), containsString( "cypherdoc--" ),
                        containsString( ".svg" ), containsString( "neoviz" ) ) );
    }

Try With Resources try(Transaction transaction=database.beginTx()) in method public graphWithoutId() : void from class org.neo4j.doc.cypherdoc.BlockTest