Обсуждение: Malformed URLs
Hello, in a project I work on we recently upgraded our JDBC driver from 8.0-311.jdbc2 to 8.3-603.jdbc4. We started receiving *lots* of errors related to too many open files that turned out to be a result of malformed DB URL. Some details: - The problematic DB URL is: jdbc:postgresql:///127.0.0.1/example (notice the triple slash before IP) - It did work fine with the old 8.0 driver - no exceptions, no problems using the DB. - After update, we started getting exceptions (stacktrace below). I think it is a bug. Firstly, it did work in older versions of the driver. Secondly, it shouldn't leave any open sockets, because this way your app will likely have difficult to track issues with number of open files. Where shall I submit this bug? org.postgresql.util.PSQLException: Something unusual has occured to cause the driver to fail. Please report this exception. ... Caused by: java.lang.IllegalArgumentException: protocol = socket host = null at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java: 146) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:358) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.<init>(Socket.java:366) at java.net.Socket.<init>(Socket.java:180) at org.postgresql.core.PGStream.<init>(PGStream.java:62) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java: 77) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java: 66) at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java: 124) at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java: 30) at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java: 29) at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java: 24) at org.postgresql.Driver.makeConnection(Driver.java:386) at org.postgresql.Driver.connect(Driver.java:260) ... 35 more Thanks. Konrad Garus
On Thu, 2 Oct 2008, Konrad Garus wrote: > in a project I work on we recently upgraded our JDBC driver from > 8.0-311.jdbc2 to 8.3-603.jdbc4. We started receiving *lots* of errors > related to too many open files that turned out to be a result of > malformed DB URL. > > Some details: > - The problematic DB URL is: jdbc:postgresql:///127.0.0.1/example > (notice the triple slash before IP) > - It did work fine with the old 8.0 driver - no exceptions, no > problems using the DB. > - After update, we started getting exceptions (stacktrace below). > > I think it is a bug. Firstly, it did work in older versions of the > driver. Secondly, it shouldn't leave any open sockets, because this > way your app will likely have difficult to track issues with number of > open files. Where shall I submit this bug? What I'm seeing doesn't match your explanation and is JVM specific. With a 1.4 JVM and either the old or new driver I get: Exception in thread "main" org.postgresql.util.PSQLException: The connection attempt failed. Exception: java.net.UnknownHostException: / If you were using the JDBC2 driver you were likely on a 1.2 or 1.3 JVM which may have had different behavior as well. With a 1.5 or 1.6 JVM I do see the same error as you report, but I don't see that we're leaking any sockets. As you can see the stacktrace is from the Socket constructor, so we certainly can't be expected to close something that was never created. It may be a problem with the JVM leaking things, but I haven't looked into that. Caused by: java.lang.IllegalArgumentException: protocol = socket host = null at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:146) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:358) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.<init>(Socket.java:366) at java.net.Socket.<init>(Socket.java:180) at org.postgresql.core.PGStream.<init>(PGStream.java:62) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:73) Kris Jurka
Hello Konrad, Konrad Garus schrieb: > - The problematic DB URL is: jdbc:postgresql:///127.0.0.1/example > (notice the triple slash before IP) > As you say, the URL is malformed. It is an URL without an Host, and the path of the URL is /127.0.0.1/example . Why don't you just fix your broken URLs? I don't think "fixing" the driver to work with errornous URLs is the right way. With best regards, Daniel Migowski