Skip to content
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

Fix for withForm bug #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public boolean hasMoreElements() {
private HashMap<String,Serializable> attributes;

private Boolean isValid = true;
private Boolean isDirty = false;
transient private ServletContext servletContext;
transient private boolean newSession;
transient private int maxInactiveInterval;
Expand Down Expand Up @@ -166,12 +167,24 @@ public void removeValue(String name){

public void invalidate(){
isValid = false;
isDirty = true;
}

protected void setIsNewSession( boolean isNewSession ){
this.newSession = isNewSession;
}

public boolean isNew(){
return ( this.newSession );
}

protected void setIsDirty(boolean isDirty)
{
this.isDirty = isDirty;
}

protected boolean getIsDirty()
{
return this.isDirty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public void restoreSession() {
// - assign the servlet context

session = sessionRepository.restoreSession( this );

// we just loaded so we can't be dirty
if (session != null)
{
session.setIsDirty(false);
}

if( sessionPersistenceListeners != null ){
// call sessionPersistenceListeners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class SessionRepositoryResponseWrapper extends HttpServletResponseWrapper
private String sessionId = "simplesession";
private SessionRepository sessionRepository;
private SessionRepositoryRequestWrapper request;
private boolean sessionSaved = false;
private boolean enforceSession = false;
private ArrayList<SessionPersistenceListener> sessionPersistenceListeners;

Expand Down Expand Up @@ -63,20 +62,17 @@ public void saveSession(){
return;
}

if( sessionSaved == true ){
if( log.isTraceEnabled() ){ log.trace("session is already saved, not attempting to save again."); }
return;
}

SerializableSession session = (SerializableSession) request.getSession(this.enforceSession);

if( session == null ){
if( log.isTraceEnabled() ){ log.trace("session is null, not saving."); }
return;
}

// flag the session as saved.
sessionSaved = true;
if(session.getIsDirty() == false ){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!session.getIsDirty()) {

if( log.isTraceEnabled() ){ log.trace("session is not dirty, not saving."); }
return;
}

if( log.isTraceEnabled() ){ log.trace("calling session repository to save session."); }

Expand All @@ -93,6 +89,7 @@ public void saveSession(){
}

sessionRepository.saveSession(session,this);
session.setIsDirty(false);
}

@Override
Expand Down