Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration handling & implementation is racy #562

Closed
snazy opened this issue Dec 16, 2024 · 1 comment · Fixed by #615
Closed

Configuration handling & implementation is racy #562

snazy opened this issue Dec 16, 2024 · 1 comment · Fixed by #615
Labels
bug Something isn't working

Comments

@snazy
Copy link
Member

snazy commented Dec 16, 2024

Describe the bug

Polaris currently uses Dropwizard and relies on Jackson for configuration, but also ties initialization/setup/business logic into configuration objects.

For example in PolarisApplicationConfig there are:

  @JsonProperty("realmContextResolver")
  @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
  public void setRealmContextResolver(RealmContextResolver realmContextResolver) {
    this.realmContextResolver = realmContextResolver;
  }

  @JsonProperty("defaultRealm")
  public void setDefaultRealm(String defaultRealm) {
    this.defaultRealm = defaultRealm;
    realmContextResolver.setDefaultRealm(defaultRealm);
  }

These code constructs are racy/error-prone, because literally nothing guarantees that realmContextResolver is set to != null when setDefaultRealm() is invoked.

@snazy snazy added the bug Something isn't working label Dec 16, 2024
@snazy
Copy link
Member Author

snazy commented Dec 16, 2024

Example stack trace:

io.dropwizard.configuration.ConfigurationParsingException: default configuration has an error:
  * Failed to parse configuration at: defaultRealm; Cannot invoke "org.apache.polaris.service.context.RealmContextResolver.setDefaultRealm(String)" because "this.realmContextResolver" is null (through reference chain: org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig["defaultRealm"])

	at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:277)
	at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:177)
	at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:121)
	at io.dropwizard.core.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:141)
	at io.dropwizard.core.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
	at io.dropwizard.core.cli.Cli.run(Cli.java:78)
	at io.dropwizard.core.Application.run(Application.java:94)
	at org.apache.polaris.service.dropwizard.PolarisApplication.main(PolarisApplication.java:153)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Cannot invoke "org.apache.polaris.service.context.RealmContextResolver.setDefaultRealm(String)" because "this.realmContextResolver" is null (through reference chain: org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig["defaultRealm"])
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
	at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1964)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:275)
	at com.fasterxml.jackson.module.blackbird.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
	at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4893)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3036)
	at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:148)
	... 6 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.polaris.service.context.RealmContextResolver.setDefaultRealm(String)" because "this.realmContextResolver" is null
	at org.apache.polaris.service.dropwizard.config.PolarisApplicationConfig.setDefaultRealm(PolarisApplicationConfig.java:307)
	at com.fasterxml.jackson.module.blackbird.deser.SettableStringProperty.set(SettableStringProperty.java:56)
	at com.fasterxml.jackson.module.blackbird.deser.SettableStringProperty.deserializeAndSet(SettableStringProperty.java:41)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:273)
	... 11 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant