quarkusio/quarkus · error · UnsupportedOperationException

Unsupported compressor in native mode

Error message

Unsupported compressor in native mode

What it means

In native mode, InternalStreamConnection.createCompressor is substituted with a stub that always throws UnsupportedOperationException — compressor creation is not supported in native images. Any negotiated compressor (other than those filtered earlier) triggers this at stream creation time.

Source

Thrown at extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/graal/MongoClientSubstitutions.java:119

    private SSLContext getSslContext() {
        try {
            return (sslSettings.getContext() == null) ? SSLContext.getDefault() : sslSettings.getContext();
        } catch (NoSuchAlgorithmException e) {
            throw new MongoClientException("Unable to create default SSLContext", e);
        }
    }
}

@TargetClass(className = "com.mongodb.internal.connection.Compressor")
final class CompressorSubstitute {

}

@TargetClass(InternalStreamConnection.class)
final class InternalStreamConnectionSubstitution {
    @Substitute
    private CompressorSubstitute createCompressor(final MongoCompressor mongoCompressor) {
        throw new UnsupportedOperationException("Unsupported compressor in native mode");
    }
}

@TargetClass(UnixSocketChannelStream.class)
@Delete
final class UnixSocketChannelStreamSubstitution {

}

@TargetClass(ServerAddressHelper.class)
final class ServerAddressHelperSubstitution {

    @Substitute
    public static ServerAddress createServerAddress(final String host, final int port) {
        if (host != null && host.endsWith(".sock")) {
            throw new UnsupportedOperationException("Unix socket not supported");
        } else {
            return new ServerAddress(host, port);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Disable compression in native mode (remove compressors from quarkus.mongodb config or set none)
  2. Use zlib and verify the Quarkus substitution for zlib is active for your Quarkus version (upgrade Quarkus if driver internals changed)
  3. Run JVM mode where compressors are fully supported

Example fix

// before
quarkus.mongodb.connection-string=mongodb://host/db?compressors=zlib
// after
quarkus.mongodb.connection-string=mongodb://host/db
Defensive patterns

Strategy: validation

Validate before calling

if (isNativeImage() && usesCompression(connectionString)) {
    log.warn("MongoDB compression is negotiated but unsupported in native mode; consider disabling compressors");
}

Try / catch

try {
    stream = internalStreamConnection;
} catch (UnsupportedOperationException e) {
    if (e.getMessage().contains("Unsupported compressor")) {
        // reconnect without compressors
    } else throw e;
}

Prevention

When it happens

Trigger: Establishing a MongoDB connection in a native executable where the driver's InternalStreamConnection attempts to instantiate a compressor for the wire protocol, typically because compression was negotiated with the server (compressors=zlib) and this substitute is reached.

Common situations: Native-image deployment connecting to MongoDB with compression enabled in the connection string; a server that requires compression negotiation; misaligned Quarkus/Mongo driver versions where the substitution is out of date.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/eaa266cbdaf5a3f6. Report an issue: GitHub.