compat/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java [281:505]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void invalidMetadata(
            RepositorySystemSession session,
            RequestTrace trace,
            Metadata metadata,
            ArtifactRepository repository,
            Exception exception) {
        RepositoryEvent.Builder event = new RepositoryEvent.Builder(session, EventType.METADATA_INVALID);
        event.setTrace(trace);
        event.setMetadata(metadata);
        event.setException(exception);
        event.setRepository(repository);

        repositoryEventDispatcher.dispatch(event.build());
    }

    private void merge(
            Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning, ArtifactRepository repository) {
        if (versioning.getRelease() != null && !versioning.getRelease().isEmpty()) {
            merge(RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository);
        }

        if (versioning.getLatest() != null && !versioning.getLatest().isEmpty()) {
            merge(LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository);
        }

        for (SnapshotVersion sv : versioning.getSnapshotVersions()) {
            if (sv.getVersion() != null && !sv.getVersion().isEmpty()) {
                String key = getKey(sv.getClassifier(), sv.getExtension());
                merge(SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository);
            }
        }

        Snapshot snapshot = versioning.getSnapshot();
        if (snapshot != null && versioning.getSnapshotVersions().isEmpty()) {
            String version = artifact.getVersion();
            if (snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0) {
                String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
                version = version.substring(0, version.length() - SNAPSHOT.length()) + qualifier;
            }
            merge(SNAPSHOT, infos, versioning.getLastUpdated(), version, repository);
        }
    }

    private void merge(
            String key,
            Map<String, VersionInfo> infos,
            String timestamp,
            String version,
            ArtifactRepository repository) {
        VersionInfo info = infos.get(key);
        if (info == null) {
            info = new VersionInfo(timestamp, version, repository);
            infos.put(key, info);
        } else if (info.isOutdated(timestamp)) {
            info.version = version;
            info.repository = repository;
            info.timestamp = timestamp;
        }
    }

    private void merge(Map<String, VersionInfo> infos, String srcKey, String dstKey) {
        VersionInfo srcInfo = infos.get(srcKey);
        VersionInfo dstInfo = infos.get(dstKey);

        if (dstInfo == null
                || (srcInfo != null
                        && dstInfo.isOutdated(srcInfo.timestamp)
                        && srcInfo.repository != dstInfo.repository)) {
            infos.put(dstKey, srcInfo);
        }
    }

    private String getKey(String classifier, String extension) {
        return (classifier == null ? "" : classifier.trim()) + ':' + (extension == null ? "" : extension.trim());
    }

    private ArtifactRepository getRepository(
            RepositorySystemSession session, List<RemoteRepository> repositories, Class<?> repoClass, String repoId) {
        if (repoClass != null) {
            if (WorkspaceRepository.class.isAssignableFrom(repoClass)) {
                return session.getWorkspaceReader().getRepository();
            } else if (LocalRepository.class.isAssignableFrom(repoClass)) {
                return session.getLocalRepository();
            } else {
                for (RemoteRepository repository : repositories) {
                    if (repoId.equals(repository.getId())) {
                        return repository;
                    }
                }
            }
        }
        return null;
    }

    private boolean isSafelyCacheable(RepositorySystemSession session, Artifact artifact) {
        /*
         * The workspace/reactor is in flux so we better not assume definitive information for any of its
         * artifacts/projects.
         */

        WorkspaceReader workspace = session.getWorkspaceReader();
        if (workspace == null) {
            return true;
        }

        Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact(artifact);

        return workspace.findArtifact(pomArtifact) == null;
    }

    private static class VersionInfo {

        String timestamp;

        String version;

        ArtifactRepository repository;

        VersionInfo(String timestamp, String version, ArtifactRepository repository) {
            this.timestamp = (timestamp != null) ? timestamp : "";
            this.version = version;
            this.repository = repository;
        }

        boolean isOutdated(String timestamp) {
            return timestamp != null && timestamp.compareTo(this.timestamp) > 0;
        }
    }

    private static class Key {

        private final String groupId;

        private final String artifactId;

        private final String classifier;

        private final String extension;

        private final String version;

        private final String context;

        private final Path localRepo;

        private final WorkspaceRepository workspace;

        private final List<RemoteRepository> repositories;

        private final int hashCode;

        Key(RepositorySystemSession session, VersionRequest request) {
            Artifact artifact = request.getArtifact();
            groupId = artifact.getGroupId();
            artifactId = artifact.getArtifactId();
            classifier = artifact.getClassifier();
            extension = artifact.getExtension();
            version = artifact.getVersion();
            localRepo = session.getLocalRepository().getBasePath();
            WorkspaceReader reader = session.getWorkspaceReader();
            workspace = (reader != null) ? reader.getRepository() : null;
            repositories = new ArrayList<>(request.getRepositories().size());
            boolean repoMan = false;
            for (RemoteRepository repository : request.getRepositories()) {
                if (repository.isRepositoryManager()) {
                    repoMan = true;
                    repositories.addAll(repository.getMirroredRepositories());
                } else {
                    repositories.add(repository);
                }
            }
            context = repoMan ? request.getRequestContext() : "";

            int hash = 17;
            hash = hash * 31 + groupId.hashCode();
            hash = hash * 31 + artifactId.hashCode();
            hash = hash * 31 + classifier.hashCode();
            hash = hash * 31 + extension.hashCode();
            hash = hash * 31 + version.hashCode();
            hash = hash * 31 + localRepo.hashCode();
            hash = hash * 31 + repositories.hashCode();
            hashCode = hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            } else if (obj == null || !getClass().equals(obj.getClass())) {
                return false;
            }

            Key that = (Key) obj;
            return artifactId.equals(that.artifactId)
                    && groupId.equals(that.groupId)
                    && classifier.equals(that.classifier)
                    && extension.equals(that.extension)
                    && version.equals(that.version)
                    && context.equals(that.context)
                    && localRepo.equals(that.localRepo)
                    && Objects.equals(workspace, that.workspace)
                    && repositories.equals(that.repositories);
        }

        @Override
        public int hashCode() {
            return hashCode;
        }
    }

    private static class Record {
        final String version;

        final String repoId;

        final Class<?> repoClass;

        Record(String version, ArtifactRepository repository) {
            this.version = version;
            if (repository != null) {
                repoId = repository.getId();
                repoClass = repository.getClass();
            } else {
                repoId = null;
                repoClass = null;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/DefaultVersionResolver.java [280:504]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void invalidMetadata(
            RepositorySystemSession session,
            RequestTrace trace,
            Metadata metadata,
            ArtifactRepository repository,
            Exception exception) {
        RepositoryEvent.Builder event = new RepositoryEvent.Builder(session, EventType.METADATA_INVALID);
        event.setTrace(trace);
        event.setMetadata(metadata);
        event.setException(exception);
        event.setRepository(repository);

        repositoryEventDispatcher.dispatch(event.build());
    }

    private void merge(
            Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning, ArtifactRepository repository) {
        if (versioning.getRelease() != null && !versioning.getRelease().isEmpty()) {
            merge(RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository);
        }

        if (versioning.getLatest() != null && !versioning.getLatest().isEmpty()) {
            merge(LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository);
        }

        for (SnapshotVersion sv : versioning.getSnapshotVersions()) {
            if (sv.getVersion() != null && !sv.getVersion().isEmpty()) {
                String key = getKey(sv.getClassifier(), sv.getExtension());
                merge(SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository);
            }
        }

        Snapshot snapshot = versioning.getSnapshot();
        if (snapshot != null && versioning.getSnapshotVersions().isEmpty()) {
            String version = artifact.getVersion();
            if (snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0) {
                String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
                version = version.substring(0, version.length() - SNAPSHOT.length()) + qualifier;
            }
            merge(SNAPSHOT, infos, versioning.getLastUpdated(), version, repository);
        }
    }

    private void merge(
            String key,
            Map<String, VersionInfo> infos,
            String timestamp,
            String version,
            ArtifactRepository repository) {
        VersionInfo info = infos.get(key);
        if (info == null) {
            info = new VersionInfo(timestamp, version, repository);
            infos.put(key, info);
        } else if (info.isOutdated(timestamp)) {
            info.version = version;
            info.repository = repository;
            info.timestamp = timestamp;
        }
    }

    private void merge(Map<String, VersionInfo> infos, String srcKey, String dstKey) {
        VersionInfo srcInfo = infos.get(srcKey);
        VersionInfo dstInfo = infos.get(dstKey);

        if (dstInfo == null
                || (srcInfo != null
                        && dstInfo.isOutdated(srcInfo.timestamp)
                        && srcInfo.repository != dstInfo.repository)) {
            infos.put(dstKey, srcInfo);
        }
    }

    private String getKey(String classifier, String extension) {
        return (classifier == null ? "" : classifier.trim()) + ':' + (extension == null ? "" : extension.trim());
    }

    private ArtifactRepository getRepository(
            RepositorySystemSession session, List<RemoteRepository> repositories, Class<?> repoClass, String repoId) {
        if (repoClass != null) {
            if (WorkspaceRepository.class.isAssignableFrom(repoClass)) {
                return session.getWorkspaceReader().getRepository();
            } else if (LocalRepository.class.isAssignableFrom(repoClass)) {
                return session.getLocalRepository();
            } else {
                for (RemoteRepository repository : repositories) {
                    if (repoId.equals(repository.getId())) {
                        return repository;
                    }
                }
            }
        }
        return null;
    }

    private boolean isSafelyCacheable(RepositorySystemSession session, Artifact artifact) {
        /*
         * The workspace/reactor is in flux so we better not assume definitive information for any of its
         * artifacts/projects.
         */

        WorkspaceReader workspace = session.getWorkspaceReader();
        if (workspace == null) {
            return true;
        }

        Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact(artifact);

        return workspace.findArtifact(pomArtifact) == null;
    }

    private static class VersionInfo {

        String timestamp;

        String version;

        ArtifactRepository repository;

        VersionInfo(String timestamp, String version, ArtifactRepository repository) {
            this.timestamp = (timestamp != null) ? timestamp : "";
            this.version = version;
            this.repository = repository;
        }

        boolean isOutdated(String timestamp) {
            return timestamp != null && timestamp.compareTo(this.timestamp) > 0;
        }
    }

    private static class Key {

        private final String groupId;

        private final String artifactId;

        private final String classifier;

        private final String extension;

        private final String version;

        private final String context;

        private final Path localRepo;

        private final WorkspaceRepository workspace;

        private final List<RemoteRepository> repositories;

        private final int hashCode;

        Key(RepositorySystemSession session, VersionRequest request) {
            Artifact artifact = request.getArtifact();
            groupId = artifact.getGroupId();
            artifactId = artifact.getArtifactId();
            classifier = artifact.getClassifier();
            extension = artifact.getExtension();
            version = artifact.getVersion();
            localRepo = session.getLocalRepository().getBasePath();
            WorkspaceReader reader = session.getWorkspaceReader();
            workspace = (reader != null) ? reader.getRepository() : null;
            repositories = new ArrayList<>(request.getRepositories().size());
            boolean repoMan = false;
            for (RemoteRepository repository : request.getRepositories()) {
                if (repository.isRepositoryManager()) {
                    repoMan = true;
                    repositories.addAll(repository.getMirroredRepositories());
                } else {
                    repositories.add(repository);
                }
            }
            context = repoMan ? request.getRequestContext() : "";

            int hash = 17;
            hash = hash * 31 + groupId.hashCode();
            hash = hash * 31 + artifactId.hashCode();
            hash = hash * 31 + classifier.hashCode();
            hash = hash * 31 + extension.hashCode();
            hash = hash * 31 + version.hashCode();
            hash = hash * 31 + localRepo.hashCode();
            hash = hash * 31 + repositories.hashCode();
            hashCode = hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            } else if (obj == null || !getClass().equals(obj.getClass())) {
                return false;
            }

            Key that = (Key) obj;
            return artifactId.equals(that.artifactId)
                    && groupId.equals(that.groupId)
                    && classifier.equals(that.classifier)
                    && extension.equals(that.extension)
                    && version.equals(that.version)
                    && context.equals(that.context)
                    && localRepo.equals(that.localRepo)
                    && Objects.equals(workspace, that.workspace)
                    && repositories.equals(that.repositories);
        }

        @Override
        public int hashCode() {
            return hashCode;
        }
    }

    private static class Record {
        final String version;

        final String repoId;

        final Class<?> repoClass;

        Record(String version, ArtifactRepository repository) {
            this.version = version;
            if (repository != null) {
                repoId = repository.getId();
                repoClass = repository.getClass();
            } else {
                repoId = null;
                repoClass = null;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



