Skip to content

RSL6b test, log errors#215

Merged
paddybyers merged 4 commits intoably:masterfrom
psolstice:RSL6_test
Nov 4, 2016
Merged

RSL6b test, log errors#215
paddybyers merged 4 commits intoably:masterfrom
psolstice:RSL6_test

Conversation

@psolstice
Copy link
Copy Markdown
Contributor

Fixed decoding message bugs, added logging for decoding/decryption problems, added test for inconsistent message encoding

…oblems, added test for inconsistent message encoding
Copy link
Copy Markdown
Member

@paddybyers paddybyers 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 pls seem comments

data = Base64Coder.decode((String) data);
}
catch (IllegalArgumentException e) {
throw AblyException.fromThrowable(e);
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.

What's going to happen to this exception? I don't think it will propagate to anywhere useful. In this case I think we should do the same as in the case of being unable to decrypt - ie leave the data and encoding unchanged, and log a message saying that the base64 decoding step failed.

Copy link
Copy Markdown
Contributor Author

@psolstice psolstice Nov 3, 2016

Choose a reason for hiding this comment

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

Without rethrowing the lib would crash on IllegalArgumentException. Exception is caught in Channel.onMessage or Channel.onPresense and logged. Rethrowing is used in the same method for JSON case.

data = opts.getCipher().decrypt((byte[]) data);
continue;
}
else
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.

If we have a compound if/then/else then it either needs braces everywhere, or nowhere, but not mixed like this. In in doublt, use braces.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, do you have a doc on code formatting style?

continue;
}
else
Log.e(TAG, "Encrypted message received but encryption is not set up");
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.

I'm not sure this is an error - I would make this Log.i I think.

Also lets say ".. encryption is not enabled on channel", and also include the channel name in the message pls.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would if it was easy to get channel name at this point. Most I can do is throw custom AblyException, catch it in Channel.onMessage and log it there. But it seems like a lot of effort for a minor thing

@paddybyers
Copy link
Copy Markdown
Member

Without rethrowing the lib would crash on IllegalArgumentException

No, without catching the lib would crash on IllegalArgumentException.

Rethrowing is used in the same method for JSON case.

Ok, well we definitely need to do the same thing in each case.

If we throw here, then the client doesn't see the event; only a log message. If we catch and do nothing except log it, the client will get an event, with an encoding field that says there are un-unwrapped JSON/Base64 encoding steps. I can't say that's especially useful either TBH but we should decide.

@paddybyers
Copy link
Copy Markdown
Member

do you have a doc on code formatting style?

No we don't. Use the same coding style as is there already pls to the extent that it's obvious what that is :)

@psolstice
Copy link
Copy Markdown
Contributor Author

By rethrowing I mean of course throwing it as a different exception. I just saw a bug (crash in case of wrong base64 data) and fixed it in a way similar to what was used in a nearby statement in the same method.

@paddybyers
Copy link
Copy Markdown
Member

@psolstice RSL6b says that invalid Base64 does not prevent the event being delivered to the listener. So I think throwing here is wrong; the decode exception should caught, and a log message written out, and the Message with unchanged data and encoding is emitted to subscribers in the normal way.

I think we should make the JSON decode failure do the same.

@psolstice
Copy link
Copy Markdown
Contributor Author

I think you're right, I'll change the behavior

data = Base64Coder.decode((String) data);
}
catch (IllegalArgumentException e) { throw AblyException.fromThrowable(e); }
catch (IllegalArgumentException e) { break; }
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.

Sorry, I should have been clearer. I think we need a log message (Log.e() I guess) in this case as well.

@paddybyers paddybyers merged commit 56a4920 into ably:master Nov 4, 2016
@paddybyers
Copy link
Copy Markdown
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants