diff --git a/core/src/main/java/jenkins/widgets/WidgetFactory.java b/core/src/main/java/jenkins/widgets/WidgetFactory.java index 41cf288cba..7befa71aaa 100644 --- a/core/src/main/java/jenkins/widgets/WidgetFactory.java +++ b/core/src/main/java/jenkins/widgets/WidgetFactory.java @@ -71,7 +71,7 @@ public abstract class WidgetFactory impl public static Iterable> factoriesFor(Class type, Class widgetType) { List> result = new ArrayList<>(); for (WidgetFactory wf : ExtensionList.lookup(WidgetFactory.class)) { - if (type.isAssignableFrom(wf.type()) && widgetType.isAssignableFrom(wf.widgetType())) { + if (wf.type().isAssignableFrom(type) && widgetType.isAssignableFrom(wf.widgetType())) { result.add(wf); } } @@ -80,7 +80,7 @@ public abstract class WidgetFactory impl public Collection createWidgetsFor(HasWidgets hasWidgets) { try { - Collection result = createFor(type().cast(this)); + Collection result = createFor(type().cast(hasWidgets)); for (W w : result) { if (!widgetType().isInstance(w)) { LOGGER.log(Level.WARNING, "Widgets from {0} for {1} included {2} not assignable to {3}", new Object[] {this, hasWidgets, w, widgetType()});