com.mongodb.internal.connection.tlschannel.NeedsTaskException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongo-java-driver Show documentation
Show all versions of mongo-java-driver Show documentation
The MongoDB Java Driver uber-artifact, containing mongodb-driver, mongodb-driver-core, and bson
/*
* Copyright 2008-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Original Work: MIT License, Copyright (c) [2015-2018] all contributors
* https://github.com/marianobarrios/tls-channel
*/
package com.mongodb.internal.connection.tlschannel;
/**
* This exception signals the caller that the operation could not continue
* because a CPU-intensive operation (typically a TLS handshaking) needs to be
* executed and the {@link TlsChannel} is configured to not run tasks.
* This allows the application to run these tasks in some other threads, in
* order to not slow the selection loop. The method that threw the exception
* should be retried once the task supplied by {@link #getTask()} is executed
* and finished.
*
* This exception is akin to the SSL_ERROR_WANT_ASYNC error code used by OpenSSL
* (but note that in OpenSSL, the task is executed by the library, while with
* the {@link TlsChannel}, the calling code is responsible for the
* execution).
*
* @see
* OpenSSL error documentation
*/
public class NeedsTaskException extends TlsChannelFlowControlException {
private static final long serialVersionUID = -7869448883241411803L;
private Runnable task;
public NeedsTaskException(final Runnable task) {
this.task = task;
}
public Runnable getTask() {
return task;
}
}