Skip to content

Commit

Permalink
Fixed bug introduced in earlier change
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryOsterman committed Oct 16, 2024
1 parent 4fb45bc commit cacf222
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 9 additions & 3 deletions sdk/eventhubs/azure_messaging_eventhubs/src/consumer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,15 @@ impl ConsumerClient {
let expires_at = token.expires_on;
cbs.authorize_path(&url, token.token.secret(), expires_at)
.await?;
scopes.insert(url.clone(), token).ok_or_else(|| {
azure_core::Error::from(ErrorKind::UnableToAddAuthenticationToken)
})?;

// insert returns some if it *fails* to insert, None if it succeeded.
let present = scopes.insert(url.clone(), token);
if present.is_some() {
return Err(azure_core::Error::from(
ErrorKind::UnableToAddAuthenticationToken,
));
}
trace!("Token added.");
}
Ok(scopes
.get(url.as_str())
Expand Down
8 changes: 5 additions & 3 deletions sdk/eventhubs/azure_messaging_eventhubs/src/producer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ impl ProducerClient {
let expires_at = token.expires_on;
cbs.authorize_path(&url, token.token.secret(), expires_at)
.await?;
scopes
.insert(url.clone(), token)
.ok_or_else(|| Error::from(ErrorKind::UnableToAddAuthenticationToken))?;
let present = scopes
.insert(url.clone(), token);
if present.is_some() {
return Err(Error::from(ErrorKind::UnableToAddAuthenticationToken));
}
}
Ok(scopes
.get(url.as_str())
Expand Down

0 comments on commit cacf222

Please sign in to comment.