@Override
  public void setAttribute(String key, Object value) {
    if (manualDirtyTrackingSupportEnabled && manualDirtyTrackingAttributeKey.equals(key)) {
      dirty = true;
      return;
    }

    Object oldValue = getAttribute(key);
    super.setAttribute(key, value);

    if ((value != null || oldValue != null)
        && (value == null && oldValue != null
            || oldValue == null && value != null
            || !value.getClass().isInstance(oldValue)
            || !value.equals(oldValue))) {
      if (this.manager instanceof RedisSessionManager
          && ((RedisSessionManager) this.manager).getSaveOnChange()) {
        try {
          ((RedisSessionManager) this.manager).save(this, true);
        } catch (IOException ex) {
          log.error(
              "Error saving session on setAttribute (triggered by saveOnChange=true): "
                  + ex.getMessage());
        }
      } else {
        changedAttributes.put(key, value);
      }
    }
  }
 @Override
 public void removeAttribute(String name) {
   super.removeAttribute(name);
   if (this.manager instanceof RedisSessionManager
       && ((RedisSessionManager) this.manager).getSaveOnChange()) {
     try {
       ((RedisSessionManager) this.manager).save(this, true);
     } catch (IOException ex) {
       log.error(
           "Error saving session on setAttribute (triggered by saveOnChange=true): "
               + ex.getMessage());
     }
   } else {
     dirty = true;
   }
 }
  public void setAttribute(String key, Object value) {
    if (manualDirtyTrackingSupportEnabled && manualDirtyTrackingAttributeKey.equals(key)) {
      dirty = true;
      return;
    }

    Object oldValue = getAttribute(key);
    if (value == null && oldValue != null
        || oldValue == null && value != null
        || !value.getClass().isInstance(oldValue)
        || !value.equals(oldValue)) {
      changedAttributes.put(key, value);
    }

    super.setAttribute(key, value);
  }
 @Override
 public void readObjectData(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException {
   super.readObjectData(in);
   this.setCreationTime(in.readLong());
 }
 @Override
 public void writeObjectData(java.io.ObjectOutputStream out) throws IOException {
   super.writeObjectData(out);
   out.writeLong(this.getCreationTime());
 }
 @Override
 public void setPrincipal(Principal principal) {
   dirty = true;
   super.setPrincipal(principal);
 }
 public void removeAttribute(String name) {
   dirty = true;
   super.removeAttribute(name);
 }