//
// ========================================================================
-// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
throws Exception
{
File file = null;
- FileOutputStream fos = null;
if (!_saveFailed && _hashSessionManager._storeDir != null)
{
- try
+ file = new File(_hashSessionManager._storeDir, super.getId());
+ if (file.exists())
+ {
+ file.delete();
+ }
+
+ try(FileOutputStream fos = new FileOutputStream(file,false))
{
- file = new File(_hashSessionManager._storeDir, super.getId());
- if (file.exists())
- file.delete();
- file.createNewFile();
- fos = new FileOutputStream(file);
save(fos);
- IO.close(fos);
}
catch (Exception e)
{
saveFailed(); // We won't try again for this session
- if (fos != null) IO.close(fos);
- if (file != null) file.delete(); // No point keeping the file if we didn't save the whole session
+ if (file != null)
+ file.delete(); // No point keeping the file if we didn't save the whole session
throw e;
}
}