JDK-8007373 : Inet6Address serialization incompatibility
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-02-01
  • Updated: 2013-07-09
  • Resolved: 2013-04-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b89Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
We seem to have changed the serialization of Inet6Address in jdk8 compared with jdk7. It is causing a problem de-serializing instances (in 7) that were serialized by 8. The scope-id is not being recreated correctly.
Comments
verified the regression test cover this issue and passed in nightlys for 2 more weeks. http://hg.openjdk.java.net/jdk8/jdk8/jdk/diff/49d6596100db/test/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java
09-07-2013

a review request for a fix has been posted @ http://cr.openjdk.java.net/~msheppar/8007373/webrev.00/
27-03-2013

another issue exist in deserialization readObject. As seen in the code extract below, the search for a scoped interfaces scope id, via the deriveNumericScope, can throw an exception. This will leave the scope id as per its serialized value, which is incorrect. It should be set to 0, and ist companion scope_id_set assigned false, in this failed context. try { scope_ifname = NetworkInterface.getByName(ifname); if (scope_ifname != null) { scope_ifname_set = true; try { scope_id = deriveNumericScope(scope_ifname); } catch (UnknownHostException e) { // typically should not happen, but it may be that // the machine being used for deserialization has // the same interface name but without IPv6 configured. } } else { /* the interface does not exist on this system, so we clear * the scope information completely */ scope_id_set = false; scope_ifname_set = false; scope_id = 0; } } catch (SocketException e) {}
27-03-2013

affected test api/java_net/Inet6Address/serial/index.html#Constructor
27-03-2013

since this issue is causing JCK failure (see JCK-7300265 for details) priority should be raised.
27-03-2013

Another potential issue worth highlighting with the 8 changes: The de-serialized state in 7 will be different to the deserialized state in 8, when an interface doesn't exist on the deserializing host. the readObject in 7 will set the following when scope_ifname == null /* the interface does not exist on this system, so we clear * the scope information completely */ scope_id_set = false; scope_ifname_set = false; scope_id = 0; In 8 the scope_id will be as per its serialized state when an interface doesn't exist on the deserializing host. In 7 it will be 0, as such getScopeId and getHostAddress my be different for a deserialized Inet6Address across 7 and 8. so to remove further incompatibility the following will be re-introduced scope_id_set = false; scope_ifname_set = false; scope_id = 0; when scope_ifname == null Also, it is worth noting that JDK7 Inet6Address serialization/deserialization is itself broken, and as such 8004675 & 8007373 will need to be applied in JDK7.
25-03-2013

if we re-instate the scope_ifname_set field and amend writeObject to set the field, if the scope_ifname != null, then "backward compatibility" with JDK7 is achieved. However, Inet6Address is a fractured class in JDK7 wrt serialization, in that a serialized jdk7 Inet6Address, will not be de-serialized correctly, because it is not serialized correctly in the first place!! As such, there is a problem with forward compatibility from jdk7 to jdk8. to fix this requires changes to getHostAddress: if (scope_ifname != null) { etc. writeObject: if (scope_ifname != null) { ifname = scope_ifname.getName(); scope_ifname_set = true; } and readObject: scope_ifname = NetworkInterface.getByName(ifname); if (scope_ifname == null) { ... } else { scope_ifname_set = true; // for consistency try { scope_id = deriveNumericScope (scope_ifname); } catch (UnknownHostException e) { // typically should not happen, but it may be that // the machine being used for deserialization has // the same interface name but without IPv6 configured. } } the exact purpose of scope_ifname_set is questionable, but as it exists we wont pursue this question any further.
12-03-2013

The fix for 8004675 incompatibly removed the 'scope_ifname_set' field.
04-02-2013