You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/08/11 03:41:25 UTC

[GitHub] [helix] manick02 commented on a change in pull request #1229: Add JarLoader interface and LocalJarLoader class

manick02 commented on a change in pull request #1229:
URL: https://github.com/apache/helix/pull/1229#discussion_r468308234



##########
File path: helix-core/src/main/java/org/apache/helix/task/api/LocalJarLoader.java
##########
@@ -0,0 +1,53 @@
+package org.apache.helix.task.api;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LocalJarLoader implements JarLoader {
+  private static final Logger LOG = LoggerFactory.getLogger(LocalJarLoader.class);
+
+  /**
+   * Loads a local JAR file and returns its URL.
+   * @param jarPath path of the JAR file
+   * @return URL of the JAR file at path jarPath
+   */
+  @Override
+  public URL loadJar(String jarPath) {
+    // If taskJarFile doesn't exist or it's a directory, throw exception
+    File taskJarFile = new File(jarPath);
+    if (!taskJarFile.exists() || taskJarFile.isDirectory()) {
+      LOG.error("Failed to find JAR " + jarPath + " for new task.");
+      throw new IllegalStateException("No JAR for task");

Review comment:
       Does it make sense to check for any other permission like whether jar file is readable etc here to make sure jar is readable for JVM to execute? 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org