apache/dubbo · error · IllegalArgumentException

Unsupported generic type <generic>

Error message

Unsupported generic type <generic>

What it means

Thrown by ServiceConfigBase.setGeneric when the supplied generic value is not recognized. Valid values are: 'true', 'nativejava', 'bean', 'protobuf-json', 'gson', 'raw.return', and 'false' (case-insensitive for the boolean). Any other string is rejected.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java:373

        return providerIds;
    }

    public void setProviderIds(String providerIds) {
        this.providerIds = providerIds;
    }

    public String getGeneric() {
        return generic;
    }

    public void setGeneric(String generic) {
        if (StringUtils.isEmpty(generic)) {
            return;
        }
        if (ProtocolUtils.isValidGenericValue(generic)) {
            this.generic = generic;
        } else {
            throw new IllegalArgumentException("Unsupported generic type " + generic);
        }
    }

    @Transient
    public ServiceMetadata getServiceMetadata() {
        return serviceMetadata;
    }

    @Override
    @Transient
    @Parameter(excluded = true, attribute = false)
    public List<String> getPrefixes() {
        List<String> prefixes = new ArrayList<>();
        // dubbo.service.{interface-name}
        prefixes.add(DUBBO + ".service." + interfaceName);
        return prefixes;
    }

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Use one of the supported values: true, nativejava, bean, protobuf-json, gson, raw.return, false.
  2. Leave generic unset if you do not need generic invocation.
  3. Verify the value against the Dubbo version in use; upgrade or align the value accordingly.

Example fix

// before
serviceConfig.setGeneric("json"); // unsupported

// after
serviceConfig.setGeneric("gson"); // or "true" for default
Defensive patterns

Strategy: validation

Validate before calling

java.util.Set<String> valid = java.util.Set.of(
    "true", "nativejava", "bean", "protobuf-json", "gson", "raw.return", "false");
if (generic != null && !valid.contains(generic.toLowerCase(java.util.Locale.ROOT))) {
    throw new IllegalArgumentException("Unsupported generic type: " + generic
        + "; valid: " + valid);
}
serviceConfig.setGeneric(generic);

Type guard

static boolean isValidGeneric(String g) {
    return g == null || org.apache.dubbo.rpc.support.ProtocolUtils.isValidGenericValue(g);
}

Try / catch

try {
    serviceConfig.setGeneric(value);
} catch (IllegalArgumentException e) {
    // value was unsupported; correct to a supported generic type or leave unset
    log.warn("Ignoring unsupported generic value {}", value);
}

Prevention

When it happens

Trigger: Calling setGeneric(String) with a value that ProtocolUtils.isValidGenericValue returns false for — i.e. not one of the supported generic serialization identifiers and not 'false'.

Common situations: Typo in the generic value (e.g. 'truee', 'json', 'generic'). Passing a value valid for a newer/older Dubbo version than the one in use (e.g. 'protobuf-json' on an old version). Custom serialization alias not registered. Misreading docs and using an unsupported identifier.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/23e40b795e0e39e6. Report an issue: GitHub.