Netty bug fix: Do not use weakValues in a cache where we track outstanding responses.
diff --git a/tools/dev/bash_profile b/tools/dev/bash_profile
index 8d4a784..b2f61f2 100644
--- a/tools/dev/bash_profile
+++ b/tools/dev/bash_profile
@@ -8,7 +8,7 @@
# Setup some environmental context for developers
if [ -z "${JAVA_HOME}" ]; then
if [ -x /usr/libexec/java_home ]; then
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
+ export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
elif [ -d /usr/lib/jvm/java-7-openjdk-amd64 ]; then
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
fi
diff --git a/utils/netty/src/main/java/org/onlab/netty/Endpoint.java b/utils/netty/src/main/java/org/onlab/netty/Endpoint.java
index a9b3b46..4c1c5ce 100644
--- a/utils/netty/src/main/java/org/onlab/netty/Endpoint.java
+++ b/utils/netty/src/main/java/org/onlab/netty/Endpoint.java
@@ -55,8 +55,8 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("port", port)
.add("host", host)
+ .add("port", port)
.toString();
}
diff --git a/utils/netty/src/main/java/org/onlab/netty/InternalMessage.java b/utils/netty/src/main/java/org/onlab/netty/InternalMessage.java
index da1427a..af461e3 100644
--- a/utils/netty/src/main/java/org/onlab/netty/InternalMessage.java
+++ b/utils/netty/src/main/java/org/onlab/netty/InternalMessage.java
@@ -26,7 +26,7 @@
*/
public final class InternalMessage implements Message {
- public static final String REPLY_MESSAGE_TYPE = "NETTY_MESSAGIG_REQUEST_REPLY";
+ public static final String REPLY_MESSAGE_TYPE = "NETTY_MESSAGING_REQUEST_REPLY";
private long id;
private Endpoint sender;
diff --git a/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java b/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
index e10ba29..33870e2 100644
--- a/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
+++ b/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
@@ -67,7 +67,6 @@
private final AtomicLong messageIdGenerator = new AtomicLong(0);
private final Cache<Long, SettableFuture<byte[]>> responseFutures = CacheBuilder.newBuilder()
.maximumSize(100000)
- .weakValues()
// TODO: Once the entry expires, notify blocking threads (if any).
.expireAfterWrite(10, TimeUnit.MINUTES)
.build();
@@ -174,7 +173,12 @@
.withType(type)
.withPayload(payload)
.build();
- sendAsync(ep, message);
+ try {
+ sendAsync(ep, message);
+ } catch (IOException e) {
+ responseFutures.invalidate(messageId);
+ throw e;
+ }
return futureResponse;
}
@@ -293,7 +297,8 @@
if (futureResponse != null) {
futureResponse.set(message.payload());
} else {
- log.warn("Received a reply. But was unable to locate the request handle");
+ log.warn("Received a reply for message id:[{}]. "
+ + "But was unable to locate the request handle", message.id());
}
} finally {
NettyMessagingService.this.responseFutures.invalidate(message.id());