diff --git a/dist/index.js b/dist/index.js
index d77e3beb..d81245c0 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -3770,7 +3770,6 @@ var HttpCodes;
     HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
     HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
     HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
-    HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
     HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
     HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
     HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
@@ -3795,18 +3794,8 @@ function getProxyUrl(serverUrl) {
     return proxyUrl ? proxyUrl.href : '';
 }
 exports.getProxyUrl = getProxyUrl;
-const HttpRedirectCodes = [
-    HttpCodes.MovedPermanently,
-    HttpCodes.ResourceMoved,
-    HttpCodes.SeeOther,
-    HttpCodes.TemporaryRedirect,
-    HttpCodes.PermanentRedirect
-];
-const HttpResponseRetryCodes = [
-    HttpCodes.BadGateway,
-    HttpCodes.ServiceUnavailable,
-    HttpCodes.GatewayTimeout
-];
+const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
+const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
 const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
 const ExponentialBackoffCeiling = 10;
 const ExponentialBackoffTimeSlice = 5;
@@ -3931,22 +3920,18 @@ class HttpClient {
      */
     async request(verb, requestUrl, data, headers) {
         if (this._disposed) {
-            throw new Error('Client has already been disposed.');
+            throw new Error("Client has already been disposed.");
         }
         let parsedUrl = url.parse(requestUrl);
         let info = this._prepareRequest(verb, parsedUrl, headers);
         // Only perform retries on reads since writes may not be idempotent.
-        let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
-            ? this._maxRetries + 1
-            : 1;
+        let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
         let numTries = 0;
         let response;
         while (numTries < maxTries) {
             response = await this.requestRaw(info, data);
             // Check if it's an authentication challenge
-            if (response &&
-                response.message &&
-                response.message.statusCode === HttpCodes.Unauthorized) {
+            if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
                 let authenticationHandler;
                 for (let i = 0; i < this.handlers.length; i++) {
                     if (this.handlers[i].canHandleAuthentication(response)) {
@@ -3964,32 +3949,21 @@ class HttpClient {
                 }
             }
             let redirectsRemaining = this._maxRedirects;
-            while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
-                this._allowRedirects &&
-                redirectsRemaining > 0) {
-                const redirectUrl = response.message.headers['location'];
+            while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
+                && this._allowRedirects
+                && redirectsRemaining > 0) {
+                const redirectUrl = response.message.headers["location"];
                 if (!redirectUrl) {
                     // if there's no location to redirect to, we won't
                     break;
                 }
                 let parsedRedirectUrl = url.parse(redirectUrl);
-                if (parsedUrl.protocol == 'https:' &&
-                    parsedUrl.protocol != parsedRedirectUrl.protocol &&
-                    !this._allowRedirectDowngrade) {
-                    throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
+                if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
+                    throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
                 }
                 // we need to finish reading the response before reassigning response
                 // which will leak the open socket.
                 await response.readBody();
-                // strip authorization header if redirected to a different hostname
-                if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
-                    for (let header in headers) {
-                        // header names are case insensitive
-                        if (header.toLowerCase() === 'authorization') {
-                            delete headers[header];
-                        }
-                    }
-                }
                 // let's make the request with the new redirectUrl
                 info = this._prepareRequest(verb, parsedRedirectUrl, headers);
                 response = await this.requestRaw(info, data);
@@ -4040,8 +4014,8 @@ class HttpClient {
      */
     requestRawWithCallback(info, data, onResult) {
         let socket;
-        if (typeof data === 'string') {
-            info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
+        if (typeof (data) === 'string') {
+            info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
         }
         let callbackCalled = false;
         let handleResult = (err, res) => {
@@ -4054,7 +4028,7 @@ class HttpClient {
             let res = new HttpClientResponse(msg);
             handleResult(null, res);
         });
-        req.on('socket', sock => {
+        req.on('socket', (sock) => {
             socket = sock;
         });
         // If we ever get disconnected, we want the socket to timeout eventually
@@ -4069,10 +4043,10 @@ class HttpClient {
             // res should have headers
             handleResult(err, null);
         });
-        if (data && typeof data === 'string') {
+        if (data && typeof (data) === 'string') {
             req.write(data, 'utf8');
         }
-        if (data && typeof data !== 'string') {
+        if (data && typeof (data) !== 'string') {
             data.on('close', function () {
                 req.end();
             });
@@ -4099,34 +4073,31 @@ class HttpClient {
         const defaultPort = usingSsl ? 443 : 80;
         info.options = {};
         info.options.host = info.parsedUrl.hostname;
-        info.options.port = info.parsedUrl.port
-            ? parseInt(info.parsedUrl.port)
-            : defaultPort;
-        info.options.path =
-            (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
+        info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
+        info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
         info.options.method = method;
         info.options.headers = this._mergeHeaders(headers);
         if (this.userAgent != null) {
-            info.options.headers['user-agent'] = this.userAgent;
+            info.options.headers["user-agent"] = this.userAgent;
         }
         info.options.agent = this._getAgent(info.parsedUrl);
         // gives handlers an opportunity to participate
         if (this.handlers) {
-            this.handlers.forEach(handler => {
+            this.handlers.forEach((handler) => {
                 handler.prepareRequest(info.options);
             });
         }
         return info;
     }
     _mergeHeaders(headers) {
-        const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
+        const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
         if (this.requestOptions && this.requestOptions.headers) {
             return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
         }
         return lowercaseKeys(headers || {});
     }
     _getExistingOrDefaultHeader(additionalHeaders, header, _default) {
-        const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
+        const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
         let clientHeader;
         if (this.requestOptions && this.requestOptions.headers) {
             clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
@@ -4164,7 +4135,7 @@ class HttpClient {
                     proxyAuth: proxyUrl.auth,
                     host: proxyUrl.hostname,
                     port: proxyUrl.port
-                }
+                },
             };
             let tunnelAgent;
             const overHttps = proxyUrl.protocol === 'https:';
@@ -4191,9 +4162,7 @@ class HttpClient {
             // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
             // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
             // we have to cast it to any and change it directly
-            agent.options = Object.assign(agent.options || {}, {
-                rejectUnauthorized: false
-            });
+            agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
         }
         return agent;
     }
@@ -4254,7 +4223,7 @@ class HttpClient {
                     msg = contents;
                 }
                 else {
-                    msg = 'Failed request: (' + statusCode + ')';
+                    msg = "Failed request: (" + statusCode + ")";
                 }
                 let err = new Error(msg);
                 // attach statusCode and body obj (if available) to the error object
@@ -4727,7 +4696,7 @@ function getJava(version, arch, jdkFile, javaPackage) {
                 }
                 const contents = yield response.readBody();
                 const refs = contents.match(/<a href.*\">/gi) || [];
-                const downloadInfo = getDownloadInfo(refs, version, javaPackage);
+                const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
                 jdkFile = yield tc.downloadTool(downloadInfo.url);
                 version = downloadInfo.version;
                 compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@@ -4742,17 +4711,9 @@ function getJava(version, arch, jdkFile, javaPackage) {
             toolPath = yield tc.cacheDir(jdkDir, javaPackage, getCacheVersionString(version), arch);
         }
         let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch;
-        core.exportVariable(extendedJavaHome, toolPath); //TODO: remove for v2
-        // For portability reasons environment variables should only consist of
-        // uppercase letters, digits, and the underscore. Therefore we convert
-        // the extendedJavaHome variable to upper case and replace '.' symbols and
-        // any other non-alphanumeric characters with an underscore.
-        extendedJavaHome = extendedJavaHome.toUpperCase().replace(/[^0-9A-Z_]/g, '_');
         core.exportVariable('JAVA_HOME', toolPath);
         core.exportVariable(extendedJavaHome, toolPath);
         core.addPath(path.join(toolPath, 'bin'));
-        core.setOutput('path', toolPath);
-        core.setOutput('version', version);
     });
 }
 exports.getJava = getJava;
@@ -4843,20 +4804,31 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
         }
     });
 }
-function getDownloadInfo(refs, version, javaPackage) {
+function getDownloadInfo(refs, version, arch, javaPackage) {
     version = normalizeVersion(version);
+    let archExtension = '';
+    if (arch === 'x86') {
+        archExtension = 'i686';
+    }
+    else if (arch === 'x64') {
+        archExtension = 'x64';
+    }
+    else {
+        throw new Error(`architecture "${arch}" is not int [x86 | x64]`);
+    }
     let extension = '';
     if (IS_WINDOWS) {
-        extension = `-win_x64.zip`;
+        extension = `-win_${archExtension}.zip`;
     }
     else {
         if (process.platform === 'darwin') {
-            extension = `-macosx_x64.tar.gz`;
+            extension = `-macosx_${archExtension}.tar.gz`;
         }
         else {
-            extension = `-linux_x64.tar.gz`;
+            extension = `-linux_${archExtension}.tar.gz`;
         }
     }
+    core.debug(`Searching for files with extension: ${extension}`);
     let pkgRegexp = new RegExp('');
     let pkgTypeLength = 0;
     if (javaPackage === 'jdk') {
@@ -4956,10 +4928,12 @@ function getProxyUrl(reqUrl) {
     }
     let proxyVar;
     if (usingSsl) {
-        proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
+        proxyVar = process.env["https_proxy"] ||
+            process.env["HTTPS_PROXY"];
     }
     else {
-        proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
+        proxyVar = process.env["http_proxy"] ||
+            process.env["HTTP_PROXY"];
     }
     if (proxyVar) {
         proxyUrl = url.parse(proxyVar);
@@ -4971,7 +4945,7 @@ function checkBypass(reqUrl) {
     if (!reqUrl.hostname) {
         return false;
     }
-    let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
+    let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
     if (!noProxy) {
         return false;
     }
@@ -4992,10 +4966,7 @@ function checkBypass(reqUrl) {
         upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
     }
     // Compare request host against noproxy
-    for (let upperNoProxyItem of noProxy
-        .split(',')
-        .map(x => x.trim().toUpperCase())
-        .filter(x => x)) {
+    for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) {
         if (upperReqHosts.some(x => x === upperNoProxyItem)) {
             return true;
         }
diff --git a/dist/setup/index.js b/dist/setup/index.js
index 3beeeece..28c5c3cc 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -28685,6 +28685,9 @@ function run() {
                 version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
             }
             const arch = core.getInput(constants.INPUT_ARCHITECTURE, { required: true });
+            if (!['x86', 'x64'].includes(arch)) {
+                throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
+            }
             const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
                 required: true
             });
@@ -33423,7 +33426,7 @@ function getJava(version, arch, jdkFile, javaPackage) {
                 }
                 const contents = yield response.readBody();
                 const refs = contents.match(/<a href.*\">/gi) || [];
-                const downloadInfo = getDownloadInfo(refs, version, javaPackage);
+                const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
                 jdkFile = yield tc.downloadTool(downloadInfo.url);
                 version = downloadInfo.version;
                 compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@@ -33539,20 +33542,22 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
         }
     });
 }
-function getDownloadInfo(refs, version, javaPackage) {
+function getDownloadInfo(refs, version, arch, javaPackage) {
     version = normalizeVersion(version);
+    const archExtension = arch === 'x86' ? 'i686' : 'x64';
     let extension = '';
     if (IS_WINDOWS) {
-        extension = `-win_x64.zip`;
+        extension = `-win_${archExtension}.zip`;
     }
     else {
         if (process.platform === 'darwin') {
-            extension = `-macosx_x64.tar.gz`;
+            extension = `-macosx_${archExtension}.tar.gz`;
         }
         else {
-            extension = `-linux_x64.tar.gz`;
+            extension = `-linux_${archExtension}.tar.gz`;
         }
     }
+    core.debug(`Searching for files with extension: ${extension}`);
     let pkgRegexp = new RegExp('');
     let pkgTypeLength = 0;
     if (javaPackage === 'jdk') {
diff --git a/src/installer.ts b/src/installer.ts
index 88a8ff18..b48eeb0b 100644
--- a/src/installer.ts
+++ b/src/installer.ts
@@ -45,7 +45,7 @@ export async function getJava(
 
       const contents = await response.readBody();
       const refs = contents.match(/<a href.*\">/gi) || [];
-      const downloadInfo = getDownloadInfo(refs, version, javaPackage);
+      const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
       jdkFile = await tc.downloadTool(downloadInfo.url);
       version = downloadInfo.version;
       compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@@ -181,20 +181,26 @@ async function unzipJavaDownload(
 function getDownloadInfo(
   refs: string[],
   version: string,
+  arch: string,
   javaPackage: string
 ): {version: string; url: string} {
   version = normalizeVersion(version);
+
+  const archExtension = arch === 'x86' ? 'i686' : 'x64';
+
   let extension = '';
   if (IS_WINDOWS) {
-    extension = `-win_x64.zip`;
+    extension = `-win_${archExtension}.zip`;
   } else {
     if (process.platform === 'darwin') {
-      extension = `-macosx_x64.tar.gz`;
+      extension = `-macosx_${archExtension}.tar.gz`;
     } else {
-      extension = `-linux_x64.tar.gz`;
+      extension = `-linux_${archExtension}.tar.gz`;
     }
   }
 
+  core.debug(`Searching for files with extension: ${extension}`);
+
   let pkgRegexp = new RegExp('');
   let pkgTypeLength = 0;
   if (javaPackage === 'jdk') {
diff --git a/src/setup-java.ts b/src/setup-java.ts
index db169f29..5ba35297 100644
--- a/src/setup-java.ts
+++ b/src/setup-java.ts
@@ -11,7 +11,12 @@ async function run() {
     if (!version) {
       version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
     }
+
     const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true});
+    if (!['x86', 'x64'].includes(arch)) {
+      throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
+    }
+
     const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
       required: true
     });