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));
}
}
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;
}
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);
}
}
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);
}
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);
}
}
Aggregations