Invalid versions don't cause IDE to crash and exit any more. They are reported and contributions are considered missing version. Fixes #2926

This commit is contained in:
Federico Fissore 2015-04-07 12:05:05 +02:00
parent 8020c0d733
commit b9a90f69d5
4 changed files with 19 additions and 8 deletions

View File

@ -8,15 +8,20 @@ public class VersionHelper {
if (ver == null) { if (ver == null) {
return null; return null;
} }
String[] verParts = ver.split("\\."); try {
if (verParts.length < 3) { String[] verParts = ver.split("\\.");
if (verParts.length == 2) { if (verParts.length < 3) {
return Version.forIntegers(Integer.valueOf(verParts[0]), Integer.valueOf(verParts[1])); if (verParts.length == 2) {
return Version.forIntegers(Integer.valueOf(verParts[0]), Integer.valueOf(verParts[1]));
} else {
return Version.forIntegers(Integer.valueOf(verParts[0]));
}
} else { } else {
return Version.forIntegers(Integer.valueOf(verParts[0])); return Version.valueOf(ver);
} }
} else { } catch (Exception e) {
return Version.valueOf(ver); System.err.println("Invalid version found: " + ver);
return null;
} }
} }

View File

@ -141,7 +141,7 @@ public abstract class ContributedLibrary extends DownloadableContribution {
String thisVersion = getParsedVersion(); String thisVersion = getParsedVersion();
String otherVersion = ((ContributedLibrary) obj).getParsedVersion(); String otherVersion = ((ContributedLibrary) obj).getParsedVersion();
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion.equals(otherVersion); boolean versionEquals = thisVersion == otherVersion || (thisVersion != null && otherVersion != null && thisVersion.equals(otherVersion));
String thisName = getName(); String thisName = getName();
String otherName = ((ContributedLibrary) obj).getName(); String otherName = ((ContributedLibrary) obj).getName();

View File

@ -48,6 +48,9 @@ public abstract class LibrariesIndex {
} }
public ContributedLibrary find(String name, String version) { public ContributedLibrary find(String name, String version) {
if (name == null || version == null) {
return null;
}
for (ContributedLibrary lib : find(name)) { for (ContributedLibrary lib : find(name)) {
if (version.equals(lib.getParsedVersion())) { if (version.equals(lib.getParsedVersion())) {
return lib; return lib;

View File

@ -47,6 +47,9 @@ public abstract class ContributedPackage {
public abstract List<ContributedTool> getTools(); public abstract List<ContributedTool> getTools();
public ContributedPlatform findPlatform(String architecture, String version) { public ContributedPlatform findPlatform(String architecture, String version) {
if (architecture == null || version == null) {
return null;
}
for (ContributedPlatform platform : getPlatforms()) { for (ContributedPlatform platform : getPlatforms()) {
if (platform.getArchitecture().equals(architecture) && version.equals(platform.getParsedVersion())) if (platform.getArchitecture().equals(architecture) && version.equals(platform.getParsedVersion()))
return platform; return platform;