dlmarion commented on a change in pull request #1715: URL: https://github.com/apache/accumulo/pull/1715#discussion_r518823871
########## File path: core/src/test/java/org/apache/accumulo/core/classloader/URLClassLoaderFactory.java ########## @@ -0,0 +1,55 @@ +/* + * 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.accumulo.core.classloader; + +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; + +import org.apache.accumulo.core.client.PluginEnvironment.Configuration; +import org.apache.accumulo.core.spi.common.ContextClassLoaderFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class URLClassLoaderFactory implements ContextClassLoaderFactory { + + private static final String COMMA = ","; + private static final Logger LOG = LoggerFactory.getLogger(URLClassLoaderFactory.class); + + @Override + public void initialize(Configuration contextProperties) throws Exception {} + + @Override + public ClassLoader getClassLoader(String contextName) throws IllegalArgumentException { + // The context name is the classpath. + var parts = contextName.split(COMMA); + var urls = new ArrayList<URL>(); + for (String p : parts) { + try { + urls.add(new URL(p)); + } catch (MalformedURLException e) { + LOG.error("Error creating URL from classpath segment: " + p); Review comment: I removed the log ########## File path: core/src/test/java/org/apache/accumulo/core/classloader/URLClassLoaderFactory.java ########## @@ -0,0 +1,55 @@ +/* + * 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.accumulo.core.classloader; + +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; + +import org.apache.accumulo.core.client.PluginEnvironment.Configuration; +import org.apache.accumulo.core.spi.common.ContextClassLoaderFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class URLClassLoaderFactory implements ContextClassLoaderFactory { + + private static final String COMMA = ","; + private static final Logger LOG = LoggerFactory.getLogger(URLClassLoaderFactory.class); + + @Override + public void initialize(Configuration contextProperties) throws Exception {} + + @Override + public ClassLoader getClassLoader(String contextName) throws IllegalArgumentException { + // The context name is the classpath. + var parts = contextName.split(COMMA); + var urls = new ArrayList<URL>(); + for (String p : parts) { + try { + urls.add(new URL(p)); + } catch (MalformedURLException e) { + LOG.error("Error creating URL from classpath segment: " + p); + throw new RuntimeException("Error creating URL from classpath segment: " + p, e); Review comment: Changed to throw IAE ---------------------------------------------------------------- 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]
