Thanks to visit codestin.com
Credit goes to github.com

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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
public class SessionNotFoundException extends SpannerException {
private static final long serialVersionUID = -6395746612598975751L;

static boolean isSessionNotFoundMessage(String message) {
return message != null && message.contains("Session not found")
|| message.contains("Session was concurrently deleted");
}

/** Private constructor. Use {@link SpannerExceptionFactory} to create instances. */
SessionNotFoundException(
DoNotConstructDirectly token, @Nullable String message, @Nullable Throwable cause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private static SpannerException newSpannerExceptionPreformatted(
case ABORTED:
return new AbortedException(token, message, cause);
case NOT_FOUND:
if (message != null && message.contains("Session not found")) {
if (SessionNotFoundException.isSessionNotFoundMessage(message)) {
return new SessionNotFoundException(token, message, cause);
}
// Fall through to the default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

/** Default implementation of the Cloud Spanner interface. */
class SpannerImpl extends BaseService<SpannerOptions> implements Spanner {
private static final int MIN_BACKOFF_MS = 1000;
private static final int MAX_BACKOFF_MS = 32000;
static final int MIN_BACKOFF_MS = 250;
static final int MAX_BACKOFF_MS = 32000;

private static final Logger logger = Logger.getLogger(SpannerImpl.class.getName());
private static final Tracer tracer = Tracing.getTracer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
class SpannerRetryHelper {
private static final RetrySettings txRetrySettings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(1000L))
.setMaxRetryDelay(Duration.ofMillis(32000L))
.setInitialRetryDelay(Duration.ofMillis(SpannerImpl.MIN_BACKOFF_MS))
.setMaxRetryDelay(Duration.ofMillis(SpannerImpl.MAX_BACKOFF_MS))
.setTotalTimeout(Duration.ofMillis(Integer.MAX_VALUE))
.build();

Expand Down