-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle index not found properly and return null in response
Signed-off-by: Aman Khare <[email protected]>
- Loading branch information
Aman Khare
committed
Mar 13, 2024
1 parent
d0d46ab
commit f05dfc2
Showing
4 changed files
with
89 additions
and
51 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
server/src/main/java/org/opensearch/gateway/BaseShardResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.opensearch.gateway; | ||
|
||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Base response class for shard response. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public abstract class BaseShardResponse { | ||
|
||
private final Exception storeException; | ||
|
||
public BaseShardResponse(Exception storeException) { | ||
this.storeException = storeException; | ||
} | ||
|
||
public abstract boolean isEmpty(); | ||
|
||
public Exception getException() { | ||
return storeException; | ||
} | ||
|
||
public BaseShardResponse(StreamInput in) throws IOException { | ||
if (in.readBoolean()) { | ||
storeException = in.readException(); | ||
} else { | ||
storeException = null; | ||
} | ||
} | ||
|
||
public void writeTo(StreamOutput out) throws IOException { | ||
if (storeException != null) { | ||
out.writeBoolean(true); | ||
out.writeException(storeException); | ||
} else { | ||
out.writeBoolean(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters