Repository: ignite Updated Branches: refs/heads/master 33ad0ad84 -> ee2a6f7c3
ignite-6745 URLClassLoader.getURLs() usages are removed Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee2a6f7c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee2a6f7c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee2a6f7c Branch: refs/heads/master Commit: ee2a6f7c3f2e3c9bd8dc61c8dbdf171e933d9481 Parents: 33ad0ad Author: Andrey Gura <ag...@apache.org> Authored: Wed Dec 27 18:50:12 2017 +0300 Committer: Andrey Gura <ag...@apache.org> Committed: Thu Dec 28 16:12:23 2017 +0300 ---------------------------------------------------------------------- .../ignite/codegen/MessageCodeGenerator.java | 8 +-- .../junits/IgniteCompatibilityAbstractTest.java | 7 +- .../junits/IgniteCompatibilityNodeRunner.java | 15 ++--- .../ignite/internal/binary/BinaryContext.java | 66 +++++++++---------- .../processors/hadoop/HadoopClassLoader.java | 5 +- .../ignite/internal/util/IgniteUtils.java | 61 ++++++++++++++++- .../hadoop/HadoopTestClassLoader.java | 5 +- .../ignite/tools/classgen/ClassesGenerator.java | 69 ++++++++++++++++++-- .../uri/GridUriDeploymentFileProcessor.java | 28 ++++---- 9 files changed, 186 insertions(+), 78 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java ---------------------------------------------------------------------- diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java index 3ea0c81..99cf849 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java @@ -26,7 +26,6 @@ import java.io.FileWriter; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.BitSet; import java.util.Collection; @@ -39,13 +38,12 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.UUID; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.GridCodegenConverter; import org.apache.ignite.internal.GridDirectCollection; import org.apache.ignite.internal.GridDirectMap; import org.apache.ignite.internal.GridDirectTransient; import org.apache.ignite.internal.IgniteCodeGeneratingFail; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; @@ -879,9 +877,9 @@ public class MessageCodeGenerator { } }); - URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); + ClassLoader ldr = getClass().getClassLoader(); - for (URL url : ldr.getURLs()) { + for (URL url : IgniteUtils.classLoaderUrls(ldr)) { File file = new File(url.toURI()); int prefixLen = file.getPath().length() + 1; http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java index 321da12..8202c1b 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java @@ -19,7 +19,6 @@ package org.apache.ignite.compatibility.testframework.junits; import java.io.File; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Collection; import java.util.UUID; @@ -32,6 +31,7 @@ import org.apache.ignite.compatibility.testframework.util.MavenUtils; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.resource.GridSpringResourceContext; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -164,12 +164,13 @@ public abstract class IgniteCompatibilityAbstractTest extends GridCommonAbstract filteredJvmArgs.add(arg); } - URLClassLoader ldr = (URLClassLoader)CLASS_LOADER; + ClassLoader ldr = CLASS_LOADER; final Collection<Dependency> dependencies = getDependencies(ver); StringBuilder pathBuilder = new StringBuilder(); - for (URL url : ldr.getURLs()) { + + for (URL url : IgniteUtils.classLoaderUrls(ldr)) { String path = url.getPath(); boolean excluded = false; http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java ---------------------------------------------------------------------- diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java index 7c9a511..7a72ea6 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityNodeRunner.java @@ -23,7 +23,6 @@ import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; @@ -33,6 +32,7 @@ import org.apache.ignite.Ignite; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.GridJavaProcess; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; @@ -137,9 +137,8 @@ public class IgniteCompatibilityNodeRunner extends IgniteNodeRunner { X.println("Ignite startup/Init closure/post configuration closure is probably hanging at"); - for (StackTraceElement ste : mainThread.getStackTrace()) { + for (StackTraceElement ste : mainThread.getStackTrace()) X.println("\t" + ste.toString()); - } X.println("\nDumping classpath"); dumpClasspath(); @@ -157,14 +156,10 @@ public class IgniteCompatibilityNodeRunner extends IgniteNodeRunner { * Dumps classpath to output stream. */ private static void dumpClasspath() { - final ClassLoader clsLdr = IgniteCompatibilityNodeRunner.class.getClassLoader(); - if (clsLdr instanceof URLClassLoader) { - URLClassLoader ldr = (URLClassLoader)clsLdr; + ClassLoader clsLdr = IgniteCompatibilityNodeRunner.class.getClassLoader(); - for (URL url : ldr.getURLs()) { - X.println("Classpath url: [" + url.getPath() + "]"); - } - } + for (URL url : IgniteUtils.classLoaderUrls(clsLdr)) + X.println("Classpath url: [" + url.getPath() + ']'); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java index 5be1d39..b161129 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java @@ -23,7 +23,6 @@ import java.lang.reflect.Field; import java.math.BigDecimal; import java.net.URISyntaxException; import java.net.URL; -import java.net.URLClassLoader; import java.sql.Time; import java.sql.Timestamp; import java.util.ArrayList; @@ -48,6 +47,7 @@ import java.util.jar.JarFile; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.binary.BinaryBasicIdMapper; import org.apache.ignite.binary.BinaryBasicNameMapper; import org.apache.ignite.binary.BinaryIdMapper; @@ -553,55 +553,53 @@ public class BinaryContext { ClassLoader ldr = U.gridClassLoader(); - if (ldr instanceof URLClassLoader) { - String pkgPath = pkgName.replaceAll("\\.", "/"); + String pkgPath = pkgName.replaceAll("\\.", "/"); - URL[] urls = ((URLClassLoader)ldr).getURLs(); + URL[] urls = IgniteUtils.classLoaderUrls(ldr); - for (URL url : urls) { - String proto = url.getProtocol().toLowerCase(); + for (URL url : urls) { + String proto = url.getProtocol().toLowerCase(); - if ("file".equals(proto)) { - try { - File cpElement = new File(url.toURI()); + if ("file".equals(proto)) { + try { + File cpElement = new File(url.toURI()); - if (cpElement.isDirectory()) { - File pkgDir = new File(cpElement, pkgPath); + if (cpElement.isDirectory()) { + File pkgDir = new File(cpElement, pkgPath); - if (pkgDir.isDirectory()) { - for (File file : pkgDir.listFiles()) { - String fileName = file.getName(); + if (pkgDir.isDirectory()) { + for (File file : pkgDir.listFiles()) { + String fileName = file.getName(); - if (file.isFile() && fileName.toLowerCase().endsWith(".class")) - clsNames.add(pkgName + '.' + fileName.substring(0, fileName.length() - 6)); - } + if (file.isFile() && fileName.toLowerCase().endsWith(".class")) + clsNames.add(pkgName + '.' + fileName.substring(0, fileName.length() - 6)); } } - else if (cpElement.isFile()) { - try { - JarFile jar = new JarFile(cpElement); + } + else if (cpElement.isFile()) { + try { + JarFile jar = new JarFile(cpElement); - Enumeration<JarEntry> entries = jar.entries(); + Enumeration<JarEntry> entries = jar.entries(); - while (entries.hasMoreElements()) { - String entry = entries.nextElement().getName(); + while (entries.hasMoreElements()) { + String entry = entries.nextElement().getName(); - if (entry.startsWith(pkgPath) && entry.endsWith(".class")) { - String clsName = entry.substring(pkgPath.length() + 1, entry.length() - 6); + if (entry.startsWith(pkgPath) && entry.endsWith(".class")) { + String clsName = entry.substring(pkgPath.length() + 1, entry.length() - 6); - if (!clsName.contains("/") && !clsName.contains("\\")) - clsNames.add(pkgName + '.' + clsName); - } + if (!clsName.contains("/") && !clsName.contains("\\")) + clsNames.add(pkgName + '.' + clsName); } } - catch (IOException ignored) { - // No-op. - } + } + catch (IOException ignored) { + // No-op. } } - catch (URISyntaxException ignored) { - // No-op. - } + } + catch (URISyntaxException ignored) { + // No-op. } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java index b1b4d18..24367f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java @@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.hadoop; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.util.ClassCache; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; @@ -60,10 +61,10 @@ public class HadoopClassLoader extends URLClassLoader implements ClassCache { "org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopShutdownHookManager"; /** */ - private static final URLClassLoader APP_CLS_LDR = (URLClassLoader)HadoopClassLoader.class.getClassLoader(); + private static final ClassLoader APP_CLS_LDR = HadoopClassLoader.class.getClassLoader(); /** */ - private static final Collection<URL> appJars = F.asList(APP_CLS_LDR.getURLs()); + private static final Collection<URL> appJars = F.asList(IgniteUtils.classLoaderUrls(APP_CLS_LDR)); /** Mutex for native libraries initialization. */ private static final Object LIBS_MUX = new Object(); http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index b3ca6ff..6fb19a1 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -240,8 +240,6 @@ import org.apache.ignite.transactions.TransactionTimeoutException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentHashMap8; -import sun.misc.SharedSecrets; -import sun.misc.URLClassPath; import sun.misc.Unsafe; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISABLE_HOSTNAME_VERIFIER; @@ -527,6 +525,21 @@ public abstract class IgniteUtils { /** */ private static final boolean assertionsEnabled; + /** Empty URL array. */ + private static final URL[] EMPTY_URL_ARR = new URL[0]; + + /** Builtin class loader class. + * + * Note: needs for compatibility with Java 9. + */ + private static final Class bltClsLdrCls = defaultClassLoaderClass(); + + /** Url class loader field. + * + * Note: needs for compatibility with Java 9. + */ + private static final Field urlClsLdrField = urlClassLoaderField(); + /* * Initializes enterprise check. */ @@ -7536,6 +7549,50 @@ public abstract class IgniteUtils { } /** + * Returns URLs of class loader + * + * @param clsLdr Class loader. + */ + public static URL[] classLoaderUrls(ClassLoader clsLdr) { + if (clsLdr == null) + return EMPTY_URL_ARR; + else if (clsLdr instanceof URLClassLoader) + return ((URLClassLoader)clsLdr).getURLs(); + else if (bltClsLdrCls != null && urlClsLdrField != null && bltClsLdrCls.isAssignableFrom(clsLdr.getClass())) { + try { + return ((URLClassLoader)urlClsLdrField.get(clsLdr)).getURLs(); + } + catch (IllegalAccessException e) { + return EMPTY_URL_ARR; + } + } + else + return EMPTY_URL_ARR; + } + + /** */ + @Nullable private static Class defaultClassLoaderClass() { + try { + return Class.forName("jdk.internal.loader.BuiltinClassLoader"); + } + catch (ClassNotFoundException e) { + return null; + } + } + + /** */ + @Nullable private static Field urlClassLoaderField() { + try { + Class cls = defaultClassLoaderClass(); + + return cls == null ? null : cls.getDeclaredField("ucp"); + } + catch (NoSuchFieldException e) { + return null; + } + } + + /** * Sleeps for given number of milliseconds. * * @param ms Time to sleep. http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTestClassLoader.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTestClassLoader.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTestClassLoader.java index 91ee0c9..2ba67c8 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTestClassLoader.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopTestClassLoader.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.hadoop; import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; @@ -32,10 +33,10 @@ import java.util.List; */ public class HadoopTestClassLoader extends URLClassLoader { /** Parent class loader. */ - private static final URLClassLoader APP_CLS_LDR = (URLClassLoader)HadoopTestClassLoader.class.getClassLoader(); + private static final ClassLoader APP_CLS_LDR = HadoopTestClassLoader.class.getClassLoader(); /** */ - private static final Collection<URL> APP_JARS = F.asList(APP_CLS_LDR.getURLs()); + private static final Collection<URL> APP_JARS = F.asList(IgniteUtils.classLoaderUrls(APP_CLS_LDR)); /** All participating URLs. */ private static final URL[] URLS; http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/tools/src/main/java/org/apache/ignite/tools/classgen/ClassesGenerator.java ---------------------------------------------------------------------- diff --git a/modules/tools/src/main/java/org/apache/ignite/tools/classgen/ClassesGenerator.java b/modules/tools/src/main/java/org/apache/ignite/tools/classgen/ClassesGenerator.java index ecc0654..2be847b 100644 --- a/modules/tools/src/main/java/org/apache/ignite/tools/classgen/ClassesGenerator.java +++ b/modules/tools/src/main/java/org/apache/ignite/tools/classgen/ClassesGenerator.java @@ -35,7 +35,6 @@ import java.util.Comparator; import java.util.TreeSet; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; - /** * Serialized classes generator. */ @@ -51,6 +50,21 @@ public class ClassesGenerator { "org.apache.ignite.tools" }; + /** Empty URL array. */ + private static final URL[] EMPTY_URL_ARR = new URL[0]; + + /** Builtin class loader class. + * + * Note: needs for compatibility with Java 9. + */ + private static final Class bltClsLdrCls = defaultClassLoaderClass(); + + /** Url class loader field. + * + * Note: needs for compatibility with Java 9. + */ + private static final Field urlClsLdrField = urlClassLoaderField(); + /** * @param args Arguments. * @throws Exception In case of error. @@ -69,9 +83,6 @@ public class ClassesGenerator { } /** */ - private final URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); - - /** */ private final Collection<Class> classes = new TreeSet<>(new Comparator<Class>() { @Override public int compare(Class c1, Class c2) { return c1.getName().compareTo(c2.getName()); @@ -112,7 +123,8 @@ public class ClassesGenerator { private void generate() throws Exception { System.out.println("Generating classnames.properties..."); - for (URL url : ldr.getURLs()) + + for (URL url : classLoaderUrls(getClass().getClassLoader())) processUrl(url); if (!errs.isEmpty()) { @@ -185,6 +197,51 @@ public class ClassesGenerator { } /** + * Returns URLs of class loader + * + * @param clsLdr Class loader. + */ + public static URL[] classLoaderUrls(ClassLoader clsLdr) { + if (clsLdr == null) + return EMPTY_URL_ARR; + else if (clsLdr instanceof URLClassLoader) + return ((URLClassLoader)clsLdr).getURLs(); + else if (bltClsLdrCls != null && urlClsLdrField != null && bltClsLdrCls.isAssignableFrom(clsLdr.getClass())) { + try { + return ((URLClassLoader)urlClsLdrField.get(clsLdr)).getURLs(); + } + catch (IllegalAccessException e) { + return EMPTY_URL_ARR; + } + } + else + return EMPTY_URL_ARR; + } + + /** */ + private static Class defaultClassLoaderClass() { + try { + return Class.forName("jdk.internal.loader.BuiltinClassLoader"); + } + catch (ClassNotFoundException e) { + return null; + } + } + + /** */ + private static Field urlClassLoaderField() { + try { + Class cls = defaultClassLoaderClass(); + + return cls == null ? null : cls.getDeclaredField("ucp"); + } + catch (NoSuchFieldException e) { + return null; + } + } + + + /** * @param path File path. * @param prefixLen Prefix length. * @throws Exception In case of error. @@ -209,7 +266,7 @@ public class ClassesGenerator { } if (included) { - Class<?> cls = Class.forName(clsName, false, ldr); + Class<?> cls = Class.forName(clsName, false, getClass().getClassLoader()); if (Serializable.class.isAssignableFrom(cls) && !(cls.getName().endsWith("Future") || cls.getName().endsWith("FutureAdapter"))) { http://git-wip-us.apache.org/repos/asf/ignite/blob/ee2a6f7c/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java ---------------------------------------------------------------------- diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java index d82a57e..3564f2f 100644 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java +++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java @@ -35,6 +35,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.compute.ComputeTask; +import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.IgniteSpiException; @@ -292,29 +293,28 @@ final class GridUriDeploymentFileProcessor { static void cleanupUnit(ClassLoader clsLdr, IgniteLogger log) { assert clsLdr != null; assert log != null; + assert clsLdr instanceof URLClassLoader; - if (clsLdr instanceof URLClassLoader) { - URLClassLoader clsLdr0 = (URLClassLoader)clsLdr; + URLClassLoader clsLdr0 = (URLClassLoader)clsLdr; - U.close(clsLdr0, log); + U.close(clsLdr0, log); - try { - URL url = clsLdr0.getURLs()[0]; + try { + URL url = IgniteUtils.classLoaderUrls(clsLdr)[0]; - File dir = new File(url.toURI()); + File dir = new File(url.toURI()); - U.delete(dir); + U.delete(dir); - if (dir.getName().startsWith("dirzip_")) { - File jarFile = new File(dir.getParentFile(), dir.getName().substring(7)); + if (dir.getName().startsWith("dirzip_")) { + File jarFile = new File(dir.getParentFile(), dir.getName().substring(7)); - U.delete(jarFile); - } - } - catch (Exception e) { - U.error(log, "Failed to cleanup unit [clsLdr=" + clsLdr + ']', e); + U.delete(jarFile); } } + catch (Exception e) { + U.error(log, "Failed to cleanup unit [clsLdr=" + clsLdr + ']', e); + } } /**