Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
distribution: 'temurin'
cache: 'maven'

- name: Update java version
run: mvn versions:set -DnewVersion=${VERSION} -B -U

- name: Package project
run: mvn clean package -DskipTests -U -B -P cf-it-tests,examples

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 1.2.1 - (12/03/2024)
- **[BUGFIX]**: plugin: fix ColdFusion detection on Windows [#116](https://github.com/intergral/deep/pull/116) [@LMarkie](https://github.com/LMarkie)
- **[BUGFIX]**: plugin: ensure that failed plugins do not block start up [#118](https://github.com/intergral/deep/pull/118) [@Umaaz](https://github.com/Umaaz)

# 1.2.0 - (06/02/2024)
- **[CHANGE]**: change log config to allow better control of logging [#103](https://github.com/intergral/deep/pull/103) [@Umaaz](https://github.com/Umaaz)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This acts as the main loader for plugins using the SPI loader system.
*/
public final class PluginSpiLoader {

private static final Logger LOGGER = LoggerFactory.getLogger(PluginSpiLoader.class);

private PluginSpiLoader() {
}

Expand All @@ -59,7 +63,12 @@ public static List<IDeepPlugin> loadPlugins(final ISettings settings, final IRef
.filter(plugin -> !ResourceDetector.isDisabled(plugin.getClass(), enabledProviders, disabledProviders))
.filter(plugin -> {
if (plugin instanceof IConditional) {
return ((IConditional) plugin).isActive();
try {
return ((IConditional) plugin).isActive();
} catch (Exception e) {
LOGGER.error("Failed to load plugin {}", plugin.getClass().getName(), e);
return false;
}
}
return true;
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2024 Intergral GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.intergral.deep.agent.plugins;

import com.intergral.deep.agent.api.spi.IConditional;
import com.intergral.deep.agent.api.spi.IDeepPlugin;

/**
* This is used to test the SPI loder and just throws an exception on activate.
*/
public class MockBadPlugin implements IDeepPlugin, IConditional {


@Override
public boolean isActive() {
throw new RuntimeException("test exception");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 Intergral GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.intergral.deep.agent.plugins;

import com.intergral.deep.agent.api.spi.IDeepPlugin;

/**
* This is used to test the SPI loder and doesn't need to actually do anything.
*/
public class MockPlugin implements IDeepPlugin {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2024 Intergral GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.intergral.deep.agent.plugins;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.intergral.deep.agent.api.settings.ISettings;
import com.intergral.deep.agent.api.spi.IDeepPlugin;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

class PluginSpiLoaderTest {

@Test
void loadPlugins() {
final ISettings settings = Mockito.mock(ISettings.class);
final List<IDeepPlugin> iDeepPlugins = PluginSpiLoader.loadPlugins(settings, null, null);
assertNotNull(iDeepPlugins);

assertTrue(iDeepPlugins.size() > 1);

final Set<String> classNames = iDeepPlugins.stream().map(Object::getClass).map(Class::getName).collect(Collectors.toSet());

assertTrue(classNames.contains(MockPlugin.class.getName()));
assertFalse(classNames.contains(MockBadPlugin.class.getName()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (C) 2024 Intergral GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
com.intergral.deep.agent.plugins.MockPlugin
com.intergral.deep.agent.plugins.MockBadPlugin