Hello Eugene,
> 1) I don't see ANY socket exceptions at all.
> 2) please take a look at this statement:
>
> else
> log.error("Socket is null");
>
> - I can see this a lot of times.
Well, here's some code from your previous post:
> Socket socket = createSocket(host, port, localAddress, localPort);
> if (socket != null) {
> ...
> } else
> log.error("Socket is null");
You said the socket is null after calling "new Socket(...)",
and I said that's not possible. Calling "new Socket(...)" is
very much different from calling a createSocket(...) method.
A method can return null, a call to "new" can not.
Here's some code from your createSocket(...) method:
> while (--localTries > 0)
> try {
> socket = new Socket(host, port, localAddress, localPort);
> maxTries = 0;
> lastException = null;
> } catch (SocketException se) {
> lastException = se;
> log.error(se.getMessage(), se);
> try {
> Thread.sleep(1000);
> } catch (InterruptedException e) {
> log.error(e, e);
> }
> }
You say that you don't see any SocketExceptions, that is
strange. You did not by any chance set "localTries" to 1?
Because that condition for while should either use post-
decrement instead of pre-decrement, or else >= instead of >.
Furthermore, the first successful socket creation will set
maxTries to 0 instead of localTries. Which kind of answers
my previous question... after the first socket creation,
localTries will always be initialized with 0 and pre-
decremented to -1 on the first check of the while condition.
That's one of the reasons why I don't like conditions with
side effects. And decrementing counters are more susceptible
to errors than incrementing ones. By the way, if you had
declared "maxTries" as final, the compiler would have told
you about this problem.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]