@Override public Object execute(Op op) throws Exception { return getConnection().execute(op); }
@Override public Object execute(Op op) throws Exception { return getConnection().execute(op); }
/** * Tell a server that a connection is being closed * * @param con the connection that is being closed * @param keepAlive whether to keep the proxy alive on the server */ public static void execute(Connection con, boolean keepAlive) throws Exception { AbstractOp op = new CloseConnectionOpImpl(keepAlive); try { con.execute(op); } catch (EOFException e) { // expected } }
private Connection getMockedConnection(ServerLocation serverLocation, Endpoint endpoint) throws Exception { /* * Mock the connection to throw a RuntimeException() when connection.Execute() is called, * so that we attempt to notify listeners in the exception handling logic in * OpExecutorImpl.executeWithPossibleReAuthentication() */ final Connection connection = mock(PooledConnection.class); doReturn(serverLocation).when(connection).getServer(); doReturn(endpoint).when(connection).getEndpoint(); doThrow(new RuntimeException()).when(connection).execute(any()); return connection; }
private Object executeWithPossibleReAuthentication(Connection conn, Op op) throws Exception { try { return conn.execute(op); } catch (ServerConnectivityException sce) { Throwable cause = sce.getCause(); if ((cause instanceof AuthenticationRequiredException && "User authorization attributes not found.".equals(cause.getMessage())) || sce.getMessage().contains("Connection error while authenticating user")) { // (ashetkar) Need a cleaner way of doing above check. // 2nd exception-message above is from AbstractOp.sendMessage() PoolImpl pool = (PoolImpl) PoolManagerImpl.getPMI().find(this.endpointManager.getPoolName()); if (!pool.getMultiuserAuthentication()) { Connection connImpl = this.connectionManager.getConnection(conn); conn.getServer().setUserId((Long) AuthenticateUserOp.executeOn(connImpl, this)); return conn.execute(op); } else { UserAttributes ua = UserAttributes.userAttributes.get(); if (ua != null) { authenticateMultiuser(pool, conn, ua); } return conn.execute(op); } } else { throw sce; } } }