-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid to retain SessionIdGenerator in session object #2387
Conversation
Could you review this PR? @rwinch @marcusdacoregio @vpavic |
Rebased and split to multiple commits for better code review. |
Hi, @quaff. I am not so sure about the pros and cons here. Imagine a scenario where I am migrating users from a legacy db to a new db and both have different strategies to generate session ids. The problem would arise when a session need to |
We could introduce a default method for public interface SessionIdGenerator {
@NonNull
String generate();
@NonNull
default String regenerate(Session session) {
return generate();
}
} @Override
public String changeSessionId(SessionIdGenerator sessionIdGenerator) {
String newSessionId = sessionIdGenerator.regenerate(this);
setId(newSessionId);
return newSessionId;
} Now we can choose strategy base on original session id. EDIT: I've pushed a new commit to accomplish this. |
26c5755
to
d2beddd
Compare
f49b763
to
d240329
Compare
organize code via centralizing the default SessionIdGenerator instance
session id generation shouldn't be the responsibility of session object, since SessionIdGenerator held by session object is only used by changeSessionId(), we could introduce overload method passing it as parameter to avoid that.
I really think it's not a good choice that domain object holds non-domain object reference, any thoughts? |
Hi, @quaff. This is not something that we want to do now. I'd prefer to receive more feedback from the community and see where the It is also strange that a low-level With that said, I'll close this issue and wait for community feedback to proceed with further changes related to it. |
session id generation shouldn't be the responsibility of session object, since
SessionIdGenerator
held by session object is only used bychangeSessionId()
, we could introduce overload method passing it as parameter to avoid that.