NIFI-526 move check into try so writeLock is released

Signed-off-by: Mark Payne <markap14@hotmail.com>
This commit is contained in:
Mark Latimer 2015-04-23 15:49:33 +01:00 committed by Mark Payne
parent 6e492b4082
commit b7d2154f7d
1 changed files with 7 additions and 6 deletions

View File

@ -434,8 +434,8 @@ public class GetHTTP extends AbstractSessionFactoryProcessor {
if (timeToPersist < System.currentTimeMillis()) { if (timeToPersist < System.currentTimeMillis()) {
readLock.unlock(); readLock.unlock();
writeLock.lock(); writeLock.lock();
if (timeToPersist < System.currentTimeMillis()) { try {
try { if (timeToPersist < System.currentTimeMillis()) {
timeToPersist = System.currentTimeMillis() + PERSISTENCE_INTERVAL_MSEC; timeToPersist = System.currentTimeMillis() + PERSISTENCE_INTERVAL_MSEC;
File httpCache = new File(HTTP_CACHE_FILE_PREFIX + getIdentifier()); File httpCache = new File(HTTP_CACHE_FILE_PREFIX + getIdentifier());
try (FileOutputStream fos = new FileOutputStream(httpCache)) { try (FileOutputStream fos = new FileOutputStream(httpCache)) {
@ -446,10 +446,11 @@ public class GetHTTP extends AbstractSessionFactoryProcessor {
} catch (IOException e) { } catch (IOException e) {
getLogger().error("Failed to persist ETag and LastMod due to " + e, e); getLogger().error("Failed to persist ETag and LastMod due to " + e, e);
} }
} finally { }
readLock.lock(); }
writeLock.unlock(); finally {
} readLock.lock();
writeLock.unlock();
} }
} }
} finally { } finally {