NIFI-5479 Upgraded Jetty. Moved where we unpack bundled deps to so we can avoid a new jetty bug with META-INF loading logic.

Signed-off-by: Koji Kawamura <ijokarumawak@apache.org>
This commit is contained in:
joewitt 2018-08-02 16:29:23 -04:00 committed by Koji Kawamura
parent 58cb900b90
commit a27ccd8a56
5 changed files with 19 additions and 11 deletions

View File

@ -176,21 +176,21 @@ public class NarClassLoader extends URLClassLoader {
/**
* Adds URLs for the resources unpacked from this NAR:
* <ul><li>the root: for classes, <tt>META-INF</tt>, etc.</li>
* <li><tt>META-INF/dependencies</tt>: for config files, <tt>.so</tt>s,
* <ul><li>the root: for classes, <tt>NAR-INF</tt>, etc.</li>
* <li><tt>NAR-INF/bundled-dependencies</tt>: for config files, <tt>.so</tt>s,
* etc.</li>
* <li><tt>META-INF/dependencies/*.jar</tt>: for dependent
* <li><tt>NAR-INF/bundled-dependencies/*.jar</tt>: for dependent
* libraries</li></ul>
*
* @param root the root directory of the unpacked NAR.
* @throws IOException if the URL list could not be updated.
*/
private void updateClasspath(File root) throws IOException {
addURL(root.toURI().toURL()); // for compiled classes, META-INF/, etc.
addURL(root.toURI().toURL()); // for compiled classes, WEB-INF, NAR-INF/, etc.
File dependencies = new File(root, "META-INF/bundled-dependencies");
File dependencies = new File(root, "NAR-INF/bundled-dependencies");
if (!dependencies.isDirectory()) {
LOGGER.warn(narWorkingDirectory + " does not contain META-INF/bundled-dependencies!");
LOGGER.warn(narWorkingDirectory + " does not contain NAR-INF/bundled-dependencies!");
}
addURL(dependencies.toURI().toURL());
if (dependencies.isDirectory()) {
@ -206,9 +206,9 @@ public class NarClassLoader extends URLClassLoader {
@Override
protected String findLibrary(final String libname) {
File dependencies = new File(narWorkingDirectory, "META-INF/bundled-dependencies");
File dependencies = new File(narWorkingDirectory, "NAR-INF/bundled-dependencies");
if (!dependencies.isDirectory()) {
LOGGER.warn(narWorkingDirectory + " does not contain META-INF/bundled-dependencies!");
LOGGER.warn(narWorkingDirectory + " does not contain NAR-INF/bundled-dependencies!");
}
final File nativeDir = new File(dependencies, "native");

View File

@ -195,7 +195,7 @@ public final class NarUnpacker {
final File unpackedNar = entry.getKey();
final BundleCoordinate bundleCoordinate = entry.getValue();
final File bundledDependencies = new File(unpackedNar, "META-INF/bundled-dependencies");
final File bundledDependencies = new File(unpackedNar, "NAR-INF/bundled-dependencies");
unpackBundleDocs(docsDirectory, mapping, bundleCoordinate, bundledDependencies);
}
@ -261,6 +261,9 @@ public final class NarUnpacker {
while (jarEntries.hasMoreElements()) {
JarEntry jarEntry = jarEntries.nextElement();
String name = jarEntry.getName();
if(name.contains("META-INF/bundled-dependencies")){
name = name.replace("META-INF/bundled-dependencies", "NAR-INF/bundled-dependencies");
}
File f = new File(workingDirectory, name);
if (jarEntry.isDirectory()) {
FileUtils.ensureDirectoryExistAndCanReadAndWrite(f);

View File

@ -384,7 +384,7 @@ public class JettyServer implements NiFiServer {
// consider each nar working directory
bundles.forEach(bundle -> {
final BundleDetails details = bundle.getBundleDetails();
final File narDependencies = new File(details.getWorkingDirectory(), "META-INF/bundled-dependencies");
final File narDependencies = new File(details.getWorkingDirectory(), "NAR-INF/bundled-dependencies");
if (narDependencies.isDirectory()) {
// list the wars from this nar
final File[] narDependencyDirs = narDependencies.listFiles(WAR_FILTER);

View File

@ -913,6 +913,11 @@
the application classpath or the maven jetty plugin classpath defined
above.
-->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jstl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>

View File

@ -93,7 +93,7 @@
<inceptionYear>2014</inceptionYear>
<org.slf4j.version>1.7.25</org.slf4j.version>
<ranger.version>1.0.0</ranger.version>
<jetty.version>9.4.3.v20170317</jetty.version>
<jetty.version>9.4.11.v20180605</jetty.version>
</properties>
<repositories>