1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

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) {
return null;
}
String[] verParts = ver.split("\\.");
if (verParts.length < 3) {
if (verParts.length == 2) {
return Version.forIntegers(Integer.valueOf(verParts[0]), Integer.valueOf(verParts[1]));
try {
String[] verParts = ver.split("\\.");
if (verParts.length < 3) {
if (verParts.length == 2) {
return Version.forIntegers(Integer.valueOf(verParts[0]), Integer.valueOf(verParts[1]));
} else {
return Version.forIntegers(Integer.valueOf(verParts[0]));
}
} else {
return Version.forIntegers(Integer.valueOf(verParts[0]));
return Version.valueOf(ver);
}
} else {
return Version.valueOf(ver);
} catch (Exception e) {
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 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 otherName = ((ContributedLibrary) obj).getName();

View File

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

View File

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