Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-response-code
Browse files Browse the repository at this point in the history
  • Loading branch information
imRishN committed Nov 18, 2022
2 parents eb35a3d + 7aa615f commit 7e7aa43
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 331 deletions.
1 change: 1 addition & 0 deletions .ci/bwcVersions
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ BWC_VERSION:
- "2.3.0"
- "2.3.1"
- "2.4.0"
- "2.4.1"
- "2.5.0"
31 changes: 14 additions & 17 deletions .github/workflows/gradle-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ jobs:
if: ${{ github.event_name == 'pull_request_target' && env.result != 'SUCCESS' }}
run: |
TEST_FAILURES=`curl -s "${{ env.workflow_url }}/testReport/api/json?tree=suites\[cases\[status,className,name\]\]" | jq -r '.. | objects | select(.status=="FAILED",.status=="REGRESSION") | (.className + "." + .name)' | uniq -c | sort -n -r | head -n 10`
echo "test_failures<<EOF" >> $GITHUB_ENV
echo "$TEST_FAILURES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
if [[ "$TEST_FAILURES" != "" ]]
then
echo "test_failures<<EOF" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "* **TEST FAILURES:**" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "$TEST_FAILURES" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Create Comment Flaky
if: ${{ github.event_name == 'pull_request_target' && success() && env.result != 'SUCCESS' }}
Expand All @@ -92,16 +99,10 @@ jobs:
issue-number: ${{ env.pr_number }}
body: |
### Gradle Check (Jenkins) Run Completed with:
* **RESULT:** ${{ env.result }} :grey_exclamation:
* **FLAKY TEST FAILURES:**
The following tests failed but succeeded upon retry:
```
${{ env.test_failures }}
```
* **RESULT:** ${{ env.result }} :grey_exclamation: ${{ env.test_failures }}
* **URL:** ${{ env.workflow_url }}
* **CommitID:** ${{ env.pr_from_sha }}
Please examine the workflow log, locate, and copy-paste the failure below, then iterate to green.
Is the failure [a flaky test](https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#flaky-tests) unrelated to your change?
Please review all [flaky tests](https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#flaky-tests) that succeeded after retry and create an issue if one does not already exist to track the flaky failure.
- name: Create Comment Failure
if: ${{ github.event_name == 'pull_request_target' && failure() }}
Expand All @@ -110,12 +111,8 @@ jobs:
issue-number: ${{ env.pr_number }}
body: |
### Gradle Check (Jenkins) Run Completed with:
* **RESULT:** ${{ env.result }} :x:
* **FAILURES:**
```
${{ env.test_failures }}
```
* **RESULT:** ${{ env.result }} :x: ${{ env.test_failures }}
* **URL:** ${{ env.workflow_url }}
* **CommitID:** ${{ env.pr_from_sha }}
Please examine the workflow log, locate, and copy-paste the failure below, then iterate to green.
Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green.
Is the failure [a flaky test](https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#flaky-tests) unrelated to your change?
4 changes: 2 additions & 2 deletions server/src/main/java/org/opensearch/OpenSearchException.java
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ public static OpenSearchException[] guessRootCauses(Throwable t) {
* parsing exception because that is generally the most interesting
* exception to return to the user. If that exception is caused by
* an OpenSearchException we'd like to keep unwrapping because
* ElasticserachExceptions tend to contain useful information for
* the user.
* OpenSearchException instances tend to contain useful information
* for the user.
*/
Throwable cause = ex.getCause();
if (cause != null) {
Expand Down
1 change: 1 addition & 0 deletions server/src/main/java/org/opensearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
public static final Version V_2_3_0 = new Version(2030099, org.apache.lucene.util.Version.LUCENE_9_3_0);
public static final Version V_2_3_1 = new Version(2030199, org.apache.lucene.util.Version.LUCENE_9_3_0);
public static final Version V_2_4_0 = new Version(2040099, org.apache.lucene.util.Version.LUCENE_9_4_1);
public static final Version V_2_4_1 = new Version(2040199, org.apache.lucene.util.Version.LUCENE_9_4_1);
public static final Version V_2_5_0 = new Version(2050099, org.apache.lucene.util.Version.LUCENE_9_4_1);
public static final Version V_3_0_0 = new Version(3000099, org.apache.lucene.util.Version.LUCENE_9_5_0);
public static final Version CURRENT = V_3_0_0;
Expand Down
19 changes: 0 additions & 19 deletions server/src/main/java/org/opensearch/common/Classes.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@
*/
public class Classes {

/**
* The package separator character '.'
*/
private static final char PACKAGE_SEPARATOR = '.';

/**
* Determine the name of the package of the given class:
* e.g. "java.lang" for the <code>java.lang.String</code> class.
*
* @param clazz the class
* @return the package name, or the empty String if the class
* is defined in the default package
*/
public static String getPackageName(Class<?> clazz) {
String className = clazz.getName();
int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
return (lastDotIndex != -1 ? className.substring(0, lastDotIndex) : "");
}

public static boolean isInnerClass(Class<?> clazz) {
return !Modifier.isStatic(clazz.getModifiers()) && clazz.getEnclosingClass() != null;
}
Expand Down

This file was deleted.

32 changes: 0 additions & 32 deletions server/src/main/java/org/opensearch/common/Numbers.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,6 @@ public static long bytesToLong(BytesRef bytes) {
return (((long) high) << 32) | (low & 0x0ffffffffL);
}

public static byte[] intToBytes(int val) {
byte[] arr = new byte[4];
arr[0] = (byte) (val >>> 24);
arr[1] = (byte) (val >>> 16);
arr[2] = (byte) (val >>> 8);
arr[3] = (byte) (val);
return arr;
}

/**
* Converts an int to a byte array.
*
* @param val The int to convert to a byte array
* @return The byte array converted
*/
public static byte[] shortToBytes(int val) {
byte[] arr = new byte[2];
arr[0] = (byte) (val >>> 8);
arr[1] = (byte) (val);
return arr;
}

/**
* Converts a long to a byte array.
*
Expand All @@ -98,16 +76,6 @@ public static byte[] longToBytes(long val) {
return arr;
}

/**
* Converts a double to a byte array.
*
* @param val The double to convert to a byte array
* @return The byte array converted
*/
public static byte[] doubleToBytes(double val) {
return longToBytes(Double.doubleToRawLongBits(val));
}

/** Returns true if value is neither NaN nor infinite. */
public static boolean isValidDouble(double value) {
if (Double.isNaN(value) || Double.isInfinite(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

package org.opensearch.common;

import org.opensearch.common.settings.SecureString;

import java.util.Arrays;
import java.util.Base64;
import java.util.Random;

Expand All @@ -54,27 +51,6 @@ public String getBase64UUID() {
return getBase64UUID(SecureRandomHolder.INSTANCE);
}

/**
* Returns a Base64 encoded {@link SecureString} of a Version 4.0 compatible UUID
* as defined here: http://www.ietf.org/rfc/rfc4122.txt
*/
public SecureString getBase64UUIDSecureString() {
byte[] uuidBytes = null;
byte[] encodedBytes = null;
try {
uuidBytes = getUUIDBytes(SecureRandomHolder.INSTANCE);
encodedBytes = Base64.getUrlEncoder().withoutPadding().encode(uuidBytes);
return new SecureString(CharArrays.utf8BytesToChars(encodedBytes));
} finally {
if (uuidBytes != null) {
Arrays.fill(uuidBytes, (byte) 0);
}
if (encodedBytes != null) {
Arrays.fill(encodedBytes, (byte) 0);
}
}
}

/**
* Returns a Base64 encoded version of a Version 4.0 compatible UUID
* randomly initialized by the given {@link java.util.Random} instance
Expand Down
67 changes: 1 addition & 66 deletions server/src/main/java/org/opensearch/common/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,67 +80,6 @@ public static void spaceify(int spaces, String from, StringBuilder to) throws Ex
}
}

/**
* Splits a backslash escaped string on the separator.
* <p>
* Current backslash escaping supported:
* <br> \n \t \r \b \f are escaped the same as a Java String
* <br> Other characters following a backslash are produced verbatim (\c =&gt; c)
*
* @param s the string to split
* @param separator the separator to split on
* @param decode decode backslash escaping
*/
public static List<String> splitSmart(String s, String separator, boolean decode) {
ArrayList<String> lst = new ArrayList<>(2);
StringBuilder sb = new StringBuilder();
int pos = 0, end = s.length();
while (pos < end) {
if (s.startsWith(separator, pos)) {
if (sb.length() > 0) {
lst.add(sb.toString());
sb = new StringBuilder();
}
pos += separator.length();
continue;
}

char ch = s.charAt(pos++);
if (ch == '\\') {
if (!decode) sb.append(ch);
if (pos >= end) break; // ERROR, or let it go?
ch = s.charAt(pos++);
if (decode) {
switch (ch) {
case 'n':
ch = '\n';
break;
case 't':
ch = '\t';
break;
case 'r':
ch = '\r';
break;
case 'b':
ch = '\b';
break;
case 'f':
ch = '\f';
break;
}
}
}

sb.append(ch);
}

if (sb.length() > 0) {
lst.add(sb.toString());
}

return lst;
}

// ---------------------------------------------------------------------
// General convenience methods for working with Strings
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -303,7 +242,7 @@ public static String replace(String inString, String oldPattern, String newPatte
// the index of an occurrence we've found, or -1
int patLen = oldPattern.length();
while (index >= 0) {
sb.append(inString.substring(pos, index));
sb.append(inString, pos, index);
sb.append(newPattern);
pos = index + patLen;
index = inString.indexOf(oldPattern, pos);
Expand Down Expand Up @@ -875,10 +814,6 @@ public static boolean isNullOrEmpty(@Nullable String s) {
return s == null || s.isEmpty();
}

public static String coalesceToEmpty(@Nullable String s) {
return s == null ? "" : s;
}

public static String padStart(String s, int minimumLength, char c) {
if (s == null) {
throw new NullPointerException("s");
Expand Down
Loading

0 comments on commit 7e7aa43

Please sign in to comment.