Miscellaneous changes to java.net worth mentioning:
Noteworthy bug fixes:
- InetAddress
A bug existed in JDK 1.0.2 where one could not create an InetAddress
out of a IP address String (for example, "192.0.2.1") if a
corresponding host name (for example, "www.example.com") could not
be found. This resulted in an UnknownHostException. The bug is
fixed in JDK 1.1. Additionally, when an InetAddress is created from
an IP address, the corresponding hostname is not looked up until
specifically requested (via InetAddress.getHostName()), as a
performance enhancement.
- ServerSocket/DatagramSocket close()
A bug existed in JDK 1.0.2 where the close()
method of
ServerSocket and DatagramSocket were synchronized
. The
result was that if one thread were blocked indefinitely in
DatagramSocket.receive() or ServerSocket.accept(), another thread
couldn't break the blocking thread out by calling close(). This is
fixed in JDK1.1 by making the close() methods unsynchronized.
- URLConnection
There was a bug in JDK 1.0.2 where the methods on URLConnection:
- setRequestProperty()
- getRequestProperty()
- getHeaderField()
- getHeaderFieldInt()
- getContentLength()
- getDate()
etc, did not work. These are fixed in JDK 1.1.
Binding to local port/address:
- Socket, ServerSocket, DatagramSocket
These classes has overloaded constructors for binding to a specific
local address and port. This is useful and necessary for
applications like proxy servers that operate on multi-homed
machines, and need particular control over which network interfaces
are used.
MulticastSocket:
- The MulticastSocket class was moved from package sun.net into
the core API of java.net.
HttpURLConnection:
- JDK1.1 introduces a new class, HttpURLConnection which extends
URLConnection, and provides additional functionality specific to
HTTP:
- Ability to use all of the request methods with HTTP/1.1, like:
- GET
- POST
- PUT
- HEAD
- TRACE
- DELETE
- OPTIONS
- Control over whether to follow HTTP redirects.