-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue nebula-plugins#78 Fixed thread-safety for DependencyLockProvide…
…r, IvyRecommendationProvider, PropertyFileRecommendationProvider
- Loading branch information
Buerenheide, Christian
committed
Dec 19, 2017
1 parent
76f5324
commit 2ef2639
Showing
3 changed files
with
53 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,33 @@ package netflix.nebula.dependency.recommender.provider | |
import org.gradle.api.Project | ||
|
||
class IvyRecommendationProvider extends FileBasedRecommendationProvider { | ||
Map<String, String> versionsByCoord | ||
volatile Map<String, String> versionsByCoord | ||
|
||
IvyRecommendationProvider(Project p) { super(p) } | ||
|
||
@Override | ||
String getVersion(String org, String name) throws Exception { | ||
if (versionsByCoord == null) { | ||
versionsByCoord = [:] | ||
getInput().withCloseable { | ||
def ivy = new XmlSlurper().parse(it) | ||
ivy.dependencies.dependency.each { d -> | ||
versionsByCoord.put("${[email protected]()}:${[email protected]()}".toString(), "${[email protected]()}") | ||
|
||
Map<String, String> tmpResult = versionsByCoord | ||
|
||
if (tmpResult == null) { | ||
synchronized (this) { | ||
tmpResult = versionsByCoord | ||
if (tmpResult == null) { | ||
tmpResult = [:] | ||
getInput().withCloseable { | ||
def ivy = new XmlSlurper().parse(it) | ||
ivy.dependencies.dependency.each { d -> | ||
tmpResult.put("${[email protected]()}:${[email protected]()}".toString(), "${[email protected]()}") | ||
} | ||
} | ||
versionsByCoord = tmpResult | ||
} | ||
} | ||
} | ||
return versionsByCoord["$org:$name".toString()] | ||
return tmpResult["$org:$name".toString()] | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public InputStreamProvider setModule(Object dependencyNotation) { | ||
if (dependencyNotation == null) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters