-
Notifications
You must be signed in to change notification settings - Fork 408
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
PSK identity related fixes #320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except details below, It sounds good to me.
if (info.getIdentity() != null) { | ||
// populate the secondary index (security info by PSK id) | ||
String oldEndpoint; | ||
if ((oldEndpoint = j.hget(PSKID_SEC, info.getIdentity())) != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Leshan code base, we generally don't initialize variable in if
condition.
Could you please, move the initialization out of the if ?
String oldEndpoint = j.hget(PSKID_SEC, info.getIdentity();
if (oldEndpoint != null ...
byte[] previousData = j.getSet((SEC_EP + info.getEndpoint()).getBytes(), data); | ||
SecurityInfo previous = previousData == null ? null : deserialize(previousData); | ||
String previousIdentity; | ||
if (previous != null && (previousIdentity = previous.getIdentity()) != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing about variable initialization here.
If you really want to avoid to call several time previous.getIdentity()
several time, you will probably need to create 2 if blocks. Personally I'm ok if you choose to not put previous.getIdentity()
in a variable.
@@ -98,6 +98,11 @@ public SecurityInfo add(SecurityInfo info) throws NonUniqueSecurityInfoException | |||
} | |||
|
|||
SecurityInfo previous = securityByEp.put(info.getEndpoint(), info); | |||
String previousIdentity; | |||
if (previous != null && (previousIdentity = previous.getIdentity()) != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment than above.
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Comments addressed, rebased. |
No description provided.