Okay, I'm now trying with this Connection Helper class. Below is my
custom connection manager class:
import org.apache.commons.httpclient.*;
import javax.net.ssl.*;
public class MyHttpConnectionManager extends
MultiThreadedHttpConnectionManager
{
public void releaseConnection(final HttpConnection conn)
{
//TODO Need something here to check if we are SSL or not
try
{
// Getting a NullPointerException here. Why?
((SSLSocket)MyConnectionHelper.getSocket(conn)).getSession().invalidate();
}
catch(ClassCastException cce)
{
// It is okay, we are most likely just not running SSL.
}
if (conn == null)
{
return;
}
conn.close();
super.releaseConnection(conn);
}
}
I get a NullPointerException on this line:
((SSLSocket)MyConnectionHelper.getSocket(conn)).getSession().invalidate();
Can anybody tell why?
Thanks
Jeremy Hicks
Novell, Inc., the leading provider of information solutions
http://www.novell.com
>>> Roland Weber <[EMAIL PROTECTED]> 07/08/06 10:49 AM >>>
Hello Jeremy,
> ((SSLSocket) conn.getSocket()).getSession().invalidate();
> won't work for me because the getSocket() call on the HttpConnection
conn is a protected method.
> I'm not within scope. What are my options?
Yet another design limitation of the 3.x codebase.
Easiest workaround is to get into scope:
package org.apache.commons.httpclient;
import java.net.Socket;
public final class MyConnectionHelper {
/** disabled constructor */
private MyConnectionHelper() {
}
public final static Socket getSocket(HttpConnection conn) {
return conn.getSocket();
}
}
I think you can rely on HttpClient not to define any classes
with a "My" prefix :-)
hope that helps,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]