Skip to content

Conversation

@pzampino
Copy link
Contributor

…knownTokenException

What changes were proposed in this pull request?

To align with other methods in the TokenStateService interface, the getTokenMetadata(String tokenId) method has modified to throw UnknownTokenException when there is no metadata for the specified token identifier.

How was this patch tested?

Existing tests have been modified/executed, and I've added org.apache.knox.gateway.services.token.impl.DefaultTokenStateServiceTest#testGetMetadata_InvalidToken(), which also gets invoked for the Alias- and Journal-based TokenStateService implementations.

@Override
public TokenMetadata getTokenMetadata(String tokenId) {
public TokenMetadata getTokenMetadata(String tokenId) throws UnknownTokenException {
TokenMetadata tokenMetadata = super.getTokenMetadata(tokenId);
Copy link
Contributor

Choose a reason for hiding this comment

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

UnknownTokenException should be handled. In HA case it may happen that the in-memory collection will not have the given token metadata -> super will throw UTE. We should catch it and continue with the alias service action.

Copy link
Contributor

@smolnar82 smolnar82 left a comment

Choose a reason for hiding this comment

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

LGTM

@pzampino pzampino merged commit 025a014 into apache:master Mar 31, 2021
stoty pushed a commit to stoty/knox that referenced this pull request May 14, 2024
…knownTokenException (apache#426)

Change-Id: Ib42a813237a04d94d40779beff9c74672331f18e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants