    public AccountResults retrieveAccounts(Account account, int start, int limit) throws ControllerException {
        try {
            AccountResults results = new AccountResults();
            EntryController entryController = new EntryController();
            LinkedList<Account> accounts = dao.retrieveAccounts(start, limit);

            ArrayList<AccountInfo> infos = new ArrayList<>();
            for (Account userAccount : accounts) {
                AccountInfo info = new AccountInfo();
                long count;
                try {
                    count = entryController.getNumberOfOwnerEntries(userAccount, userAccount.getEmail());
                    info.setUserEntryCount(count);
                } catch (ControllerException e) {
                    Logger.error("Error retrieving entry count for user " + userAccount.getEmail());
                    info.setUserEntryCount(-1);
                }

                info.setEmail(userAccount.getEmail());
                info.setAdmin(isAdministrator(userAccount));
                info.setFirstName(userAccount.getFirstName());
                info.setLastName(userAccount.getLastName());
                info.setLastLogin(userAccount.getLastLoginTime());
                info.setId(account.getId());
                infos.add(info);
            }
            results.getResults().addAll(infos);
            int count = dao.retrieveAllAccountCount();
            results.setResultCount(count);
            return results;

        } catch (DAOException e) {
            throw new ControllerException(e);
        }
    }

    public AccountResults retrieveAccounts(Account account, int start, int limit) throws ControllerException {
        try {
            AccountResults results = new AccountResults();
            EntryController entryController = new EntryController();
            LinkedList<Account> accounts = dao.retrieveAccounts(start, limit);

            ArrayList<AccountInfo> infos = new ArrayList<AccountInfo>();
            for (Account userAccount : accounts) {
                AccountInfo info = new AccountInfo();
                long count;
                try {
                    count = entryController.getNumberOfOwnerEntries(userAccount, userAccount.getEmail());
                    info.setUserEntryCount(count);
                } catch (ControllerException e) {
                    Logger.error("Error retrieving entry count for user " + userAccount.getEmail());
                    info.setUserEntryCount(-1);
                }

                info.setEmail(userAccount.getEmail());
                info.setAdmin(isAdministrator(userAccount));
                info.setFirstName(userAccount.getFirstName());
                info.setLastName(userAccount.getLastName());
                info.setLastLogin(userAccount.getLastLoginTime());
                info.setId(account.getId());
                infos.add(info);
            }
            results.getResults().addAll(infos);
            int count = dao.retrieveAllAccountCount();
            results.setResultCount(count);
            return results;

        } catch (DAOException e) {
            throw new ControllerException(e);
        }
    }

