JDK-4301064 : Name Resolution problem with Java PlugIn
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.2.2
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-12-21
  • Updated: 2001-10-19
  • Resolved: 2000-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other Other
1.2.2_005 005Fixed 1.2.2_006Fixed 1.3.0Fixed 1.3.1Fixed
Related Reports
Relates :  
Relates :  
Description
This problem occurs when constructing a URL and/or when passing the URL to
the showDocument method of AppletContext, when there is no DNS or WINS
available in the network. 

Here's how to reproduce this bug:

This bug requires that you have two web servers.  Let's call them ONE and
TWO.  The idea is to use ONE as the primary server and TWO as the secondary
server.  There are two applets involved. One is named showDocBugApplet and
should be available on server ONE.  The other is named showDocBugSubApplet
and should be available on server TWO.  The first applet uses showDocument
to invoke the second applet from server TWO.  You will need to modify the
source showDocBugApplet.java to put the IP Address of server TWO into the
URL construction code (in place of 192.168.68.55).  You must use the IP addr
-- not the name.  Then recompile.

Next rebuild the Jar files.  The HTML files assume there are two JAR files,
one for showDocBugApplet.jar and another for showDocBugSubApplet.jar.  Then
install these two JAR files plus the two HTML files.  [You can just put all
four files on both servers :-) ]

Now here's how you run these.  From IE or Netscape on a PC ( I did not check
if the bug exists on Solaris clents), launch the top-level applet from
server ONE, as follows:

      http://one/showDocBugApplet.html                 <-- depending where
you put the HTML file, etc.

You should see a simple JApplet with a button.  Click the button, and it
will do the work to show the subapplet from server TWO.

If you have normal DNS/WINS/etc. setup, it should launch the new applet just
fine.  Now exit.

Next, change your network so that the two servers and a pc client are not
able to communicate with the DNS server or WINS server.  Simulate a broken network by putting your pc and the two servers in a single IP network (or subnet).  You don't need a router.  Then exit the any browser windows (to give the Java PlugIn VM afresh start).  Then launch IE (or Netscape) on the client PC.  Then enterthe URL mentioned above.  It should launch fine.

Then click the button.  The browser/plugin/applet will take on the order of
minutes (about 60 TIMES) as long as it did before, to launch the subApplet.
You'll probably think it is not working at all.  During this time the PC
appears to have problems doing a reverse lookup of the IP address for the
second server.  When convinced that there is a problem, kill the IE windows.

Pull out a sniffer or use snoop to look at the traffic and you'll see "NS"
packets for name resolution, which repeat over and over for a "long" time,
getting TIMEOUTs but continuing to try.

Source code for the test case is below.  You'll also find a copy of the source
files in /home/nrodin/cases/brocade/722335, as well as sniffer output from our 
testing.  The file cap40secs.txt showed the network packets when there were no dns or wins entries configured.  The applet launch took 40 seconds, compared to about 5 seconds normally.

The second capture, cap10mins.txt, was from a situation where we also put in ipaddresses fora primary and secondary DNS server, as well as a primary and secondary WINSserver, and (probably without impact) a domain name of "sun.com".  Those addresses for DNS and WINS were NOT present in the network.  The delay
increased from 40 (vs. 5) seconds to a total of ten minutes!

--------------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>ShowDocBugApplet</TITLE>
</HEAD>

<BODY BGCOLOR=#000000 TEXT="#ffffff">
<center>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.0 -->

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 550 HEIGHT = 250  codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">
<PARAM NAME = CODE VALUE = showDocBugApplet >
<PARAM NAME = ARCHIVE VALUE = "showDocBugApplet.jar" >

<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.2.2" java_CODE = showDocBugApplet java_ARCHIVE = "showDocBugApplet.jar" WIDTH = 550 HEIGHT = 250  simulatenot = "yes"  pluginspage="http://java.sun.com/products/plugin/1.2.2/plugin-install.html"><NOEMBED></COMMENT>
alt="Java applet support is not working.  Verify installation/configuration of Java PlugIn, version 1.2.2.  You may download the plugin from <a href=http://java.sun.com/products/plugin/1.2.2/plugin-install.html>http://java.sun.com/products/plugin/1.2.2/plugin-install.html</a>"
</NOEMBED></EMBED>
</OBJECT>

<!--
<APPLET  CODE = showDocBugApplet ARCHIVE = "showDocBugApplet.jar" WIDTH = 550 HEIGHT = 250 
	alt="Java applet support is not working.  Verify that your browser supports Java version 1.1.5 or higher">
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
<br>
</center>
</BODY>
</HTML>
--------------------------------------------------------------------------------
import java.awt.*;
import javax.swing.*;
import java.net.URL;

/**
 * A basic extension of the javax.swing.JApplet class
 */
public class showDocBugApplet extends JApplet
{
	javax.swing.JButton showDocButton = new javax.swing.JButton();

