hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Hicks" <jehi...@novell.com>
Subject Re: Force-close connections queston
Date Mon, 17 Jul 2006 17:00:04 GMT
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

    public void releaseConnection(final HttpConnection conn) 
    //TODO Need something here to check if we are SSL or not 
    // Getting a NullPointerException here. Why? 

    catch(ClassCastException cce) 
    // It is okay, we are most likely just not running SSL. 
    if (conn == null) 

I get a NullPointerException on this line: 


Can anybody tell why? 


Jeremy Hicks
Novell, Inc., the leading provider of information solutions

>>> Roland Weber <http-async@dubioso.net> 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,

To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message