Skip to content

Commit

Permalink
remove no longer required classloading workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschmid committed Oct 25, 2019
1 parent d85840e commit 87325c1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void apply(Project project) {

private CpdExtension createExtension(Project project) {
CpdExtension extension = project.getExtensions().create("cpd", CpdExtension.class);
extension.setToolVersion("6.13.0");
extension.setToolVersion("6.14.0");
return extension;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,12 @@ private Properties createLanguageProperties(CpdWorkParameters config) {
}

private Language createLanguage(String language, Properties languageProperties) {
ClassLoader previousContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
// Workaround for https://github.com/pmd/pmd/issues/1788 as Gradle Worker API uses special classloader internally
Thread.currentThread().setContextClassLoader(CpdExecutor.class.getClassLoader());

Language result = LanguageFactory.createLanguage(language, languageProperties);
logger.info("Using CPD language class '{}' for checking duplicates.", result);
if (result instanceof AnyLanguage) {
logger.warn("Could not detect CPD language for '{}', using 'any' as fallback language.", language);
}
return result;
} finally {
Thread.currentThread().setContextClassLoader(previousContextClassLoader);
Language result = LanguageFactory.createLanguage(language, languageProperties);
logger.info("Using CPD language class '{}' for checking duplicates.", result);
if (result instanceof AnyLanguage) {
logger.warn("Could not detect CPD language for '{}', using 'any' as fallback language.", language);
}
return result;
}

private String asClickableFileUrl(File path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void generate(List<Report> reports, List<Match> matches) {

ClassLoader previousContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
// Workaround for Gradle Worker API uses special classloaders which Xerces dynamic implementation loading does not like
// Workaround for Gradle Worker API using special class loader which Xerces dynamic implementation loading does not like
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

renderer.render(matches.iterator(), fileWriter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CpdPluginTest extends BaseSpec {
!ext.skipLexicalErrors
ext.skipBlocks
ext.skipBlocksPattern == Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN
ext.toolVersion == '6.13.0'
ext.toolVersion == '6.14.0'
}

def "applying 'CpdPlugin' creates and configures configuration 'cpd'"() {
Expand Down

0 comments on commit 87325c1

Please sign in to comment.