Skip to content

Commit 91e3a2e

Browse files
authored
Merge pull request #1 from jcoleman/master
full
2 parents a22bb01 + d166222 commit 91e3a2e

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ example-app/build/*
44
example-app/.gradle/*
55
.DS_Store
66
.rspec
7+
*.iml
8+
.idea/*

README.markdown

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ Finalized branches include:
4040
* `tomcat-7`: Has been merged into `master`. Compatible with Java 6 or 7.
4141
* `java-7`: Has been merged into `master`. All of the work from master for Tomcat 7 but taking advantage of new features in Java 7. Compatible with Java 7 only.
4242

43+
Tomcat 8
44+
--------
45+
46+
Tomcat 8 is not currently supported and has not been tested or developed for at all In fact, as noted in various bug reports, the project currently fails to compile when linked with Tomcat 8.
47+
48+
I currently don't have the time to add Tomcat 8 support in my spare time. However if you're interested in Tomcat 8 support for your particular use case and/or business, as the README notes, I'm available as a consultancy on a contractual basis. If you'd like to pursue getting this feature added at a contract rate (and gain some commercial support as well), feel free to contact me at james@orangefunction.com.
49+
4350
Architecture
4451
------------
4552

src/main/java/com/orangefunction/tomcat/redissessions/RedisSessionManager.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,19 +344,13 @@ public Session createSession(String requestedSessionId) {
344344

345345
// Ensure generation of a unique session identifier.
346346
if (null != requestedSessionId) {
347-
sessionId = requestedSessionId;
348-
if (jvmRoute != null) {
349-
sessionId += '.' + jvmRoute;
350-
}
347+
sessionId = sessionIdWithJvmRoute(requestedSessionId, jvmRoute);
351348
if (jedis.setnx(sessionId.getBytes(), NULL_SESSION) == 0L) {
352349
sessionId = null;
353350
}
354351
} else {
355352
do {
356-
sessionId = generateSessionId();
357-
if (jvmRoute != null) {
358-
sessionId += '.' + jvmRoute;
359-
}
353+
sessionId = sessionIdWithJvmRoute(generateSessionId(), jvmRoute);
360354
} while (jedis.setnx(sessionId.getBytes(), NULL_SESSION) == 0L); // 1 = key set; 0 = key already existed
361355
}
362356

@@ -402,6 +396,14 @@ This ensures that the save(session) at the end of the request
402396
return session;
403397
}
404398

399+
private String sessionIdWithJvmRoute(String sessionId, String jvmRoute) {
400+
if (jvmRoute != null) {
401+
String jvmRoutePrefix = '.' + jvmRoute;
402+
return sessionId.endsWith(jvmRoutePrefix) ? sessionId : sessionId + jvmRoutePrefix;
403+
}
404+
return sessionId;
405+
}
406+
405407
@Override
406408
public Session createEmptySession() {
407409
return new RedisSession(this);

0 commit comments

Comments
 (0)