JDK-8010826 : Inet6Address deserialization produces inconsistent scope_id state when a scoped interface
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • Submitted: 2013-03-26
  • Updated: 2013-05-31
  • Resolved: 2013-05-31
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
8Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
When an Inet6Address object is deserialized the scope_id can be left incorrect when the scoped interface in the serialized object does not exist on the deserializing host.

This relates to the readObject method's use
of NetworkInterface.getByName, and how it processes this interface to obtain
the scope id. In the code extract below the inner try catch block which
is searching for the scope id can throw an UnknownHostException which is
silently caught, and the scope id will remain as per its serialised value.
It would seem appropriate to set the scope_id to 0 ,
and correspondingly scope_id_set = 0.


     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) {}

The logic here is that if an interface name has been set in the serialized object,
look for a corresponding NetworkInterface on the deserializing host, then look for its
scope id. The scope id serach can throw an UnknownHostException, typically with a no scope id found.
This then leaves
the value of scope id as per its serialized value. While scope_id = 0 and 
scope_id_set = false would appear more appropriate in this failed scope id search context

In reality, the only state of an Inet6Address, 
which will be consistent across serialization/deserialization
and across hosts, is the hostName and the address. 
The scope_id is effectively transient outside of
the host on which the Inet6Address was serialized.

Comments
The fix for 8007373 resolves this issue.
31-05-2013