Skip to content

Commit

Permalink
Suppress this-escape warning for JDK21 (elastic#101519)
Browse files Browse the repository at this point in the history
* Suppress this-escape warning for JDK21

* add suppression to all ctors in esql Lexer & Parser
  • Loading branch information
benwtrent authored Oct 31, 2023
1 parent 3a087e4 commit 1722c0a
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class AbstractInstrument<T> implements Instrument {
private final String description;
private final String unit;

@SuppressWarnings("this-escape")
public AbstractInstrument(Meter meter, String name, String description, String unit) {
this.name = Objects.requireNonNull(name);
this.description = Objects.requireNonNull(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ public Clusters(int total, int successful, int skipped) {
this.clusterInfo = Collections.emptyMap(); // will never be used if created from this constructor
}

@SuppressWarnings("this-escape")
public Clusters(StreamInput in) throws IOException {
this.total = in.readVInt();
int successfulTemp = in.readVInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected HandledTransportAction(
this(actionName, true, transportService, actionFilters, requestReader, executor);
}

@SuppressWarnings("this-escape")
protected HandledTransportAction(
String actionName,
boolean canTripCircuitBreaker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected TransportNodesAction(
* @deprecated Use the local-only constructor instead.
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("this-escape")
protected TransportNodesAction(
String actionName,
ThreadPool threadPool,
Expand Down
17 changes: 17 additions & 0 deletions x-pack/plugin/esql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,23 @@ tasks.register("regen") {
ant.replaceregexp(match: '\t', flags: 'g', replace: ' ', encoding: 'UTF-8') {
fileset(dir: outputPath, includes: 'EsqlBase*.java')
}
// suppress this-escape warnings on EsqlBaseLexer
ant.replaceregexp(
match: 'public EsqlBaseLexer',
replace: '@SuppressWarnings("this-escape")${line.separator} public EsqlBaseLexer',
encoding: 'UTF-8'
) {
fileset(dir: outputPath, includes: 'EsqlBaseLexer.java')
}
// suppress this-escape warnings on all internal EsqlBaseParser class constructores
ant.replaceregexp(
match: '([ ]+)public ([A-Z][a-z]+[a-z,A-Z]+\\()',
flags: 'g',
replace: '\\1@SuppressWarnings("this-escape")${line.separator}\\1public \\2',
encoding: 'UTF-8'
) {
fileset(dir: outputPath, includes: 'EsqlBaseParser.java')
}
// fix line endings
ant.fixcrlf(srcdir: outputPath, eol: 'lf') {
patternset(includes: 'EsqlBase*.java')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class DocVector extends AbstractVector implements Vector {

final DocBlock block;

@SuppressWarnings("this-escape")
public DocVector(IntVector shards, IntVector segments, IntVector docs, Boolean singleSegmentNonDecreasing) {
super(shards.getPositionCount(), null);
this.shards = shards;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public Vocabulary getVocabulary() {
}


@SuppressWarnings("this-escape")
public EsqlBaseLexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
Expand Down
Loading

0 comments on commit 1722c0a

Please sign in to comment.