[CONJ-37] Support custom SocketFactory which does not support an InetSocketAddress Created: 2013-05-16 Updated: 2013-07-05 Resolved: 2013-05-21 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | None |
| Affects Version/s: | 1.1.2 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Torsten Krah | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux, JDK 1.7 |
||
| Description |
|
Its possible to use a custom SocketFactory. To use unix Sockets theres exist a project called junixsocket here: http://code.google.com/p/junixsocket/ I've writte a custom SocketFactory which does create unix sockets - but the code does force the connect to an InetSocketAddress sockAddr = new InetSocketAddress(host, port); in connect of MySQLProtocol class - which are of cause not supported and denied by the AFUnixSocket implementation. I've patched the Protocol class to read like this:
and did specify the property unixsocket - value does not matter - to the properties given to the Driver class. Would be nice if its possible to get some patch or property switch like this one, to make use of them. |
| Comments |
| Comment by Vladislav Vaintroub [ 2013-05-16 ] |
|
I might have misunderstood the issue (you did not attach the factory implementation) , however
|
| Comment by Torsten Krah [ 2013-05-21 ] |
|
Yes the factory does create AF_UNIX sockets which are already connected - there is no need to connect this socket at all. Although it would be nice to not have the call to "connect" at all but let this handle the socket factory - like the mysql com.mysql.jdbc.Socketfactory class does. |
| Comment by Vladislav Vaintroub [ 2013-05-21 ] |
|
I pushed a fix similar to yours, but instead of using dummy property, I just check if socket created by the factory is connected. If so, I skip connecting. |
| Comment by Torsten Krah [ 2013-07-05 ] |
|
Confirmed its fixed, thx. |
| Comment by Vladislav Vaintroub [ 2013-07-05 ] |
|
BTW, I recently implemented Unix domain socket support in the current trunk. Maybe you'll find it helpful. It needs JNA (Java Native Access) library to work (http://mvnrepository.com/artifact/net.java.dev.jna/jna). You'll need to use localSocket=/path/to/mysql.sock to connect via unix socket. |