From 93a2742c846c0e30a04b394b31c2c6219e227c10 Mon Sep 17 00:00:00 2001 From: "Bernhard K. Weisshuhn" Date: Wed, 25 Sep 2013 13:04:54 +0200 Subject: [PATCH] do not silently fail on plugin install with source files --- .../org/elasticsearch/plugins/PluginManager.java | 2 +- .../elasticsearch/plugin/PluginManagerTests.java | 7 +++++++ .../plugin/plugin_with_sourcefiles.zip | Bin 0 -> 2412 bytes 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/org/elasticsearch/plugin/plugin_with_sourcefiles.zip diff --git a/src/main/java/org/elasticsearch/plugins/PluginManager.java b/src/main/java/org/elasticsearch/plugins/PluginManager.java index d9bde8df37b..c1b302f98db 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginManager.java +++ b/src/main/java/org/elasticsearch/plugins/PluginManager.java @@ -186,7 +186,7 @@ public class PluginManager { if (FileSystemUtils.hasExtensions(extractLocation, ".java")) { debug("Plugin installation assumed to be site plugin, but contains source code, aborting installation..."); FileSystemUtils.deleteRecursively(extractLocation); - return; + throw new IllegalArgumentException("Plugin installation assumed to be site plugin, but contains source code, aborting installation."); } File binFile = new File(extractLocation, "bin"); diff --git a/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java b/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java index 7c75d354dd4..a788769cae9 100644 --- a/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java +++ b/src/test/java/org/elasticsearch/plugin/PluginManagerTests.java @@ -104,6 +104,13 @@ public class PluginManagerTests extends AbstractIntegrationTest { assertPluginAvailable(nodeName, pluginName); } + @Test(expected = IllegalArgumentException.class) + public void testSitePluginWithSourceThrows() throws Exception { + String pluginName = "plugin-with-source"; + URL url = PluginManagerTests.class.getResource("plugin_with_sourcefiles.zip"); + downloadAndExtract(pluginName, "file://" + url.getFile()); + } + private static PluginManager pluginManager(String pluginUrl) { Tuple initialSettings = InternalSettingsPreparer.prepareSettings( ImmutableSettings.settingsBuilder().build(), false); diff --git a/src/test/resources/org/elasticsearch/plugin/plugin_with_sourcefiles.zip b/src/test/resources/org/elasticsearch/plugin/plugin_with_sourcefiles.zip new file mode 100644 index 0000000000000000000000000000000000000000..ccd194fc737086a846607f474aee493556cc1a34 GIT binary patch literal 2412 zcmWIWW@h1H0D;&fOJ^_xN=PusFcjpJrf25GmuHq_#24q67A2>qW#*(7>xYJLGB8iv z;S|KQ(6-T$D_vsfq+l%}vbABhzR#VvNp8EK4NQ zd@Z8Q&o4?R(+&%g>`2W?EH24RE>2A>O3onDMtcfugd{jJEq0~c;-bv5)FL9SpM;iS z{HbMqaei(pl0!b@&SxUP{Kmlma>(|@3Y!gpJR=}ZroKahfldkng-rmsM9>2zdT=2C zavTVw6$08GKIi;={6kOZdtLWF>#3u6(nrtFSI6tz1?>}>zUR+e);^`%igat#P^@7F7RR`P3FHy5HPE7qbi1@r>`EruE=Vy(x_uTX_8lk5KJ+4ubldGw zY`0`0He^A*MYSDXypiq*R}@EVqTCU%5{9r-Fbg{5EMv$_ad<$Sf?VtY9fhS-f#hRc og&xFFz_h`zq;VJZ9fiFJ#N|*{HlRBgxPb6H3j;$t5Hm0U0D)R=i2wiq literal 0 HcmV?d00001