Skip to content

Commit

Permalink
* Explicitely wrap loadSessionData() into a transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
hns committed Feb 7, 2008
1 parent d80558b commit 9705a0a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/helma/framework/core/SessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package helma.framework.core;

import helma.objectmodel.INode;
import helma.objectmodel.db.Node;
import helma.objectmodel.db.NodeHandle;
import helma.objectmodel.db.Transactor;
import helma.scripting.ScriptingEngine;

import java.util.*;
Expand Down Expand Up @@ -206,8 +206,10 @@ public void loadSessionData(File f, ScriptingEngine engine) {
}

long now = System.currentTimeMillis();
Transactor tx = Transactor.getInstance(app.getNodeManager());

try {
tx.begin("sessionloader");
// load the stored data:
InputStream istream = new BufferedInputStream(new FileInputStream(f));
ObjectInputStream p = new ObjectInputStream(istream);
Expand All @@ -230,11 +232,17 @@ public void loadSessionData(File f, ScriptingEngine engine) {
istream.close();
sessions = newSessions;
app.logEvent("loaded " + newSessions.size() + " sessions from file");
tx.commit();
} catch (FileNotFoundException fnf) {
// suppress error message if session file doesn't exist
tx.abort();
} catch (Exception e) {
app.logError("error loading session data.", e);
tx.abort();
} finally {
tx.closeConnections();
}

}

/**
Expand Down

0 comments on commit 9705a0a

Please sign in to comment.