protected void removeOrRenewExpiredProfiles(final LinkedHashMap<String, UserProfile> profiles, final boolean readFromSession) {
        var profilesUpdated = false;
        for (Iterator<Map.Entry<String, UserProfile>> profileIterator = profiles.entrySet().iterator(); profileIterator.hasNext(); ) {
            val entry= profileIterator.next();
            val key = entry.getKey();
            val profile = entry.getValue();
            if (profile.isExpired()) {
                LOGGER.debug("Expired profile: {}", profile);
                profilesUpdated = true;
                boolean removeEntry = true;
                if (config != null && profile.getClientName() != null) {
                    val client = config.getClients().findClient(profile.getClientName());
                    if (client.isPresent()) {
                        try {
                            val newProfile = client.get().renewUserProfile(new CallContext(context, sessionStore), profile);
                            if (newProfile.isPresent()) {
                                LOGGER.debug("Renewed by profile: {}", newProfile);
                                removeEntry = false;
                                entry.setValue(newProfile.get());
                            }
                        } catch (final RuntimeException e) {
                            logger.error("Unable to renew the user profile for key: {}", key, e);
                        }
                    }
                }
                if(removeEntry)
                    profileIterator.remove();
            }
        }
        if (profilesUpdated) {
            saveAll(profiles, readFromSession);
        }
    }
<p>removeOrRenewExpiredProfiles.</p>

@param profiles a {@link LinkedHashMap} object
@param readFromSession a boolean
pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java