lhotari commented on code in PR #25865:
URL: https://github.com/apache/pulsar/pull/25865#discussion_r3296620577
##########
pulsar-websocket/src/main/java/org/apache/pulsar/websocket/ReaderHandler.java:
##########
@@ -385,13 +397,25 @@ private int getReceiverQueueSize() {
return size;
}
- private MessageId getMessageId() throws IOException {
+ private MessageId getMessageId() {
MessageId messageId = MessageId.latest;
- if (isNotBlank(queryParams.get("messageId"))) {
- if (queryParams.get("messageId").equals("earliest")) {
+ String messageIdParam = queryParams.get("messageId");
+ if (isNotBlank(messageIdParam)) {
+ if (messageIdParam.equals("earliest")) {
messageId = MessageId.earliest;
- } else if (!queryParams.get("messageId").equals("latest")) {
- messageId =
MessageIdImpl.fromByteArray(Base64.getDecoder().decode(queryParams.get("messageId")));
+ } else if (!messageIdParam.equals("latest")) {
+ final byte[] decoded;
+ try {
+ decoded = Base64.getDecoder().decode(messageIdParam);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Invalid messageId
base64 value", e);
+ }
+
+ try {
+ messageId = MessageIdImpl.fromByteArray(decoded);
+ } catch (IOException e) {
Review Comment:
MessageIdImpl.fromByteArray could also throw `IllegalStateException`, does
that get handled in other layers?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]