File tree Expand file tree Collapse file tree 4 files changed +19
-8
lines changed
arduino-core/src/cc/arduino/contributions Expand file tree Collapse file tree 4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -8,15 +8,20 @@ public static Version valueOf(String ver) {
8
8
if (ver == null ) {
9
9
return null ;
10
10
}
11
- String [] verParts = ver .split ("\\ ." );
12
- if (verParts .length < 3 ) {
13
- if (verParts .length == 2 ) {
14
- return Version .forIntegers (Integer .valueOf (verParts [0 ]), Integer .valueOf (verParts [1 ]));
11
+ try {
12
+ String [] verParts = ver .split ("\\ ." );
13
+ if (verParts .length < 3 ) {
14
+ if (verParts .length == 2 ) {
15
+ return Version .forIntegers (Integer .valueOf (verParts [0 ]), Integer .valueOf (verParts [1 ]));
16
+ } else {
17
+ return Version .forIntegers (Integer .valueOf (verParts [0 ]));
18
+ }
15
19
} else {
16
- return Version .forIntegers ( Integer . valueOf (verParts [ 0 ]) );
20
+ return Version .valueOf (ver );
17
21
}
18
- } else {
19
- return Version .valueOf (ver );
22
+ } catch (Exception e ) {
23
+ System .err .println ("Invalid version found: " + ver );
24
+ return null ;
20
25
}
21
26
}
22
27
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ public boolean equals(Object obj) {
141
141
String thisVersion = getParsedVersion ();
142
142
String otherVersion = ((ContributedLibrary ) obj ).getParsedVersion ();
143
143
144
- boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion .equals (otherVersion );
144
+ boolean versionEquals = thisVersion == otherVersion || ( thisVersion != null && otherVersion != null && thisVersion .equals (otherVersion ) );
145
145
146
146
String thisName = getName ();
147
147
String otherName = ((ContributedLibrary ) obj ).getName ();
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ public boolean apply(ContributedLibrary contributedLibrary) {
48
48
}
49
49
50
50
public ContributedLibrary find (String name , String version ) {
51
+ if (name == null || version == null ) {
52
+ return null ;
53
+ }
51
54
for (ContributedLibrary lib : find (name )) {
52
55
if (version .equals (lib .getParsedVersion ())) {
53
56
return lib ;
Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ public abstract class ContributedPackage {
47
47
public abstract List <ContributedTool > getTools ();
48
48
49
49
public ContributedPlatform findPlatform (String architecture , String version ) {
50
+ if (architecture == null || version == null ) {
51
+ return null ;
52
+ }
50
53
for (ContributedPlatform platform : getPlatforms ()) {
51
54
if (platform .getArchitecture ().equals (architecture ) && version .equals (platform .getParsedVersion ()))
52
55
return platform ;
You can’t perform that action at this time.
0 commit comments