Skip to content

Java client: cannot configure 'authParams' with PulsarClient.builder().loadConf #8509

Open

Description

@racorn

ClientBuilder loadConf(Map<String, Object> config) does not support authParams nor authParamMap anymore.

Most likely this was broken by #8110

Possible fix:

Add annotation:

@Target({ ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
@JsonSerialize(using = SecretsSerializer.class)
public @interface Secret {
}

Serializer:

public class SecretsSerializer extends JsonSerializer<Object> {

    @Override
    public void serialize(final Object value, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
            throws IOException, JsonProcessingException {
        if (value == null) {
            serializerProvider.defaultSerializeNull(jsonGenerator);
            return;
        }
        Object output = serializerProvider.getActiveView() == Views.Internal.class ? value : "*****";
        jsonGenerator.writeObject(output);

    }
}

And view:

public interface Views {
    interface Internal {
    }
}

Then in ClientConfigurationData

@Secret
private String authParams;
@Secret
private Map<String, String> authParamMap;

and in ConfigurationDataUtils.loadData

mapper.writerWithView(Views.Internal.class).writeValueAsString ...

Version: 2.6.2

Activity

  1. added
    type/bug
    on Nov 10, 2020
  2. codelipenghui commented on Nov 11, 2020

    @codelipenghui
    Contributor

    @hangc0276 Could you please help take a look at this issue?

  3. hangc0276 commented on Nov 11, 2020

    @hangc0276
    Contributor

    OK, I will take a look.

  4. self-assigned this
    on Nov 12, 2020
  5. racorn commented on Nov 19, 2020

    @racorn
    ContributorAuthor

    Also see my comment here that explains what I think is the problem

  6. added a commit that references this issue on Dec 12, 2020
    59660e4
  7. michaeljmarshall commented on May 27, 2022

    @michaeljmarshall
    Member

    I think we need to add support for the View concept described in this issue and in this comment: #8910 (comment). The current implementation of the @Secret annotation negatively affects the ConfigurationDataUtils#loadData method in such a way that you cannot override certain fields.

    I am not able to look into this just yet, but I am going to re-open this issue.

  8. added
    bug-verified
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug-verifiedtype/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions