I received the following from Janning:

Janning Vygen wrote:
> Hi Tom,
> 
> I don't know how to reopen the original bug report. but my problem from 
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543523
> is biting me again.
> 
> But now I got it! xml::simple parses the attributes like 'name="http-8080"' 
> only to hash values in the data structure if you have more than one of them.
> 
> from perldoc XML::Simple
> "The key attribute names should be supplied in an arrayref if there is more 
> than one"
> 
> so, if you have a tomcat running with only ONE connector, the plugin does not 
> work, regardless on which port it runs. In the standard installation you have 
> always http and ajp connector, so XML::Simple parses the output correctly.
> 
> so all tomcat plugins should be fixed with a patch like this:
> 
> 87c87,89
> < my $xml = $xs->XMLin($response->content);
> ---
>> my %options = ( KeyAttr => { connector => 'name' }, ForceArray => 1 );
>> my $xml = $xs->XMLin($response->content, %options);
> 
> 
> look at this small script to show you what I mean with wrong attribute 
> parsing:
> 
> #!/usr/bin/perl
> use strict;
> use XML::Simple;
> use Data::Dumper;
> 
> my $tomcat1 = q|<?xml version="1.0" encoding="utf-8"?>
> <status>
>   <connector name="http-80">
>     <requestInfo maxTime="16326237"/>
>   </connector>
> </status>
> |;
> 
> my $tomcat2 = q|<?xml version="1.0" encoding="utf-8"?>
> <status>
>   <connector name="http-80">
>     <requestInfo maxTime="16326237"/>
>   </connector>
>   <connector name="http-81">
>     <requestInfo maxTime="16326237"/>
>   </connector>
> </status>|;
> 
> my $PORT = 80;
> my $ret = undef;
> my $xs = new XML::Simple;
> 
> my $xml1 = $xs->XMLin($tomcat1);
> print Dumper($xml1);
> my $xml2 = $xs->XMLin($tomcat2);
> print Dumper($xml2);
> 
> I hope this helped. 
> 
> kind regards
> Janning
> 
> 


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to