Search in sources :

Example 16 with Error

use of org.apache.qpid.server.protocol.v1_0.type.transport.Error in project qpid-broker-j by apache.

the class AttachTest method emptyAttach.

@Test
@SpecificationTest(section = "1.3.4", description = "Attach without mandatory fields should result in a decoding error.")
public void emptyAttach() throws Exception {
    final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
    try (FrameTransport transport = new FrameTransport(addr).connect()) {
        Close responseClose = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(null).attachHandle(null).attachName(null).attach().consumeResponse().getLatestResponse(Close.class);
        assertThat(responseClose.getError(), is(notNullValue()));
        assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InetSocketAddress(java.net.InetSocketAddress) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 17 with Error

use of org.apache.qpid.server.protocol.v1_0.type.transport.Error in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method getSession.

private Session_1_0 getSession(final int channel) {
    Session_1_0 session = _receivingSessions[channel];
    if (session == null) {
        Error error = new Error();
        error.setCondition(ConnectionError.FRAMING_ERROR);
        error.setDescription("Frame received on channel " + channel + " which is not known as a begun session.");
        handleError(error);
    }
    return session;
}
Also used : ConnectionError(org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error)

Example 18 with Error

use of org.apache.qpid.server.protocol.v1_0.type.transport.Error in project qpid-broker-j by apache.

the class AbstractLinkEndpoint method receiveAttach.

@Override
public void receiveAttach(final Attach attach) throws AmqpErrorException {
    _errored = false;
    boolean isAttachingRemoteTerminusNull = (attach.getRole() == Role.SENDER ? attach.getSource() == null : attach.getTarget() == null);
    boolean isAttachingLocalTerminusNull = (attach.getRole() == Role.SENDER ? attach.getTarget() == null : attach.getSource() == null);
    boolean isLocalTerminusNull = (attach.getRole() == Role.SENDER ? getTarget() == null : getSource() == null);
    if (isAttachingRemoteTerminusNull) {
        throw new AmqpErrorException(AmqpError.INVALID_FIELD, "received Attach with remote null terminus.");
    }
    if (isAttachingLocalTerminusNull) {
        recoverLink(attach);
    } else if (isLocalTerminusNull) {
        establishLink(attach);
    } else if (attach.getUnsettled() != null) {
        // TODO: QPID-7845 : Functionality for resuming links is not fully implemented
        if (attach.getUnsettled().isEmpty()) {
            resumeLink(attach);
        } else {
            throw new AmqpErrorException(new Error(AmqpError.NOT_IMPLEMENTED, "Resuming link is not implemented."));
        }
    } else {
        reattachLink(attach);
    }
}
Also used : AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)

Example 19 with Error

use of org.apache.qpid.server.protocol.v1_0.type.transport.Error in project qpid-broker-j by apache.

the class AbstractLinkEndpoint method detach.

protected void detach(Error error, boolean close) {
    if (error != null && !getSession().isSyntheticError(error)) {
        _errored = true;
    }
    // TODO: QPID-7954: improve detach
    switch(_state) {
        case ATTACHED:
            _state = State.DETACH_SENT;
            break;
        case DETACH_RECVD:
            _state = State.DETACHED;
            break;
        default:
            // disassociate the link from the session so that the new connection can use it.
            if (close) {
                getSession().dissociateEndpoint(this);
                destroy();
                _link.linkClosed();
            }
            return;
    }
    if (getSession().getSessionState() != SessionState.END_RECVD && !getSession().isEnded()) {
        Detach detach = new Detach();
        detach.setHandle(getLocalHandle());
        if (close) {
            detach.setClosed(close);
        }
        detach.setError(error);
        getSession().sendDetach(detach);
    }
    if (close) {
        destroy();
        _link.linkClosed();
    }
    setLocalHandle(null);
}
Also used : Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 20 with Error

use of org.apache.qpid.server.protocol.v1_0.type.transport.Error in project qpid-broker-j by apache.

the class AbstractReceivingLinkEndpoint method receiveTransfer.

void receiveTransfer(final Transfer transfer) {
    if (!isErrored()) {
        Error error = validateTransfer(transfer);
        if (error != null) {
            transfer.dispose();
            if (_currentDelivery != null) {
                _currentDelivery.discard();
                _currentDelivery = null;
            }
            close(error);
            return;
        }
        if (_currentDelivery == null) {
            error = validateNewTransfer(transfer);
            if (error != null) {
                transfer.dispose();
                close(error);
                return;
            }
            _currentDelivery = new Delivery(transfer, this);
            setLinkCredit(getLinkCredit().subtract(UnsignedInteger.ONE));
            getDeliveryCount().incr();
            getSession().getIncomingDeliveryRegistry().addDelivery(transfer.getDeliveryId(), new UnsettledDelivery(transfer.getDeliveryTag(), this));
        } else {
            error = validateSubsequentTransfer(transfer);
            if (error != null) {
                transfer.dispose();
                _currentDelivery.discard();
                _currentDelivery = null;
                close(error);
                return;
            }
            _currentDelivery.addTransfer(transfer);
        }
        if (_currentDelivery.getTotalPayloadSize() > getSession().getConnection().getMaxMessageSize()) {
            error = new Error(LinkError.MESSAGE_SIZE_EXCEEDED, String.format("delivery '%s' exceeds max-message-size %d", _currentDelivery.getDeliveryTag(), getSession().getConnection().getMaxMessageSize()));
            _currentDelivery.discard();
            _currentDelivery = null;
            close(error);
            return;
        }
        if (!_currentDelivery.getResume()) {
            _unsettled.put(_currentDelivery.getDeliveryTag(), _currentDelivery.getState());
        }
        if (_currentDelivery.isAborted() || (_currentDelivery.getResume() && !_unsettled.containsKey(_currentDelivery.getDeliveryTag()))) {
            _unsettled.remove(_currentDelivery.getDeliveryTag());
            getSession().getIncomingDeliveryRegistry().removeDelivery(_currentDelivery.getDeliveryId());
            _currentDelivery = null;
            setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
            getDeliveryCount().decr();
        } else if (_currentDelivery.isComplete()) {
            try {
                if (_currentDelivery.isSettled()) {
                    _unsettled.remove(_currentDelivery.getDeliveryTag());
                    getSession().getIncomingDeliveryRegistry().removeDelivery(_currentDelivery.getDeliveryId());
                }
                error = receiveDelivery(_currentDelivery);
                if (error != null) {
                    close(error);
                }
            } finally {
                _currentDelivery = null;
            }
        }
    } else {
        End end = new End();
        end.setError(new Error(SessionError.ERRANT_LINK, String.format("Received TRANSFER for link handle %s which is in errored state.", transfer.getHandle())));
        getSession().end(end);
    }
}
Also used : UnsettledDelivery(org.apache.qpid.server.protocol.v1_0.delivery.UnsettledDelivery) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) SessionError(org.apache.qpid.server.protocol.v1_0.type.transport.SessionError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) UnsettledDelivery(org.apache.qpid.server.protocol.v1_0.delivery.UnsettledDelivery)

Aggregations

Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)49 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)40 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)30 Test (org.junit.Test)30 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)28 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)22 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)17 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)15 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)15 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)15 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)15 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)14 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)14 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)14 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)13 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)12 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)12 LinkError (org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)12 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)11 InetSocketAddress (java.net.InetSocketAddress)10