Skip to content

Commit

Permalink
Merge pull request #57 from robot9xvt/patch-1
Browse files Browse the repository at this point in the history
Fix issue with ContextClassLoader with jaxb when scan cloc.xml file
  • Loading branch information
ivaivalous authored Feb 2, 2020
2 parents db38837 + 1d0a6fe commit e3edcd2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public SloccountReport parseFiles(java.io.File[] files) {
}

private void parse(java.io.File file, SloccountReportInterface report) throws IOException {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
// Try cloc report file first, XML has precise structure
ClocReport.parse(file).toSloccountReport(report, commentIsCode);
} catch (JAXBException e) {
Expand All @@ -95,6 +97,8 @@ private void parse(java.io.File file, SloccountReportInterface report) throws IO
in.close();
}
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}

Expand Down Expand Up @@ -140,4 +144,4 @@ private void parseLine(String line, SloccountReportInterface report){

report.add(filePath, languageName, moduleName, lineCount, 0);
}
}
}

0 comments on commit e3edcd2

Please sign in to comment.