@@ -371,7 +371,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
371371 throw new IllegalStateException ("Source and target cannot be equal: " + source ());
372372 }
373373 List <Transformation > transformations = new ArrayList <Transformation >(getTransformations ());
374- ClassLoader classLoader = ByteBuddySkippingUrlClassLoader .of (getClass ().getClassLoader (), discoverySet (), classPath () );
374+ ClassLoader classLoader = ByteBuddySkippingUrlClassLoader .of (getClass ().getClassLoader (), discoverySet ());
375375 Plugin .Engine .Summary summary ;
376376 try {
377377 if (discovery .isDiscover (transformations )) {
@@ -465,7 +465,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
465465 classFileLocator .close ();
466466 }
467467 } finally {
468- if (classLoader instanceof Closeable ) {
468+ if (classLoader instanceof Closeable && classLoader instanceof ByteBuddySkippingUrlClassLoader ) {
469469 ((Closeable ) classLoader ).close ();
470470 }
471471 }
@@ -580,21 +580,23 @@ protected ByteBuddySkippingUrlClassLoader(ClassLoader parent, URL[] url) {
580580 *
581581 * @param classLoader The class loader of the Byte Buddy plugin.
582582 * @param discoverySet The source set to discover plugins from or {@code null} if no source set is used.
583- * @param classPath The configured class path.
584583 * @return The resolved class loader.
585584 */
586- protected static ClassLoader of (ClassLoader classLoader , @ MaybeNull Iterable <File > discoverySet , Iterable <File > classPath ) {
585+ protected static ClassLoader of (ClassLoader classLoader , @ MaybeNull Iterable <File > discoverySet ) {
586+ if (discoverySet == null ) {
587+ return classLoader ;
588+ }
587589 List <URL > urls = new ArrayList <URL >();
588- for (File file : discoverySet == null
589- ? classPath
590- : discoverySet ) {
590+ for (File file : discoverySet ) {
591591 try {
592592 urls .add (file .toURI ().toURL ());
593593 } catch (MalformedURLException e ) {
594594 throw new IllegalStateException (e );
595595 }
596596 }
597- return new ByteBuddySkippingUrlClassLoader (classLoader , urls .toArray (new URL [0 ]));
597+ return urls .isEmpty ()
598+ ? classLoader
599+ : new ByteBuddySkippingUrlClassLoader (classLoader , urls .toArray (new URL [0 ]));
598600 }
599601
600602 @ Override
0 commit comments