Skip to content

Commit

Permalink
Catch session unavailable exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Needham authored and gitmate-bot committed Feb 2, 2018
1 parent 1dbc499 commit b17d059
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/private/Session/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function reopen() {
*/
private function validateSession() {
if ($this->sessionClosed) {
throw new Exception('Session has been closed - no further changes to the session are allowed');
throw new SessionNotAvailableException('Session has been closed - no further changes to the session are allowed');
}
}
}
11 changes: 11 additions & 0 deletions tests/lib/Session/CryptoSessionDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Test\Session;

use OC\Session\CryptoSessionData;
use OCP\Session\Exceptions\SessionNotAvailableException;

class CryptoSessionDataTest extends Session {
/** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Security\ICrypto */
Expand Down Expand Up @@ -50,4 +51,14 @@ protected function setUp() {

$this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
}

/**
* Thrown exception during session destruct/close should be handled silently
*/
protected function testDestructExceptionCatching() {
$instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
$e = new SessionNotAvailableException();
$this->wrappedSession->expects($this->once())->method('set')->willThrowException($e);
$instance->__destruct();
}
}

0 comments on commit b17d059

Please sign in to comment.