Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gradle Precommit
name: Gradle PreCommit
on: [pull_request]

jobs:
Expand All @@ -21,8 +21,11 @@ jobs:
java-version: ${{ matrix.java }}
distribution: temurin
cache: gradle
- name: Run Gradle (precommit)
- name: Run Gradle (pre-commit)
continue-on-error: ${{ matrix.experimental }}
shell: bash
run: |
./gradlew javadoc precommit --parallel
run: ./gradlew javadoc precommit --parallel
- name: Run Gradle (sanity-check)
continue-on-error: ${{ matrix.experimental }}
shell: bash
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx8G
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add build-tooling to run in FIPS environment ([#18921](https://github.com/opensearch-project/OpenSearch/pull/18921))
- Add SMILE/CBOR/YAML document format support to Bulk GRPC endpoint ([#19744](https://github.com/opensearch-project/OpenSearch/pull/19744))
- Implement GRPC ConstantScoreQuery, FuzzyQuery, MatchBoolPrefixQuery, MatchPhrasePrefix, PrefixQuery, MatchQuery ([#19854](https://github.com/opensearch-project/OpenSearch/pull/19854))
- [rewrite] Add `GradleBestPractices` ([#19885](https://github.com/opensearch-project/OpenSearch/pull/19885))
- [prone] Add `error-prone.picnic.tech` featuring `RedundantStringConversion` ([#18791](https://github.com/opensearch-project/OpenSearch/pull/18791))

### Changed
- Faster `terms` query creation for `keyword` field with index and docValues enabled ([#19350](https://github.com/opensearch-project/OpenSearch/pull/19350))
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ plugins {
id "org.gradle.test-retry" version "1.6.2" apply false
id "test-report-aggregation"
id 'jacoco-report-aggregation'
id 'org.openrewrite.rewrite' version '7.19.0' apply false
id 'net.ltgt.errorprone' version '4.3.0' apply false
}

apply from: 'gradle/build-complete.gradle'
Expand All @@ -70,14 +72,12 @@ apply from: 'gradle/local-distribution.gradle'
apply from: 'gradle/run.gradle'
apply from: 'gradle/missing-javadoc.gradle'
apply from: 'gradle/code-coverage.gradle'
apply from: 'gradle/rewrite.gradle'

// Apply FIPS configuration to all projects
allprojects {
apply from: "$rootDir/gradle/error-prone.gradle"
apply from: "$rootDir/gradle/fips.gradle"
}

// common maven publishing configuration
allprojects {
// common maven publishing configuration
group = 'org.opensearch'
version = VersionProperties.getOpenSearch()
description = "OpenSearch subproject ${project.path}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private void runBuild(final String task, final boolean preserveFileTimestamps) {
.withProjectDir(getProjectDir())
.withArguments(
task,
"-Dtests.symbolic_link_preserving_tar_source=" + temporaryFolder.getRoot().toString(),
"-Dtests.symbolic_link_preserving_tar_source=" + temporaryFolder.getRoot(),
"-Dtests.symbolic_link_preserving_tar_preserve_file_timestamps=" + preserveFileTimestamps,
"-i"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private Path locateReaperJar() {

private void ensureReaperAlive() {
if (reaperProcess.isAlive() == false) {
throw new IllegalStateException("Reaper process died unexpectedly! Check the log at " + logFile.toString());
throw new IllegalStateException("Reaper process died unexpectedly! Check the log at " + logFile);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static Version fromString(final String s, final Mode mode) {

@Override
public String toString() {
return String.valueOf(getMajor()) + "." + String.valueOf(getMinor()) + "." + String.valueOf(getRevision());
return getMajor() + "." + getMinor() + "." + getRevision();
}

public boolean before(Version compareTo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ private static String distributionProjectName(OpenSearchDistribution distributio
switch (distribution.getType()) {
case ARCHIVE:
if (Version.fromString(distribution.getVersion()).onOrAfter("7.0.0")) {
projectName += platform.toString() + archString + (platform == OpenSearchDistribution.Platform.WINDOWS
? "-zip"
: "-tar");
projectName += platform + archString + (platform == OpenSearchDistribution.Platform.WINDOWS ? "-zip" : "-tar");
} else {
projectName = "zip";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void addLocalMavenRepo(Project project) {
publishing.repositories(repositories -> {
repositories.maven(maven -> {
maven.setName(STAGING_REPO);
maven.setUrl(buildDirectory.toString() + LOCAL_STAGING_REPO_PATH);
maven.setUrl(buildDirectory + LOCAL_STAGING_REPO_PATH);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void rule(Map<String, String> props) {
throw new InvalidUserDataException("Missing [pattern] for invalid pattern rule");
}
if (props.isEmpty() == false) {
throw new InvalidUserDataException("Unknown arguments for ForbiddenPatterns rule mapping: " + props.keySet().toString());
throw new InvalidUserDataException("Unknown arguments for ForbiddenPatterns rule mapping: " + props.keySet());
}
// TODO: fail if pattern contains a newline, it won't work (currently)
patterns.put(name, pattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ public void validate(InputChanges inputChanges) throws IOException {

private void maybeLogAndCollectError(Set<ValidationMessage> messages, Map<File, Set<String>> errors, File file) {
for (ValidationMessage message : messages) {
getLogger().error("[validate JSON][ERROR][{}][{}]", file.getName(), message.toString());
errors.computeIfAbsent(file, k -> new LinkedHashSet<>())
.add(String.format("%s: %s", file.getAbsolutePath(), message.toString()));
getLogger().error("[validate JSON][ERROR][{}][{}]", file.getName(), message);
errors.computeIfAbsent(file, k -> new LinkedHashSet<>()).add(String.format("%s: %s", file.getAbsolutePath(), message));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ private void logToProcessStdout(String message) {
}
Files.write(
stdoutFile,
("[" + Instant.now().toString() + "] [BUILD] " + message + "\n").getBytes(StandardCharsets.UTF_8),
("[" + Instant.now() + "] [BUILD] " + message + "\n").getBytes(StandardCharsets.UTF_8),
StandardOpenOption.CREATE,
StandardOpenOption.APPEND
);
Expand Down Expand Up @@ -707,7 +707,7 @@ public void extraConfigFile(String destination, File from, PropertyNormalization
@Override
public void extraJarFile(File from) {
if (from.toString().endsWith(".jar") == false) {
throw new IllegalArgumentException("extra jar file " + from.toString() + " doesn't appear to be a JAR");
throw new IllegalArgumentException("extra jar file " + from + " doesn't appear to be a JAR");
}
extraJarFiles.add(from);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static Request listTasks(ListTasksRequest listTaskRequest) {

static Request getTask(GetTaskRequest getTaskRequest) {
String endpoint = new EndpointBuilder().addPathPartAsIs("_tasks")
.addPathPartAsIs(getTaskRequest.getNodeId() + ":" + Long.toString(getTaskRequest.getTaskId()))
.addPathPartAsIs(getTaskRequest.getNodeId() + ":" + getTaskRequest.getTaskId())
.build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public String toString() {
if (h != 0) {
b.append(',');
}
b.append(headers.get(h).toString());
b.append(headers.get(h));
}
}
if (parameters.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static String buildMessage(Response response) throws IOException {
response.getRequestLine().getMethod(),
response.getHost(),
response.getRequestLine().getUri(),
response.getStatusLine().toString()
response.getStatusLine()
);

if (response.hasWarnings()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testTraceResponse() throws IOException, ParseException {
int statusCode = randomIntBetween(200, 599);
String reasonPhrase = "REASON";
StatusLine statusLine = new StatusLine(protocolVersion, statusCode, reasonPhrase);
String expected = "# " + statusLine.toString();
String expected = "# " + statusLine;
ClassicHttpResponse httpResponse = new BasicClassicHttpResponse(statusCode, reasonPhrase);
int numHeaders = randomIntBetween(0, 3);
for (int i = 0; i < numHeaders; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testResponseException() throws IOException, ParseException {
response.getRequestLine().getMethod(),
response.getHost(),
response.getRequestLine().getUri(),
response.getStatusLine().toString()
response.getStatusLine()
);

if (hasBody) {
Expand Down
4 changes: 2 additions & 2 deletions distribution/archives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import org.opensearch.gradle.JavaPackageType
import org.opensearch.gradle.JavaPackageType

apply plugin: 'opensearch.internal-distribution-archive-setup'

Expand Down Expand Up @@ -193,7 +193,7 @@ distribution_archives {
}
}


linuxPpc64leTar {
archiveClassifier = 'linux-ppc64le'
content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void executeCommand(Terminal terminal, OptionSet options, Environment

final Path file = getPath(argumentValues.get(i + 1));
if (Files.exists(file) == false) {
throw new UserException(ExitCodes.IO_ERROR, "File [" + file.toString() + "] does not exist");
throw new UserException(ExitCodes.IO_ERROR, "File [" + file + "] does not exist");
}

keyStore.setFile(setting, Files.readAllBytes(file));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private Path download(Terminal terminal, String pluginId, Path tmpDir, boolean i
List<String> plugins = checkMisspelledPlugin(pluginId);
String msg = "Unknown plugin " + pluginId;
if (plugins.isEmpty() == false) {
msg += ", did you mean " + (plugins.size() == 1 ? "[" + plugins.get(0) + "]" : "any of " + plugins.toString()) + "?";
msg += ", did you mean " + (plugins.size() == 1 ? "[" + plugins.get(0) + "]" : "any of " + plugins) + "?";
}
throw new UserException(ExitCodes.USAGE, msg);
}
Expand Down
42 changes: 42 additions & 0 deletions gradle/error-prone.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

apply plugin: 'net.ltgt.errorprone'

repositories {
mavenCentral()
}

configurations.all { // remove once in sync (collision resolved)
resolutionStrategy {
force 'com.google.code.findbugs:jsr305:3.0.2'
force 'com.google.errorprone:error_prone_annotations:2.42.0'
force 'com.google.errorprone:error_prone_core:2.42.0'
force 'com.google.guava:guava:33.4.0-jre'
force 'org.checkerframework:checker-qual:3.43.0'
}
}

dependencies {
errorprone('com.google.errorprone:error_prone_core:2.42.0')
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.25.0')
}

tasks.withType(JavaCompile).configureEach {
options.errorprone {
disableAllChecks = true // remove once complain.
disableWarningsInGeneratedCode = true
error('RedundantStringConversion')
if (!System.getenv().containsKey('CI') && System.getenv('IN_PLACE')?.toBoolean()) { // remove once complain.
errorproneArgs.addAll(
'-XepPatchLocation:IN_PLACE',
'-XepPatchChecks:RedundantStringConversion'
)
}
}
}
28 changes: 28 additions & 0 deletions gradle/rewrite.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

project.apply plugin: 'org.openrewrite.rewrite'

rewrite {
activeRecipe('org.opensearch.openrewrite.SanityCheck')
exclusion('**ActionListener.java')
exclusion('**SearchAfterIT.java')
exclusion('**StarTreeMapper.java')
exclusion('**package-info.java')
setExportDatatables(true)
setFailOnDryRunResults(true)
}

dependencies {
rewrite(platform('org.openrewrite.recipe:rewrite-recipe-bom:3.17.0'))
rewrite('org.openrewrite.recipe:rewrite-migrate-java:3.20.0')
rewrite('org.openrewrite.recipe:rewrite-java-security:3.19.2')
rewrite('org.openrewrite.recipe:rewrite-rewrite:0.14.1')
rewrite('org.openrewrite.recipe:rewrite-static-analysis:2.20.0')
rewrite('org.openrewrite.recipe:rewrite-third-party:0.30.0')
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=16f2b95838c1ddcf7242b1c39e7bbbb43c842f1f1a1a0dc4959b6d4d68abcac3
distributionSha256Sum=df67a32e86e3276d011735facb1535f64d0d88df84fa87521e90becc2d735444
4 changes: 2 additions & 2 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions gradlew.bat
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static void checkJavaVersion(String resource, String targetVersion) {
Version version = Version.parse(targetVersion);
if (Runtime.version().compareTo(version) < 0) {
throw new IllegalStateException(
String.format(Locale.ROOT, "%s requires Java %s:, your system: %s", resource, targetVersion, Runtime.version().toString())
String.format(Locale.ROOT, "%s requires Java %s:, your system: %s", resource, targetVersion, Runtime.version())
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public String toString() {
String hostString = publishAddress.address().getHostString();
String publishAddressString = publishAddress.toString();
if (InetAddresses.isInetAddress(hostString) == false) {
publishAddressString = hostString + '/' + publishAddress.toString();
publishAddressString = hostString + '/' + publishAddress;
}
builder.append(publishAddressString);
builder.append("}, bound_addresses ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ public void recordResourceUsageMetrics(ResourceUsageMetric... resourceUsageMetri
updateResourceUsageInfo(resourceStatsInfo, resourceUsageMetric);
} else {
throw new IllegalStateException(
"cannot update ["
+ resourceUsageMetric.getStats().toString()
+ "] entry as its not present current_stats_info:"
+ statsInfo
"cannot update [" + resourceUsageMetric.getStats() + "] entry as its not present current_stats_info:" + statsInfo
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public Value parse(XContentParser parser, Value value, Context context) throws I
StringBuilder message = new StringBuilder();
for (List<String> fieldset : exclusiveFields) {
if (fieldset.size() > 1) {
message.append("The following fields are not allowed together: ").append(fieldset.toString()).append(" ");
message.append("The following fields are not allowed together: ").append(fieldset).append(" ");
}
}
if (message.length() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public XContentLocation getLocation() {

@Override
public String getMessage() {
return location.map(l -> "[" + l.toString() + "] ").orElse("") + super.getMessage();
return location.map(l -> "[" + l + "] ").orElse("") + super.getMessage();
}
}
Loading
Loading