Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6643559

NullPointerException thrown while de-serializing IPV6 Address.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6u3
    • core-libs
    • other
    • generic

      OPERATING SYSTEM(S):
      --------------------
      ALL

      FULL JDK VERSION(S):
      -------------------
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

      DESCRIPTION:
      ------------
      Null Pointer Exception was raised while reading from serialized IPv6 address object.

      In this scenario, user creates a VLAN and serialize the address associated with the VLAN. Later point of time, they remove the VLAN and de-serialize the address and experience a NullPointerException.

      Recreation Steps:

      1. Enable VLAN on your machine
      for example,
      vconfig add eth0 5
      ifconfig eth0.5
      ifconfig eth0.5 10.182.9.144 netmask 255.255.255.0 broadcast 10.182.9.255 up
      (change ip addresses as required)

      2. Execute WriteIPv6.java file (See below)

      3. Disable VLAN
      for example,
      ifconfig eth0.5 down
      vconfig rem eth0.5

      4. Execute ReadIPv6.java file (see below)

      The following exception is raised while trying to deserialize the object:

      java.lang.NullPointerException
              at java.net.Inet6Address.deriveNumericScope(Inet6Address.java:343)
              at java.net.Inet6Address.readObject(Inet6Address.java:406)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:591)
              at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
              at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
              at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
              at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
              at ReadIPv6.main(ReadIPv6.java:10)

      TESTCASE SOURCE
      ---------------
      File: WriteIPv6.java

      import java.io.*;
      import java.net.*;
      import java.util.*;
      public class WriteIPv6 {
          public static void main(String[] args) {
              try {
                  InetAddress iaddr = InetAddress.getByName("fe80::20c:29ff:fef6:3aad%eth0.5");
                  System.out.println(iaddr);
                  ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("test.ser")));
                  oos.writeObject(iaddr);
                  oos.close();
            } catch ( Exception e ) {
                  e.printStackTrace();
              }
          }
      }

      File: ReadIPv6.java

      import java.io.*;
      import java.net.*;
      import java.util.*;
      public class ReadIPv6 {
          public static void main(String[] args) {
              try {
                  ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("test.ser")));
                  InetAddress iaddr2 = (InetAddress)ois.readObject();
                  ois.close();
                  System.out.println(iaddr2);
            } catch ( Exception e ) {
                  e.printStackTrace();
              }
          }
      }

            Unassigned Unassigned
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: