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

[fix][bookie] Correctly handle list configuration values #17661

Conversation

michaeljmarshall
Copy link
Member

Motivation

When the metadataServiceUri or the zkServers configuration for BookieRackAffinityMapping is provided as a comma delimited list, it is automatically parsed into an ArrayList by the configuration class because the Bookkeeper configuration class relies on the defaults in the org.apache.commons.configuration.AbstractConfiguration class. Here is a sample error:

2022-07-29T19:25:43,437+0000 [main] ERROR org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl - Failed to initialize DNS Resolver org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping, used default subnet resolver
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader 'bootstrap')

Also, see #6349 and #6343 for context.

Modifications

  • Move the castToString method out to a shared class.
  • Use the castToString method to safely get the configuration value.

Verifying this change

This PR includes a test.

Documentation

  • doc-not-needed

@michaeljmarshall michaeljmarshall added type/bug The PR fixed a bug or issue reported a bug component/bookkeeper doc-not-needed Your PR changes do not impact docs labels Sep 15, 2022
@michaeljmarshall michaeljmarshall added this to the 2.12.0 milestone Sep 15, 2022
@michaeljmarshall michaeljmarshall self-assigned this Sep 15, 2022
@michaeljmarshall
Copy link
Member Author

@lhotari @eolivelli - PTAL, thanks!

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect

@michaeljmarshall michaeljmarshall merged commit 69deb1f into apache:master Oct 11, 2022
@michaeljmarshall michaeljmarshall deleted the fix-comma-delimited-list-for-rack-awareness branch October 11, 2022 20:19
michaeljmarshall added a commit that referenced this pull request Oct 11, 2022
* [fix][bookie] Correctly handle list configuration values

* Remove unused import

### Motivation

When the `metadataServiceUri` or the `zkServers` configuration for `BookieRackAffinityMapping` is provided as a comma delimited list, it is automatically parsed into an ArrayList by the configuration class because the Bookkeeper configuration class relies on the defaults in the `org.apache.commons.configuration.AbstractConfiguration` class. Here is a sample error:

```
2022-07-29T19:25:43,437+0000 [main] ERROR org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl - Failed to initialize DNS Resolver org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping, used default subnet resolver
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader 'bootstrap')
```

Also, see #6349 and #6343 for context.

### Modifications

* Move the `castToString` method out to a shared class.
* Use the `castToString` method to safely get the configuration value.

### Verifying this change

This PR includes a test.

### Documentation

- [x] `doc-not-needed`

(cherry picked from commit 69deb1f)
michaeljmarshall added a commit that referenced this pull request Oct 11, 2022
* [fix][bookie] Correctly handle list configuration values

* Remove unused import

### Motivation

When the `metadataServiceUri` or the `zkServers` configuration for `BookieRackAffinityMapping` is provided as a comma delimited list, it is automatically parsed into an ArrayList by the configuration class because the Bookkeeper configuration class relies on the defaults in the `org.apache.commons.configuration.AbstractConfiguration` class. Here is a sample error:

```
2022-07-29T19:25:43,437+0000 [main] ERROR org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl - Failed to initialize DNS Resolver org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping, used default subnet resolver
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader 'bootstrap')
```

Also, see #6349 and #6343 for context.

### Modifications

* Move the `castToString` method out to a shared class.
* Use the `castToString` method to safely get the configuration value.

### Verifying this change

This PR includes a test.

### Documentation

- [x] `doc-not-needed`

(cherry picked from commit 69deb1f)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Oct 12, 2022
* [fix][bookie] Correctly handle list configuration values

* Remove unused import

### Motivation

When the `metadataServiceUri` or the `zkServers` configuration for `BookieRackAffinityMapping` is provided as a comma delimited list, it is automatically parsed into an ArrayList by the configuration class because the Bookkeeper configuration class relies on the defaults in the `org.apache.commons.configuration.AbstractConfiguration` class. Here is a sample error:

```
2022-07-29T19:25:43,437+0000 [main] ERROR org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl - Failed to initialize DNS Resolver org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping, used default subnet resolver
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader 'bootstrap')
```

Also, see apache#6349 and apache#6343 for context.

### Modifications

* Move the `castToString` method out to a shared class.
* Use the `castToString` method to safely get the configuration value.

### Verifying this change

This PR includes a test.

### Documentation

- [x] `doc-not-needed`

(cherry picked from commit 69deb1f)
(cherry picked from commit 9759815)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants