An error occurred in the production environment of the latest project:
At org. hibernate. impl. sessionfactoryimpl. Get (sessionfactoryimpl. Java: 339)
At org. hibernate. impl. sessionfactoryimpl. getquery (sessionfactoryimpl. Java: 411)
At org. hibernate. impl. sessionimpl. getqueries (sessionimpl. Java: 884)
At org. hibernate. impl. sessionimpl. iterate (sessionimpl. Java: 920)
At org. hibernate. impl. queryimpl. iterate (queryimpl. Java: 41)
....
The above is to call hibernate to query data. after iterate ();, an error is thrown. According to log analysis, the error log is generally recorded in Java. lang. arrayindexoutofboundsexception:-68, followed by a negative number in the range of-128, and gradually increases according to time, such as to Java. lang. arrayindexoutofboundsexception:-2, and then Java. lang. arrayindexoutofboundsexception:-1, and then reincarnation to Java. lang. arrayindexoutofboundsexception:-127.
I 've been searching for myself for a long time.CodeFinally, check the code near 339 of hibernate source code sessionfactoryimpl. java. The method is as follows:
Private synchronized object get (Object key)
{
Object result = This. softquerycache. Get (key );
If (result! = NULL ){
This. strongrefs [(++ this. strongrefindex % 128)] = result;
}
Return result;
}
This. strongrefs [(++ this. strongrefindex % 128)] = result; Is 339th rows. The strongrefs array is an array with an initial length of 128. strongrefindex is defined as private transient int strongrefindex = 0;
Strongrefindex increases by 1 based on each retrieved data. According to the error message, it should be because strongrefindex is a negative number, and it is indeed increasing at each time.
Through the above analysis, the strongrefindex field is not modified for no reason in the memory, or is increased to the maximum length of int 2147483647, resulting in a negative number. It seems that there is no other way. You can only restart the website. After the restart, the problem is solved!