[Lock] Distinguish FileNotFound error from all other
Related-To: PRODX-8457
Change-Id: I9697dedcd56559619e78e9385af15d888f1a826c
diff --git a/src/com/mirantis/mk/Lock.groovy b/src/com/mirantis/mk/Lock.groovy
index 10efa71..d72ceed 100644
--- a/src/com/mirantis/mk/Lock.groovy
+++ b/src/com/mirantis/mk/Lock.groovy
@@ -10,6 +10,7 @@
private String lockFileContent
private String lockFileContentCache
+ private Boolean fileNotFound
final private String fileUri
@@ -53,8 +54,14 @@
if (this.lockFileContentCache == null) {
try {
this.lockFileContentCache = artifactoryTools.restCall(this.artObj, this.fileUri, 'GET', null, [:], '')
- } catch (Exception e) {
+ this.fileNotFound = false // file found
+ } catch (java.io.FileNotFoundException e) {
this.lockFileContentCache = ''
+ this.fileNotFound = true // file not found
+ } catch (Exception e) {
+ common.errorMsg(e.message)
+ this.lockFileContentCache = ''
+ this.fileNotFound = null // we don't know about file existence
}
}
return this.lockFileContentCache
@@ -131,7 +138,9 @@
}
private Boolean isLockFileExist() {
- return !this.lockFileContent.isEmpty()
+ // If there is something in file's content that it definitly exists
+ // If we don't know about file existence (fileNotFound == null) we assume it exists
+ return !this.lockFileContent.isEmpty() || !this.fileNotFound
}
private Boolean isLockExpired() {