eolivelli commented on a change in pull request #10878:
URL: https://github.com/apache/pulsar/pull/10878#discussion_r649708530



##########
File path: 
pulsar-functions/runtime-all/src/test/java/org/apache/pulsar/functions/instance/JavaInstanceDepsTest.java
##########
@@ -0,0 +1,74 @@
+/**
+ * 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.functions.instance;
+
+import lombok.extern.slf4j.Slf4j;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+@Slf4j
+/**
+ * This test serves to make sure that the correct classes are included in the 
java-instance.jar
+ * THAT JAR SHOULD ONLY CONTAIN THE INTERFACES THAT PULSAR FUNCTION'S 
FRAMEWORK USES TO INTERACT WITH USER CODE
+ * WHICH INCLUDES CLASSES FROM THE FOLLOWING LIBRARIES
+ *     1. pulsar-io-core
+ *     2. pulsar-functions-api
+ *     3. pulsar-client-api
+ *     4. slf4j-api
+ *     5. log4j-slf4j-impl
+ *     6. log4j-api
+ *     7. log4j-core
+ */
+public class JavaInstanceDepsTest {
+
+    @Test
+    public void testInstanceJarDeps() throws IOException {
+        File jar = new File("target/java-instance.jar");
+        ZipInputStream zip = new 
ZipInputStream(jar.toURI().toURL().openStream());

Review comment:
       Nit: please close the stream

##########
File path: 
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntime.java
##########
@@ -179,7 +179,6 @@ public void start() throws Exception {
                 String.format("%s-%s",
                         
FunctionCommon.getFullyQualifiedName(instanceConfig.getFunctionDetails()),
                         instanceConfig.getInstanceId()));
-        this.fnThread.setContextClassLoader(functionClassLoader);

Review comment:
       @jerrypeng 
   why are we dropping this line ?
   

##########
File path: 
pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/AvroSchemaCache.java
##########
@@ -65,7 +66,7 @@ public AvroSchemaCache(SchemaRegistryClient 
schemaRegistryClient) {
             org.apache.avro.Schema schema = 
schemaRegistryClient.getById(schemaId);
             String definition = schema.toString(false);
             log.info("Schema {} definition {}", schemaId, definition);
-            SchemaInfo schemaInfo = SchemaInfo.builder()
+            SchemaInfo schemaInfo = SchemaInfoImpl.builder()

Review comment:
       This is the code of a Source, we cannot use Impl classes.
   They are not available here directly 

##########
File path: 
pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/AvroSchemaCache.java
##########
@@ -65,7 +66,7 @@ public AvroSchemaCache(SchemaRegistryClient 
schemaRegistryClient) {
             org.apache.avro.Schema schema = 
schemaRegistryClient.getById(schemaId);
             String definition = schema.toString(false);
             log.info("Schema {} definition {}", schemaId, definition);
-            SchemaInfo schemaInfo = SchemaInfo.builder()
+            SchemaInfo schemaInfo = SchemaInfoImpl.builder()

Review comment:
       yes, but this is not good anyway, because if you develop a Source you 
cannot use this class.
   is this Source adding pulsar-common in the dependencies ?
   

##########
File path: 
pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/AvroSchemaCache.java
##########
@@ -65,7 +66,7 @@ public AvroSchemaCache(SchemaRegistryClient 
schemaRegistryClient) {
             org.apache.avro.Schema schema = 
schemaRegistryClient.getById(schemaId);
             String definition = schema.toString(false);
             log.info("Schema {} definition {}", schemaId, definition);
-            SchemaInfo schemaInfo = SchemaInfo.builder()
+            SchemaInfo schemaInfo = SchemaInfoImpl.builder()

Review comment:
       it does not matter that this Source is inside the main Pulsar repo

##########
File path: tests/docker-images/java-test-functions/pom.xml
##########
@@ -82,24 +82,10 @@
                             </transformers>
                             <artifactSet>
                                 <includes>
-                                    
<include>org.apache.pulsar:pulsar-client-original</include>
-                                    
<include>org.apache.pulsar:pulsar-client-api</include>
-                                    
<include>org.apache.pulsar:pulsar-client-admin-api</include>
+                                    
<include>org.apache.pulsar:pulsar-client</include>

Review comment:
       Does this line mean that a function should bundle the whole pulsar 
client (shaded) in order to be able to work




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to