Skip to content

Add ability to set attributes on a SslContext#9654

Merged
normanmaurer merged 3 commits into4.1from
ssl_context_attr_map
Oct 22, 2019
Merged

Add ability to set attributes on a SslContext#9654
normanmaurer merged 3 commits into4.1from
ssl_context_attr_map

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

Motivation:

Sometimes it is useful to be able to set attributes on a SslContext.

Modifications:

Add new method that will return a AttributeMap that is tied to a SslContext instance

Result:

Fixes #6542.

Motivation:

Sometimes it is useful to be able to set attributes on a SslContext.

Modifications:

Add new method that will return a AttributeMap that is tied to a SslContext instance

Result:

Fixes #6542.
@normanmaurer normanmaurer requested review from njhill and rkapsi October 11, 2019 09:05
@slandelle
Copy link
Copy Markdown
Contributor

Do you have an example of a use case?

@normanmaurer
Copy link
Copy Markdown
Member Author

@slandelle #6542 would be an example.... that said it is basically the same as SSLSession.putValue etc.

Copy link
Copy Markdown
Member

@rkapsi rkapsi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

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

Did you consider having SslContext extend DefaultAttributeMap a la AbstractChannel? (I know there are downsides of doing that too)

/**
* Returns the {@link AttributeMap} that is tied to this {@link SslContext} instance.
*/
public final AttributeMap attributeMap() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WDYT about naming this attributes() instead of attributeMap()?

@normanmaurer
Copy link
Copy Markdown
Member Author

normanmaurer commented Oct 15, 2019

@njhill yeah I did consider but I thought how it is done here may be better.. WDYT ?

@njhill
Copy link
Copy Markdown
Member

njhill commented Oct 15, 2019

@normanmaurer I don't have a strong opinion but would probably lean towards subclassing, other things being equal. In future if we wanted to extend a different class then DefaultAttributeMap could be moved to a field and just delegate the attr and hasAttr interface methods. Really fine either way though :)

@normanmaurer
Copy link
Copy Markdown
Member Author

@njhill @rkapsi ok did extend at the end to make it consistent.... PTAL again

@rkapsi
Copy link
Copy Markdown
Member

rkapsi commented Oct 16, 2019

I'm a sucker for composition. The change is OK but my eye twitches about why SslContext is an instanceof AttributeMap.

Copy link
Copy Markdown
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

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

LGTM but also fine with reverting if @rkapsi feels strongly!

@normanmaurer
Copy link
Copy Markdown
Member Author

@rkapsi fair enough... use attributes() then.

@normanmaurer normanmaurer requested review from njhill and rkapsi October 17, 2019 14:08
@normanmaurer
Copy link
Copy Markdown
Member Author

@rkapsi @njhill PTAL again

@normanmaurer
Copy link
Copy Markdown
Member Author

@netty-bot test this please

@normanmaurer normanmaurer added this to the 4.1.43.Final milestone Oct 17, 2019
Copy link
Copy Markdown
Member

@rkapsi rkapsi left a comment

Choose a reason for hiding this comment

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

LGTM and thank you for considering composition over inheritance :)

@normanmaurer normanmaurer merged commit 247a4db into 4.1 Oct 22, 2019
@normanmaurer normanmaurer deleted the ssl_context_attr_map branch October 22, 2019 13:39
normanmaurer added a commit that referenced this pull request Oct 22, 2019
Motivation:

Sometimes it is useful to be able to set attributes on a SslContext.

Modifications:

Add new method that will return a AttributeMap that is tied to a SslContext instance

Result:

Fixes #6542.
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.

Ability to pass along attributes via SslContext

4 participants