Workaround for NoClassDefFound issue in Netty.
SimpleChannelInboundHandler generates `message` instance check code on the fly,
using JavaAssist. Which was not working, when a new Connection was created on the thread
outside of NettyMessagingManager bundle, which did not have access to netty classes.
- Implemented equivalent for SimpleChannelInboundHandler<InternaleMessage>
without specifying type parameter, avoiding on the fly code generation.
Other changes:
- Add a method in IpAddress to return InetAddress instance.
Change-Id: Ie97294a5650683457b9395e773269c5232d8e602
diff --git a/utils/misc/src/main/java/org/onlab/packet/IpAddress.java b/utils/misc/src/main/java/org/onlab/packet/IpAddress.java
index f47b065..bf01406 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IpAddress.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IpAddress.java
@@ -16,6 +16,7 @@
package org.onlab.packet;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.nio.ByteBuffer;
@@ -142,6 +143,20 @@
}
/**
+ * Returns the IP address as InetAddress.
+ *
+ * @return InetAddress
+ */
+ public InetAddress toInetAddress() {
+ try {
+ return InetAddress.getByAddress(octets);
+ } catch (UnknownHostException e) {
+ // Should never reach here
+ return null;
+ }
+ }
+
+ /**
* Computes the IP address byte length for a given IP version.
*
* @param version the IP version