Skip to content

Commit

Permalink
fix(iot-dev):Fix amqp layer not handling proton:io exceptions
Browse files Browse the repository at this point in the history
Server causes this error type to appear during TCP connection lost tests, so it must be a retryable exception
  • Loading branch information
timtay-microsoft committed May 31, 2019
1 parent 295bd39 commit d50d831
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ static TransportException convertToAmqpException(String exceptionCode, String de
case AmqpConnectionThrottledException.errorCode:
// Codes_SRS_AMQPSEXCEPTIONTRANSLATOR_28_001: [The function shall map amqp exception code "com.microsoft:device-container-throttled" to TransportException "AmqpConnectionThrottledException".]
return new AmqpConnectionThrottledException(description);
case ProtonIOException.errorCode:
return new ProtonIOException(description);
default:
// Codes_SRS_AMQPSEXCEPTIONTRANSLATOR_34_026: [The function shall map all other amqp exception codes to the generic TransportException "ProtocolException".]
return new ProtocolException(description);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.microsoft.azure.sdk.iot.device.transport.amqps.exceptions;

import com.microsoft.azure.sdk.iot.device.exceptions.ProtocolException;

public class ProtonIOException extends ProtocolException
{
public static final String errorCode = "proton:io";

public ProtonIOException()
{
super();
this.isRetryable = true;
}

public ProtonIOException(String message)
{
super(message);
this.isRetryable = true;
}

public ProtonIOException(String message, Throwable cause)
{
super(message, cause);
this.isRetryable = true;
}

public ProtonIOException(Throwable cause)
{
super(cause);
this.isRetryable = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ public void getConnectionStatusExceptionFromAMQPExceptionCodeReturnsExpectedMapp
assertTrue(Deencapsulation.invoke(AmqpsExceptionTranslator.class, "convertToAmqpException", AmqpLinkRedirectException.errorCode, "") instanceof AmqpLinkRedirectException);
assertTrue(Deencapsulation.invoke(AmqpsExceptionTranslator.class, "convertToAmqpException", AmqpConnectionThrottledException.errorCode, "") instanceof AmqpConnectionThrottledException);
assertTrue(Deencapsulation.invoke(AmqpsExceptionTranslator.class, "convertToAmqpException", "Not a protocol standard error code", "") instanceof ProtocolException);
assertTrue(Deencapsulation.invoke(AmqpsExceptionTranslator.class, "convertToAmqpException", ProtonIOException.errorCode, "") instanceof ProtonIOException);
}
}

0 comments on commit d50d831

Please sign in to comment.