Re: Usage of SocketFactory#createSocket(String host, int port)

2018-03-16 Thread Pascal Schumacher

Thanks for the feedback Claus and Andrea!

I did not find anything in the javadoc concerning default timeouts etc.

As SocketFactory is an abstract class, the behavior of 
#createSocket(String host, int port) of course depends on the concrete 
implementation in use, but at least the default implementation of Oracle 
Java 8 Update 152 connects without using a timeout.


I created https://issues.apache.org/jira/browse/CAMEL-12358 and 
https://github.com/apache/camel/pull/2258 for this.


Cheers,
Pascal

Am 16.03.2018 um 07:18 schrieb Claus Ibsen:

Yeah that sounds reasonable, have you checked the javadoc of the jdk
operations? But in all regards I do think your suggestion seems
better. You are welcome to do a PR / commit / JIRA etc.

On Tue, Mar 13, 2018 at 8:33 PM, Pascal Schumacher
 wrote:

Hello everybody,

took a look at the camel-smpp source code and noticed that is using
javax.net.SocketFactory#createSocket(String host, int port) which "creates a
socket and connects it to the specified port number at the specified
address" according to the javadoc.

As Socket#setSoTimeout is called later on and Socket#connect(SocketAddress
endpoint, int timeout) exists, I guess the initial connection is created
without any timeout?

As blocking operations without timeouts should be avoided, should the code
be changed to:

socket = socketFactory.createSocket();
socket.connect(new InetSocketAddress(host, port), timeout);

or am I missing something?

Thanks,

Pascal









Re: Usage of SocketFactory#createSocket(String host, int port)

2018-03-15 Thread Andrea Cosentino
I believe you're right.

--
Andrea Cosentino 
--
Apache Camel PMC Member
Apache Karaf Committer
Apache Servicemix PMC Member
Email: ancosen1...@yahoo.com
Twitter: @oscerd2
Github: oscerd






On Tuesday, March 13, 2018, 8:33:51 PM GMT+1, Pascal Schumacher 
 wrote: 





Hello everybody,

took a look at the camel-smpp source code and noticed that is using 
javax.net.SocketFactory#createSocket(String host, int port) which 
"creates a socket and connects it to the specified port number at the 
specified address" according to the javadoc.

As Socket#setSoTimeout is called later on and 
Socket#connect(SocketAddress endpoint, int timeout) exists, I guess the 
initial connection is created without any timeout?

As blocking operations without timeouts should be avoided, should the 
code be changed to:

socket = socketFactory.createSocket();
socket.connect(new InetSocketAddress(host, port), timeout);

or am I missing something?

Thanks,

Pascal




Usage of SocketFactory#createSocket(String host, int port)

2018-03-13 Thread Pascal Schumacher

Hello everybody,

took a look at the camel-smpp source code and noticed that is using 
javax.net.SocketFactory#createSocket(String host, int port) which 
"creates a socket and connects it to the specified port number at the 
specified address" according to the javadoc.


As Socket#setSoTimeout is called later on and 
Socket#connect(SocketAddress endpoint, int timeout) exists, I guess the 
initial connection is created without any timeout?


As blocking operations without timeouts should be avoided, should the 
code be changed to:


socket = socketFactory.createSocket();
socket.connect(new InetSocketAddress(host, port), timeout);

or am I missing something?

Thanks,

Pascal