From owner-freebsd-java@FreeBSD.ORG Mon Oct 16 17:24:12 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A652816A4C2 for ; Mon, 16 Oct 2006 17:24:12 +0000 (UTC) (envelope-from fireduck@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FB7843D49 for ; Mon, 16 Oct 2006 17:24:08 +0000 (GMT) (envelope-from fireduck@gmail.com) Received: by ug-out-1314.google.com with SMTP id m2so755038uge for ; Mon, 16 Oct 2006 10:24:08 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=ON/LlK/neLrY31/BSo4zWJcs4KZPm0ItRJB46OMz/wVk74Lm7LjvPNrYLkvlcYqNiPo+bJww/TwGg2yI45Xkf1C0TKYzaZLUyyanT4WF49gdgkoGeVAxCL4wYZ2EV/BbsRY/V48KcOeaxm+XjWMbxe0r9eLYkTcLLH7xQlG9qTM= Received: by 10.82.126.5 with SMTP id y5mr1144163buc; Mon, 16 Oct 2006 10:24:08 -0700 (PDT) Received: by 10.82.190.1 with HTTP; Mon, 16 Oct 2006 10:24:08 -0700 (PDT) Message-ID: <7956f3200610161024o3598e217oba81116bd84a7c99@mail.gmail.com> Date: Mon, 16 Oct 2006 13:24:08 -0400 From: "Joseph Gleason" To: freebsd-java@freebsd.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_32835_26806047.1161019448435" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Bug in java.net.Socket close() behavior? X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Oct 2006 17:24:12 -0000 ------=_Part_32835_26806047.1161019448435 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline According to the API for java.net.Socket close(): "Any thread currently blocked in an I/O operation upon this socket will throw a SocketException." http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() I have observed that java 1.5 on FreeBSD does not follow this while the Windows and Linux ones I have tested do. On the FreeBSD runtimes that I have tested, a thread blocked on reading a socket just hangs forever if the socket is closed. Attached is a simple program that tests this behavior. It just connects to a port on one of my servers and has a reader thread watching input from the socket and closes the socket in a different thread to see if the reader thread gets an exception. Java runtimes that I have tested this on: # java -version java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.5.0-b01) Java HotSpot(TM) 64-Bit Server VM (build diablo-1.5.0_07-b01, mixed mode) # java -version java version "1.5.0-p2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-p2-root_07_mar_2006_02_41) Java HotSpot(TM) 64-Bit Server VM (build 1.5.0-p2-root_07_mar_2006_02_41, mixed mode) ------=_Part_32835_26806047.1161019448435--