Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<charset>UTF-8</charset>
<!-- The imported OpenSearch tree documents itself only partially, which is upstream's
business, not a defect here. Check syntax, HTML, accessibility and references -
the groups that catch real breakage - and leave completeness alone. -->
<doclint>all,-missing</doclint>
<!-- Block tags the forked OpenSearch sources carry; javadoc rejects them unless declared. -->
<tags>
<tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ protected static List<String> readStringArray(final XContentParser parser) throw
* Internal container holding the parsed fields of a resolved index entry.
*/
protected static class ResolvedIndexData {
/**
* Creates a new ResolvedIndexData.
*/
protected ResolvedIndexData() {
}

String name;
List<String> aliases = new ArrayList<>();
List<String> attributes = new ArrayList<>();
Expand All @@ -263,6 +269,12 @@ protected static class ResolvedIndexData {
* Internal container holding the parsed fields of a resolved alias entry.
*/
protected static class ResolvedAliasData {
/**
* Creates a new ResolvedAliasData.
*/
protected ResolvedAliasData() {
}

String name;
List<String> indices = new ArrayList<>();
}
Expand All @@ -271,6 +283,12 @@ protected static class ResolvedAliasData {
* Internal container holding the parsed fields of a resolved data stream entry.
*/
protected static class ResolvedDataStreamData {
/**
* Creates a new ResolvedDataStreamData.
*/
protected ResolvedDataStreamData() {
}

String name;
List<String> backingIndices = new ArrayList<>();
String timestampField;
Expand Down
60 changes: 60 additions & 0 deletions src/main/java/org/codelibs/fesen/opensearch/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,38 @@ public class Build {
*/
public enum Type {

/**
* The DEB value.
*/
DEB("deb"),
/**
* The DOCKER value.
*/
DOCKER("docker"),
/**
* The RPM value.
*/
RPM("rpm"),
/**
* The TAR value.
*/
TAR("tar"),
/**
* The ZIP value.
*/
ZIP("zip"),
/**
* The UNKNOWN value.
*/
UNKNOWN("unknown");

final String displayName;

/**
* Returns the display name.
*
* @return the display name
*/
public String displayName() {
return displayName;
}
Expand All @@ -78,6 +101,13 @@ public String displayName() {
this.displayName = displayName;
}

/**
* Creates an instance from display name.
*
* @param displayName the display name
* @param strict the strict
* @return the new display name
*/
public static Type fromDisplayName(final String displayName, final boolean strict) {
switch (displayName) {
case "deb":
Expand Down Expand Up @@ -189,6 +219,16 @@ static URL getOpenSearchCodeSourceLocation() {
private final String version;
private final String distribution;

/**
* Creates a new Build.
*
* @param type the type
* @param hash the hash
* @param date the date
* @param isSnapshot the is snapshot
* @param version the version
* @param distribution the distribution
*/
public Build(final Type type, final String hash, final String date, boolean isSnapshot, String version, String distribution) {
this.type = type;
this.hash = hash;
Expand All @@ -198,10 +238,20 @@ public Build(final Type type, final String hash, final String date, boolean isSn
this.distribution = distribution;
}

/**
* Returns the hash.
*
* @return the hash
*/
public String hash() {
return hash;
}

/**
* Returns the date.
*
* @return the date
*/
public String date() {
return date;
}
Expand All @@ -227,10 +277,20 @@ public String getQualifiedVersion() {
return version;
}

/**
* Returns the type.
*
* @return the type
*/
public Type type() {
return type;
}

/**
* Returns the snapshot flag.
*
* @return the snapshot flag
*/
public boolean isSnapshot() {
return isSnapshot;
}
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/org/codelibs/fesen/opensearch/ExceptionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ private ErrorMessages() {
// utility class: no ctor
private ExceptionsHelper() {}

/**
* Returns the status.
*
* @param t the t
* @return the status
*/
public static RestStatus status(Throwable t) {
return switch (t) {
case OpenSearchException ose -> ose.status();
Expand All @@ -122,6 +128,12 @@ public static RestStatus status(Throwable t) {
};
}

/**
* Returns the summary message.
*
* @param t the t
* @return the summary message
*/
public static String summaryMessage(Throwable t) {
return switch (t) {
case OpenSearchException ose -> getExceptionSimpleClassName(t) + "[" + ose.getMessage() + "]";
Expand All @@ -133,6 +145,12 @@ public static String summaryMessage(Throwable t) {
};
}

/**
* Unwraps the cause.
*
* @param t the t
* @return this instance
*/
public static Throwable unwrapCause(Throwable t) {
int counter = 0;
Throwable result = t;
Expand Down Expand Up @@ -173,6 +191,8 @@ public static Throwable unwrapToOpenSearchException(Throwable e) {
}

/**
* @param t the t
* @return the detailed message
* @deprecated Don't swallow exceptions, allow them to propagate.
*/
@Deprecated
Expand Down Expand Up @@ -201,20 +221,35 @@ public static String detailedMessage(Throwable t) {
}
}

/**
* Returns the stack trace.
*
* @param e the exception
* @return the stack trace
*/
public static String stackTrace(Throwable e) {
StringWriter stackTraceStringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stackTraceStringWriter);
e.printStackTrace(printWriter);
return stackTraceStringWriter.toString();
}

/**
* Formats the stack trace.
*
* @param stackTrace the stack trace
* @return this instance
*/
public static String formatStackTrace(final StackTraceElement[] stackTrace) {
return Arrays.stream(stackTrace).skip(1).map(e -> "\tat " + e).collect(Collectors.joining("\n"));
}

/**
* Throws a runtime exception with all given exceptions added as suppressed.
* If the given list is empty no exception is thrown
*
* @param <T> the element type
* @param exceptions the exceptions
*/
public static <T extends Throwable> void maybeThrowRuntimeAndSuppress(List<T> exceptions) {
T main = null;
Expand All @@ -226,6 +261,14 @@ public static <T extends Throwable> void maybeThrowRuntimeAndSuppress(List<T> ex
}
}

/**
* Returns the use or suppress.
*
* @param <T> the element type
* @param first the first
* @param second the second
* @return the use or suppress
*/
public static <T extends Throwable> T useOrSuppress(T first, T second) {
if (first == null) {
return second;
Expand Down Expand Up @@ -268,6 +311,9 @@ public static Throwable unwrap(Throwable t, Class<?>... clazzes) {

/**
* Throws the specified exception. If null if specified then <code>true</code> is returned.
*
* @param e the exception
* @return the re throw if not null
*/
public static boolean reThrowIfNotNull(@Nullable Throwable e) {
if (e != null) {
Expand All @@ -280,6 +326,14 @@ public static boolean reThrowIfNotNull(@Nullable Throwable e) {
return true;
}

/**
* Unwraps the causes and suppressed.
*
* @param <T> the element type
* @param cause the cause
* @param predicate the predicate
* @return this instance
*/
@SuppressWarnings("unchecked")
public static <T extends Throwable> Optional<T> unwrapCausesAndSuppressed(Throwable cause, Predicate<Throwable> predicate) {
if (predicate.test(cause)) {
Expand Down Expand Up @@ -317,6 +371,9 @@ public static Optional<Error> maybeError(final Throwable cause) {

/**
* Deduplicate the failures by exception message and index.
*
* @param failures the failures
* @return the group by
*/
public static ShardOperationFailedException[] groupBy(ShardOperationFailedException[] failures) {
List<ShardOperationFailedException> uniqueFailures = new ArrayList<>();
Expand Down
Loading
Loading