Skip to content

Commit

Permalink
Fix: args passing & increase attempts interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaaming committed Jul 31, 2024
1 parent 59195dc commit d45c79f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public void start(BundleContext context) throws Exception {
ImporterPlugin.instance = this;
bundleVersion = context.getBundle().getVersion().toString();
digestStore = new DigestStore(getStateLocation().toFile());
Optional<File> bundleFile = FileLocator.getBundleFileLocation(context.getBundle());
if (!bundleFile.isPresent()) {
throw new IllegalStateException("Failed to get bundle location.");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void attemptConnection(File pipeFile) throws IOException {

private void sleep(IOException e, int attempts) {
try {
Thread.sleep(1000);
Thread.sleep(2000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new RuntimeException("Thread interrupted while handling connection failure", ie);
Expand Down
11 changes: 6 additions & 5 deletions extension/src/server/GradleServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as getPort from "get-port";
import * as kill from "tree-kill";
import { commands } from "vscode";
import { sendInfo } from "vscode-extension-telemetry-wrapper";
import { getGradleServerCommand, getGradleServerEnv } from "./serverUtil";
import { getGradleServerCommand, getGradleServerEnv, quoteArg } from "./serverUtil";
import { Logger } from "../logger/index";
import { NO_JAVA_EXECUTABLE, OPT_RESTART } from "../constant";
import { redHatJavaInstalled } from "../util/config";
Expand Down Expand Up @@ -63,13 +63,14 @@ export class GradleServer {
}
const startBuildServer = redHatJavaInstalled() ? "true" : "false";
const args = [
`--port=${this.taskServerPort}`,
`--startBuildServer=${startBuildServer}`,
`--languageServerPipePath=${this.languageServerPipePath}`,
quoteArg(`--port=${this.taskServerPort}`),
quoteArg(`--startBuildServer=${startBuildServer}`),
quoteArg(`--languageServerPipePath=${this.languageServerPipePath}`),
];
if (startBuildServer === "true") {
const buildServerPipeName = this.bspProxy.getBuildServerPipeName();
args.push(`--pipeName=${buildServerPipeName}`, `--bundleDir=${bundleDirectory}`);
args.push(quoteArg(`--pipeName=${buildServerPipeName}`));
args.push(quoteArg(`--bundleDir=${bundleDirectory}`));
}
this.logger.debug(`Gradle Server cmd: ${cmd} ${args.join(" ")}`);

Expand Down
4 changes: 4 additions & 0 deletions extension/src/server/serverUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export interface ProcessEnv {
[key: string]: string | undefined;
}

export function quoteArg(arg: string): string {
return `"${arg}"`;
}

export async function getGradleServerEnv(): Promise<ProcessEnv | undefined> {
const javaHome = getConfigJavaImportGradleJavaHome() || getRedHatJavaEmbeddedJRE() || (await findValidJavaHome());
const env = { ...process.env };
Expand Down

0 comments on commit d45c79f

Please sign in to comment.