From 7cf407661112203a5996782c4da1be12477d4c28 Mon Sep 17 00:00:00 2001 From: edgarzhavoronkov Date: Mon, 23 Aug 2021 16:30:17 +0300 Subject: [PATCH 1/2] make HttpApiImpl use external cache instead of global one from Play --- .../server/auth/awsplay/HttpApiImpl.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/bardsoftware/server/auth/awsplay/HttpApiImpl.java b/src/com/bardsoftware/server/auth/awsplay/HttpApiImpl.java index 5f2d848..3372260 100644 --- a/src/com/bardsoftware/server/auth/awsplay/HttpApiImpl.java +++ b/src/com/bardsoftware/server/auth/awsplay/HttpApiImpl.java @@ -4,7 +4,7 @@ import com.google.common.base.Joiner; import com.google.common.base.MoreObjects; import com.google.common.collect.Maps; -import play.cache.Cache; +import play.cache.SyncCacheApi; import play.mvc.Http; import play.mvc.Http.Request; import play.mvc.Http.Response; @@ -21,6 +21,7 @@ public class HttpApiImpl implements HttpApi { private static final Logger LOGGER = Logger.getLogger("HttpApiImpl"); private static final String SESSION_ID_KEY = "JSESSIONID"; + private static SyncCacheApi ourCache; private final Request myRequest; private final Response myResponse; @@ -33,6 +34,11 @@ public HttpApiImpl(Http.Request req, Http.Response resp, Http.Session session) { myResponse = resp; mySession = session; } + + public static void setup(SyncCacheApi cacheApi) { + ourCache = cacheApi; + } + @Override public String getRequestUrl() { String scheme = MoreObjects.firstNonNull(myRequest.getHeader("X-Scheme"), "http"); @@ -86,7 +92,7 @@ public Object getSessionAttribute(String name) { return null; } String attrKey = sessionId + "." + name; - Object attrVal = Cache.get(attrKey); + Object attrVal = ourCache.get(attrKey); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(String.format("getting attribute: got key=%s value=%s", attrKey, attrVal)); } @@ -104,7 +110,7 @@ public void setSessionAttribute(String name, Object object) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(String.format("setting attribute: key=%s value=%s", attrKey, object)); } - Cache.set(attrKey, object); + ourCache.set(attrKey, object); } @Override From 4a0e1401a51e273a136fc13e55865e388c8ef9ee Mon Sep 17 00:00:00 2001 From: edgarzhavoronkov Date: Mon, 23 Aug 2021 16:30:51 +0300 Subject: [PATCH 2/2] bump Play versions --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 8bbdadb..aed0e4a 100644 --- a/build.gradle +++ b/build.gradle @@ -33,12 +33,12 @@ dependencies { implementation "com.google.guava:guava:30.+" //implementation "com.googlecode.objectify:objectify:5.1.+" - //implementation 'javax.servlet:javax.servlet-api:3.1.0' + implementation 'javax.servlet:javax.servlet-api:3.1.0' //implementation "com.google.appengine:appengine-api-1.0-sdk:1.9.+" implementation "org.scribe:scribe:1.3.+" //implementation "com.google.code.findbugs:jsr305:3.+" - implementation "com.typesafe.play:play-java_2.11:2.4.8" - implementation "com.typesafe.play:play-cache_2.11:2.4.8" + implementation "com.typesafe.play:play-java_2.11:2.6.10" + implementation "com.typesafe.play:play-cache_2.11:2.6.10" } publishing { @@ -52,7 +52,7 @@ publishing { maven(MavenPublication) { groupId 'com.bardsoftware' artifactId 'vaxter' - version '2021.06.29' + version 'prj-17' from components.java }