nahguam commented on code in PR #16659:
URL: https://github.com/apache/pulsar/pull/16659#discussion_r925552061
##########
pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java:
##########
@@ -1253,14 +1253,14 @@ private void testIncompatibleSchema() throws Exception {
Message<User> message1 = consumer.receive();
Assert.assertEquals(test, message1.getValue());
Message<User> message2 = consumer.receive();
+
+ boolean exceptionHappened = false;
Review Comment:
AssertJ has assertions for these cases:
```
assertThatExceptionOfType(SchemaSerializationException.class).isThrownBy(()
-> {
message2.getValue();
});
```
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageImpl.java:
##########
@@ -489,9 +490,9 @@ private T decodeBySchema(byte[] schemaVersion) {
return value;
}
if (null == schemaVersion) {
- return schema.decode(getData());
+ return schema.decode(new ByteBufInputStream(payload));
Review Comment:
I presume this bit is the optimisation that prevents the payload copy?
##########
pulsar-client-api/src/main/java/org/apache/pulsar/common/utils/IOUtils.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.common.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Utils for I/O operations.
+ */
+public final class IOUtils {
Review Comment:
Do you mean it was copied from JDK 9+ `InputStream.readAllBytes()`?
Would it be useful to put a comment in the code the describe it as such?
Perhaps also a TODO to remove it when the client code compilation target is
upgraded to >= 9.
--
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]