Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-411

Preferences service throws ClassCastException

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • prefs-1.0.2
    • Preferences Service
    • None

    Description

      The preferences admin throws a ClassCastException when writing its cache. The exception is
      java.lang.ClassCastException: [Lorg.apache.felix.prefs.PreferencesImpl; cannot be cast to org.apache.felix.prefs.PreferencesImpl
      at org.apache.felix.prefs.impl.PreferencesManager.save(PreferencesManager.java:179)
      ...

      This seems to have to do with the implementation of PreferencesImpl: in its constructor, all preferences are loaded. The system preferences are stored,
      61 this.systemTree = prefs[i];
      but the user preferences are stored incorrectly:
      63 this.trees.put(prefs[i].getDescription().getIdentifier(), prefs);
      The full array of prefs is stored, not just prefs[i]; this causes the classcastexception.

      A possible fix could be
      63 this.trees.put(prefs[i].getDescription().getIdentifier(), prefs[i]);

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            cziegeler Carsten Ziegeler
            angelovds Angelo van der Sijpt
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment