On Sat, Apr 20, 2013 at 10:05 AM, Afkham Azeez <[email protected]> wrote:

> Another good catch! The port mapping ports also have to be checked in a
> similar manner
>
Thanks! Will look into the port mapping ports as well.

> --
> Afkham Azeez
> Sent from my phone
> On Apr 20, 2013 7:47 AM, "Nirmal Fernando" <[email protected]> wrote:
>
>> Hi All,
>>
>> While looking into solve an issue, I saw another possible bug in Tribes'
>> DefaultGroupManagement class.
>>
>> Currently, its canConnect method has following code portion:
>>
>> ============================================================
>>
>>                     InetAddress addr =
>> InetAddress.getByName(member.getHostName());
>>                     int httpPort = member.getHttpPort();
>>                     if (log.isDebugEnabled()) {
>>                         log.debug("HTTP Port=" + httpPort);
>>                     }
>>                     if (httpPort != -1) {
>>                         SocketAddress httpSockaddr = new
>> InetSocketAddress(addr, httpPort);
>>                         new Socket().connect(httpSockaddr, 10000);
>>                     }
>>                     int httpsPort = member.getHttpsPort();
>>                     if (log.isDebugEnabled()) {
>>                         log.debug("HTTPS Port=" + httpsPort);
>>                     }
>>                     if (httpsPort != -1) {
>>                         SocketAddress httpsSockaddr = new
>> InetSocketAddress(addr, httpsPort);
>>                         new Socket().connect(httpsSockaddr, 10000);
>>                     }
>>                     return true;
>> =============================================================
>>
>> So, according to this code, if a member (for some reason) advertises both
>> http and https ports as -1, DefaultGroupManagement won't complain anything,
>> rather happily says that the member is reachable.
>>
>> IMO, this is a bug. It's a fair thing to say, if at least there's a one
>> valid port, and that port is connectable, the member is reachable, but not
>> if the both ports advertised are invalid.
>>
>> So I'd propose to add following code segment to fix the issue.
>>
>> ============================================================
>>
>>                     InetAddress addr =
>> InetAddress.getByName(member.getHostName());
>>                     int httpPort = member.getHttpPort();
>>                     if (log.isDebugEnabled()) {
>>                         log.debug("HTTP Port=" + httpPort);
>>                     }
>>                     if(httpPort == -1 && httpsPort == -1){
>>                         // none of the ports are valid
>>                         return false;
>>                     }
>>                     if (httpPort != -1) {
>>                         SocketAddress httpSockaddr = new
>> InetSocketAddress(addr, httpPort);
>>                         new Socket().connect(httpSockaddr, 10000);
>>                     }
>>                     int httpsPort = member.getHttpsPort();
>>                     if (log.isDebugEnabled()) {
>>                         log.debug("HTTPS Port=" + httpsPort);
>>                     }
>>                     if (httpsPort != -1) {
>>                         SocketAddress httpsSockaddr = new
>> InetSocketAddress(addr, httpsPort);
>>                         new Socket().connect(httpsSockaddr, 10000);
>>                     }
>>                     return true;
>> ===========================================================
>>
>> Any concerns?
>>
>> --
>>
>> Thanks & regards,
>> Nirmal
>>
>> Software Engineer- Platform Technologies Team, WSO2 Inc.
>> Mobile: +94715779733
>> Blog: http://nirmalfdo.blogspot.com/
>>
>> <http://nirmalfdo.blogspot.com/>
>>
>


-- 

Thanks & regards,
Nirmal

Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/

<http://nirmalfdo.blogspot.com/>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to