poorbarcode commented on code in PR #20958: URL: https://github.com/apache/pulsar/pull/20958#discussion_r1304065669
########## pulsar-client-api/src/main/java/org/apache/pulsar/client/api/DummyCryptoKeyReaderImpl.java: ########## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.client.api; + +import java.util.Map; + +public class DummyCryptoKeyReaderImpl implements CryptoKeyReader { Review Comment: Done ########## pulsar-websocket/src/main/java/org/apache/pulsar/websocket/ProducerHandler.java: ########## @@ -206,7 +242,7 @@ public void onWebSocketText(String message) { } }).exceptionally(exception -> { log.warn("[{}] Error occurred while producer handler was sending msg from {}: {}", producer.getTopic(), - getRemote().getInetSocketAddress().toString(), exception.getMessage()); + getRemote().getInetSocketAddress().toString(), exception.getMessage(), exception); Review Comment: fixed ########## pulsar-websocket/src/main/java/org/apache/pulsar/websocket/ProducerHandler.java: ########## @@ -192,6 +207,27 @@ public void onWebSocketText(String message) { builder.deliverAfter(sendRequest.deliverAfterMs, TimeUnit.MILLISECONDS); } + // If client-side encryption is enabled, the attributes "encryptParam", "uncompressedMessageSize", + // "uncompressedMessageSize" and "batchSize" of message metadata must be set according to the parameters + // when the client sends messages. + if (clientSideEncrypt) { + try { + if (!StringUtils.isBlank(sendRequest.encryptionParam)) { + builder.getMetadataBuilder().setEncryptionParam(Base64.getDecoder() + .decode(sendRequest.encryptionParam)); + } + } catch (Exception e){ + String msg = format("Invalid Base64 encryptionParam error=%s", e.getMessage()); + sendAckResponse(new ProducerAck(PayloadEncodingError, msg, null, requestContext)); + return; + } + if (sendRequest.compressionType != null && sendRequest.uncompressedMessageSize != null) { + // Set compression information. + builder.getMetadataBuilder().setCompression(sendRequest.compressionType); + builder.getMetadataBuilder().setUncompressedSize(sendRequest.uncompressedMessageSize); Review Comment: Added a check -- 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]
