@Test public void testValidateLocalFileUrl() throws Exception { String fileLocation = FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath(); try { FunctionCommon.extractClassLoader(fileLocation); Assert.fail("should fail with invalid url: without protocol"); } catch (IllegalArgumentException ie) { } String fileLocationWithProtocol = "file: FunctionCommon.extractClassLoader(fileLocationWithProtocol); fileLocationWithProtocol = "file:" + fileLocation; FunctionCommon.extractClassLoader(fileLocationWithProtocol); }
public static ClassLoader extractClassLoader(String destPkgUrl) throws IOException, URISyntaxException { File file = extractFileFromPkgURL(destPkgUrl); try { return ClassLoaderUtils.loadJar(file); } catch (MalformedURLException e) { throw new IllegalArgumentException( "Corrupt User PackageFile " + file + " with error " + e.getMessage()); } }
FunctionCommon { public static ClassLoader extractClassLoader(String destPkgUrl) throws IOException, URISyntaxException { File file = extractFileFromPkgURL(destPkgUrl); try { return ClassLoaderUtils.loadJar(file); } catch (MalformedURLException e) { throw new IllegalArgumentException( "Corrupt User PackageFile " + file + " with error " + e.getMessage()); } } }
FunctionCommon { public static ClassLoader extractClassLoader(String destPkgUrl) throws IOException, URISyntaxException { File file = extractFileFromPkgURL(destPkgUrl); try { return ClassLoaderUtils.loadJar(file); } catch (MalformedURLException e) { throw new IllegalArgumentException( "Corrupt User PackageFile " + file + " with error " + e.getMessage()); } }  }
FunctionCommon { public static ClassLoader extractClassLoader(String destPkgUrl) throws IOException, URISyntaxException { File file = extractFileFromPkgURL(destPkgUrl); try { return ClassLoaderUtils.loadJar(file); } catch (MalformedURLException e) { throw new IllegalArgumentException( "Corrupt User PackageFile " + file + " with error " + e.getMessage()); } }  static String printJson(MessageOrBuilder msg); static void mergeJson(String json, Builder builder); static int findAvailablePort(); static Class<?>[] getFunctionTypes(FunctionConfig functionConfig, ClassLoader classLoader); static Class<?>[] getFunctionTypes(Class userClass, boolean isWindowConfigPresent); static Object createInstance(String userClassName, ClassLoader classLoader); static Runtime convertRuntime(FunctionConfig.Runtime runtime); static FunctionConfig.Runtime convertRuntime(Runtime runtime); static org.apache.pulsar.functions.proto.Function.ProcessingGuarantees convertProcessingGuarantee(
            FunctionConfig.ProcessingGuarantees processingGuarantees); static FunctionConfig.ProcessingGuarantees convertProcessingGuarantee(
            org.apache.pulsar.functions.proto.Function.ProcessingGuarantees processingGuarantees); static Class<?> getSourceType(String className, ClassLoader classLoader); static Class<?> getSourceType(Class sourceClass); static Class<?> getSinkType(String className, ClassLoader classLoader); static void downloadFromHttpUrl(String destPkgUrl, File targetFile); static ClassLoader extractClassLoader(String destPkgUrl); static File createPkgTempFile(); static File extractFileFromPkgURL(String destPkgUrl); static NarClassLoader extractNarClassLoader(Path archivePath, File packageFile,
                                                       String narExtractionDirectory); static String getFullyQualifiedInstanceId(org.apache.pulsar.functions.proto.Function.Instance instance); static String getFullyQualifiedInstanceId(String tenant, String namespace,
                                                     String functionName, int instanceId); static final long getSequenceId(MessageId messageId); static final MessageId getMessageId(long sequenceId); static byte[] toByteArray(Object obj); static String getUniquePackageName(String packageName); static String getStateNamespace(String tenant, String namespace); static String getFullyQualifiedName(org.apache.pulsar.functions.proto.Function.FunctionDetails FunctionDetails); static String getFullyQualifiedName(String tenant, String namespace, String functionName); static String extractTenantFromFullyQualifiedName(String fqfn); static String extractNamespaceFromFullyQualifiedName(String fqfn); static String extractNameFromFullyQualifiedName(String fqfn); static Class<?> getTypeArg(String className, Class<?> funClass, ClassLoader classLoader); static double roundDecimal(double value, int places); }
FunctionCommon { public static ClassLoader extractClassLoader(String destPkgUrl) throws IOException, URISyntaxException { File file = extractFileFromPkgURL(destPkgUrl); try { return ClassLoaderUtils.loadJar(file); } catch (MalformedURLException e) { throw new IllegalArgumentException( "Corrupt User PackageFile " + file + " with error " + e.getMessage()); } }  static String printJson(MessageOrBuilder msg); static void mergeJson(String json, Builder builder); static int findAvailablePort(); static Class<?>[] getFunctionTypes(FunctionConfig functionConfig, ClassLoader classLoader); static Class<?>[] getFunctionTypes(Class userClass, boolean isWindowConfigPresent); static Object createInstance(String userClassName, ClassLoader classLoader); static Runtime convertRuntime(FunctionConfig.Runtime runtime); static FunctionConfig.Runtime convertRuntime(Runtime runtime); static org.apache.pulsar.functions.proto.Function.ProcessingGuarantees convertProcessingGuarantee(
            FunctionConfig.ProcessingGuarantees processingGuarantees); static FunctionConfig.ProcessingGuarantees convertProcessingGuarantee(
            org.apache.pulsar.functions.proto.Function.ProcessingGuarantees processingGuarantees); static Class<?> getSourceType(String className, ClassLoader classLoader); static Class<?> getSourceType(Class sourceClass); static Class<?> getSinkType(String className, ClassLoader classLoader); static void downloadFromHttpUrl(String destPkgUrl, File targetFile); static ClassLoader extractClassLoader(String destPkgUrl); static File createPkgTempFile(); static File extractFileFromPkgURL(String destPkgUrl); static NarClassLoader extractNarClassLoader(Path archivePath, File packageFile,
                                                       String narExtractionDirectory); static String getFullyQualifiedInstanceId(org.apache.pulsar.functions.proto.Function.Instance instance); static String getFullyQualifiedInstanceId(String tenant, String namespace,
                                                     String functionName, int instanceId); static final long getSequenceId(MessageId messageId); static final MessageId getMessageId(long sequenceId); static byte[] toByteArray(Object obj); static String getUniquePackageName(String packageName); static String getStateNamespace(String tenant, String namespace); static String getFullyQualifiedName(org.apache.pulsar.functions.proto.Function.FunctionDetails FunctionDetails); static String getFullyQualifiedName(String tenant, String namespace, String functionName); static String extractTenantFromFullyQualifiedName(String fqfn); static String extractNamespaceFromFullyQualifiedName(String fqfn); static String extractNameFromFullyQualifiedName(String fqfn); static Class<?> getTypeArg(String className, Class<?> funClass, ClassLoader classLoader); static double roundDecimal(double value, int places);  }