Replace Generic With Diamond ArrayList<AccountInfo> with ArrayList<> in method public retrieveAccounts(account Account, start int, limit int) : AccountResults from class org.jbei.ice.lib.account.AccountController


    private static ArrayList<String> parseSequenceLine(String sequenceLine) {
        //returns start, stop, sequence
        ArrayList<String> result = new ArrayList<>(3);

        Matcher matcher = SEQ_REGEXP_PATTERN.matcher(sequenceLine);
        if (matcher.find()) {
            result.add(matcher.group(1));
            result.add(matcher.group(3));
            result.add(matcher.group(2));
        }

        return result;
    }

    private static ArrayList<String> parseSequenceLine(String sequenceLine) {
        //returns start, stop, sequence
        ArrayList<String> result = new ArrayList<String>(3);

        Matcher matcher = SEQ_REGEXP_PATTERN.matcher(sequenceLine);
        if (matcher.find()) {
            result.add(matcher.group(1));
            result.add(matcher.group(3));
            result.add(matcher.group(2));
        }

        return result;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method private parseSequenceLine(sequenceLine String) : ArrayList<String> from class org.jbei.ice.lib.parsers.bl2seq.Bl2SeqParser


    @Override
    public IDNASequence parse(String textSequence) throws InvalidFormatParserException {
        FeaturedDNASequence sequence = null;
        try {
            textSequence = cleanSequence(textSequence);

            ArrayList<Tag> tags = splitTags(textSequence, NORMAL_TAGS, IGNORE_TAGS);
            tags = parseTags(tags);

            sequence = new FeaturedDNASequence();
            for (Tag tag : tags) {
                if (tag instanceof LocusTag) {
                    sequence.setName(((LocusTag) tag).getLocusName());
                    sequence.setIsCircular(((LocusTag) tag).isCircular());
                } else if (tag instanceof OriginTag) {
                    sequence.setSequence(((OriginTag) tag).getSequence());
                } else if (tag instanceof FeaturesTag) {
                    sequence.setFeatures(((FeaturesTag) tag).getFeatures());
                }
            }
        } catch (NullPointerException | StringIndexOutOfBoundsException e) {
            recordParsingError(textSequence, e);
        }
        return sequence;
    }

    @Override
    public IDNASequence parse(String textSequence) throws InvalidFormatParserException {
        FeaturedDNASequence sequence = null;
        try {
            textSequence = cleanSequence(textSequence);

            ArrayList<Tag> tags = splitTags(textSequence, NORMAL_TAGS, IGNORE_TAGS);
            tags = parseTags(tags);

            sequence = new FeaturedDNASequence();
            for (Tag tag : tags) {
                if (tag instanceof LocusTag) {
                    sequence.setName(((LocusTag) tag).getLocusName());
                    sequence.setIsCircular(((LocusTag) tag).isCircular());
                } else if (tag instanceof OriginTag) {
                    sequence.setSequence(((OriginTag) tag).getSequence());
                } else if (tag instanceof FeaturesTag) {
                    sequence.setFeatures(((FeaturesTag) tag).getFeatures());
                }
            }
        } catch (NullPointerException e) {
            recordParsingError(textSequence, e);
        } catch (StringIndexOutOfBoundsException e) {
            recordParsingError(textSequence, e);
        }
        return sequence;
    }

Merge Catch [catch(NullPointerException e), catch(StringIndexOutOfBoundsException e)] to catch(NullPointerException|StringIndexOutOfBoundsException e) in method public parse(textSequence String) : IDNASequence from class org.jbei.ice.lib.parsers.genbank.IceGenbankParser


    @SuppressWarnings({"unchecked"})
    public List<Folder> getFoldersByEntry(Entry entry) throws DAOException {
        ArrayList<Folder> folders = new ArrayList<>();
        Session session = currentSession();

        try {
            String hql = "select distinct folder from " + Folder.class.getName()
                    + " folder join folder.contents contents where :entry in contents";
            Query query = session.createQuery(hql);
            query.setParameter("entry", entry);
            folders.addAll(query.list());
        } catch (HibernateException e) {
            throw new DAOException("Failed to retrieve folders!", e);
        }

        return folders;
    }

    @SuppressWarnings({"unchecked"})
    public List<Folder> getFoldersByEntry(Entry entry) throws DAOException {
        ArrayList<Folder> folders = new ArrayList<Folder>();
        Session session = currentSession();

        try {
            String hql = "select distinct folder from " + Folder.class.getName()
                    + " folder join folder.contents contents where :entry in contents";
            Query query = session.createQuery(hql);
            query.setParameter("entry", entry);
            folders.addAll(query.list());
        } catch (HibernateException e) {
            throw new DAOException("Failed to retrieve folders!", e);
        }

        return folders;
    }

Replace Generic With Diamond ArrayList<Folder> with ArrayList<> in method public getFoldersByEntry(entry Entry) : List<Folder> from class org.jbei.ice.lib.folder.FolderDAO


    /**
     * Retrieves list of bulk imports that are owned by the system. System ownership is assigned to
     * all bulk imports that are submitted by non-admins and indicates that it is pending approval.
     * <p>Administrative privileges are required for making this call
     *
     * @param account account for user making call. expected to be an administrator
     * @return list of bulk imports pending verification
     * @throws ControllerException
     * @throws PermissionException
     */
    public ArrayList<BulkUploadInfo> retrievePendingImports(Account account)
            throws ControllerException, PermissionException {

        // check for admin privileges
        if (!accountController.isAdministrator(account))
            throw new PermissionException("Administrative privileges are required!");

        ArrayList<BulkUploadInfo> infoList = new ArrayList<>();
        ArrayList<BulkUpload> results;

        try {
            results = dao.retrieveByAccount(accountController.getSystemAccount());
            if (results == null || results.isEmpty())
                return infoList;
        } catch (DAOException e) {
            throw new ControllerException(e);
        }

        for (BulkUpload draft : results) {

            BulkUploadInfo info = new BulkUploadInfo();
            Account draftAccount = draft.getAccount();
            AccountInfo accountInfo = new AccountInfo();
            accountInfo.setEmail(draftAccount.getEmail());
            accountInfo.setFirstName(draftAccount.getFirstName());
            accountInfo.setLastName(draftAccount.getLastName());
            info.setAccount(accountInfo);

            info.setId(draft.getId());
            info.setLastUpdate(draft.getLastUpdateTime());
            int count = draft.getContents().size();
//            try {
//                count = dao.retrieveSavedDraftCount(draft.getId());
//            } catch (DAOException e) {
//                Logger.error(e); // we care about the data more than the count
//            }

            info.setCount(count);
            info.setType(EntryAddType.stringToType(draft.getImportType()));
            info.setCreated(draft.getCreationTime());
            info.setName(draft.getName());

            infoList.add(info);
        }

        return infoList;
    }

    /**
     * Retrieves list of bulk imports that are owned by the system. System ownership is assigned to
     * all bulk imports that are submitted by non-admins and indicates that it is pending approval.
     * <p>Administrative privileges are required for making this call
     *
     * @param account account for user making call. expected to be an administrator
     * @return list of bulk imports pending verification
     * @throws ControllerException
     * @throws PermissionException
     */
    public ArrayList<BulkUploadInfo> retrievePendingImports(Account account)
            throws ControllerException, PermissionException {

        // check for admin privileges
        if (!accountController.isAdministrator(account))
            throw new PermissionException("Administrative privileges are required!");

        ArrayList<BulkUploadInfo> infoList = new ArrayList<BulkUploadInfo>();
        ArrayList<BulkUpload> results;

        try {
            results = dao.retrieveByAccount(accountController.getSystemAccount());
            if (results == null || results.isEmpty())
                return infoList;
        } catch (DAOException e) {
            throw new ControllerException(e);
        }

        for (BulkUpload draft : results) {

            BulkUploadInfo info = new BulkUploadInfo();
            Account draftAccount = draft.getAccount();
            AccountInfo accountInfo = new AccountInfo();
            accountInfo.setEmail(draftAccount.getEmail());
            accountInfo.setFirstName(draftAccount.getFirstName());
            accountInfo.setLastName(draftAccount.getLastName());
            info.setAccount(accountInfo);

            info.setId(draft.getId());
            info.setLastUpdate(draft.getLastUpdateTime());
            int count = draft.getContents().size();
//            try {
//                count = dao.retrieveSavedDraftCount(draft.getId());
//            } catch (DAOException e) {
//                Logger.error(e); // we care about the data more than the count
//            }

            info.setCount(count);
            info.setType(EntryAddType.stringToType(draft.getImportType()));
            info.setCreated(draft.getCreationTime());
            info.setName(draft.getName());

            infoList.add(info);
        }

        return infoList;
    }

Replace Generic With Diamond ArrayList<BulkUploadInfo> with ArrayList<> in method public retrievePendingImports(account Account) : ArrayList<BulkUploadInfo> from class org.jbei.ice.lib.bulkupload.BulkUploadController


    /**
     * Retrieves list of user saved bulk imports
     *
     * @param account     account of requesting user
     * @param userAccount account whose saved drafts are being requested
     * @return list of draft infos representing saved drafts.
     * @throws ControllerException
     */
    public ArrayList<BulkUploadInfo> retrieveByUser(Account account, Account userAccount)
            throws ControllerException {

        ArrayList<BulkUpload> results;

        try {
            results = dao.retrieveByAccount(userAccount);
        } catch (DAOException e) {
            throw new ControllerException(e);
        }

        ArrayList<BulkUploadInfo> infoArrayList = new ArrayList<>();

        for (BulkUpload draft : results) {
            Account draftAccount = draft.getAccount();

            boolean isOwner = account.equals(draftAccount);
            boolean isAdmin = accountController.isAdministrator(account);
            if (!isOwner && !isAdmin)
                continue;

            BulkUploadInfo draftInfo = new BulkUploadInfo();
            draftInfo.setCreated(draft.getCreationTime());
            draftInfo.setLastUpdate(draft.getLastUpdateTime());
            draftInfo.setId(draft.getId());

            draftInfo.setName(draft.getName());
            draftInfo.setType(EntryAddType.stringToType(draft.getImportType()));
            draftInfo.setCount(draft.getContents().size());

//            try {
//                int count = dao.retrieveSavedDraftCount(draft.getId());
//                draftInfo.setCount(count);
//            } catch (DAOException e) {
//                draftInfo.setCount(-1);
//                Logger.error(e);
//            }

            // set the account info
            AccountInfo accountInfo = new AccountInfo();
            accountInfo.setEmail(draftAccount.getEmail());
            accountInfo.setFirstName(draftAccount.getFirstName());
            accountInfo.setLastName(draftAccount.getLastName());
            draftInfo.setAccount(accountInfo);
            infoArrayList.add(draftInfo);
        }

        return infoArrayList;
    }

    /**
     * Retrieves list of user saved bulk imports
     *
     * @param account     account of requesting user
     * @param userAccount account whose saved drafts are being requested
     * @return list of draft infos representing saved drafts.
     * @throws ControllerException
     */
    public ArrayList<BulkUploadInfo> retrieveByUser(Account account, Account userAccount)
            throws ControllerException {

        ArrayList<BulkUpload> results;

        try {
            results = dao.retrieveByAccount(userAccount);
        } catch (DAOException e) {
            throw new ControllerException(e);
        }

        ArrayList<BulkUploadInfo> infoArrayList = new ArrayList<BulkUploadInfo>();

        for (BulkUpload draft : results) {
            Account draftAccount = draft.getAccount();

            boolean isOwner = account.equals(draftAccount);
            boolean isAdmin = accountController.isAdministrator(account);
            if (!isOwner && !isAdmin)
                continue;

            BulkUploadInfo draftInfo = new BulkUploadInfo();
            draftInfo.setCreated(draft.getCreationTime());
            draftInfo.setLastUpdate(draft.getLastUpdateTime());
            draftInfo.setId(draft.getId());

            draftInfo.setName(draft.getName());
            draftInfo.setType(EntryAddType.stringToType(draft.getImportType()));
            draftInfo.setCount(draft.getContents().size());

//            try {
//                int count = dao.retrieveSavedDraftCount(draft.getId());
//                draftInfo.setCount(count);
//            } catch (DAOException e) {
//                draftInfo.setCount(-1);
//                Logger.error(e);
//            }

            // set the account info
            AccountInfo accountInfo = new AccountInfo();
            accountInfo.setEmail(draftAccount.getEmail());
            accountInfo.setFirstName(draftAccount.getFirstName());
            accountInfo.setLastName(draftAccount.getLastName());
            draftInfo.setAccount(accountInfo);
            infoArrayList.add(draftInfo);
        }

        return infoArrayList;
    }

Replace Generic With Diamond ArrayList<BulkUploadInfo> with ArrayList<> in method public retrieveByUser(account Account, userAccount Account) : ArrayList<BulkUploadInfo> from class org.jbei.ice.lib.bulkupload.BulkUploadController


    protected void saveSamples(Account account, SampleStorage sampleStorage, Entry entry) throws ControllerException {
        if (sampleStorage == null || sampleStorage.getSample() == null)
            return;

        // check is there is an existing sample(s) and delete
        ArrayList<Sample> samples = sampleController.getSamples(entry);
        try {
            if (samples != null) {
                for (Sample sample : samples)
                    sampleController.deleteSample(account, sample);   // TODO : does this delete locations (storage)
            }
        } catch (PermissionException pe) {
            Logger.error(pe);
            return;
        }

        // create new samples
        SampleInfo sampleInfo = sampleStorage.getSample();
        LinkedList<StorageInfo> locations = sampleStorage.getStorageList();
        Sample sample = sampleController.createSample(sampleInfo.getLabel(), account.getEmail(), sampleInfo.getNotes());
        sample.setEntry(entry);

        if (locations == null || locations.isEmpty()) {
            throw new ControllerException("Attempting to create sample without a location");
        }

        try {
            Storage scheme = storageController.get(Long.parseLong(sampleInfo.getLocationId()), false);
            // create sample and location
            List<Storage> schemes = scheme.getSchemes();
            if (schemes.size() != locations.size())
                throw new ControllerException("Locations and schemes do not match up");

            String[] labels = new String[locations.size()];
            for (StorageInfo storageInfo : locations) {
                int i = 0;
                for (Storage storage : schemes) {
                    if (storageInfo.getType().equalsIgnoreCase(storage.getStorageType().name())) {
                        labels[i] = storageInfo.getDisplay();
                        break;
                    }
                    i += 1;
                }
            }

            Storage storage = storageController.getLocation(scheme, labels);
            storage = storageController.update(storage);
            sample.setStorage(storage);
            sampleController.saveSample(account, sample);
        } catch (NumberFormatException | PermissionException e) {
            Logger.error(e);
        }
    }

    protected void saveSamples(Account account, SampleStorage sampleStorage, Entry entry) throws ControllerException {
        if (sampleStorage == null || sampleStorage.getSample() == null)
            return;

        // check is there is an existing sample(s) and delete
        ArrayList<Sample> samples = sampleController.getSamples(entry);
        try {
            if (samples != null) {
                for (Sample sample : samples)
                    sampleController.deleteSample(account, sample);   // TODO : does this delete locations (storage)
            }
        } catch (PermissionException pe) {
            Logger.error(pe);
            return;
        }

        // create new samples
        SampleInfo sampleInfo = sampleStorage.getSample();
        LinkedList<StorageInfo> locations = sampleStorage.getStorageList();
        Sample sample = sampleController.createSample(sampleInfo.getLabel(), account.getEmail(), sampleInfo.getNotes());
        sample.setEntry(entry);

        if (locations == null || locations.isEmpty()) {
            throw new ControllerException("Attempting to create sample without a location");
        }

        try {
            Storage scheme = storageController.get(Long.parseLong(sampleInfo.getLocationId()), false);
            // create sample and location
            List<Storage> schemes = scheme.getSchemes();
            if (schemes.size() != locations.size())
                throw new ControllerException("Locations and schemes do not match up");

            String[] labels = new String[locations.size()];
            for (StorageInfo storageInfo : locations) {
                int i = 0;
                for (Storage storage : schemes) {
                    if (storageInfo.getType().equalsIgnoreCase(storage.getStorageType().name())) {
                        labels[i] = storageInfo.getDisplay();
                        break;
                    }
                    i += 1;
                }
            }

            Storage storage = storageController.getLocation(scheme, labels);
            storage = storageController.update(storage);
            sample.setStorage(storage);
            sampleController.saveSample(account, sample);
        } catch (NumberFormatException e) {
            Logger.error(e);
        } catch (PermissionException e) {
            Logger.error(e);
        }
    }

Merge Catch [catch(NumberFormatException e), catch(PermissionException e)] to catch(NumberFormatException|PermissionException e) in method protected saveSamples(account Account, sampleStorage SampleStorage, entry Entry) : void from class org.jbei.ice.lib.bulkupload.BulkUploadController


    public String getNamesAsString() {
        String result;
        ArrayList<String> names = new ArrayList<>();
        for (Name name : this.names) {
            names.add(name.getName());
        }
        result = org.jbei.ice.lib.utils.Utils.join(", ", names);
        return result;
    }

    public String getNamesAsString() {
        String result;
        ArrayList<String> names = new ArrayList<String>();
        for (Name name : this.names) {
            names.add(name.getName());
        }
        result = org.jbei.ice.lib.utils.Utils.join(", ", names);
        return result;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public getNamesAsString() : String from class org.jbei.ice.lib.entry.model.Entry


    /**
     * Generate a String representation of the {@link SelectionMarker}s associated with this entry.
     *
     * @return Comma separated selection markers.
     */
    public String getSelectionMarkersAsString() {
        String result;
        ArrayList<String> markers = new ArrayList<>();
        for (SelectionMarker marker : selectionMarkers) {
            markers.add(marker.getName());
        }
        result = org.jbei.ice.lib.utils.Utils.join(", ", markers);

        return result;
    }

    /**
     * Generate a String representation of the {@link SelectionMarker}s associated with this entry.
     *
     * @return Comma separated selection markers.
     */
    public String getSelectionMarkersAsString() {
        String result;
        ArrayList<String> markers = new ArrayList<String>();
        for (SelectionMarker marker : selectionMarkers) {
            markers.add(marker.getName());
        }
        result = org.jbei.ice.lib.utils.Utils.join(", ", markers);

        return result;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public getSelectionMarkersAsString() : String from class org.jbei.ice.lib.entry.model.Entry


    /**
     * String representation of {@link Link}s.
     *
     * @return Comma separated list of links.
     */
    public String getLinksAsString() {
        String result;
        ArrayList<String> links = new ArrayList<>();
        for (Link link : this.links) {
            links.add(link.getLink());
        }
        result = org.jbei.ice.lib.utils.Utils.join(", ", links);

        return result;
    }

    /**
     * String representation of {@link Link}s.
     *
     * @return Comma separated list of links.
     */
    public String getLinksAsString() {
        String result;
        ArrayList<String> links = new ArrayList<String>();
        for (Link link : this.links) {
            links.add(link.getLink());
        }
        result = org.jbei.ice.lib.utils.Utils.join(", ", links);

        return result;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public getLinksAsString() : String from class org.jbei.ice.lib.entry.model.Entry


    public ArrayList<AccountInfo> retrieveGroupMembers(String uuid) throws ControllerException {
        try {
            ArrayList<AccountInfo> result = new ArrayList<>();
            Group group = dao.get(uuid);
            for (Account account : group.getMembers()) {
                AccountInfo accountInfo = AccountUtils.accountToInfo(account);
                result.add(accountInfo);
            }
            return result;
        } catch (DAOException e) {
            throw new ControllerException(e);
        }
    }

    public ArrayList<AccountInfo> retrieveGroupMembers(String uuid) throws ControllerException {
        try {
            ArrayList<AccountInfo> result = new ArrayList<AccountInfo>();
            Group group = dao.get(uuid);
            for (Account account : group.getMembers()) {
                AccountInfo accountInfo = AccountUtils.accountToInfo(account);
                result.add(accountInfo);
            }
            return result;
        } catch (DAOException e) {
            throw new ControllerException(e);
        }
    }

Replace Generic With Diamond ArrayList<AccountInfo> with ArrayList<> in method public retrieveGroupMembers(uuid String) : ArrayList<AccountInfo> from class org.jbei.ice.lib.group.GroupController


    private ArrayList<Entry> retrieveEntries(Account account, String commaSeparated,
            EntryController controller) {
        ArrayList<Entry> entries = new ArrayList<Entry>();
        String[] idStrs = commaSeparated.split(",");

        for (String idStr : idStrs) {
            Entry entry;
            try {
                long id = Long.decode(idStr.trim());
                entry = controller.get(account, id);
            } catch (NumberFormatException nfe) {
                Logger.error("Could not convert string id to long : " + idStr);
                continue;
            } catch (ControllerException | PermissionException e) {
                Logger.error(e);
                continue;
            }

            if (entry != null)
                entries.add(entry);
        }
        return entries;
    }

    private ArrayList<Entry> retrieveEntries(Account account, String commaSeparated,
            EntryController controller) {
        ArrayList<Entry> entries = new ArrayList<Entry>();
        String[] idStrs = commaSeparated.split(",");

        for (String idStr : idStrs) {
            Entry entry;
            try {
                long id = Long.decode(idStr.trim());
                entry = controller.get(account, id);
            } catch (NumberFormatException nfe) {
                Logger.error("Could not convert string id to long : " + idStr);
                continue;
            } catch (ControllerException e) {
                Logger.error(e);
                continue;
            } catch (PermissionException e) {
                Logger.error(e);
                continue;
            }

            if (entry != null)
                entries.add(entry);
        }
        return entries;
    }

Merge Catch [catch(ControllerException e), catch(PermissionException e)] to catch(ControllerException|PermissionException e) in method private retrieveEntries(account Account, commaSeparated String, controller EntryController) : ArrayList<Entry> from class org.jbei.ice.server.servlet.EntryExportServlet


    /**
     * Retrieve {@link UserRestrictionEnzymes} for the given session.
     *
     * @param sessionId session key.
     * @return UserRestrictionEnzymes object for the current user.
     */
    public UserRestrictionEnzymes getUserRestrictionEnzymes(String sessionId) {
        UserRestrictionEnzymes userRestrictionEnzymes = null;
        AccountController controller = ApplicationController.getAccountController();

        try {
            Account account = getAccountBySessionId(sessionId);

            if (account == null) {
                return null;
            }

            AccountPreferences accountPreferences = controller.getAccountPreferences(account);

            if (accountPreferences != null && accountPreferences.getRestrictionEnzymes() != null
                    && !accountPreferences.getRestrictionEnzymes().isEmpty()) {
                userRestrictionEnzymes = (UserRestrictionEnzymes) SerializationUtils
                        .deserializeStringToObject(accountPreferences.getRestrictionEnzymes());
            } else {
                userRestrictionEnzymes = new UserRestrictionEnzymes();
            }
        } catch (SerializationUtils.SerializationUtilsException | ControllerException e) {
            Logger.error(getServiceName(), e);
            return null;
        } catch (Exception e) {
            Logger.error(getServiceName(), e);
            return null;
        }

        return userRestrictionEnzymes;
    }

    /**
     * Retrieve {@link UserRestrictionEnzymes} for the given session.
     *
     * @param sessionId session key.
     * @return UserRestrictionEnzymes object for the current user.
     */
    public UserRestrictionEnzymes getUserRestrictionEnzymes(String sessionId) {
        UserRestrictionEnzymes userRestrictionEnzymes = null;
        AccountController controller = new AccountController();

        try {
            Account account = getAccountBySessionId(sessionId);

            if (account == null) {
                return null;
            }

            AccountPreferences accountPreferences = controller.getAccountPreferences(account);

            if (accountPreferences != null && accountPreferences.getRestrictionEnzymes() != null
                    && !accountPreferences.getRestrictionEnzymes().isEmpty()) {
                userRestrictionEnzymes = (UserRestrictionEnzymes) SerializationUtils
                        .deserializeStringToObject(accountPreferences.getRestrictionEnzymes());
            } else {
                userRestrictionEnzymes = new UserRestrictionEnzymes();
            }
        } catch (SerializationUtils.SerializationUtilsException e) {
            Logger.error(getServiceName(), e);

            return null;
        } catch (ControllerException e) {
            Logger.error(getServiceName(), e);

            return null;
        } catch (Exception e) {
            Logger.error(getServiceName(), e);

            return null;
        }

        return userRestrictionEnzymes;
    }

Merge Catch [catch(SerializationUtils.SerializationUtilsException e), catch(ControllerException e)] to catch(SerializationUtils.SerializationUtilsException|ControllerException e) in method public getUserRestrictionEnzymes(sessionId String) : UserRestrictionEnzymes from class org.jbei.ice.services.blazeds.RegistryAMFAPI


    /**
     * Create a new {@link SequenceCheckerProject} in the database.
     *
     * @param sessionId              session key.
     * @param sequenceCheckerProject SequenceCheckerProject to save.
     * @return SequenceCheckerProject that was saved in the database.
     */
    public SequenceCheckerProject createSequenceCheckerProject(String sessionId,
            SequenceCheckerProject sequenceCheckerProject) {
        if (sequenceCheckerProject == null || sessionId == null) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        String serializedSequenceCheckerData = "";

        try {
            serializedSequenceCheckerData = SerializationUtils
                    .serializeObjectToString(sequenceCheckerProject.getSequenceCheckerData());
        } catch (SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        }

        ProjectController projectController = new ProjectController();

        Project project = projectController.createProject(account,
                                                          sequenceCheckerProject.getName(),
                                                          sequenceCheckerProject.getDescription(),
                                                          serializedSequenceCheckerData,
                                                          sequenceCheckerProject.typeName(), new Date(),
                                                          new Date());

        try {
            Project savedProject = projectController.save(account, project);

            sequenceCheckerProject.setName(savedProject.getName());
            sequenceCheckerProject.setDescription(savedProject.getDescription());
            sequenceCheckerProject.setUuid(savedProject.getUuid());
            sequenceCheckerProject.setOwnerEmail(savedProject.getAccount().getEmail());
            sequenceCheckerProject.setOwnerName(savedProject.getAccount().getFullName());
            sequenceCheckerProject.setCreationTime(savedProject.getCreationTime());
            sequenceCheckerProject.setModificationTime(savedProject.getModificationTime());
        } catch (ControllerException | PermissionException e) {
            Logger.error(getLoggerPrefix(), e);
            return null;
        }

        return sequenceCheckerProject;
    }

    /**
     * Create a new {@link SequenceCheckerProject} in the database.
     *
     * @param sessionId              session key.
     * @param sequenceCheckerProject SequenceCheckerProject to save.
     * @return SequenceCheckerProject that was saved in the database.
     */
    public SequenceCheckerProject createSequenceCheckerProject(String sessionId,
            SequenceCheckerProject sequenceCheckerProject) {
        if (sequenceCheckerProject == null || sessionId == null) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        String serializedSequenceCheckerData = "";

        try {
            serializedSequenceCheckerData = SerializationUtils
                    .serializeObjectToString(sequenceCheckerProject.getSequenceCheckerData());
        } catch (SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        }

        ProjectController projectController = new ProjectController();

        Project project = projectController.createProject(account,
                                                          sequenceCheckerProject.getName(),
                                                          sequenceCheckerProject.getDescription(),
                                                          serializedSequenceCheckerData,
                                                          sequenceCheckerProject.typeName(), new Date(),
                                                          new Date());

        try {
            Project savedProject = projectController.save(account, project);

            sequenceCheckerProject.setName(savedProject.getName());
            sequenceCheckerProject.setDescription(savedProject.getDescription());
            sequenceCheckerProject.setUuid(savedProject.getUuid());
            sequenceCheckerProject.setOwnerEmail(savedProject.getAccount().getEmail());
            sequenceCheckerProject.setOwnerName(savedProject.getAccount().getFullName());
            sequenceCheckerProject.setCreationTime(savedProject.getCreationTime());
            sequenceCheckerProject.setModificationTime(savedProject.getModificationTime());
        } catch (ControllerException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        } catch (PermissionException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        }

        return sequenceCheckerProject;
    }

Merge Catch [catch(ControllerException e), catch(PermissionException e)] to catch(ControllerException|PermissionException e) in method public createSequenceCheckerProject(sessionId String, sequenceCheckerProject SequenceCheckerProject) : SequenceCheckerProject from class org.jbei.ice.services.blazeds.RegistryAMFAPI


    /**
     * Save the given {@link SequenceCheckerProject} in the database.
     *
     * @param sessionId              session key.
     * @param sequenceCheckerProject SequenceCheckerProject to save.
     * @return SequenceCheckerProject that was saved in the database.
     */
    public SequenceCheckerProject saveSequenceCheckerProject(String sessionId,
            SequenceCheckerProject sequenceCheckerProject) {
        if (sessionId == null || sessionId.isEmpty() || sequenceCheckerProject == null
                || sequenceCheckerProject.getUuid() == null) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        SequenceCheckerProject resultSequenceCheckerProject = null;

        ProjectController projectController = new ProjectController();
        try {
            Project project = projectController.getProjectByUUID(sequenceCheckerProject.getUuid());

            project.setName(sequenceCheckerProject.getName());
            project.setDescription(sequenceCheckerProject.getDescription());
            project.setModificationTime(new Date());
            project.setData(SerializationUtils.serializeObjectToString(sequenceCheckerProject
                                                                               .getSequenceCheckerData()));

            Project savedProject = projectController.save(account, project);

            resultSequenceCheckerProject = new SequenceCheckerProject(savedProject.getName(),
                                                                      savedProject.getDescription(),
                                                                      savedProject.getUuid(), savedProject
                    .getAccount().getEmail(), savedProject.getAccount().getFullName(),
                                                                      savedProject.getCreationTime(),
                                                                      savedProject.getModificationTime(),
                                                                      sequenceCheckerProject.getSequenceCheckerData());
        } catch (ControllerException | SerializationUtilsException | PermissionException e) {
            Logger.error(getLoggerPrefix(), e);
            return null;
        }

        return resultSequenceCheckerProject;
    }

    /**
     * Save the given {@link SequenceCheckerProject} in the database.
     *
     * @param sessionId              session key.
     * @param sequenceCheckerProject SequenceCheckerProject to save.
     * @return SequenceCheckerProject that was saved in the database.
     */
    public SequenceCheckerProject saveSequenceCheckerProject(String sessionId,
            SequenceCheckerProject sequenceCheckerProject) {
        if (sessionId == null || sessionId.isEmpty() || sequenceCheckerProject == null
                || sequenceCheckerProject.getUuid() == null) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        SequenceCheckerProject resultSequenceCheckerProject = null;

        ProjectController projectController = new ProjectController();
        try {
            Project project = projectController.getProjectByUUID(sequenceCheckerProject.getUuid());

            project.setName(sequenceCheckerProject.getName());
            project.setDescription(sequenceCheckerProject.getDescription());
            project.setModificationTime(new Date());
            project.setData(SerializationUtils.serializeObjectToString(sequenceCheckerProject
                                                                               .getSequenceCheckerData()));

            Project savedProject = projectController.save(account, project);

            resultSequenceCheckerProject = new SequenceCheckerProject(savedProject.getName(),
                                                                      savedProject.getDescription(),
                                                                      savedProject.getUuid(), savedProject
                    .getAccount().getEmail(), savedProject.getAccount().getFullName(),
                                                                      savedProject.getCreationTime(),
                                                                      savedProject.getModificationTime(),
                                                                      sequenceCheckerProject.getSequenceCheckerData());
        } catch (ControllerException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        } catch (SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        } catch (PermissionException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        }

        return resultSequenceCheckerProject;
    }

Merge Catch [catch(ControllerException e), catch(SerializationUtilsException e), catch(PermissionException e)] to catch(ControllerException|SerializationUtilsException|PermissionException e) in method public saveSequenceCheckerProject(sessionId String, sequenceCheckerProject SequenceCheckerProject) : SequenceCheckerProject from class org.jbei.ice.services.blazeds.RegistryAMFAPI


    /**
     * Retrieve the specified {@link SequenceCheckerProject} in the database.
     *
     * @param sessionId session key.
     * @param projectId uuid of the SequenceCheckerProject to retrieve.
     * @return SequenceCheckerProject object.
     */
    public SequenceCheckerProject getSequenceCheckerProject(String sessionId, String projectId) {
        if (projectId == null || sessionId == null || sessionId.isEmpty() || projectId.isEmpty()) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        SequenceCheckerProject sequenceCheckerProject = null;

        ProjectController projectController = new ProjectController();
        try {
            Project project = projectController.getProjectByUUID(projectId);

            SequenceCheckerData sequenceCheckerData = (SequenceCheckerData) SerializationUtils
                    .deserializeStringToObject(project.getData());

            sequenceCheckerProject = new SequenceCheckerProject(project.getName(),
                                                                project.getDescription(), project.getUuid(),
                                                                account.getEmail(),
                                                                account.getFullName(), project.getCreationTime(),
                                                                project.getModificationTime(), sequenceCheckerData);
        } catch (ControllerException | SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);
            return null;
        }

        return sequenceCheckerProject;
    }

    /**
     * Retrieve the specified {@link SequenceCheckerProject} in the database.
     *
     * @param sessionId session key.
     * @param projectId uuid of the SequenceCheckerProject to retrieve.
     * @return SequenceCheckerProject object.
     */
    public SequenceCheckerProject getSequenceCheckerProject(String sessionId, String projectId) {
        if (projectId == null || sessionId == null || sessionId.isEmpty() || projectId.isEmpty()) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        SequenceCheckerProject sequenceCheckerProject = null;

        ProjectController projectController = new ProjectController();
        try {
            Project project = projectController.getProjectByUUID(projectId);

            SequenceCheckerData sequenceCheckerData = (SequenceCheckerData) SerializationUtils
                    .deserializeStringToObject(project.getData());

            sequenceCheckerProject = new SequenceCheckerProject(project.getName(),
                                                                project.getDescription(), project.getUuid(),
                                                                account.getEmail(),
                                                                account.getFullName(), project.getCreationTime(),
                                                                project.getModificationTime(), sequenceCheckerData);
        } catch (ControllerException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        } catch (SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        }

        return sequenceCheckerProject;
    }

Merge Catch [catch(ControllerException e), catch(SerializationUtilsException e)] to catch(ControllerException|SerializationUtilsException e) in method public getSequenceCheckerProject(sessionId String, projectId String) : SequenceCheckerProject from class org.jbei.ice.services.blazeds.RegistryAMFAPI


    /**
     * Retrieve the specified {@link VectorEditorProject}.
     *
     * @param sessionId session key.
     * @param projectId UUID of the desired VectorEditorProject.
     * @return VectorEditorProject.
     */
    public VectorEditorProject getVectorEditorProject(String sessionId, String projectId) {
        if (projectId == null || sessionId == null || sessionId.isEmpty() || projectId.isEmpty()) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        VectorEditorProject vectorEditorProject = null;

        ProjectController projectController = new ProjectController();
        try {
            Project project = projectController.getProjectByUUID(projectId);

            FeaturedDNASequence featuredDNASequence = (FeaturedDNASequence) SerializationUtils
                    .deserializeStringToObject(project.getData());

            vectorEditorProject = new VectorEditorProject(project.getName(),
                                                          project.getDescription(), project.getUuid(),
                                                          account.getEmail(),
                                                          account.getFullName(), project.getCreationTime(),
                                                          project.getModificationTime(), featuredDNASequence);
        } catch (ControllerException | SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);
            return null;
        }

        return vectorEditorProject;
    }

    /**
     * Retrieve the specified {@link VectorEditorProject}.
     *
     * @param sessionId session key.
     * @param projectId UUID of the desired VectorEditorProject.
     * @return VectorEditorProject.
     */
    public VectorEditorProject getVectorEditorProject(String sessionId, String projectId) {
        if (projectId == null || sessionId == null || sessionId.isEmpty() || projectId.isEmpty()) {
            return null;
        }

        Account account = getAccountBySessionId(sessionId);

        if (account == null) {
            return null;
        }

        VectorEditorProject vectorEditorProject = null;

        ProjectController projectController = new ProjectController();
        try {
            Project project = projectController.getProjectByUUID(projectId);

            FeaturedDNASequence featuredDNASequence = (FeaturedDNASequence) SerializationUtils
                    .deserializeStringToObject(project.getData());

            vectorEditorProject = new VectorEditorProject(project.getName(),
                                                          project.getDescription(), project.getUuid(),
                                                          account.getEmail(),
                                                          account.getFullName(), project.getCreationTime(),
                                                          project.getModificationTime(), featuredDNASequence);
        } catch (ControllerException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        } catch (SerializationUtilsException e) {
            Logger.error(getLoggerPrefix(), e);

            return null;
        }

        return vectorEditorProject;
    }

Merge Catch [catch(ControllerException e), catch(SerializationUtilsException e)] to catch(ControllerException|SerializationUtilsException e) in method public getVectorEditorProject(sessionId String, projectId String) : VectorEditorProject from class org.jbei.ice.services.blazeds.RegistryAMFAPI


    /**
     * Runs a parser on a given string. The returned value is a `ParserState` with a `.getResult()` method to get the result of parsing. If the parser fails, the value of `parserState.isException()` will be true, and the `parserState.getException()` will return the exception.
     * @param input The string to parse.
     * @return A `ParserState` with information about the result, and whether the string could be parsed.
     */
    public ParserState<ResultType> run(String input) {
        return parse(new ParserState<>(input));
    }

    /**
     * Runs a parser on a given string. The returned value is a `ParserState` with a `.getResult()` method to get the result of parsing. If the parser fails, the value of `parserState.isException()` will be true, and the `parserState.getException()` will return the exception.
     * @param input The string to parse.
     * @return A `ParserState` with information about the result, and whether the string could be parsed.
     */
    public ParserState<ResultType> run(String input) {
        return parse(new ParserState<ResultType>(input));
    }

Replace Generic With Diamond ParserState<ResultType> with ParserState<> in method public run(input String) : ParserState<ResultType> from class gg.valgo.gradian.Parser


				public String nextPhrase() {
					if (OutputServer.getCurrentServer() == null) return "";

					Server s = Client.getCurrentClient().getServer();
					if (s == null) return "";

					double g = s.getNodeGroup().getActivityRating() / 2;
					double r = 0.5 + s.getNodeGroup().getAverageConnectivityRating();
					double b = s.getNodeGroup().getAverageConnectivityRating() / 2.0;

					final RGB color = new RGB(r, g, b);

					try {
						SwingUtilities.invokeAndWait(() -> {
							if (FlowTreeCliServer.this.display == null) return;

							FlowTreeCliServer.this.display.setBackground(
									GraphicsConverter.convertToAWTColor(color));
							FlowTreeCliServer.this.display.repaint();
						});
					} catch (InterruptedException e) {
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}

					if (last == 0) {
						last = 1;
						return "Running " + s.getNodeGroup().getNodes().length + " nodes at " +
								s.getLocalSocketAddress() + ".";
					} else if (last == 1) {
						last = 2;
						return "Connected to " + s.getNodeGroup().getServers().length + " servers.";
					} else if (last == 2) {
						last = 3;
						return "Worked for " + Node.formatTime(s.getNodeGroup().getTimeWorked()) +
								" and completed " + s.getNodeGroup().getCompletedJobCount() + " jobs.";
					} else {
						last = 0;
						return "Communicated for " +
								Node.formatTime(s.getNodeGroup().getTimeCommunicated()) + ".";
					}
				}

				public String nextPhrase() {
					if (OutputServer.getCurrentServer() == null) return "";

					Server s = Client.getCurrentClient().getServer();
					if (s == null) return "";

					double g = s.getNodeGroup().getActivityRating() / 2;
					double r = 0.5 + s.getNodeGroup().getAverageConnectivityRating();
					double b = s.getNodeGroup().getAverageConnectivityRating() / 2.0;

					final RGB color = new RGB(r, g, b);

					try {
						SwingUtilities.invokeAndWait(new Runnable() {
							public void run() {
								if (FlowTreeCliServer.this.display == null) return;

								FlowTreeCliServer.this.display.setBackground(
										GraphicsConverter.convertToAWTColor(color));
								FlowTreeCliServer.this.display.repaint();
							}
						});
					} catch (InterruptedException e) {
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}

					if (last == 0) {
						last = 1;
						return "Running " + s.getNodeGroup().getNodes().length + " nodes at " +
								s.getLocalSocketAddress() + ".";
					} else if (last == 1) {
						last = 2;
						return "Connected to " + s.getNodeGroup().getServers().length + " servers.";
					} else if (last == 2) {
						last = 3;
						return "Worked for " + Node.formatTime(s.getNodeGroup().getTimeWorked()) +
								" and completed " + s.getNodeGroup().getCompletedJobCount() + " jobs.";
					} else {
						last = 0;
						return "Communicated for " +
								Node.formatTime(s.getNodeGroup().getTimeCommunicated()) + ".";
					}
				}

Replace Anonymous With Lambda io.flowtree.cli.FlowTreeCliServer.FlowTreeCliServer.producer.new ScrollingTextDisplay.TextProducer.nextPhrase.invokeAndWait.new Runnable with () -> {if(FlowTreeCliServer.this.display == null)return; in method public nextPhrase() : String from class io.flowtree.cli.FlowTreeCliServer.FlowTreeCliServer.producer.new ScrollingTextDisplay.TextProducer


	public FlowTreeCliServer(String httpwww, int jobSize, int port, boolean gui) throws IOException {
		FlowTreeCliServer.current = this;
		FlowTreeCliServer.httpwww = httpwww;
		FlowTreeCliServer.jobSize = jobSize;

		this.commands = new Hashtable();

		this.socket = new ServerSocket(port);

		if (gui) {
			JFrame graphFrame = new JFrame("Graphs");
			graphFrame.setSize(100, 200);

			Container c = graphFrame.getContentPane();
			c.setLayout(new GridLayout(0, 1));

			this.activityGraph = new GraphDisplay();
			this.sleepGraph = new GraphDisplay();

			c.add(this.activityGraph);
			c.add(this.sleepGraph);
			// c.add(this.relayPGraph);
			// c.add(this.connectPGraph);

			// graphFrame.setVisible(true);

			OutputServer.getCurrentServer().getNodeServer().getNodeGroup().addActivityListener(this);

			this.loadIcons();
			this.dialog = new NetworkDialog();

			Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

			JWindow f = new JWindow();
			f.setSize(300, 40);
			f.setLocation(d.width - 300, d.height - 60);

			this.button = new JButton(this.activeIcon);
			this.button.addActionListener((e) -> FlowTreeCliServer.this.dialog.showDialog());

			JButton closeButton = new JButton(closeIcon);
			closeButton.addActionListener((e) -> {
					try {
						Server s = OutputServer.getCurrentServer().getNodeServer();

						if (s.getNodeGroup().getServers().length > 0 &&
							JOptionPane.showConfirmDialog(null, "Are you sure?", "Quit",
										JOptionPane.YES_NO_OPTION)
										!= JOptionPane.YES_OPTION) {
							return;
						}
					} catch (Exception ex) { }

					System.exit(0);
				});

			ScrollingTextDisplay.TextProducer producer = new ScrollingTextDisplay.TextProducer() {
				private int last = 0;

				public String nextPhrase() {
					if (OutputServer.getCurrentServer() == null) return "";

					Server s = Client.getCurrentClient().getServer();
					if (s == null) return "";

					double g = s.getNodeGroup().getActivityRating() / 2;
					double r = 0.5 + s.getNodeGroup().getAverageConnectivityRating();
					double b = s.getNodeGroup().getAverageConnectivityRating() / 2.0;

					final RGB color = new RGB(r, g, b);

					try {
						SwingUtilities.invokeAndWait(() -> {
							if (FlowTreeCliServer.this.display == null) return;

							FlowTreeCliServer.this.display.setBackground(
									GraphicsConverter.convertToAWTColor(color));
							FlowTreeCliServer.this.display.repaint();
						});
					} catch (InterruptedException e) {
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}

					if (last == 0) {
						last = 1;
						return "Running " + s.getNodeGroup().getNodes().length + " nodes at " +
								s.getLocalSocketAddress() + ".";
					} else if (last == 1) {
						last = 2;
						return "Connected to " + s.getNodeGroup().getServers().length + " servers.";
					} else if (last == 2) {
						last = 3;
						return "Worked for " + Node.formatTime(s.getNodeGroup().getTimeWorked()) +
								" and completed " + s.getNodeGroup().getCompletedJobCount() + " jobs.";
					} else {
						last = 0;
						return "Communicated for " +
								Node.formatTime(s.getNodeGroup().getTimeCommunicated()) + ".";
					}
				}
			};

			this.display = new ScrollingTextDisplay(producer, 30);
			this.display.setOpaque(true);

			f.getContentPane().setLayout(new BorderLayout());
			f.getContentPane().add(this.button, BorderLayout.WEST);
			f.getContentPane().add(this.display, BorderLayout.CENTER);
			f.getContentPane().add(closeButton, BorderLayout.EAST);

//			TODO  Separate UI elsewhere
//			f.setVisible(true);

			Thread t = new Thread((Runnable) () -> {
				while (true) {
					try {
						Thread.sleep(60000);

						Client c1 = Client.getCurrentClient();
						Server s = c1.getServer();
						NodeGroup g = s.getNodeGroup();

						if (FlowTreeCliServer.this.activityGraph != null) {
							FlowTreeCliServer.this.activityGraph.addEntry(
									(int)(g.getAverageActivityRating() * 10));
						}

						if (FlowTreeCliServer.this.sleepGraph != null) {
							FlowTreeCliServer.this.sleepGraph.addEntry(
									(int)(g.getSleep() / 10000));
						}

						if (FlowTreeCliServer.this.dialog.isVisible() && c1 != null) {
							SwingUtilities.invokeAndWait(new Runnable() {
								public void run() {
									FlowTreeCliServer.this.dialog.updateStatus();
								}
							});
						}
					} catch (InterruptedException ie) {
					} catch (InvocationTargetException ite) {
						ite.printStackTrace();
					}
				}
			});

			t.setName("Rendering Client Status Update Thread");
			t.setDaemon(true);
			t.start();
		}
	}

	public FlowTreeCliServer(String httpwww, int jobSize, int port, boolean gui) throws IOException {
		FlowTreeCliServer.httpwww = httpwww;
		FlowTreeCliServer.jobSize = jobSize;

		this.commands = new Hashtable();

		this.socket = new ServerSocket(port);

		if (gui) {
			JFrame graphFrame = new JFrame("Graphs");
			graphFrame.setSize(100, 200);

			Container c = graphFrame.getContentPane();
			c.setLayout(new GridLayout(0, 1));

			this.activityGraph = new GraphDisplay();
			this.sleepGraph = new GraphDisplay();

			c.add(this.activityGraph);
			c.add(this.sleepGraph);
			// c.add(this.relayPGraph);
			// c.add(this.connectPGraph);

			// graphFrame.setVisible(true);

			OutputServer.getCurrentServer().getNodeServer().getNodeGroup().addActivityListener(this);

			this.loadIcons();
			this.dialog = new NetworkDialog();

			Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

			JWindow f = new JWindow();
			f.setSize(300, 40);
			f.setLocation(d.width - 300, d.height - 60);

			this.button = new JButton(this.activeIcon);
			this.button.addActionListener((e) -> FlowTreeCliServer.this.dialog.showDialog());

			JButton closeButton = new JButton(closeIcon);
			closeButton.addActionListener((e) -> {
					try {
						Server s = OutputServer.getCurrentServer().getNodeServer();

						if (s.getNodeGroup().getServers().length > 0 &&
							JOptionPane.showConfirmDialog(null, "Are you sure?", "Quit",
										JOptionPane.YES_NO_OPTION)
										!= JOptionPane.YES_OPTION) {
							return;
						}
					} catch (Exception ex) { }

					System.exit(0);
				});

			ScrollingTextDisplay.TextProducer producer = new ScrollingTextDisplay.TextProducer() {
				private int last = 0;

				public String nextPhrase() {
					if (OutputServer.getCurrentServer() == null) return "";

					Server s = Client.getCurrentClient().getServer();
					if (s == null) return "";

					double g = s.getNodeGroup().getActivityRating() / 2;
					double r = 0.5 + s.getNodeGroup().getAverageConnectivityRating();
					double b = s.getNodeGroup().getAverageConnectivityRating() / 2.0;

					final RGB color = new RGB(r, g, b);

					try {
						SwingUtilities.invokeAndWait(new Runnable() {
							public void run() {
								if (FlowTreeCliServer.this.display == null) return;

								FlowTreeCliServer.this.display.setBackground(
										GraphicsConverter.convertToAWTColor(color));
								FlowTreeCliServer.this.display.repaint();
							}
						});
					} catch (InterruptedException e) {
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}

					if (last == 0) {
						last = 1;
						return "Running " + s.getNodeGroup().getNodes().length + " nodes at " +
								s.getLocalSocketAddress() + ".";
					} else if (last == 1) {
						last = 2;
						return "Connected to " + s.getNodeGroup().getServers().length + " servers.";
					} else if (last == 2) {
						last = 3;
						return "Worked for " + Node.formatTime(s.getNodeGroup().getTimeWorked()) +
								" and completed " + s.getNodeGroup().getCompletedJobCount() + " jobs.";
					} else {
						last = 0;
						return "Communicated for " +
								Node.formatTime(s.getNodeGroup().getTimeCommunicated()) + ".";
					}
				}
			};

			this.display = new ScrollingTextDisplay(producer, 30);
			this.display.setOpaque(true);

			f.getContentPane().setLayout(new BorderLayout());
			f.getContentPane().add(this.button, BorderLayout.WEST);
			f.getContentPane().add(this.display, BorderLayout.CENTER);
			f.getContentPane().add(closeButton, BorderLayout.EAST);

//			TODO  Separate UI elsewhere
//			f.setVisible(true);

			Thread t = new Thread(new Runnable() {
				public void run() {
					while (true) {
						try {
							Thread.sleep(60000);

							Client c = Client.getCurrentClient();
							Server s = c.getServer();
							NodeGroup g = s.getNodeGroup();

							if (FlowTreeCliServer.this.activityGraph != null) {
								FlowTreeCliServer.this.activityGraph.addEntry(
										(int)(g.getAverageActivityRating() * 10));
							}

							if (FlowTreeCliServer.this.sleepGraph != null) {
								FlowTreeCliServer.this.sleepGraph.addEntry(
										(int)(g.getSleep() / 10000));
							}

							if (FlowTreeCliServer.this.dialog.isVisible() && c != null) {
								SwingUtilities.invokeAndWait(new Runnable() {
									public void run() {
										FlowTreeCliServer.this.dialog.updateStatus();
									}
								});
							}
						} catch (InterruptedException ie) {
						} catch (InvocationTargetException ite) {
							ite.printStackTrace();
						}
					}
				}
			});

			t.setName("Rendering Client Status Update Thread");
			t.setDaemon(true);
			t.start();
		}
	}

Replace Anonymous With Lambda io.flowtree.cli.FlowTreeCliServer.FlowTreeCliServer.t.new Thread.new Runnable with () -> {while(true){tryThread.sleep(60000); in method public FlowTreeCliServer(httpwww String, jobSize int, port int, gui boolean) from class io.flowtree.cli.FlowTreeCliServer


	/**
	 * Constructs a new Node object using the specified parent and id.
	 *
	 * @param parent  Parent of this Node object. If set to null this node
	 *                will not start a thread for completing jobs.
	 * @param id  Integer id unique for the specified parent.
	 * @param maxJobs  Maximum number of jobs stored by this node before it starts sending jobs to peers.
	 * @param maxPeers  Maximum number of peers before this node stops adding connections.
	 */
	public Node(NodeGroup parent, int id, int maxJobs, int maxPeers) {
		this.parent = parent;
		this.id = id;
		this.maxJobs = maxJobs;
		this.maxPeers = maxPeers;

		this.peers = new HashSet();
		this.jobs = new ArrayList();
		this.listeners = new ArrayList();

		this.relayGraph = new Chart();
		this.relayGraph.setDivisions(40);
		this.connectGraph = new Chart();
		this.connectGraph.setDivisions(40);

		Client c = Client.getCurrentClient();
		ThreadGroup g = null;
		if (c != null) g = c.getServer().getThreadGroup();
		this.nodeThread = new Thread(g, this, "Node " + this.id + " Activity Thread");
		this.nodeThread.setPriority(Server.MODERATE_PRIORITY);

		this.worker = new Thread(() -> {
				while (true) {
					Job j = Node.this.nextJob();
					Node.this.currentJob = j;

					if (j != null) {
						long start = System.currentTimeMillis();

						synchronized (Node.this.listeners) {
							Node.this.working = true;
							Node.this.startedWorking();
						}

						Node.this.working = true;

						boolean complete = false;

						try {
							j.setExecutorService(pool);
							j.run();
							complete = true;
						} catch (Exception e) {
							if (e instanceof RuntimeException)
								Node.this.displayMessage("Exception while working -- "
															+ e.getMessage());
							else
								Node.this.displayMessage("Exception while working -- ");

							e.printStackTrace();

							if (e instanceof NullPointerException) e.printStackTrace();
							Node.this.totalErrJobs++;
							Node.this.addFailedJob(j.encode());
						}

						Node.this.working = false;

						synchronized (Node.this.listeners) {
							Iterator itr = Node.this.listeners.iterator();
							while (itr.hasNext()) ((ActivityListener)itr.next()).stoppedWorking();

							if (Node.this.parent != null) {
								itr = Node.this.parent.listeners.iterator();
								while (itr.hasNext()) ((ActivityListener)itr.next()).stoppedWorking();
							}
						}

						Node.this.totalJobs++;

						long end = System.currentTimeMillis();
						long tot = end - start;
						Node.this.totalWorkTime += tot;

						if (complete) {
							Node.this.displayMessage("Completed job " + j + " in " +
											tot / 1000.0 + " seconds.");
						}
					} else {
						try {
							Thread.sleep(5000);
						} catch (InterruptedException ie) {
							System.out.println("Node " + Node.this.id + ": " + ie);
						}
					}
				}
		}, "Node " + this.id + " Worker Thread");
		this.worker.setPriority(Server.HIGH_PRIORITY);
		this.worker.setDaemon(true);

		this.pool = Executors.newFixedThreadPool(1, this);

		this.setSleep((int)(1.5 * this.minSleep));
		this.setRelayProbability(1.0);
		this.setConnectProbability(0.5);
		this.setMinJobs((int)(this.maxJobs * this.minJobP));

		if (this.parent != null) {
			this.rssfile = this.parent.rssfile;
			this.log = this.parent.log;
		} else {
			this.worker = null;
		}

		this.setName("Node " + this.id);
	}

	/**
	 * Constructs a new Node object using the specified parent and id.
	 *
	 * @param parent  Parent of this Node object. If set to null this node
	 *                will not start a thread for completing jobs.
	 * @param id  Integer id unique for the specified parent.
	 * @param maxJobs  Maximum number of jobs stored by this node before it starts sending jobs to peers.
	 * @param maxPeers  Maximum number of peers before this node stops adding connections.
	 */
	public Node(NodeGroup parent, int id, int maxJobs, int maxPeers) {
		this.parent = parent;
		this.id = id;
		this.maxJobs = maxJobs;
		this.maxPeers = maxPeers;

		this.peers = new HashSet();
		this.jobs = new ArrayList();
		this.listeners = new ArrayList();

		this.relayGraph = new Chart();
		this.relayGraph.setDivisions(40);
		this.connectGraph = new Chart();
		this.connectGraph.setDivisions(40);

		Client c = Client.getCurrentClient();
		ThreadGroup g = null;
		if (c != null) g = c.getServer().getThreadGroup();
		this.nodeThread = new Thread(g, this, "Node " + this.id + " Activity Thread");
		this.nodeThread.setPriority(Server.MODERATE_PRIORITY);

		this.worker = new Thread(new Runnable() {
			public void run() {
				while (true) {
					Job j = Node.this.nextJob();
					Node.this.currentJob = j;

					if (j != null) {
						long start = System.currentTimeMillis();

						synchronized (Node.this.listeners) {
							Node.this.working = true;
							Node.this.startedWorking();
						}

						Node.this.working = true;

						boolean complete = false;

						try {
							j.run();
							complete = true;
						} catch (Exception e) {
							if (e instanceof RuntimeException)
								Node.this.displayMessage("Exception while working -- "
															+ e.getMessage());
							else
								Node.this.displayMessage("Exception while working -- ");

							if (e instanceof NullPointerException) e.printStackTrace();
							Node.this.totalErrJobs++;
							Node.this.addFailedJob(j.encode());
						}

						Node.this.working = false;

						synchronized (Node.this.listeners) {
							Iterator itr = Node.this.listeners.iterator();
							while (itr.hasNext()) ((ActivityListener)itr.next()).stoppedWorking();

							if (Node.this.parent != null) {
								itr = Node.this.parent.listeners.iterator();
								while (itr.hasNext()) ((ActivityListener)itr.next()).stoppedWorking();
							}
						}

						Node.this.totalJobs++;

						long end = System.currentTimeMillis();
						long tot = end - start;
						Node.this.totalWorkTime += tot;

						if (complete) {
							Node.this.displayMessage("Completed job " + j + " in " +
											tot / 1000.0 + " seconds.");
						}
					} else {
						try {
							Thread.sleep(5000);
						} catch (InterruptedException ie) {
							System.out.println("Node " + Node.this.id + ": " + ie);
						}
					}
				}
			}
		}, "Node " + this.id + " Worker Thread");
		this.worker.setPriority(Server.HIGH_PRIORITY);
		this.worker.setDaemon(true);

		this.setSleep((int)(1.5 * this.minSleep));
		this.setRelayProbability(1.0);
		this.setConnectProbability(0.5);
		this.setMinJobs((int)(this.maxJobs * this.minJobP));

		if (this.parent != null) {
			this.rssfile = this.parent.rssfile;
			this.log = this.parent.log;
		} else {
			this.worker = null;
		}

		this.setName("Node " + this.id);
	}

Replace Anonymous With Lambda io.flowtree.node.Node.Node.new Thread.new Runnable with () -> {while(true){Job j=Node.this.nextJob(); in method public Node(parent NodeGroup, id int, maxJobs int, maxPeers int) from class io.flowtree.node.Node


			public void actionPerformed(ActionEvent e) {
				JFileChooser f = new JFileChooser();
				if (f.showSaveDialog(frame) != JFileChooser.APPROVE_OPTION)
					return;

				try (XMLEncoder enc = new XMLEncoder(new FileOutputStream(f.getSelectedFile()))) {
					enc.writeObject(db);
				} catch (FileNotFoundException fnf) {
					fnf.printStackTrace();
				}
			}

			public void actionPerformed(ActionEvent e) {
				JFileChooser f = new JFileChooser();
				if (f.showSaveDialog(frame) != JFileChooser.APPROVE_OPTION)
					return;

				try {
					XMLEncoder enc = new XMLEncoder(new FileOutputStream(f.getSelectedFile()));
					enc.writeObject(db);
					enc.close();
				} catch (FileNotFoundException fnf) {
					fnf.printStackTrace();
				}
			}

Try With Resources try(XMLEncoder enc=new XMLEncoder(new FileOutputStream(f.getSelectedFile()))) in method public actionPerformed(e ActionEvent) : void from class com.almostrealism.promotions.PromotionApp.main.addActionListener.new ActionListener


	public void run() throws RuntimeException {
		long start, end, tot = 0, bs = 0;

		for (int i = 0; i < this.size; i++) {
			start = System.currentTimeMillis();

			String d[] = this.uri.split("\\\\");
			StringBuffer b = new StringBuffer();
			for (int j = 0; j < d.length; j++) b.append(d[j]);
			uri = b.toString();

			try (InputStream in = new URL(this.uri).openStream()) {
				while (in.available() > 0) { in.read(); bs++; }
			} catch (MalformedURLException murl) {
				throw new RuntimeException("UrlProfilingJob -- " + murl.getMessage());
			} catch (IOException e) { }

			end = System.currentTimeMillis();
			tot += end - start;

			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
			}
		}

		if (this.size <= 0) return;

		long avgTime = tot / this.size;
		long avgBs = bs / this.size;

		StringBuffer b = new StringBuffer();
		b.append(this.uri.substring(this.uri.lastIndexOf("/")));
		b.append(":");
		b.append(this.size);
		b.append(":");
		b.append(avgTime);
		b.append(":");
		b.append(avgBs);
		b.append(":");

		Client.getCurrentClient().writeOutput(new JobOutput("", "", b.toString()));
	}

	public void run() throws RuntimeException {
		long start, end, tot = 0, bs = 0;

		for (int i = 0; i < this.size; i++) {
			start = System.currentTimeMillis();

			String d[] = this.uri.split("\\\\");
			StringBuffer b = new StringBuffer();
			for (int j = 0; j < d.length; j++) b.append(d[j]);
			uri = b.toString();

			try {
				InputStream in = new URL(this.uri).openStream();
				while (in.available() > 0) { in.read(); bs++; }
				in.close();
			} catch (MalformedURLException murl) {
				throw new RuntimeException("UrlProfilingJob -- " + murl.getMessage());
			} catch (IOException e) { }

			end = System.currentTimeMillis();
			tot += end - start;

			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
			}
		}

		if (this.size <= 0) return;

		long avgTime = tot / this.size;
		long avgBs = bs / this.size;

		StringBuffer b = new StringBuffer();
		b.append(this.uri.substring(this.uri.lastIndexOf("/")));
		b.append(":");
		b.append(this.size);
		b.append(":");
		b.append(avgTime);
		b.append(":");
		b.append(avgBs);
		b.append(":");

		Client.getCurrentClient().writeOutput(new JobOutput("", "", b.toString()));
	}

Try With Resources try(InputStream in=new URL(this.uri).openStream()) in method public run() : void from class com.almostrealism.flow.tests.UrlProfilingJob


	public long getTotalBytes() {
		ResourceDistributionTask t = ResourceDistributionTask.getCurrentTask();

		try (BufferedReader buf = new BufferedReader(new InputStreamReader(super.getInputStream()))) {
			String l = buf.readLine();
			l = l.substring(header.length());
			String c[] = t.getChildren(l);
			long tot = c.length * 2;

			for (int i = 0; i < c.length; i++) {
				DistributedResource r = t.getResource(c[i]);
				tot += r.getTotalBytes();
			}

			tot += footer.getBytes().length;
			return tot;
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public long getTotalBytes() {
		ResourceDistributionTask t = ResourceDistributionTask.getCurrentTask();
		BufferedReader buf = new BufferedReader(new InputStreamReader(super.getInputStream()));

		try {
			String l = buf.readLine();
			buf.close();
			l = l.substring(header.length());
			String c[] = t.getChildren(l);
			long tot = c.length * 2;

			for (int i = 0; i < c.length; i++) {
				DistributedResource r = t.getResource(c[i]);
				tot += r.getTotalBytes();
			}

			tot += footer.getBytes().length;
			return tot;
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

Try With Resources try(BufferedReader buf=new BufferedReader(new InputStreamReader(super.getInputStream()))) in method public getTotalBytes() : long from class com.almostrealism.flow.resources.ConcatenatedResource


	public void run() {
		while (true) {
			boolean done = false;

			try (Socket s = this.socket.accept();
				ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
				ObjectInputStream in = new ObjectInputStream(s.getInputStream())) {

				String type = in.readUTF();

				Object o = Class.forName(type).newInstance();
				if (o instanceof Externalizable)
					((Externalizable)o).readExternal(in);
				else
					System.out.println("DBS: Recieved class that is not externalizable.");

//				Object o = in.readObject();

				if (o instanceof Query) {
					Hashtable h = this.db.executeQuery((Query)o);

					out.writeObject(h);
					out.flush();
				} else if (o instanceof JobOutput) {
					this.db.storeOutput((JobOutput)o);
				} else {
					System.out.println("DBS: Recieved " + o);
				}

				done = true;
			} catch (EOFException eof) {
				if (!done) System.out.println("DB Server: EOF Error (" + eof.getMessage() + ")");
			} catch (ClassNotFoundException cnf) {
				System.out.println("DB Server: Recieved an unknown class type.");
			} catch (IOException ioe) {
				if (!done) {
					System.out.println("DB Server: IO Error (" + ioe.getMessage() + ")");
					ioe.printStackTrace(System.out);
				}
			} catch (Exception e) {
				System.out.println("DB Server: " + e);
				e.printStackTrace();
			}
		}
	}

	public void run() {
		while (true) {
			boolean done = false;

			try {
				Socket s = this.socket.accept();

				// System.out.println("DBS: Accepted connection " + s);

				ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
				ObjectInputStream in = new ObjectInputStream(s.getInputStream());

				String type = in.readUTF();

				Object o = Class.forName(type).newInstance();
				if (o instanceof Externalizable)
					((Externalizable)o).readExternal(in);
				else
					System.out.println("DBS: Recieved class that is not externalizable.");

//				Object o = in.readObject();

				if (o instanceof Query) {
					Hashtable h = this.db.executeQuery((Query)o);

					out.writeObject(h);
					out.flush();
				} else if (o instanceof JobOutput) {
					this.db.storeOutput((JobOutput)o);
				} else {
					System.out.println("DBS: Recieved " + o);
				}

				done = true;

				in.close();
				out.close();
				s.close();
			} catch (EOFException eof) {
				if (!done) System.out.println("DB Server: EOF Error (" + eof.getMessage() + ")");
			} catch (ClassNotFoundException cnf) {
				System.out.println("DB Server: Recieved an unknown class type.");
			} catch (IOException ioe) {
				if (!done) {
					System.out.println("DB Server: IO Error (" + ioe.getMessage() + ")");
					ioe.printStackTrace(System.out);
				}
			} catch (Exception e) {
				System.out.println("DB Server: " + e);
				e.printStackTrace();
			}
		}
	}

Try With Resources try(Socket s=this.socket.accept(); ObjectOutputStream out=new ObjectOutputStream(s.getOutputStream()); ObjectInputStream in=new ObjectInputStream(s.getInputStream())) in method public run() : void from class com.almostrealism.flow.db.OutputServer


	/**
	 * Sends the specified Query to the output server.
	 *
	 * @param q  Query object to send.
	 * @return  The Hashtable resulting from the query or null if an error occurs.
	 */
	public Hashtable sendQuery(Query q) {
		try (Socket s = new Socket(this.outputHost, this.outputPort);
			ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
			ObjectInputStream in = new ObjectInputStream(s.getInputStream())) {

			out.writeUTF(q.getClass().getName());
			q.writeExternal(out);

			out.flush();

			Hashtable h = (Hashtable) in.readObject();
			return h;
		} catch (ClassNotFoundException cnf) {
			System.out.println("Client: " + cnf);
			return null;
		} catch (UnknownHostException uh) {
			System.out.println("Client: Output host " + this.outputHost + ":"+ this.outputPort + ") not found.");
			return null;
		} catch (IOException ioe) {
			System.out.println("Client: " + ioe);
			return null;
		}
	}

	/**
	 * Sends the specified Query to the output server.
	 *
	 * @param q  Query object to send.
	 * @return  The Hashtable resulting from the query or null if an error occurs.
	 */
	public Hashtable sendQuery(Query q) {
		Socket s = null;

		try {
			s = new Socket(this.outputHost, this.outputPort);

			ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
			ObjectInputStream in = new ObjectInputStream(s.getInputStream());

			out.writeUTF(q.getClass().getName());
			q.writeExternal(out);

			out.flush();

			Hashtable h = (Hashtable) in.readObject();

			in.close();
			out.close();
			s.close();

			return h;
		} catch (ClassNotFoundException cnf) {
			System.out.println("Client: " + cnf);
			return null;
		} catch (UnknownHostException uh) {
			System.out.println("Client: Output host " + this.outputHost + ":"+ this.outputPort + ") not found.");
			return null;
		} catch (IOException ioe) {
			System.out.println("Client: " + ioe);
			return null;
		}
	}

Try With Resources try(Socket s=new Socket(this.outputHost,this.outputPort); ObjectOutputStream out=new ObjectOutputStream(s.getOutputStream()); ObjectInputStream in=new ObjectInputStream(s.getInputStream())) in method public sendQuery(q Query) : Hashtable from class com.almostrealism.flow.db.Client


	/**
	 * Sends the specified JobOutput object to the output server.
	 *
	 * @param out  Output to send.
	 * @return  True if send is successful, false otherwise.
	 */
	public boolean writeOutput(JobOutput o) {
		boolean done = false;
		int sleep = 3;

		for (int i = 0; !done; i++) {
			try (Socket s = new Socket(this.outputHost, this.outputPort);
				ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
				ObjectInputStream in = new ObjectInputStream(s.getInputStream())) {

				if (Message.verbose)
					System.out.println("Client: Opened socket " + s);

				if (Message.verbose)
					System.out.println("Client: Writing " + o + "...");
				out.writeUTF(o.getClass().getName());
				o.writeExternal(out);

//				out.writeObject(o);

				done = true;

				return true;
			} catch (ConnectException ce) {
				if (i >= 4) {
					System.out.println("Client: Error connection to output host - giving up");
					return false;
				} else {
					System.out.println("Client: Error connecting to output host - retry in " + sleep + " sec.");
					try { Thread.sleep(sleep * 1000); } catch (InterruptedException ie) {}
				}
			} catch (UnknownHostException uh) {
				System.out.println("Client: Output host (" + this.outputHost + ":"+ this.outputPort + ") not found.");
				return false;
			} catch (IOException ioe) {
				System.out.println("Client: " + ioe);
				ioe.printStackTrace(System.out);
				return false;
			} catch (Exception e) {
				if (done)
					System.out.println("Client.writeOutput: " + e);
				else
					System.out.println("Client.writeOutput: Ended prematurely due to " + e);
			}
		}

		return done;
	}

	/**
	 * Sends the specified JobOutput object to the output server.
	 *
	 * @param out  Output to send.
	 * @return  True if send is successful, false otherwise.
	 */
	public boolean writeOutput(JobOutput o) {
		Socket s = null;

		boolean done = false;
		int sleep = 3;

		for (int i = 0; !done; i++) {
			try {
				s = new Socket(this.outputHost, this.outputPort);

				if (Message.verbose)
					System.out.println("Client: Opened socket " + s);

				ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
				ObjectInputStream in = new ObjectInputStream(s.getInputStream());

				if (Message.verbose)
					System.out.println("Client: Writing " + o + "...");
				out.writeUTF(o.getClass().getName());
				o.writeExternal(out);

//				out.writeObject(o);

				done = true;

				in.close();
				out.close();
				s.close();

				return true;
			} catch (ConnectException ce) {
				if (i >= 4) {
					System.out.println("Client: Error connection to output host - giving up");
					return false;
				} else {
					System.out.println("Client: Error connecting to output host - retry in " + sleep + " sec.");
					try { Thread.sleep(sleep * 1000); } catch (InterruptedException ie) {}
				}
			} catch (UnknownHostException uh) {
				System.out.println("Client: Output host (" + this.outputHost + ":"+ this.outputPort + ") not found.");
				return false;
			} catch (IOException ioe) {
				System.out.println("Client: " + ioe);
				ioe.printStackTrace(System.out);
				return false;
			} catch (Exception e) {
				if (done)
					System.out.println("Client.writeOutput: " + e);
				else
					System.out.println("Client.writeOutput: Ended prematurely due to " + e);
			}
		}

		return done;
	}

Try With Resources try(Socket s=new Socket(this.outputHost,this.outputPort); ObjectOutputStream out=new ObjectOutputStream(s.getOutputStream()); ObjectInputStream in=new ObjectInputStream(s.getInputStream())) in method public writeOutput(o JobOutput) : boolean from class com.almostrealism.flow.db.Client


	public void writeLogFile(int ttl) {
		if (this.rssfile == null || this.log == null) return;

		try (PrintStream p = new PrintStream(new FileOutputStream(this.rssfile))) {
			this.log.write(p, ttl);

			p.flush();
		} catch (FileNotFoundException fnf) {
			fnf.printStackTrace(System.out);
		}
	}

	public void writeLogFile(int ttl) {
		if (this.rssfile == null || this.log == null) return;

		try {
			PrintStream p = new PrintStream(new FileOutputStream(this.rssfile));

			this.log.write(p, ttl);

			p.flush();
			p.close();
		} catch (FileNotFoundException fnf) {
			fnf.printStackTrace(System.out);
		}
	}

Try With Resources try(PrintStream p=new PrintStream(new FileOutputStream(this.rssfile))) in method public writeLogFile(ttl int) : void from class com.almostrealism.flow.Node


	public void run() {
		while (true) {
			try (Socket connection = this.socket.accept()) {
				System.out.println("NetworkClient: Accepted connection...");

				this.in = connection.getInputStream();
				this.out = connection.getOutputStream();
				System.out.println("NetworkClient: Got IO streams...");

				this.ps = new PrintStream(this.out, false, "US-ASCII");
				System.out.println("NetworkClient: Constructed print stream...");

				this.write("Welcome to Rings " + Settings.version + " Network Client\n");
				System.out.println("NetworkClient: Wrote welcome message...");

				w: while(true) {
					this.write("[----]> ");

					String s = this.read();

					if (s == null)
						break w;
					else
						s = s.substring(0, s.length() - 2);

					if (s.equals("exit")) break w;

					this.write(this.runCommand(s.trim()));
					this.write("\n");
				}

				this.in.close();
				this.out.close();
				connection.close();
			} catch (IOException ioe) {
				System.out.println("NetworkClient: IO error accepting connection (" +
									ioe.getMessage() + ")");
			} catch (Exception e) {
				System.out.println("NetworkClient: " + e);
			}
		}
	}

	public void run() {
		while (true) {
			try {
				Socket connection = this.socket.accept();
				System.out.println("NetworkClient: Accepted connection...");

				this.in = connection.getInputStream();
				this.out = connection.getOutputStream();
				System.out.println("NetworkClient: Got IO streams...");

				this.ps = new PrintStream(this.out, false, "US-ASCII");
				System.out.println("NetworkClient: Constructed print stream...");

				this.write("Welcome to Rings " + Settings.version + " Network Client\n");
				System.out.println("NetworkClient: Wrote welcome message...");

				w: while(true) {
					this.write("[----]> ");

					String s = this.read();

					if (s == null)
						break w;
					else
						s = s.substring(0, s.length() - 2);

					if (s.equals("exit")) break w;

					this.write(this.runCommand(s.trim()));
					this.write("\n");
				}

				this.in.close();
				this.out.close();
				connection.close();
			} catch (IOException ioe) {
				System.out.println("NetworkClient: IO error accepting connection (" +
									ioe.getMessage() + ")");
			} catch (Exception e) {
				System.out.println("NetworkClient: " + e);
			}
		}
	}

Try With Resources try(Socket connection=this.socket.accept()) in method public run() : void from class com.almostrealism.flow.NetworkClient


	public void run() {
		while (true) {
			try (Socket connection = this.socket.accept()) {
				System.out.println("HttpCommandServer: Accepted connection...");

				this.in = connection.getInputStream();
				this.out = connection.getOutputStream();
				System.out.println("HttpCommandServer: Got IO streams...");

				this.br = new BufferedReader(new InputStreamReader(this.in));
				this.ps = new PrintStream(this.out, false, "US-ASCII");
				System.out.println("HttpCommandServer: Constructed input buffer and print stream...");

				String command = null;

				w: while(true) {
					String s = this.br.readLine();

					s = s.trim();

					if (s == null || s.equals("")) {
						break w;
					} else if (s.startsWith("GET /")) {
						int p = s.indexOf("?") + 1;
						int q = s.indexOf(" HTTP/");

						command = s.substring(p, q);
						command = command.replaceAll("%20", " ");
					}
				}

				if (Message.verbose)
					System.out.println("HttpCommandServer: Recieved " + command);

				if (command != null) {
					String date = HttpCommandServer.format.format(new Date());

					this.ps.println("HTTP/1.0 200 OK");
					this.ps.println("Date: " + date);
					this.ps.println("Content-Type: text/html");
					this.ps.println("Connection: Close");
					this.ps.println();
					this.ps.println(NetworkClient.runCommand(command, ps));

					if (Message.verbose)
						System.out.println("HttpCommandServer: Sent HTTP header and output.");
				} else {
					System.out.println("HttpCommandServer: Recieved null command");
				}

				this.in.close();
				this.out.close();
				connection.close();
			} catch (IOException ioe) {
				System.out.println("HttpCommandServer: IO error accepting connection (" +
									ioe.getMessage() + ")");
			} catch (Exception e) {
				System.out.println("HttpCommandServer: " + e);
			}
		}
	}

	public void run() {
		while (true) {
			try {
				Socket connection = this.socket.accept();
				System.out.println("HttpCommandServer: Accepted connection...");

				this.in = connection.getInputStream();
				this.out = connection.getOutputStream();
				System.out.println("HttpCommandServer: Got IO streams...");

				this.br = new BufferedReader(new InputStreamReader(this.in));
				this.ps = new PrintStream(this.out, false, "US-ASCII");
				System.out.println("HttpCommandServer: Constructed input buffer and print stream...");

				String command = null;

				w: while(true) {
					String s = this.br.readLine();

					s = s.trim();

					if (s == null || s.equals("")) {
						break w;
					} else if (s.startsWith("GET /")) {
						int p = s.indexOf("?") + 1;
						int q = s.indexOf(" HTTP/");

						command = s.substring(p, q);
						command = command.replaceAll("%20", " ");
					}
				}

				if (Message.verbose)
					System.out.println("HttpCommandServer: Recieved " + command);

				if (command != null) {
					String date = HttpCommandServer.format.format(new Date());

					this.ps.println("HTTP/1.0 200 OK");
					this.ps.println("Date: " + date);
					this.ps.println("Content-Type: text/html");
					this.ps.println("Connection: Close");
					this.ps.println();
					this.ps.println(NetworkClient.runCommand(command, ps));

					if (Message.verbose)
						System.out.println("HttpCommandServer: Sent HTTP header and output.");
				} else {
					System.out.println("HttpCommandServer: Recieved null command");
				}

				this.in.close();
				this.out.close();
				connection.close();
			} catch (IOException ioe) {
				System.out.println("HttpCommandServer: IO error accepting connection (" +
									ioe.getMessage() + ")");
			} catch (Exception e) {
				System.out.println("HttpCommandServer: " + e);
			}
		}
	}

Try With Resources try(Socket connection=this.socket.accept()) in method public run() : void from class com.almostrealism.flow.HttpCommandServer


	/**
	 * Write a sript to be used to compose the output image to form an animation.
	 *
	 * @param instance  The instance string for the animation.
	 */
	public void writeEncodeScript(String instance) {
		System.out.print("Writing encode script: ");

		try (PrintWriter out = new PrintWriter(new FileWriter(new File(this.dir + "encode.sh")))) {
			out.println("#!/bin/sh");
			out.print("mencoder mf://");

			Iterator itr = this.inputFiles.iterator();
			int i = 0;
			int l = this.inputFiles.size();

			while (itr.hasNext()) {
				out.print(((File)itr.next()).getName());
				if (i < l) out.print(",");

				i++;
			}

			int w = this.imageWidth;
			int h = this.imageHeight;
			int fps = (int)(1 / this.fdt);

			out.print(" -mf w=" + w + ":h=" + h + ":fps=" + fps + ":type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o output.avi");
			out.println();
			out.flush();
			out.close();

			System.out.println("Done");
		} catch (IOException ioe) {
			System.out.println("Error writing encode script: " + ioe);
		}
	}

	/**
	 * Write a sript to be used to compose the output image to form an animation.
	 *
	 * @param instance  The instance string for the animation.
	 */
	public void writeEncodeScript(String instance) {
		try {
			System.out.print("Writing encode script: ");

			PrintWriter out = new PrintWriter(new FileWriter(new File(this.dir + "encode.sh")));

			out.println("#!/bin/sh");
			out.print("mencoder mf://");

			Iterator itr = this.inputFiles.iterator();
			int i = 0;
			int l = this.inputFiles.size();

			while (itr.hasNext()) {
				out.print(((File)itr.next()).getName());
				if (i < l) out.print(",");

				i++;
			}

			int w = this.imageWidth;
			int h = this.imageHeight;
			int fps = (int)(1 / this.fdt);

			out.print(" -mf w=" + w + ":h=" + h + ":fps=" + fps + ":type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o output.avi");
			out.println();
			out.flush();
			out.close();

			System.out.println("Done");
		} catch (IOException ioe) {
			System.out.println("Error writing encode script: " + ioe);
		}
	}

Try With Resources try(PrintWriter out=new PrintWriter(new FileWriter(new File(this.dir + "encode.sh")))) in method public writeEncodeScript(instance String) : void from class com.almostrealism.physics.Simulation


						public void run() {
							try (PrintWriter out = new PrintWriter(new FileOutputStream(fileChooser.getSelectedFile()))) {
							    out.write(text);
							    out.flush();
							} catch (IOException ioe) {
								JOptionPane.showMessageDialog(null, "An IO error occured while saving.",
										"IO Error", JOptionPane.ERROR_MESSAGE);
							}

							frame.setVisible(false);
						}

						public void run() {
							try {
							    PrintWriter out = new PrintWriter(new FileOutputStream(fileChooser.getSelectedFile()));
							    out.write(text);
							    out.flush();
							    out.close();
							} catch (IOException ioe) {
								JOptionPane.showMessageDialog(null, "An IO error occured while saving.",
										"IO Error", JOptionPane.ERROR_MESSAGE);
							}

							frame.setVisible(false);
						}

Try With Resources try(PrintWriter out=new PrintWriter(new FileOutputStream(fileChooser.getSelectedFile()))) in method public run() : void from class com.almostrealism.ui.panels.DebugOutputPanel.DebugOutputPanel.addActionListener.new ActionListener.actionPerformed.saver.new Thread.new Runnable