diff --git a/java/java-tests/testData/ide/plugins/pluginDescriptor/family/META-INF/brian.xml b/java/java-tests/testData/ide/plugins/pluginDescriptor/family/META-INF/brian.xml
new file mode 100644
index 000000000000..affe2a025c85
--- /dev/null
+++ b/java/java-tests/testData/ide/plugins/pluginDescriptor/family/META-INF/brian.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/java/java-tests/testData/ide/plugins/pluginDescriptor/family/META-INF/plugin.xml b/java/java-tests/testData/ide/plugins/pluginDescriptor/family/META-INF/plugin.xml
new file mode 100644
index 000000000000..18772c54c4dd
--- /dev/null
+++ b/java/java-tests/testData/ide/plugins/pluginDescriptor/family/META-INF/plugin.xml
@@ -0,0 +1,4 @@
+
+ griffins
+ pets.allowed
+
\ No newline at end of file
diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
index bd7ce82e0f8e..f3279c0e25cd 100644
--- a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
+++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
@@ -633,15 +633,14 @@ public class PluginManagerCore {
try {
IdeaPluginDescriptorImpl descriptor = new IdeaPluginDescriptorImpl(notNull(pluginPath, file), bundled);
descriptor.readExternal(descriptorFile.toURI().toURL());
- validateDescriptor(descriptor);
return descriptor;
}
- catch (XmlSerializationException e) {
- getLogger().info("Cannot load " + file, e);
+ catch (XmlSerializationException | InvalidDataException e) {
+ getLogger().info("Cannot load " + descriptorFile, e);
prepareLoadingPluginsErrorMessage(singletonList("File '" + file.getName() + "' contains invalid plugin descriptor."));
}
catch (Throwable e) {
- getLogger().info("Cannot load " + file, e);
+ getLogger().info("Cannot load " + descriptorFile, e);
}
}
@@ -670,33 +669,21 @@ public class PluginManagerCore {
Document document = JDOMUtil.loadDocument(zipFile.getInputStream(entry));
IdeaPluginDescriptorImpl descriptor = new IdeaPluginDescriptorImpl(notNull(pluginPath, file), bundled);
descriptor.readExternal(document, jarURL, pathResolver);
- validateDescriptor(descriptor);
context.myLastZipFileContainingDescriptor = file;
return descriptor;
}
}
- catch (XmlSerializationException e) {
- getLogger().info("Cannot load " + file, e);
+ catch (XmlSerializationException | InvalidDataException e) {
+ getLogger().info("Cannot load " + file + "!/META-INF/" + fileName, e);
prepareLoadingPluginsErrorMessage(singletonList("File '" + file.getName() + "' contains invalid plugin descriptor."));
}
catch (Throwable e) {
- getLogger().info("Cannot load " + file, e);
+ getLogger().info("Cannot load " + file + "!/META-INF/" + fileName, e);
}
return null;
}
- private static void validateDescriptor(IdeaPluginDescriptorImpl descriptor) {
- /*
- if (descriptor.getPluginId() == null) {
- throw new IllegalStateException("Skipped plugin with null ID: " + descriptor);
- }
- else if (descriptor.getName() == null) {
- throw new IllegalStateException("Skipped plugin without name: " + descriptor);
- }
- */
- }
-
@Nullable
public static IdeaPluginDescriptorImpl loadDescriptor(@NotNull File file, @NotNull String fileName) {
return loadDescriptor(file, fileName, false);
@@ -780,6 +767,12 @@ public class PluginManagerCore {
}
if (descriptor != null) {
+ if (PLUGIN_XML.equals(pathName) && (descriptor.getPluginId() == null || descriptor.getName() == null)) {
+ getLogger().info("Cannot load descriptor from " + file + ": ID or name missing");
+ prepareLoadingPluginsErrorMessage(singletonList("'" + file.getName() + "' contains invalid plugin descriptor."));
+ return null;
+ }
+
resolveOptionalDescriptors(pathName, descriptor, (@SystemIndependent String optPathName) -> {
IdeaPluginDescriptorImpl optionalDescriptor = null;
if (context.myLastZipFileContainingDescriptor != null) { // try last file that had the descriptor that worked
@@ -1491,11 +1484,7 @@ public class PluginManagerCore {
@NotNull
public static Logger getLogger() {
- return LoggerHolder.ourLogger;
- }
-
- private static class LoggerHolder {
- private static final Logger ourLogger = Logger.getInstance("#com.intellij.ide.plugins.PluginManager");
+ return Logger.getInstance("#com.intellij.ide.plugins.PluginManager");
}
static class EssentialPluginMissingException extends RuntimeException {
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginDescriptorTest.java b/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginDescriptorTest.java
index ddedce14db98..55875424d630 100644
--- a/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginDescriptorTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/ide/plugins/PluginDescriptorTest.java
@@ -30,6 +30,13 @@ public class PluginDescriptorTest {
assertEquals("ASP", descriptor.getName());
}
+ @Test
+ public void testOptionalDescriptors() {
+ IdeaPluginDescriptorImpl descriptor = loadDescriptor("family");
+ assertNotNull(descriptor);
+ assertEquals(1, descriptor.getOptionalDescriptors().size());
+ }
+
@Test
public void testMalformedDescriptor() {
assertNull(loadDescriptor("malformed"));
@@ -118,8 +125,14 @@ public class PluginDescriptorTest {
}
private static IdeaPluginDescriptorImpl loadDescriptor(String dirName) {
- File dir = new File(getTestDataPath(), dirName);
- assertTrue(dir + " does not exist", dir.exists());
- return PluginManagerCore.loadDescriptor(dir, PluginManagerCore.PLUGIN_XML);
+ try {
+ File dir = new File(getTestDataPath(), dirName);
+ assertTrue(dir + " does not exist", dir.exists());
+ return PluginManagerCore.loadDescriptor(dir, PluginManagerCore.PLUGIN_XML);
+ }
+ catch (AssertionError e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("Problems found loading plugins"));
+ return null;
+ }
}
}
\ No newline at end of file