	public void init()
	{
		// This line prevents the "Swing: checked access to system event queue" message
		// seen in some browsers.
		getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
		
		getContentPane().setLayout(null);
		setSize(426,266);
		showDocButton.setText("Invoke showDocBugSubApplet");
		getContentPane().add(showDocButton);
		showDocButton.setBounds(36,36,333,127);
	
		SymAction lSymAction = new SymAction();
		showDocButton.addActionListener(lSymAction);
	}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == showDocButton)
				showDocButton_actionPerformed(event);
		}
	}

	void showDocButton_actionPerformed(java.awt.event.ActionEvent event)
	{
		try {
		    URL url;
		    System.err.println("starting showDocument button actionPerformed");
		    System.err.println("constructing url to other device");
		    url = new URL(getDocumentBase(), "http://129.144.238.3/showDocBugSubApplet.html");
		    System.err.println("constructed url to other device"+url.toString());
		    String browserTitle = "showDocBugSubApplet";
		    System.err.println("invoking showDocument to that url");
		    getAppletContext().showDocument(url, browserTitle);
		    System.err.println("invoked showDocument to that url");
		    System.err.println("finished showDocument button actionPerformed");
		} catch (Exception ex) {
		    System.err.println("Exception: "+ex);
		}
	}
}

--------------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>ShowDocBugSubApplet</TITLE>
</HEAD>

<BODY BGCOLOR=#000000 TEXT="#ffffff">
<center>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.0 -->

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 550 HEIGHT = 250  codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">
<PARAM NAME = CODE VALUE = showDocBugSubApplet >
<PARAM NAME = ARCHIVE VALUE = "showDocBugSubApplet.jar" >

<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.2.2" java_CODE = showDocBugSubApplet java_ARCHIVE = "showDocBugSubApplet.jar" WIDTH = 550 HEIGHT = 250  simulatenot = "yes"  pluginspage="http://java.sun.com/products/plugin/1.2.2/plugin-install.html"><NOEMBED></COMMENT>
alt="Java applet support is not working.  Verify installation/configuration of Java PlugIn, version 1.2.2.  You may download the plugin from <a href=http://java.sun.com/products/plugin/1.2.2/plugin-install.html>http://java.sun.com/products/plugin/1.2.2/plugin-install.html</a>"
</NOEMBED></EMBED>
</OBJECT>

<!--
<APPLET  CODE = showDocBugSubApplet ARCHIVE = "showDocBugSubApplet.jar" WIDTH = 550 HEIGHT = 250 
	alt="Java applet support is not working.  Verify that your browser supports Java version 1.1.5 or higher">
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
<br>
</center>
</BODY>
</HTML>
--------------------------------------------------------------------------------

import java.awt.*;
import javax.swing.*;
import java.net.URL;

/**
 * A basic extension of the javax.swing.JApplet class
 */
public class showDocBugSubApplet extends JApplet
{
	javax.swing.JButton showDocSubButton = new javax.swing.JButton();

	public void init()
	{
		// This line prevents the "Swing: checked access to system event queue" message
		// seen in some browsers.
		getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
		
		getContentPane().setLayout(null);
		setSize(426,266);
		showDocSubButton.setText("We made it here");
		getContentPane().add(showDocSubButton);
		showDocSubButton.setBounds(36,36,333,127);
	
		SymAction lSymAction = new SymAction();
		showDocSubButton.addActionListener(lSymAction);
	}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == showDocSubButton)
				showDocSubButton_actionPerformed(event);
		}
	}

	void showDocSubButton_actionPerformed(java.awt.event.ActionEvent event)
	{
	        System.err.println("Did SubApplet's NOOP actionPerformed");
	}
}



Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel-rc3 FIXED IN: kestrel INTEGRATED IN: 1.2.2_005 1.2.2_006 1.3.1 kestrel VERIFIED IN: 1.2.2_005 1.2.2_006 1.3.1_01a kestrel-rc3
14-06-2004

SUGGESTED FIX FYI: The suggested fix has a flaw and should not be used. An more optimal fix was implemented for Kestrel. gary.ellison@eng 2000-08-25 Previously problematic fix removed from Suggested Fix section. lew.yobs@Eng 2000-09-29 Corrected fix applied to Kestrel is to two files; required to be used jointly: (1) src/share/classes/java/net/SocketPermission.java *** 1035,1041 **** if (isReadOnly()) throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection"); ! permissions.addElement(permission); } /** --- 1035,1043 ---- if (isReadOnly()) throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection"); ! // optimization to ensure perms most likely to be tested ! // show up early (4301064) ! permissions.add(0, permission); } /** (2) src/share/classes/sun/security/provider/PolicyFile.java *** 1113,1118 **** --- 1113,1121 ---- if (perms == null) perms = new Permissions(); + // optimization to put the most likely to be + // used permissions first (4301064) + policy.getPermissions(perms,codesource); if (additionalPerms != null) { Enumeration e = additionalPerms.elements(); while (e.hasMoreElements()) { *************** *** 1120,1126 **** } additionalPerms = null; } - policy.getPermissions(perms,codesource); notInit=false; } } --- 1123,1128 ----
11-06-2004

EVALUATION too risky to fix for kestrel jerome.dochez@Eng 2000-01-05 In Java Plug-in, we always try to do reverse DNS lookup for security check. When a security check is triggered, the DNS lookup will be done through java.net.InetAddress and java.net.SocketPermission. This problem occurs when DNS is not available, and a reverse lookup is needed for localhost, and it just blocks for a long time because the JDK keeps trying to resolve the DNS with a long timeout. This is not a plug-in bug. However, we may need to re-adjust the timeout value for DNS lookup, or do some special cases for localhost in java.net. I will reassign this bug to the java.net owner. stanley.ho@Eng 2000-02-09 The suggested fix to order the SocketPermission collection based on most (likely) recently used is a good compromise. gary.ellison@eng 2000-02-21 FYI: The suggested fix has a flaw and should not be used. An more optimal fix was implemented for Kestrel. gary.ellison@eng 2000-08-25
21-02-2000