redisson/redisson · warning · UnsupportedOperationException

Should be defined through Redisson Config object

Error message

Should be defined through Redisson Config object

What it means

RedissonConnection.setClientName() deliberately throws UnsupportedOperationException with the message 'Should be defined through Redisson Config object'. Redisson establishes and pools its connections through its own Config, so the Spring Data CLIENT SETNAME call cannot meaningfully reach the connections actually in use; the client name must be set in Redisson's configuration instead.

Source

Thrown at redisson-spring/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java:1704

    public void resetConfigStats() {
        write(null, StringCodec.INSTANCE, RedisCommands.CONFIG_RESETSTAT);
    }

    private static final RedisStrictCommand<Long> TIME = new RedisStrictCommand<Long>("TIME", new TimeLongObjectDecoder());
    
    @Override
    public Long time() {
        return read(null, LongCodec.INSTANCE, TIME);
    }

    @Override
    public void killClient(String host, int port) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void setClientName(byte[] name) {
        throw new UnsupportedOperationException("Should be defined through Redisson Config object");
    }

    @Override
    public String getClientName() {
        throw new UnsupportedOperationException();
    }

    @Override
    public List<RedisClientInfo> getClientList() {
        return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST);
    }

    @Override
    public void slaveOf(String host, int port) {
        throw new UnsupportedOperationException();
    }

    @Override

View on GitHub (pinned to 91188987c2)

Solutions

  1. Set the name in Redisson's Config: config.useSingleServer().setClientName("my-app") (or the equivalent for cluster/sentinel config)
  2. Remove the setClientName call from Spring Data code paths when using the Redisson adapter
  3. For per-instance identification, use the Redisson-assigned client names visible in CLIENT LIST after configuring Config.clientName

Example fix

// before
redisTemplate.execute((RedisCallback<Object>) conn -> {
    conn.setClientName("my-app".getBytes()); // throws
    return null;
});

// after
Config config = new Config();
config.useSingleServer()
      .setAddress("redis://localhost:6379")
      .setClientName("my-app");
Redisson.create(config);
Defensive patterns

Strategy: type-guard

Validate before calling

// capability check before calling
try {
    conn.setClientName(name); // will throw on Redisson adapter
} catch (UnsupportedOperationException e) { /* expected on Redisson */ }

Type guard

boolean supportsSetClientName(RedisConnectionFactory f) {
    return !(f instanceof RedissonConnectionFactory);
}

Try / catch

try {
    connection.setClientName(name.getBytes());
} catch (UnsupportedOperationException e) {
    log.debug("client name managed via Redisson Config; skipping");
}

Prevention

When it happens

Trigger: Calling connection.setClientName(name) (e.g. RedisTemplate.execute with conn.setClientName, or library/tooling that sets client names for diagnostics) on the redisson-spring-data connection adapter.

Common situations: Application monitoring/audit tooling that tags every Redis connection with a client name; code migrated from Jedis/Lettuce Spring Data adapters where setClientName works; attempting to identify app connections in CLIENT LIST output.

Related errors


AI-assisted analysis of redisson/redisson@91188987c2 (2026-08-14). Data as JSON: /api/errors/580d902c6b366b88. Report an issue: GitHub.