This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

NPE in Socket()#connect(SocketAddress) for giberish socket-address?


Hi there,

I have stumbled across a possible fixed bug in my "ancient" libgcj.
I have the following small piece of code:

--- 8< 8< 8< ---
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;

public class SocketConnectNullPointer
{
  public static void main(String[] args) throws IOException
  {
    String host = "giberish";
    int port = 110;
    Socket s = new Socket();
    System.out.println( "Connecting 1..." );
    InetSocketAddress isa = new InetSocketAddress(host, port);
    System.out.println( "Connecting 2..." );
    isa.getAddress();
    System.out.println( "Connecting 3..." );
    isa.getPort();
    System.out.println( "Connecting 4..." );
    s.connect(isa, 10000);
    System.out.println( "Done!" );
  } // main
} // SocketCon...
--- 8< 8< 8< ---

And if run with a non-giberish host-name (something that resolves), it works. However, when running with something that does not resolve I get a null pointer exception:

# /tmp/scnp
Connecting 1...
Connecting 2...
Connecting 3...
Connecting 4...
Exception in thread "main" java.lang.NullPointerException
--- 8< 8< 8< ---

My "natPlainSocketImplPosix.cc" is from CVS 2005-11-04 (updated due to a bug fixed wrt. Socket#close() http://gcc.gnu.org/ml/java/2005-11/msg00098.html).

Ok... Now, before sending this question, I just checked the bug-database, and it seems like Tromey beat me to it:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21941

So I reckon this has not been fixed yet?

// Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]