Skip to content

Commit

Permalink
Issue #4156 Simplyify getAndEnter method more
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Nov 14, 2019
1 parent 1ad7a3c commit 515ed5b
Showing 1 changed file with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,43 +342,36 @@ protected Session getAndEnter(String id, boolean enter) throws Exception
{
Session session = null;

session = doGet(id);

if (session == null)
session = doComputeIfAbsent(id, k ->
{
if (LOG.isDebugEnabled())
LOG.debug("Session {} not found locally in {}, attempting to load", id, this);

session = doComputeIfAbsent(id, k ->
try
{
try
Session s = loadSession(k);
if (s != null)
{
return loadSession(k);
try (Lock lock = s.lock())
{
s.setResident(true); //ensure freshly loaded session is resident
}
}
catch (Exception e)
else
{
LOG.warn("Error loading session {}", id, e);
return null;
if (LOG.isDebugEnabled())
LOG.debug("Session {} not loaded by store", id);
}
});

if (session == null) //session does not exist in store
{
if (LOG.isDebugEnabled())
LOG.debug("Session {} not loaded by store", id);
return null;
return s;
}
else
catch (Exception e)
{
try (Lock lock = session.lock())
{
session.setResident(true); //ensure freshly loaded session is resident
if (enter)
session.use();
}
LOG.warn("Error loading session {}", id, e);
return null;
}
}
else
});

if (session != null)
{
try (Lock lock = session.lock())
{
Expand Down

0 comments on commit 515ed5b

Please sign in to comment.