A variety of problems that are not experienced in the project

Source: Internet
Author: User
1.java Foundation is not strong, about the object and class declaration cycle, etc. do not understand

When you do the app login token verification. I designed a tokenutil to add a member variable map, each time the login succeeds, put tokens in. Removed later to verify. Did a test, landed, re-visited, no problem, show landed successfully.

Then thought OK, then suddenly want to change a user login to see, so it delirious. Because I found that when I change a user login, the original user login is invalid. How can this be.

So, I tried n methods, both failed. Think of feeling wrong, originally I was a user in the landing, just toke changed, I record token is the user ID key.

In this way, I refresh the landing page, found token transform (token with timestamp encryption), that is the new user login. In fact, I find that there is always only one set of tokens in the map, and I suspect that this class will not be initialized any time, and I don't know how the life cycle is going to count. And, of course, I'm not going to figure out what the declaration cycle is. Trying another method doesn't work either. After debugging n times suddenly found that my key has been the same, think of the map when the key is the same time back to overwrite the original. So, excited. Again, it sure is possible.

This way, the description class is always loaded and not destroyed. And I am a careless problem is, I put the refresh login as a new user login, and mark the user login key is the user ID, the same user of course will only mark a group.

Lesson:

I should slow down and think about the problem carefully. From the beginning, a little bit of thinking, I should first think: Analog login 1th Enter the user name and password. And this point if you see clearly will find the problem solved, I have always been a user to test the results of multiple users, certainly not. In addition, and I was too confused, not to understand the life cycle and multi-threaded synchronization and other issues. Wait for a closer look.

A variety of problems that are not experienced in the project

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.