DescribeSecurityGroupsResponseHandler and empty XML tags

18 views
Skip to first unread message

Jan

unread,
Dec 12, 2011, 10:29:40 PM12/12/11
to jclou...@googlegroups.com
Hi,

here is something I'm fighting with on OpenStack/Eucalyptus API:

An example from DescribeSecurityGroupsResponseHandler:

this.fromPort = Integer.parseInt(currentOrNull(currentText));
this.toPort = Integer.parseInt(currentOrNull(currentText));
...
and i expect many other places..

What happens if the response XML has an empty tag (e.g. <toPort/>, <fromPort/>)
Than currentOrNull(currentText) returns null and Integer.parseInt(null) fails with java.lang.NumberFormatException: null

I dont know why but one entry in a security group is empty and i get error as described above.
comments?

cheers,
Jan

Adrian Cole

unread,
Dec 12, 2011, 10:53:43 PM12/12/11
to jclou...@googlegroups.com
Hi, Jan.

This is a case where I put a comment like

// <some ec2 clone> doesn't always return a value

then change the parser to permit nulls, and add a test case for the
xml where the entry is deformed.

-A

> --
> You received this message because you are subscribed to the Google Groups
> "jclouds-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/jclouds-dev/-/_VM5TlM18-cJ.
> To post to this group, send email to jclou...@googlegroups.com.
> To unsubscribe from this group, send email to
> jclouds-dev...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jclouds-dev?hl=en.

Adrian Cole

unread,
Dec 12, 2011, 11:36:37 PM12/12/11
to jclou...@googlegroups.com
P.S. I suspect in this case, we'd be best return start port: 0 end
port: 65535 on nulls, right?

-A

Jan

unread,
Dec 13, 2011, 12:59:32 AM12/13/11
to jclou...@googlegroups.com
I dont know if no values mean "all ports open" or the opposite.
J.

Adrian Cole

unread,
Dec 13, 2011, 1:34:43 AM12/13/11
to jclou...@googlegroups.com
good point. perhaps you can ping the clone in question for an answer
to this? If the behavior is product conditional, I can help you find
a way to switch on that.

-A

On Mon, Dec 12, 2011 at 9:59 PM, Jan <jpa...@gmail.com> wrote:
> I dont know if no values mean "all ports open" or the opposite.
> J.
>

> --
> You received this message because you are subscribed to the Google Groups
> "jclouds-dev" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/jclouds-dev/-/zceSwzY_siwJ.

Jan

unread,
Dec 14, 2011, 1:53:58 PM12/14/11
to jclou...@googlegroups.com
Hi,
took me a while but it seems that if port range numbers are missing then no ports are open (using nmap scanner). Also, it is safe to assume this with respect to other cloud providers.
J.

Adrian Cole

unread,
Dec 14, 2011, 1:56:03 PM12/14/11
to jclou...@googlegroups.com
heh.. it is not safe to assume this for all providers, but then again,
not returning info isn't expected either. I would go ahead and
default, and make a test case that shows our decision clearly.

-A

> --
> You received this message because you are subscribed to the Google Groups
> "jclouds-dev" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/jclouds-dev/-/UnUYvT1SMUsJ.

Jan

unread,
Dec 14, 2011, 4:40:20 PM12/14/11
to jclou...@googlegroups.com
this is a XML response it is failing on. Any comments on how to deal with it? When I try to set the ports to -1 it is still failing..

<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
  <requestId>NOC4CS9A5RPYYN5CD1LG</requestId>
  <securityGroupInfo>
    <item>
      <ipPermissions>
        <item>
          <toPort>22</toPort>
          <ipProtocol>tcp</ipProtocol>
          <ipRanges>
            <item>
              <cidrIp>0.0.0.0/0</cidrIp>
            </item>
          </ipRanges>
          <groups/>
          <fromPort>22</fromPort>
        </item>
        <item>
          <toPort/>
          <ipProtocol/>
          <ipRanges/>
          <groups>
            <item>
              <groupName>jclouds#cluster#quebec</groupName>
              <userId>XXX</userId>
            </item>
          </groups>
          <fromPort/>
        </item>
      </ipPermissions>
      <groupName>jclouds#cluster#quebec</groupName>
      <groupDescription>jclouds#cluster#quebec</groupDescription>
      <ownerId>XXX</ownerId>
    </item>
  </securityGroupInfo>
</DescribeSecurityGroupsResponse>

Jan

unread,
Dec 14, 2011, 5:07:49 PM12/14/11
to jclou...@googlegroups.com
i forgot to deal with ipProtocol the same way... Its working now.

Adrian Cole

unread,
Dec 14, 2011, 9:03:11 PM12/14/11
to jclou...@googlegroups.com
heh happy to help :)

On Wed, Dec 14, 2011 at 2:07 PM, Jan <jpa...@gmail.com> wrote:
> i forgot to deal with ipProtocol the same way... Its working now.
>

> --
> You received this message because you are subscribed to the Google Groups
> "jclouds-dev" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/jclouds-dev/-/pG5HYv4HkmIJ.

Reply all
Reply to author
Forward
0 new messages