You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Al...@finnova.ch on 2009/05/06 18:07:24 UTC

Bundle.getHeaders() returns a Dictionary

Hi out there

I just found out that as of Felix 1.6.1 the Bundle.getHeaders() returns a Dictionary whose keys are of
type java.util.jar.Attribute.Name. The corresponding code is in org.apache.felix.framework.cache.JarRevision:

        Manifest mf = jarFile.getManifest();
            // Create a case insensitive map of manifest attributes.
            return new StringMap(mf.getMainAttributes(), false);

Somehow I doubt that this is the right behavior but perhaps someone can prove me wrong :-)
This behavior did not disturb my code as long as it was running on a SUN JVM (java 6) but it caused
severe trouble when running on IBM's JVM (java 6). I guess this is because IBM and SUN might have
different implementations of equals(Object o) and hashCode() for the class java.util.jar.Attribute.Name.
However after changing the suspicious code in JarRevision like this:

        Manifest mf = jarFile.getManifest();
            // Create a case insensitive map of manifest attributes.
            final Attributes attributes = mf.getMainAttributes();
            final StringMap m = new StringMap(false);
            for ( final Object name : attributes.keySet() ) {
                final String text = name.toString();
                m.put(text, attributes.getValue(text));
            }
            return m;

the problem disappeared and it also worked on IBM's JVM.

So can anybody please confirm or deny that this is a bug in Felix 1.6.1. If so I will open a JIRA issue.

Kind regards
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


AW: Bundle.getHeaders() returns a Dictionary

Posted by Al...@finnova.ch.
Ok I opened a JIRA issue for this bug:

https://issues.apache.org/jira/browse/FELIX-1130

- alex
--
finnova AG Bankware
Alexander Berger
Team SR Peripheral
Merkurstrasse 6
CH-5600 Lenzburg
Tel: +41 (0)62 886 48 07 (direkt)
Tel: +41 (0)62 886 47 47 (zentrale)
Fax: +41 (0)62 886 48 88 mailto:alexander.berger@finnova.ch
http://www.finnova.ch


-----Ursprüngliche Nachricht-----
Von: Richard S. Hall [mailto:heavy@ungoverned.org]
Gesendet: Mittwoch, 6. Mai 2009 18:35
An: users@felix.apache.org
Betreff: Re: Bundle.getHeaders() returns a Dictionary<java.util.jar.Attribute.Name,String>

p.s. Maybe we could just modify StringMap to always do a toString() on
the keys it adds to itself via that constructor...that is what we do in
StringMap.put()...

On 5/6/09 12:07 PM, Alexander.Berger@finnova.ch wrote:
> Hi out there
>
> I just found out that as of Felix 1.6.1 the Bundle.getHeaders() returns a Dictionary whose keys are of
> type java.util.jar.Attribute.Name. The corresponding code is in org.apache.felix.framework.cache.JarRevision:
>
>          Manifest mf = jarFile.getManifest();
>              // Create a case insensitive map of manifest attributes.
>              return new StringMap(mf.getMainAttributes(), false);
>
> Somehow I doubt that this is the right behavior but perhaps someone can prove me wrong :-)
> This behavior did not disturb my code as long as it was running on a SUN JVM (java 6) but it caused
> severe trouble when running on IBM's JVM (java 6). I guess this is because IBM and SUN might have
> different implementations of equals(Object o) and hashCode() for the class java.util.jar.Attribute.Name.
> However after changing the suspicious code in JarRevision like this:
>
>          Manifest mf = jarFile.getManifest();
>              // Create a case insensitive map of manifest attributes.
>              final Attributes attributes = mf.getMainAttributes();
>              final StringMap m = new StringMap(false);
>              for ( final Object name : attributes.keySet() ) {
>                  final String text = name.toString();
>                  m.put(text, attributes.getValue(text));
>              }
>              return m;
>
> the problem disappeared and it also worked on IBM's JVM.
>
> So can anybody please confirm or deny that this is a bug in Felix 1.6.1. If so I will open a JIRA issue.
>
> Kind regards
> Alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Bundle.getHeaders() returns a Dictionary

Posted by "Richard S. Hall" <he...@ungoverned.org>.
p.s. Maybe we could just modify StringMap to always do a toString() on 
the keys it adds to itself via that constructor...that is what we do in 
StringMap.put()...

On 5/6/09 12:07 PM, Alexander.Berger@finnova.ch wrote:
> Hi out there
>
> I just found out that as of Felix 1.6.1 the Bundle.getHeaders() returns a Dictionary whose keys are of
> type java.util.jar.Attribute.Name. The corresponding code is in org.apache.felix.framework.cache.JarRevision:
>
>          Manifest mf = jarFile.getManifest();
>              // Create a case insensitive map of manifest attributes.
>              return new StringMap(mf.getMainAttributes(), false);
>
> Somehow I doubt that this is the right behavior but perhaps someone can prove me wrong :-)
> This behavior did not disturb my code as long as it was running on a SUN JVM (java 6) but it caused
> severe trouble when running on IBM's JVM (java 6). I guess this is because IBM and SUN might have
> different implementations of equals(Object o) and hashCode() for the class java.util.jar.Attribute.Name.
> However after changing the suspicious code in JarRevision like this:
>
>          Manifest mf = jarFile.getManifest();
>              // Create a case insensitive map of manifest attributes.
>              final Attributes attributes = mf.getMainAttributes();
>              final StringMap m = new StringMap(false);
>              for ( final Object name : attributes.keySet() ) {
>                  final String text = name.toString();
>                  m.put(text, attributes.getValue(text));
>              }
>              return m;
>
> the problem disappeared and it also worked on IBM's JVM.
>
> So can anybody please confirm or deny that this is a bug in Felix 1.6.1. If so I will open a JIRA issue.
>
> Kind regards
> Alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Bundle.getHeaders() returns a Dictionary

Posted by "Richard S. Hall" <he...@ungoverned.org>.
It sounds like a bug to me. Definitely create a JIRA issue.

Thanks for reporting it.

-> richard

On 5/6/09 12:07 PM, Alexander.Berger@finnova.ch wrote:
> Hi out there
>
> I just found out that as of Felix 1.6.1 the Bundle.getHeaders() returns a Dictionary whose keys are of
> type java.util.jar.Attribute.Name. The corresponding code is in org.apache.felix.framework.cache.JarRevision:
>
>          Manifest mf = jarFile.getManifest();
>              // Create a case insensitive map of manifest attributes.
>              return new StringMap(mf.getMainAttributes(), false);
>
> Somehow I doubt that this is the right behavior but perhaps someone can prove me wrong :-)
> This behavior did not disturb my code as long as it was running on a SUN JVM (java 6) but it caused
> severe trouble when running on IBM's JVM (java 6). I guess this is because IBM and SUN might have
> different implementations of equals(Object o) and hashCode() for the class java.util.jar.Attribute.Name.
> However after changing the suspicious code in JarRevision like this:
>
>          Manifest mf = jarFile.getManifest();
>              // Create a case insensitive map of manifest attributes.
>              final Attributes attributes = mf.getMainAttributes();
>              final StringMap m = new StringMap(false);
>              for ( final Object name : attributes.keySet() ) {
>                  final String text = name.toString();
>                  m.put(text, attributes.getValue(text));
>              }
>              return m;
>
> the problem disappeared and it also worked on IBM's JVM.
>
> So can anybody please confirm or deny that this is a bug in Felix 1.6.1. If so I will open a JIRA issue.
>
> Kind regards
> Alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org