Skip to content

Commit

Permalink
[JavaToolInstaller]. Handling for 'unknown' errors (#13237)
Browse files Browse the repository at this point in the history
* [JavaToolInsteller]. Added handling for 'unknown' errors

* [JavaToolInstaller] Bumped task version

* [JavaToolInstaller] Fixed code review points.

* [JavaToolInsteller] Fixed code review points.
  • Loading branch information
Sergey Dobrodeev authored Jul 10, 2020
1 parent 97d4f5f commit 900d618
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
13 changes: 12 additions & 1 deletion Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface IDirectoriesDictionary {
}

export class JavaFilesExtractor {
private readonly ERR_SHARE_ACCESS = -4094;
public destinationFolder: string;
public readonly win: boolean;

Expand Down Expand Up @@ -170,7 +171,17 @@ export class JavaFilesExtractor {
initialDirectoriesList = taskLib.find(this.destinationFolder).filter(x => taskLib.stats(x).isDirectory());

const jdkFile = path.normalize(repoRoot);
const stats = taskLib.stats(jdkFile);

let stats: taskLib.FsStats;
try {
stats = taskLib.stats(jdkFile);
} catch (error) {
if (error.errno === this.ERR_SHARE_ACCESS) {
throw new Error(taskLib.loc('ShareAccessError', error.path));
}
throw(error);
}

if (stats.isFile()) {
await this.extractFiles(jdkFile, fileEnding);
finalDirectoriesList = taskLib.find(this.destinationFolder).filter(x => taskLib.stats(x).isDirectory());
Expand Down
5 changes: 3 additions & 2 deletions Tasks/JavaToolInstallerV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 171,
"Minor": 173,
"Patch": 0
},
"satisfies": [
Expand Down Expand Up @@ -177,6 +177,7 @@
"CorrelationIdForARM": "Correlation ID from ARM api call response : %s",
"JavaNotPreinstalled": "Java %s is not preinstalled on this agent",
"UsePreinstalledJava": "Use preinstalled JDK from %s",
"WrongArchiveStructure": "JDK file is not valid. Verify if JDK file contains only one root folder with 'bin' inside."
"WrongArchiveStructure": "JDK file is not valid. Verify if JDK file contains only one root folder with 'bin' inside.",
"ShareAccessError": "Network shared resource not available: (%s)"
}
}
2 changes: 1 addition & 1 deletion Tasks/JavaToolInstallerV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 171,
"Minor": 173,
"Patch": 0
},
"satisfies": [
Expand Down

0 comments on commit 900d618

Please sign in to comment.