session.getDataHashCode not equals Arrays.hashCode( attributesData ) when session attributes whithout changes by msm-kryo-serializer
final ConcurrentMap<String, Object> attributes = _session.getAttributesFiltered();
final byte[] attributesData = serializeAttributes( _session, attributes );
final int hashCode = Arrays.hashCode( attributesData );
//<editor-fold desc="additional logs">
if ( _log.isDebugEnabled() ) {
_log.debug( "attributesData " + new String(attributesData) );
_log.debug( "Arrays.hashCode " + hashCode + ",Session.getDataHashCode " + _session.getDataHashCode() );
}
final BackupResult result;
//</editor-fold>
if ( _session.getDataHashCode() != hashCode
|| _force
|| _session.authenticationChanged() ) {
_session.setLastBackupTime( System.currentTimeMillis() );
final byte[] data = _transcoderService.serialize( _session, attributesData );
result = doBackupSession( _session, data, attributesData );
if ( result.isSuccess() ) {
_session.setDataHashCode( hashCode );
}
} else {
result = new BackupResult( BackupResultStatus.SKIPPED );
}
session will be backup when _session.getDataHashCode != Arrays.hashCode( attributesData ) ,sometiems, session attributes without any changes, but attributesData has changed . For example: put two attributes into session, (iccid = 1234 , cityCode = heibei ) first access log:
Jan 19, 2017 4:11:53 PM de.javakaffee.web.msm.BackupSessionTask call FINE: attributesData cityCod�heibe�icci�123�
Jan 19, 2017 4:11:53 PM de.javakaffee.web.msm.BackupSessionTask call FINE: Arrays.hashCode -1759883946,Session.getDataHashCode 1744582514 Jan 19, 2017 4:11:53 PM
second access log
Jan 19, 2017 4:11:55 PM de.javakaffee.web.msm.BackupSessionTask call FINE: attributesData icci�123�cityCod�heibe�
Jan 19, 2017 4:11:55 PM de.javakaffee.web.msm.BackupSessionTask call FINE: Arrays.hashCode 1744582514,Session.getDataHashCode -1759883946 Jan 19, 2017 4:11:55 PM
in this case, session will be covered in concurrent requests even if the attributes have not changes.

If Req_A is a get request, just read session attributes ,Req_B is a post request ,modify session attributes . Session will be covered when Req_A finished. So, i will get the attribute from session that is set by Req_B is null in the next request. How to solve this question?
version info: msm : 2.1.1 kryo : 4.0.0 kryo-serializers : 0.41 minlog : 1.2 objenesis: 2.2 reflectasm: 1.11.3 asm: 5.0.4 setting:
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.16.50.65:11211"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="1800000"
copyCollectionsForSerialization="false"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"/>
Thanks for this detailed report! AFAICS the two request logs show a different order of the attributes (attributesData), which most probably explains the different hashcode. Therefore we'd have to sort attributes before computing the hashcode. WDYT? Do you want to submit a pull request?
Thanks for the reply! Now we get hashcode by the attributesData(the attributes has been serialized). If sort attributes before computing the hashcode , we'll get hashcode by the attributes has been ordered instead of the attributesData, right? Or we sort attributes before serialize attributes?
Right, I meant to sort the attributes (the result of _session.getAttributesFiltered()).
Thank you very much! I got the same hashcode when the attributes been sorted.