Skip to content

Commit cf1554f

Browse files
committed
right semantics for backwards compatibility
1 parent e849096 commit cf1554f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.File;
2121
import java.io.IOException;
2222
import java.util.Arrays;
23-
import java.util.Collections;
2423
import java.util.Date;
2524
import java.util.HashSet;
2625
import java.util.Map;
@@ -181,15 +180,22 @@ public String[] listTokenValues(String token, Map<String, String> otherTokenValu
181180
return new String[0];
182181
}
183182

183+
// new API: provide the default implementation for third party implementations that lack it
184+
@SuppressWarnings("deprecation")
184185
public Set<Map<String, String>> listTokenValues(Set<String> tokens, Map<String, Object> criteria) {
185-
return Collections.emptySet();
186+
Set<Map<String, String>> tokenValueSet = new HashSet<>();
187+
for (Map<String, String> tokenValue :
188+
listTokenValues(tokens.toArray(new String[tokens.size()]), criteria)) {
189+
tokenValueSet.add(tokenValue);
190+
}
191+
return tokenValueSet;
186192
}
187193

194+
// old API
188195
@SuppressWarnings("unchecked")
189196
@Deprecated
190197
public Map<String, String>[] listTokenValues(String[] tokens, Map<String, Object> criteria) {
191-
Set<Map<String, String>> listTokenValues = listTokenValues(new HashSet<>(Arrays.asList(tokens)), criteria);
192-
return listTokenValues.toArray(new Map[listTokenValues.size()]);
198+
return new Map[0];
193199
}
194200

195201
public OrganisationEntry[] listOrganisations() {

src/java/org/apache/ivy/plugins/resolver/ChainResolver.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,21 @@ public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data
181181
}
182182

183183
@Override
184+
@SuppressWarnings("deprecation")
184185
public Set<Map<String, String>> listTokenValues(Set<String> tokens, Map<String, Object> criteria) {
185186
Set<Map<String, String>> result = new HashSet<>();
186187
for (DependencyResolver resolver : chain) {
187-
result.addAll(resolver.listTokenValues(tokens, new HashMap<>(criteria)));
188+
if (resolver instanceof AbstractResolver) {
189+
// new API
190+
result.addAll(resolver.listTokenValues(tokens, new HashMap<>(criteria)));
191+
} else {
192+
// old API
193+
for (Map<String, String> tokenValue :
194+
resolver.listTokenValues(tokens.toArray(new String[tokens.size()]), criteria)) {
195+
result.add(tokenValue);
196+
}
197+
}
188198
}
189-
190199
return result;
191200
}
192201

0 commit comments

Comments
 (0)