检查属性是否改变修改为克隆方式(防止热部署出现强转异常)

dep_wangsr
RuoYi 5 years ago committed by Limy
parent dc94455e0a
commit b660965ecb

@ -14,6 +14,8 @@ import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.shiro.session.OnlineSession;
import com.ruoyi.system.domain.SysUserOnline;
@ -34,8 +36,8 @@ public class OnlineWebSessionManager extends DefaultWebSessionManager
super.setAttribute(sessionKey, attributeKey, value);
if (value != null && needMarkAttributeChanged(attributeKey))
{
OnlineSession s = (OnlineSession) doGetSession(sessionKey);
s.markAttributeChanged();
OnlineSession session = getOnlineSession(sessionKey);
session.markAttributeChanged();
}
}
@ -68,13 +70,25 @@ public class OnlineWebSessionManager extends DefaultWebSessionManager
Object removed = super.removeAttribute(sessionKey, attributeKey);
if (removed != null)
{
OnlineSession s = (OnlineSession) doGetSession(sessionKey);
OnlineSession s = getOnlineSession(sessionKey);
s.markAttributeChanged();
}
return removed;
}
public OnlineSession getOnlineSession(SessionKey sessionKey)
{
OnlineSession session = null;
Object obj = doGetSession(sessionKey);
if (StringUtils.isNotNull(obj))
{
session = new OnlineSession();
BeanUtils.copyBeanProp(session, obj);
}
return session;
}
/**
* session session
*/

Loading…
Cancel
Save