Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-519

ThreadContext.setResources() doesn't handle empty maps correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.2.2, 1.2.3
    • None
    • Session Management
    • None

    Description

      ThreadLocal.setResources() doesn't handle the case where resources is want to be cleared.

      This could be used in situation when session is switched temporary to another thread.

      One could do:

      old = ThreadContext.getResources();
      ThreadContext.setResources(new);
      // do the magic
      ThreadContext.setResources(old);

      If the old resources was empty it will leave new resources in place.

      Fix would be trivial:

          public static void setResources(Map<Object, Object> newResources) {
              if (CollectionUtils.isEmpty(newResources)) {
                  return;
              }
              resources.get().clear();
              resources.get().putAll(newResources);
          }
      

      ->

          public static void setResources(Map<Object, Object> newResources) {
              resources.get().clear();
              if (CollectionUtils.isEmpty(newResources)) {
                  return;
              }
              resources.get().putAll(newResources);
          }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            dachaac Vesa Jääskeläinen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: