Add descriptive message for MessagingExceptions.
We can print this message in EventuallyConsistentMapImpl rather than printing
a stack trace which doesn't add any value because the exception always comes
from the same place.
Change-Id: Ia233e7ae8605b2b59ffd4ef834209fdaa86e9376
diff --git a/core/api/src/main/java/org/onosproject/store/cluster/messaging/MessagingException.java b/core/api/src/main/java/org/onosproject/store/cluster/messaging/MessagingException.java
index ce47258..d0b8cbb 100644
--- a/core/api/src/main/java/org/onosproject/store/cluster/messaging/MessagingException.java
+++ b/core/api/src/main/java/org/onosproject/store/cluster/messaging/MessagingException.java
@@ -42,17 +42,26 @@
* Exception indicating no remote registered remote handler.
*/
public static class NoRemoteHandler extends MessagingException {
+ public NoRemoteHandler() {
+ super("No remote message handler registered for this message");
+ }
}
/**
* Exception indicating handler failure.
*/
public static class RemoteHandlerFailure extends MessagingException {
+ public RemoteHandlerFailure() {
+ super("Remote handler failed to handle message");
+ }
}
/**
- * Exception indicating failure due to invalid message strucuture such as an incorrect preamble.
+ * Exception indicating failure due to invalid message structure such as an incorrect preamble.
*/
- public static class ProcotolException extends MessagingException {
+ public static class ProtocolException extends MessagingException {
+ public ProtocolException() {
+ super("Failed to process message due to invalid message structure");
+ }
}
-}
\ No newline at end of file
+}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
index e9b50c4..2e8682b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
@@ -545,7 +545,7 @@
} else if (message.status() == Status.ERROR_HANDLER_EXCEPTION) {
callback.completeExceptionally(new MessagingException.RemoteHandlerFailure());
} else if (message.status() == Status.PROTOCOL_EXCEPTION) {
- callback.completeExceptionally(new MessagingException.ProcotolException());
+ callback.completeExceptionally(new MessagingException.ProtocolException());
}
} else {
log.debug("Received a reply for message id:[{}]. "
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/EventuallyConsistentMapImpl.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/EventuallyConsistentMapImpl.java
index ffbb0c5..bba165f 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/EventuallyConsistentMapImpl.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/EventuallyConsistentMapImpl.java
@@ -588,7 +588,8 @@
peer)
.whenComplete((result, error) -> {
if (error != null) {
- log.debug("Failed to send anti-entropy advertisement to {}", peer, error);
+ log.debug("Failed to send anti-entropy advertisement to {}: {}",
+ peer, error.getMessage());
} else if (result == AntiEntropyResponse.PROCESSED) {
antiEntropyTimes.put(peer, adCreationTime);
}
@@ -603,7 +604,8 @@
peer)
.whenComplete((result, error) -> {
if (error != null) {
- log.debug("Failed to send update request to {}", peer, error);
+ log.debug("Failed to send update request to {}: {}",
+ peer, error.getMessage());
}
});
}