t-rana commented on code in PR #1675:
URL: https://github.com/apache/jackrabbit-oak/pull/1675#discussion_r1735804744
##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureRepositoryLock.java:
##########
@@ -137,17 +137,23 @@ private void refreshLease() {
writeAccessController.enableWriting();
lastUpdate = System.currentTimeMillis();
}
- } catch (StorageException e) {
+ } catch (Exception e) {
timeSinceLastUpdate = (System.currentTimeMillis() -
lastUpdate) / 1000;
if (timeSinceLastUpdate > timeToWaitBeforeWriteBlock) {
writeAccessController.disableWriting();
}
- if (Set.of(StorageErrorCodeStrings.OPERATION_TIMED_OUT,
StorageErrorCode.SERVICE_INTERNAL_ERROR, StorageErrorCodeStrings.SERVER_BUSY,
StorageErrorCodeStrings.INTERNAL_ERROR).contains(e.getErrorCode())) {
- log.warn("Could not renew the lease due to the operation
timeout or service unavailability. Retry in progress ...", e);
- } else if (e.getHttpStatusCode() ==
Constants.HeaderConstants.HTTP_UNUSED_306) {
- log.warn("Client side error. Retry in progress ...", e);
+ StorageException storageException = e instanceof
StorageException ? (StorageException) e : null;
+
+ if (storageException != null
Review Comment:
can we wrap the entire block in a single storage storageException != null.
Something like this
`if (e instanceof StorageException) {
StorageException storageException = (StorageException) e;
if (Set.of(StorageErrorCodeStrings.OPERATION_TIMED_OUT,
StorageErrorCode.SERVICE_INTERNAL_ERROR,
StorageErrorCodeStrings.SERVER_BUSY,
StorageErrorCodeStrings.INTERNAL_ERROR).contains(storageException.getErrorCode()))
{
log.warn("Could not renew the lease due to the
operation timeout or service unavailability. Retry in progress ...", e);
} else if (storageException.getHttpStatusCode() ==
Constants.HeaderConstants.HTTP_UNUSED_306) {
log.warn("Client side error. Retry in progress ...",
e);
} else {
log.warn("Could not renew lease due to storage
exception. Retry in progress ... ", e);
}
} else {
log.error("Can't renew the lease", e);
shutdownHook.run();
doUpdate = false;
return;
}`
Looks a bit cleaner to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]