apache/maven · error · ChecksumAlgorithmServiceException

unsupported algorithm

Error message

unsupported algorithm

What it means

DefaultChecksumAlgorithmService.select(algorithmName) delegates to the resolver's ChecksumAlgorithmFactorySelector, which only knows factories registered in the container (by default SHA-1, SHA-256, SHA-512 in Maven's wiring). An unknown or misspelled name throws ChecksumAlgorithmServiceException('unsupported algorithm') with the selector's IllegalArgumentException as cause. Algorithm names are case-sensitive as registered (e.g. 'SHA-256', not 'sha256').

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultChecksumAlgorithmService.java:70

    public DefaultChecksumAlgorithmService(ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector) {
        this.checksumAlgorithmFactorySelector =
                requireNonNull(checksumAlgorithmFactorySelector, "checksumAlgorithmFactorySelector");
    }

    @Override
    public Collection<String> getChecksumAlgorithmNames() {
        return checksumAlgorithmFactorySelector.getChecksumAlgorithmFactories().stream()
                .map(ChecksumAlgorithmFactory::getName)
                .collect(Collectors.toList());
    }

    @Override
    public ChecksumAlgorithm select(String algorithmName) {
        requireNonNull(algorithmName, "algorithmName");
        try {
            return new DefaultChecksumAlgorithm(checksumAlgorithmFactorySelector.select(algorithmName));
        } catch (IllegalArgumentException e) {
            throw new ChecksumAlgorithmServiceException("unsupported algorithm", e);
        }
    }

    @Override
    public Collection<ChecksumAlgorithm> select(Collection<String> algorithmNames) {
        requireNonNull(algorithmNames, "algorithmNames");
        try {
            return checksumAlgorithmFactorySelector.selectList(new ArrayList<>(algorithmNames)).stream()
                    .map(DefaultChecksumAlgorithm::new)
                    .collect(Collectors.toList());
        } catch (IllegalArgumentException e) {
            throw new ChecksumAlgorithmServiceException("unsupported algorithm", e);
        }
    }

    @Override
    public Map<ChecksumAlgorithm, String> calculate(byte[] data, Collection<ChecksumAlgorithm> algorithms) {
        requireNonNull(data, "data");

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Use a name returned by checksumService.getChecksumAlgorithmNames() (typically 'SHA-1', 'SHA-256', 'SHA-512')
  2. Validate user-supplied names against getChecksumAlgorithmNames() before selecting
  3. If MD5 is genuinely required, register an Md5ChecksumAlgorithmFactory-based component in your container wiring

Example fix

// before
ChecksumAlgorithm alg = service.select('sha-256'); // throws

// after
ChecksumAlgorithm alg = service.select(
        service.getChecksumAlgorithmNames().stream()
                .filter(n -> n.equalsIgnoreCase('sha-256'))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException('unsupported checksum algorithm')));
Defensive patterns

Strategy: validation

Validate before calling

Set<String> supported = Set.copyOf(service.getChecksumAlgorithmNames());
if (!supported.contains(algorithmName)) {
    throw new IllegalArgumentException('Unsupported checksum algorithm: ' + algorithmName + '; supported: ' + supported);
}

Type guard

static boolean isSupportedAlgorithm(ChecksumAlgorithmService s, String name) { return s.getChecksumAlgorithmNames().contains(name); }

Prevention

When it happens

Trigger: Calling checksumService.select('MD5') when no MD5 factory is registered, select('sha-256') (lowercase), or select('SHA-512') in a container wiring where the SHA-512 factory was not installed.

Common situations: Hardcoding 'MD5' from older tooling; copy-pasting lowercase hex-style names; embedding Resolver in a standalone app and registering only some checksum factories; configuration files referencing checksum algorithms by wrong casing.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/3cda34538dd1368e. Report an issue: GitHub.