Is it safe to store data in a static field when deployed to Google App Engine?

I was looking at the Vosao CMS code, an open source CMS hosted by the Google App Engine (which I find an amazing idea), and I came across the following code inside the CurrentUser class :

/**
 * Current user session value cache class. Due to GAE single-threaded nature
 * we can cache currently logged in user in static property. Which we set in 
 * authentication filter.
 */
public class CurrentUser {

        private static UserEntity user;

        public static UserEntity getInstance2() {
                return user;
        }

        public static void setInstance2(UserEntity aUser) {
                user = aUser;
        }
}

I have never used GAE, but it sounds very strange to me.

  • Is GAE really single-threaded? Is it safe to store data with query scope in a static field when using GAE?

  • Does this mean that for each instance of JVM will run only HTTP-request one , and all other requests are waiting for?

  • GAE? , GAE UserEntity ? ThreadLocal , Spring ? - bean ( Injection Dependency)?

+3
2

GAE ""? GAE?

( 1.4.3), - .

, , JVM/.

, JVM HTTP- , ?

, , JVM. . .

+4

Java Python App Engine ; , , JVM HTTP-, JVM .

, - Java Servlet . ThreadLocal.

+4

Source: https://habr.com/ru/post/1771597/


All Articles