JDK-4757713 : java.net.URI.getHost() == null for URIs with host names starting with a digit
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2002-10-03
  • Updated: 2002-10-04
  • Resolved: 2002-10-04
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 10/03/2002


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


FULL OPERATING SYSTEM VERSION :

glibc-2.2.5-16mdk

Linux jakarta.cpd.ufsm.br 2.4.19-16mdk-leonardo #2 Wed Oct 2
13:58:10 BRT 2002 i686 unknown unknown GNU/Linux

Mandrake Linux release 9.0 (dolphin) for i586

Windows 2000

A DESCRIPTION OF THE PROBLEM :
If a java.net.URI is constructed with an URI whose host name
starts with a digit and is not a valid IP address,
java.net.URI.getHost() == null.

This bug is critical in my organization, where the host
names start with the room number. We're deploying RMI
services, and the clients (applets) can't connect with the
registry service because java.rmi.Naming uses java.net.URI
internally. When java.net.URI.getHost() returns null,
java.rmi.Naming tries to connect with a registry in the
local host, producing an AccessControlException (and a
ConnectException).


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Construct a new java.net.URI with a string representing a
URI in the form :

[scheme]://[one_or_more_digits][remaining_host_name]/[anything]
(for example: rmi://126g/MyServer)

2. java.net.URI.getHost() returns null
(it should return "126g" in that case)


EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected Result:
java.net.URI.getHost() returns the host name

Actual Result:
java.net.URI.getHost() returns null

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No exceptions.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.net.URI;

public class Test
{
	public static void main(String[] args)
		throws Exception
	{
		String uri = "rmi://126g/MyServer";
		System.out.println("uri = " + uri);
		System.out.println("getHost() = " + new URI(uri).getHost());
	}
}

---------- END SOURCE ----------

(Review ID: 165342) 
======================================================================

Comments
EVALUATION The issue require a clarification to the URI spec. This is in progress for mantis - see 4715098 & 4671369. ###@###.### 2002-10-04
04-10-2002