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

Socket can be connected and closed at the same time

XMLWordPrintable

    • b05
    • x86, sparc
    • linux, solaris_8
    • Not verified

        ())
              {
                System.err.println("Before close - isConnected(): "+s.isConnected());
                System.err.println("Before close - isClosed(): "+s.isClosed());
                s.close();
                System.err.println("After close - isConnected(): "+s.isConnected());
                System.err.println("After close - isClosed(): "+s.isClosed());
              }
              else
              {
                System.err.println("not really connected");
              }
            }
            catch (Exception x)
            {
              x.printStackTrace();
            }
          }
        }

        ---------- END SOURCE ----------
        (Review ID: 145755)
        ======================================================================
        Name: gm110360 Date: 04/22/2002


        FULL PRODUCT VERSION :
        [372]$ java -version
        java version "1.4.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
        Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)



        FULL OPERATING SYSTEM VERSION :
        SunOS piscs5 5.8 Generic_108528-07 sun4u sparc
        SUNW,Ultra-Enterprise


        ADDITIONAL OPERATING SYSTEMS :

        Windows_NT BRUNKPC 4 00 586

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        [2]$ sysinfo


        G E N E R A L I N F O R M A T I O N

        Host Name is piscs5
        Host Aliases is mgscs3
        Host Address(es) is 144.14.134.55
        Host ID is 80e565a8
        Serial Number is 2162517416
        Manufacturer is Sun (Sun Microsystems)
        Manufacturer (Short) is Sun
        Manufacturer (Full) is Sun Microsystems
        System Model is Enterprise E4500/E5500
        Main Memory is 6.0 GB
        Virtual Memory is 16.8 GB
        ROM Version is OBP 3.2.26 2000/05/09 19:07
        Number of CPUs is 6
        CPU Type is sparcv9+vis
        CPU Speed is 400 MHz
        App Architecture is sparc
        Kernel Architecture is sun4u
        OS Name is SunOS
        OS Version is 5.8
        OS Distribution is Solaris 8 4/01 s28s_u4wos_08 SPARC
        Libc Name is libc
        Libc Version is 1
        Kernel Version is SunOS Release 5.8 Version
        Generic_108528-07 64-bit
        Boot Time is Sun Apr 21 07:12:27 2002 EDT
        Current Time is Mon Apr 22 16:55:49 2002 EDT


        K E R N E L I N F O R M A T I O N

        Maximum number of processes for system is 30000
        Maximum number of processes per user is 29995
        Maximum number of users (for system tables) is 2048
        Maximum number of BSD (/dev/ptyXX) pty's is 256
        Maximum number of System V (/dev/pts/*) pty's is 256
        Size of the virtual address cache is 16384
        Size of the callout table is 316
        Size of the inode table is
        128512
        Size of the directory name lookup cache is
        128512
        STREAMS: Maximum number of pushes allowed is 9
        Maximum global priority in sys class is 64
        Has UFS driver is TRUE
        Has NFS driver is TRUE
        Has TMPFS driver is TRUE
        Has SD driver is TRUE
        Has FD driver is TRUE
        Has NFSSERVER is TRUE
        Has IPCSEMAPHORE is TRUE


        S Y S C O N F I N F O R M A T I O N

        Max combined size of argv[] and envp[]
        is 2096640
        Max processes allowed to any UID
        is 29995
        Clock ticks per second
        is 100
        Max simultaneous groups per user
        is 16
        Max open files per process
        is 256
        System memory page size
        is 8192
        Job control supported
        is TRUE
        Savid ids (seteuid()) supported
        is TRUE
        Version of POSIX.1 standard supported
        is 199506
        Version of the X/Open standard supported
        is 3
        Max log name
        is 8
        Max password length
        is 8
        Number of processors (CPUs) configured
        is 6
        Number of processors (CPUs) online
        is 6
          Total number of pages of physical memory
        is 786432
        Number of pages of physical memory not currently in use
        is 645693
        Max number of I/O operations in single list I/O call
        is 4096
        Max amount a process can decrease its async I/O priority
        level is 0
        Max number of timer expiration overruns
        is 2147483647
        Max number of open message queue descriptors per process
        is 32
        Max number of message priorities supported
        is 32
        Max number of realtime signals
        is 8
        Max number of semaphores per process
        is 2147483647
        Max value a semaphore may have
        is 2147483647
        Max number of queued signals per process
        is 32
        Max number of timers per process
        is 32
        Supports asyncronous I/O
        is TRUE
        Supports File Synchronization
        is TRUE
        Supports memory mapped files
        is TRUE
        Supports process memory locking
        is TRUE
        Supports range memory locking
        is TRUE
        Supports memory protection
        is TRUE
        Supports message passing
        is TRUE
        Supports process scheduling
        is TRUE
        Supports realtime signals
        is TRUE
        Supports semaphores
        is TRUE
        Supports shared memory objects
        is TRUE
        Supports syncronized I/O
        is TRUE
        Supports timers
        is TRUE
        Supports C language binding option
        is TRUE
        Supports C language development utilities
        is TRUE
        Version of ISO POSIX-2 standard (Commands)
        is 199209
        Supports creation of locales by localedef
        is TRUE
        Supports Software Development Utitility
        is TRUE
        Supports User Portability Utilities
        is TRUE
        Version of ISO POSIX-2 standard (C Language binding)
        is 199209
        Maximum obase values allowed by bc
        is 99
        Maximum number of elements in array in bc
        is 2048
        Maximum scale value in bc
        is 99
        Maximum string constant in bc
        is 1000
        Maximum weights for LC_COLLATE
        is 10
        Maximum expressionss in expr
        is 32
        Maximum length of input line
        is 2048
        Maximum repeated _SC_REALTIME_SIGNALS
        is 255
        Supports X/Open Encryption Features
        is TRUE
        Supports X/Open Enhanced Internationalization Features
        is TRUE
        Supports X/Open Shared Memory Features
        is TRUE
        Supports Character Terminals
        is TRUE
        Version of supported XCU
        is 4
        Maximum functions in atexit()
        is 32
        Maximum iovec structures for readv()/writev()
        is 16
        Supports X/Open CAE 8/1994
        is TRUE
        Maximum pid value
        is 30000
        Default stack protection
        is 3
        Max size of group entry buffer
        is 10496
        Max size of password entry buffer
        is 1024
        Max login name
        is 9
        Max TTY name
        is 128
        Supports POSIX Threads
        is TRUE
        Supports Thread Stack Address Attriutes
        is TRUE
        Supports Thread Stack Size Attribute
        is TRUE
        Supports Thread Priority Scheduling
        is TRUE
        Supports Thread Priority Inherit
        is TRUE
        Supports Thread Priority Protection
        is TRUE
        Supports Thread Process Sharing
        is TRUE
        Supports Thread Safe Functions
        is TRUE
        Supports X/Open Legacy Feature Group
        is TRUE
        Supports X/Open POSIX Realtime Feature Group
        is TRUE
        Supports X/Open POSIX Realtime Threads Feature Group
        is TRUE
        Supports X/Open ILP32 w/32-bit offset
        is TRUE
        Supports X/Open LP32 w/64-bit offset
        is TRUE
        Supports X/Open LP64, 64-bit offset
        is TRUE
        Supports X/Open LP64, 64-bit offset
        is TRUE


        P A R T I T I O N I N F O R M A T I O N

        swapvol is a SWAP partition
        rootvol is a 187 MB ufs partition in use as /
        afscache is a 590 MB ufs partition in use as
        /afscache
        varvol is a 4.0 GB vxfs partition in use as /var
        swp.0 is a SWAP partition
        swp.1 is a SWAP partition
        swp.2 is a SWAP partition
        swp.3 is a SWAP partition
        swp.4 is a SWAP partition
        swp.5 is a SWAP partition
        releng is a 1024 MB vxfs partition in use as
        /d/releng
        usag is a 10 MB vxfs partition in use as /d/usag
        usag1 is a 10 MB vxfs partition in use as /d/usag1
        stock is a 10 MB vxfs partition in use as /d/stock
        grace is a 2.0 GB vxfs partition in use as
        /d/grace
        msde is a 1024 MB vxfs partition in use as
        /d/msde
        ebi is a 3.0 GB vxfs partition in use as /d/ebi


        D E V I C E I N F O R M A T I O N

        SUNW,Ultra-Enterprise
            openprom1 is a "Sun Open Boot PROM" device
            options0 is a "PROM Settings"
            aliases1 is a "PROM Device Aliases"
            central0 is a "System Clock Board"
                fhc5 is a "FireHost Controller" Utility Bus
                    eeprom1 is a "EEPROM" device
                    zs0 is a "Zilog 8530" serial device
                    zs1 is a "Zilog 8530" serial device
                        kbd is a "Unknown" Keyboard
                    clock-board0 is a "Clock Board"
            sysboard0 is a "CPU & Memory Board"
                fhc0 is a "Sun FireHost Controller" Utility Bus
                    ac0 is a "Sun Memory Controller"
                    simm-status0 is a "SIMM Status"
                    environment0 is a "Environmental Sensor"
                    sram0 is a "SRAM"
                    flashprom1 is a "Sun Flash PROM"
            cpu0 is a "Sun UltraSPARC-II" 400 MHz CPU
            cpu1 is a "Sun UltraSPARC-II" 400 MHz CPU
            sysboard2 is a "CPU & Memory Board"
                fhc1 is a "Sun FireHost Controller" Utility Bus
                    ac1 is a "Sun Memory Controller"
                    simm-status1 is a "SIMM Status"
                    environment1 is a "Environmental Sensor"
                    sram1 is a "SRAM"
                    flashprom3 is a "Sun Flash PROM"
            cpu2 is a "Sun UltraSPARC-II" 400 MHz CPU
            cpu3 is a "Sun UltraSPARC-II" 400 MHz CPU
            sysboard4 is a "CPU & Memory Board"
                fhc2 is a "Sun FireHost Controller" Utility Bus
                    ac2 is a "Sun Memory Controller"
                    simm-status2 is a "SIMM Status"
                    environment2 is a "Environmental Sensor"
                    sram2 is a "SRAM"
                    flashprom5 is a "Sun Flash PROM"
            cpu4 is a "Sun UltraSPARC-II" 400 MHz CPU
            cpu5 is a "Sun UltraSPARC-II" 400 MHz CPU
            sysboard1 is a "System Board"
                sbus0 is a "Sun SBus" system bus
                    SUNW,socal0 is a "Sun Serial Optical Controller
        FC-AL" disk controller
                        sf0 is a "Sun SOC FC-AL" SCSI
                        sf1 is a "Sun SOC FC-AL" SCSI
                    QLGC,isp0 is a "Q-Logic DWIS/S" SCSI controller
                        c0t2d0 (sd12) is a "SEAGATE ST318305LSUN18G"
        SCSI 16.9 GB disk drive
                fhc3 is a "Sun FireHost Controller" Utility Bus
                    ac3 is a "Sun Memory Controller"
                    environment3 is a "Environmental Sensor"
                    flashprom7 is a "Sun Flash PROM"
                    eeprom3 is a "EEPROM" device
                sbus1 is a "Sun SBus" system bus
                    hme0 is a "Sun" 100-Mb Fast Ethernet network
        interface
                    SUNW,fas0 is a "Sun FAS366 Fast" SCSI controller
            sysboard3 is a "System Board"
                sbus2 is a "Sun SBus" system bus
                    SUNW,socal1 is a "Sun Serial Optical Controller
        FC-AL" disk controller
                        sf2 is a "Sun SOC FC-AL" SCSI
                        sf3 is a "Sun SOC FC-AL" SCSI
                fhc4 is a "Sun FireHost Controller" Utility Bus
                    ac4 is a "Sun Memory Controller"
                    environment4 is a "Environmental Sensor"
                    flashprom9 is a "Sun Flash PROM"
                    eeprom5 is a "EEPROM" device
                sbus3 is a "Sun SBus" system bus
                    SUNW,fas1 is a "Sun FAS366 Fast" SCSI controller
                        c1t2d0 (sd300) is a "SEAGATE
        ST318305LSUN18G" SCSI 16.9 GB disk drive
        fcaw0 is a "compatible"
            c4t116d38 (sd1404) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c4t116d39 (sd1405) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c4t116d48 (sd1414) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c4t116d49 (sd1415) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c4t35d38 (sd1650) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
            c4t35d39 (sd1651) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
            c4t35d48 (sd1660) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
            c4t35d49 (sd1661) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
        fcaw1 is a "compatible"
            c3t116d38 (sd1896) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c3t116d39 (sd1897) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c3t116d48 (sd1906) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c3t116d49 (sd1907) is a "HITACHI DF400" SCSI 16.7 GB
        disk drive
            c3t35d38 (sd2142) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
            c3t35d39 (sd2143) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
            c3t35d48 (sd2152) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
            c3t35d49 (sd2153) is a "HITACHI DF400" SCSI 16.7 GB disk
        drive
        [3]$

        A DESCRIPTION OF THE PROBLEM :
        Socket.close() does not seem to update the connection state
        of the socket. So after closing a previously connected
        socket, both isConnected() and isClosed() return true.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the code, you'll see it.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        actual results:

        [370]$ java TestClose
        Before close - isConnected(): true
        Before close - isClosed(): false
        After close - isConnected(): true
        After close - isClosed(): true


        I would expect to see isConnected return false after the
        socket is closed.


        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.net.*;
        import java.nio.channels.*;

        public class TestClose
        {
          public static void main(String[] args_)
          {
            String host = "sascs5";
            int port = 7;
            try
            {
              if (args_.length > 0)
              {
                host = args_[0];
                if (args_.length > 1)
                {
                  port = Integer.parseInt(args_[1]);
                }
              }
              Socket s = new Socket();
              InetSocketAddress addr = new InetSocketAddress(host, port);
              s.connect(addr);

              if (s.isConnected

              jccollet Jean-Christophe Collet (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: