DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=28322>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28322 Connection timeout logic redesign ------- Additional Comments From [EMAIL PROTECTED] 2004-04-12 12:46 ------- > Completely agree. The trouble is that javax.net.SocketFactory is available as of > Java 1.4 only. I was thinking about using ProtocolSocketFactory instead but > initially decided against it, as it results in a sort of logical recursion: a > helper class takes a class as a parameter for which it acts as a helper class. > Thinking about it causes stack overflow in my brain requiring a hard reboot with > a glass of malt whisky. But I'll give it another shot, as it can potentially a > lot of ugly code in the protocol socket factories Good point. SocketFactory is a part of JSSE, but it may be annoying for users to include JSSE if they're not using it. This may be a lost cause. > I seriously do not know what code may be moved to a static initializer unless we > create a dummy socket and try calling connect on it. But to which port? Am I > missing something? What if we just set a static flag: refection failed, do not > try it again? This is what I was thinking: private static boolean connectSupported; private static Constructor insetSocketAddressConstructor; private static Method connectMethod; static { try { Class addressClass = Class.forName("java.net.InetSocketAddress"); insetSocketAddressConstructor = addressClass.getConstructor( new Class[] { String.class, Integer.TYPE }); connectMethod = Socket.class.getMethod("connect", new Class[] {Class.forName("java.net.SocketAddress"), Integer.TYPE}); connectSupported = true; } catch (Exception e) { // 1.4 socket connect method not supported connectSupported = false; } } Inside createSocket() we could just test 'connectSupported' instead of trying the reflection. We can also reuse the Constructor and Method to avoid looking them up again. Mike --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]