mirror of https://github.com/apache/lucene.git
LUCENE-10419: fix rat thread safety bug.
This commit is contained in:
parent
a861ff8df2
commit
8aa4763070
|
@ -117,6 +117,7 @@ configure(project(':lucene:benchmark')) {
|
||||||
|
|
||||||
@CacheableTask
|
@CacheableTask
|
||||||
class ValidateSourcePatternsTask extends DefaultTask {
|
class ValidateSourcePatternsTask extends DefaultTask {
|
||||||
|
private static final Object ratBug = new Object()
|
||||||
private ProgressLoggerFactory progressLoggerFactory
|
private ProgressLoggerFactory progressLoggerFactory
|
||||||
|
|
||||||
@InputFiles
|
@InputFiles
|
||||||
|
@ -165,7 +166,6 @@ class ValidateSourcePatternsTask extends DefaultTask {
|
||||||
def javaCommentPattern = ~$/(?sm)^\Q/*\E(.*?)\Q*/\E/$;
|
def javaCommentPattern = ~$/(?sm)^\Q/*\E(.*?)\Q*/\E/$;
|
||||||
def xmlCommentPattern = ~$/(?sm)\Q<!--\E(.*?)\Q-->\E/$;
|
def xmlCommentPattern = ~$/(?sm)\Q<!--\E(.*?)\Q-->\E/$;
|
||||||
def lineSplitter = ~$/[\r\n]+/$;
|
def lineSplitter = ~$/[\r\n]+/$;
|
||||||
def licenseMatcher = Defaults.createDefaultMatcher();
|
|
||||||
def validLoggerPattern = ~$/(?s)\b(private\s|static\s|final\s){3}+\s*Logger\s+\p{javaJavaIdentifierStart}+\s+=\s+\QLoggerFactory.getLogger(MethodHandles.lookup().lookupClass());\E/$;
|
def validLoggerPattern = ~$/(?s)\b(private\s|static\s|final\s){3}+\s*Logger\s+\p{javaJavaIdentifierStart}+\s+=\s+\QLoggerFactory.getLogger(MethodHandles.lookup().lookupClass());\E/$;
|
||||||
def validLoggerNamePattern = ~$/(?s)\b(private\s|static\s|final\s){3}+\s*Logger\s+log+\s+=\s+\QLoggerFactory.getLogger(MethodHandles.lookup().lookupClass());\E/$;
|
def validLoggerNamePattern = ~$/(?s)\b(private\s|static\s|final\s){3}+\s*Logger\s+log+\s+=\s+\QLoggerFactory.getLogger(MethodHandles.lookup().lookupClass());\E/$;
|
||||||
def packagePattern = ~$/(?m)^\s*package\s+org\.apache.*;/$;
|
def packagePattern = ~$/(?m)^\s*package\s+org\.apache.*;/$;
|
||||||
|
@ -173,8 +173,12 @@ class ValidateSourcePatternsTask extends DefaultTask {
|
||||||
def validSPINameJavadocTag = ~$/(?s)\s*\*\s*@lucene\.spi\s+\{@value #NAME\}/$;
|
def validSPINameJavadocTag = ~$/(?s)\s*\*\s*@lucene\.spi\s+\{@value #NAME\}/$;
|
||||||
|
|
||||||
def isLicense = { matcher, ratDocument ->
|
def isLicense = { matcher, ratDocument ->
|
||||||
licenseMatcher.reset()
|
// See LUCENE-10419 - rat is not thread safe.
|
||||||
return lineSplitter.split(matcher.group(1)).any { licenseMatcher.match(ratDocument, it) }
|
synchronized (ratBug) {
|
||||||
|
def licenseMatcher = Defaults.createDefaultMatcher();
|
||||||
|
licenseMatcher.reset()
|
||||||
|
return lineSplitter.split(matcher.group(1)).any { licenseMatcher.match(ratDocument, it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def checkLicenseHeaderPrecedes = { f, description, contentPattern, commentPattern, text, ratDocument ->
|
def checkLicenseHeaderPrecedes = { f, description, contentPattern, commentPattern, text, ratDocument ->
|
||||||
|
|
Loading…
Reference in New Issue