JDK-6799990 : unrecognized message ID 42 (or 46) with next-generation Java plug-in
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10,6u22
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: other,windows,windows_xp
  • CPU: generic,x86
  • Submitted: 2009-02-02
  • Updated: 2011-04-27
  • Resolved: 2011-03-31
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.
JDK 6 JDK 7
6u24-rev b25Fixed 7Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
jre 1.6.0_10 and 1.6.0_11


ADDITIONAL OS VERSION INFORMATION :
Mine is Windows XP version 2002 SP3 plus Firfox 3.0.5. But seems to happen in any OS and any browser.


EXTRA RELEVANT SYSTEM CONFIGURATION :
Only happen in plug-in 1.6.0_10 and 1.6.0_11 with "Enable the next-generation Java plug-in" checked in java control panel.

A DESCRIPTION OF THE PROBLEM :
Our java applet based application broke constantly in clients machine since they upgrade to java plu-in 1.6.0_10 or 1.6.0_11.
Upon close exam, we believe there is a bug in HttpURLConnection class that
when a thread running  HttpURLConnection is being interrupted by another thread, the class is corrupted somewhere and print our an InterruptedException. In java console, following interruptedException is printed along with unrecognized message ID 42 (message id 46 sometimes). Once we see this exception, unexpected behavior happens in our application afterwords, such as cookie lost. The problem never happens when running in a JDE or  webstart. It also never happen in previous version of jre plug-in or turn "Enable the next-generation java plug-in" off. It only happens with applet, with plug-in 1.6.0_10 or 11 and with the next-generation java plug-in enabled.

java.lang.InterruptedException
	at java.lang.Object.wait(Native Method)
	at sun.plugin2.message.Queue.waitForMessage(Unknown Source)
	at sun.plugin2.message.Pipe.receive(Unknown Source)
	at sun.plugin2.main.client.MessagePassingExecutionContext.getProxyList(Unknown Source)
	at sun.plugin2.main.client.PluginProxySelector.select(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at TestApplet$3.run(TestApplet.java:48)
	at java.lang.Thread.run(Unknown Source)
sun.plugin2.main.client.PluginMain: unrecognized message ID 42



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please use the test case code I posted.
- Compile it to a jar
- Sign the jar
- Run it as a applet in a browser (I use both firefox 3.0.5 and IE 6.0.29)
- Make sure browser has Java Plug-in 1.6.0_10 or  1.6.0_11
- Make sure  "Enable the next-generation java plug-in" is checked in java control panel.
- set java colsole trace level to 5 by pressing 5.
- click on test button
- watch java console, java.lang.InterruptedException and unrecognized message ID 42 (or 46) will appear.




EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Some messages printed but  no InterruptedException, no unrecognized message ID 42 (or 46)

ACTUAL -
Java console print out exceptions as following:

Request: http://www.google.com
Connected to http://www.google.com
network: Cache entry not found [url: http://www.google.com/, version: null]
java.lang.InterruptedException
	at java.lang.Object.wait(Native Method)
	at sun.plugin2.message.Queue.waitForMessage(Unknown Source)
	at sun.plugin2.message.Pipe.receive(Unknown Source)
	at sun.plugin2.main.client.MessagePassingExecutionContext.getProxyList(Unknown Source)
	at sun.plugin2.main.client.PluginProxySelector.select(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at TestApplet$3.run(TestApplet.java:48)
	at java.lang.Thread.run(Unknown Source)
network: Connecting http://www.google.com/ with proxy=DIRECT
sun.plugin2.main.client.PluginMain: unrecognized message ID 42
network: Connecting http://www.google.com:80/ with proxy=DIRECT
network: Connecting http://www.google.com/ with cookie "PREF=ID=c6fa9c86bc98312b:TM=1232480837:LM=1232480837:S=F2wXIF7ZbsKD_hK7"
network: Cache entry not found [url: http://www.google.ca/, version: null]
network: Connecting http://www.google.ca/ with proxy=DIRECT
network: Connecting http://www.google.ca:80/ with proxy=DIRECT
network: Connecting http://www.google.ca/ with cookie "PREF=ID=c5a56a5bfc85c016:TM=1232480837:LM=1232480837:S=EuFaQsFtaTEw_APv"
Fecthed data from http://www.google.com



ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.InterruptedException
	at java.lang.Object.wait(Native Method)
	at sun.plugin2.message.Queue.waitForMessage(Unknown Source)
	at sun.plugin2.message.Pipe.receive(Unknown Source)
	at sun.plugin2.main.client.MessagePassingExecutionContext.getProxyList(Unknown Source)
	at sun.plugin2.main.client.PluginProxySelector.select(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at TestApplet$3.run(TestApplet.java:48)
	at java.lang.Thread.run(Unknown Source)
sun.plugin2.main.client.PluginMain: unrecognized message ID 42


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.SwingUtilities;

/**
 * @author Stone Huang
 *
 */
@SuppressWarnings("serial")
public class TestApplet extends JApplet {
	@Override
	public void start() {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				setLayout(new FlowLayout());
				add(createTestButton());
			}
		});
	}
	private JButton createTestButton() {
		JButton button = new JButton("Test");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				test();
			}
		});
		return button;
	}

    public void test() {
		final Thread thread = new Thread(new Runnable() {
		    public void run() {
			try {
			    URL url = getUrl("http://www.google.com");
			    System.out.println("Request: " + url.toString());
			    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
			    System.out.println("Connected to " + url.toString());
			    BufferedReader  reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			    String data = reader.readLine();
			    System.out.println("Fecthed data from " + url.toString());
			    reader.close();
			    conn.disconnect();
			    System.out.println("Response: " + data);
			} catch (IOException e) {
				e.printStackTrace();
			}
		    }
		});
		
		thread.start();
		thread.interrupt();
    }
    
    private URL getUrl(String url) {
    	try {
    	    return new URL(url);
    	} catch (MalformedURLException e) {
    	    e.printStackTrace();
    	    return null;
    	}
    }
}



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

