Commit ca1b639
committed
Fix NPE when using deprecated Azure settings (#28769)
* Fix NPE when using deprecated Azure settings
When someone migrates from 5.6 to 6.x with deprecated settings like:
```
cloud:
azure:
storage:
foo:
account: <my_account>
key: <my_key>
```
It produces a NPE anytime someone wants to use a repository which name is not `default`.
This has been introduced by #23518 when I backported it to 6.x branch.
In this case, when we generate an OperationContext, we only try to get azure settings from "normal" `storageSettings` with:
```java
this.storageSettings.get(clientName)
```
But in the context of deprecated settings, this returns `null` which causes the NPE just after.
This commit adds a check and if no settings are found in the "normal" `storageSettings`, we look at settings from `deprecatedStorageSettings`.
The reason I missed it in the 7.0 version (master branch) is because actually `deprecatedStorageSettings` has been removed there already.
Also I renamed the `testGetSelectedClientDefault` method to `testGenerateOperationContext`
as it was only doing exactly the same thing as `testGetDefaultClientWithPrimaryAndSecondaries`.
Closes #28299.
Backport of #28769 in 6.2 branch.1 parent b70f9ab commit ca1b639
File tree
2 files changed
+9
-4
lines changed- plugins/repository-azure/src
- main/java/org/elasticsearch/cloud/azure/storage
- test/java/org/elasticsearch/cloud/azure/storage
2 files changed
+9
-4
lines changedLines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
394 | 394 | | |
395 | | - | |
396 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
| |||
0 commit comments