use of com.mongodb.MongoInternalException in project mongo-java-driver by mongodb.
the class DefaultConnectionPool method get.
@Override
public InternalConnection get(final long timeout, final TimeUnit timeUnit) {
try {
if (waitQueueSize.incrementAndGet() > settings.getMaxWaitQueueSize()) {
throw createWaitQueueFullException();
}
try {
connectionPoolListener.waitQueueEntered(new ConnectionPoolWaitQueueEnteredEvent(serverId, currentThread().getId()));
PooledConnection pooledConnection = getPooledConnection(timeout, timeUnit);
if (!pooledConnection.opened()) {
try {
pooledConnection.open();
} catch (Throwable t) {
pool.release(pooledConnection.wrapped, true);
if (t instanceof MongoException) {
throw (MongoException) t;
} else {
throw new MongoInternalException(t.toString(), t);
}
}
}
return pooledConnection;
} finally {
connectionPoolListener.waitQueueExited(new ConnectionPoolWaitQueueExitedEvent(serverId, currentThread().getId()));
}
} finally {
waitQueueSize.decrementAndGet();
}
}
use of com.mongodb.MongoInternalException in project mongo-java-driver by mongodb.
the class SocketStreamHelper method initialize.
static void initialize(final Socket socket, final ServerAddress address, final SocketSettings settings, final SslSettings sslSettings) throws IOException {
socket.setTcpNoDelay(true);
socket.setSoTimeout(settings.getReadTimeout(MILLISECONDS));
socket.setKeepAlive(settings.isKeepAlive());
if (settings.getReceiveBufferSize() > 0) {
socket.setReceiveBufferSize(settings.getReceiveBufferSize());
}
if (settings.getSendBufferSize() > 0) {
socket.setSendBufferSize(settings.getSendBufferSize());
}
if (sslSettings.isEnabled() || socket instanceof SSLSocket) {
if (!(socket instanceof SSLSocket)) {
throw new MongoInternalException("SSL is enabled but the socket is not an instance of javax.net.ssl.SSLSocket");
}
SSLSocket sslSocket = (SSLSocket) socket;
SSLParameters sslParameters = sslSocket.getSSLParameters();
enableSni(address, sslParameters);
if (!sslSettings.isInvalidHostNameAllowed()) {
enableHostNameVerification(sslParameters);
}
sslSocket.setSSLParameters(sslParameters);
}
socket.connect(address.getSocketAddress(), settings.getConnectTimeout(MILLISECONDS));
}
use of com.mongodb.MongoInternalException in project morphia by mongodb.
the class TestQuery method testWhereWithInvalidStringQuery.
@Test
public void testWhereWithInvalidStringQuery() {
getDs().save(new PhotoWithKeywords());
final CodeWScope hasKeyword = new CodeWScope("keywords != null", new BasicDBObject());
try {
// must fail
assertNotNull(getDs().find(PhotoWithKeywords.class).where(hasKeyword.getCode()).get());
fail("Invalid javascript magically isn't invalid anymore?");
} catch (MongoInternalException e) {
// fine
} catch (MongoException e) {
// fine
}
}
Aggregations