Code review comment: The direct mode will also use the proxy configuration which is from the gateconnection configuration, then the gateconnection will have the high priority to apply.

Code under review:
protected void configureService(CosmosClientBuilder builder) {
        PropertyMapper map = new PropertyMapper();

        map.from(this.cosmosProperties.getEndpoint()).to(builder::endpoint);
        map.from(this.cosmosProperties.getConsistencyLevel()).to(builder::consistencyLevel);
        map.from(this.cosmosProperties.getClientTelemetryEnabled()).to(builder::clientTelemetryEnabled);
        map.from(this.cosmosProperties.getConnectionSharingAcrossClientsEnabled()).to(builder::connectionSharingAcrossClientsEnabled);
        map.from(this.cosmosProperties.getContentResponseOnWriteEnabled()).to(builder::contentResponseOnWriteEnabled);
        map.from(this.cosmosProperties.getEndpointDiscoveryEnabled()).to(builder::endpointDiscoveryEnabled);
        map.from(this.cosmosProperties.getMultipleWriteRegionsEnabled()).to(builder::multipleWriteRegionsEnabled);
        map.from(this.cosmosProperties.getReadRequestsFallbackEnabled()).to(builder::readRequestsFallbackEnabled);
        map.from(this.cosmosProperties.getSessionCapturingOverrideEnabled()).to(builder::sessionCapturingOverrideEnabled);
        map.from(this.cosmosProperties.getPreferredRegions()).whenNot(List::isEmpty).to(builder::preferredRegions);
        map.from(this.cosmosProperties.getThrottlingRetryOptions()).to(builder::throttlingRetryOptions);

        
        map.from(this.cosmosProperties.getResourceToken()).to(builder::resourceToken);
        map.from(this.cosmosProperties.getPermissions()).whenNot(List::isEmpty).to(builder::permissions);

        builder.gatewayMode(this.cosmosProperties.getGatewayConnection());
        if (ConnectionMode.DIRECT.equals(this.cosmosProperties.getConnectionMode())) {
            builder.directMode(this.cosmosProperties.getDirectConnection());
        }
    }

Line commented on: builder.gatewayMode(this.cosmosProperties.getGatewayConnection());

Revised code:
protected void configureService(CosmosClientBuilder builder) {
        PropertyMapper map = new PropertyMapper();

        map.from(this.cosmosProperties.getEndpoint()).to(builder::endpoint);
        map.from(this.cosmosProperties.getConsistencyLevel()).to(builder::consistencyLevel);
        map.from(this.cosmosProperties.getClientTelemetryEnabled()).to(builder::clientTelemetryEnabled);
        map.from(this.cosmosProperties.getConnectionSharingAcrossClientsEnabled()).to(builder::connectionSharingAcrossClientsEnabled);
        map.from(this.cosmosProperties.getContentResponseOnWriteEnabled()).to(builder::contentResponseOnWriteEnabled);
        map.from(this.cosmosProperties.getEndpointDiscoveryEnabled()).to(builder::endpointDiscoveryEnabled);
        map.from(this.cosmosProperties.getMultipleWriteRegionsEnabled()).to(builder::multipleWriteRegionsEnabled);
        map.from(this.cosmosProperties.getReadRequestsFallbackEnabled()).to(builder::readRequestsFallbackEnabled);
        map.from(this.cosmosProperties.getSessionCapturingOverrideEnabled()).to(builder::sessionCapturingOverrideEnabled);
        map.from(this.cosmosProperties.getPreferredRegions()).whenNot(List::isEmpty).to(builder::preferredRegions);
        map.from(this.cosmosProperties.getThrottlingRetryOptions()).to(builder::throttlingRetryOptions);

        
        map.from(this.cosmosProperties.getResourceToken()).to(builder::resourceToken);
        map.from(this.cosmosProperties.getPermissions()).whenNot(List::isEmpty).to(builder::permissions);
        if (ConnectionMode.DIRECT.equals(this.cosmosProperties.getConnectionMode())) {
            builder.directMode(this.cosmosProperties.getDirectConnection(), this.cosmosProperties.getGatewayConnection());
        } else if (ConnectionMode.GATEWAY.equals(this.cosmosProperties.getConnectionMode())) {
            builder.gatewayMode(this.cosmosProperties.getGatewayConnection());
        }
    }