@Override
    public void unloadPlugin(GoPluginBundleDescriptor pluginDescriptor) {
        Bundle bundle = pluginDescriptor.bundle();

        if (bundle == null || bundle.getState() == Bundle.UNINSTALLED) {
            LOGGER.info(format("Skipping plugin '%s' uninstall as it is already uninstalled.", pluginDescriptor));
            return;
        }

        try {
            bundle.stop();
            bundle.uninstall();
        } catch (Exception e) {
            throw new RuntimeException("Failed to unload plugin: " + bundle, e);
        }
    }
@Test
    void shouldNotFailToUnloadAPluginWhoseBundleIsNull() {
        GoPluginBundleDescriptor pluginDescriptor = mock(GoPluginBundleDescriptor.class);
        when(pluginDescriptor.bundle()).thenReturn(null);

        try {
            spy.unloadPlugin(pluginDescriptor);
        } catch (Exception e) {
            fail("Should not have thrown an exception");
        }
    }