CUSTOMER SUBMITTED WORKAROUND :
None.

Release Regression From : 6u7
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
SUGGESTED FIX Webrev: http://jpsesvr.sfbay.sun.com:8080/ctetools/html/ViewDetail.jsp?index=3970 RTI: https://jetsvr.sfbay.sun.com:8443/BugApproval/ViewDetail.jsp?index=10532
01-04-2011

EVALUATION As Hao Dong's comment says, "unrecognized message ID 42" and "unrecognized message ID 46" are not problematic in itself. They mean that the corresponding processing context for ProxyReply and CookieReply messages was destroyed, and there may be many legitimate reasons for this, for example, an explicit interrupt() call issued by the applet's code (the customer confirmed that this is their case). The problem is that in plugin2 we didn't provide workaround mechanisms for situations when proxy/cookie information is not available from the browser side. Actually, plugin2-client already features a local cache for cookie values (see src\common\share\classes\com\sun\deploy\net\cookie\DeployCookieSelector.java, getCookieInfo() method) but it does not work as expected. The idea behind the code is that DeployCookieSelector should intercept CookieUnavailableException, and get the cookie value from the local cache (this value is updated after every successful CookieReplyMessage from plugin2-server). But CookieUnavailableException is mistakenly intercepted by deploy\src\plugin\share\classes\sun\plugin2\main\client\MessagePassingExecutionContext.java doCookieOp() method. The fix is to modify doCookieOp() exception handlers. This fix also introduces the proxy cache (thanks to Poonam's help!). Most part of the code came from the implementation in the old plugin. The behavior is the same. I changed the base of PluginProxySelector from DeployProxySelector to ProxySelector - this is to eliminate the dependency on the old plugin code (most methods of the base class were overriden anyway). I confirmed with PTS that we do not have an internal test case/environment for this issue. The test case in this bug report do not fully represent the problem (it just shows that the messages 42 and 46 may appear in the log). The cookie cache part was verified with the customer in earlier debug sessions. I verified the proxy cache part internally using the testcase http://sqeweb.sfbay.sun.com/jsn/users/fred/master_run/deployment/src/plugin/CustomProgressBar/CustomProgressBar/html/NoCustomJarTest.html and also a couple of others from the same folder (BasicTest.html, NoCustomJarTest.html). I used the instrumented version of the fix and confirmed the correct proxy cache behavior with both FF and IE. I didn't see any 42 or 46 messages, and could not reproduce the original problem. The customer is also verifying the latest proxy cache changes.
04-03-2011

EVALUATION Message ID 42 is a ProxyReply Message and 46 is a CookieReply Message sent from the browser side vm. The applet execution thread is interrupted when it is waiting for proxy or cookie list from the browser. The conversation is closed therefore and reply messages from the browser are delivered to the plugin main thread which is not supposed to process such messages. We plan to implement a proxy/cookie cache at client side. When problems like above happen, we can use the last known proxy/cookie to do the network.
02-02-2009