Sessionfactoryimpl. Get error: Java. Lang. arrayindexoutofboundsexception:-68 Problem

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.