Skip to content

Commit

Permalink
fix: Prevent from telemetry crash when language servers starts
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Oct 8, 2023
1 parent 52d82de commit 1fef847
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.Project;
import com.redhat.devtools.intellij.lsp4mp4ij.settings.MicroProfileInspectionsInfo;
import com.redhat.devtools.intellij.quarkus.TelemetryService;
import com.redhat.devtools.intellij.lsp4ij.server.JavaProcessCommandBuilder;
import com.redhat.devtools.intellij.lsp4ij.server.ProcessStreamConnectionProvider;
import com.redhat.devtools.intellij.lsp4mp4ij.settings.UserDefinedMicroProfileSettings;
import com.redhat.devtools.intellij.quarkus.TelemetryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.URI;
Expand All @@ -32,6 +33,8 @@
*/
public class QuarkusServer extends ProcessStreamConnectionProvider {

private static final Logger LOGGER = LoggerFactory.getLogger(QuarkusServer.class);

private final Project project;

public QuarkusServer(Project project) {
Expand All @@ -40,14 +43,18 @@ public QuarkusServer(Project project) {
File lsp4mpServerPath = new File(descriptor.getPath(), "lib/server/org.eclipse.lsp4mp.ls-uber.jar");
File quarkusServerPath = new File(descriptor.getPath(), "lib/server/com.redhat.quarkus.ls.jar");

List<String> commands = new JavaProcessCommandBuilder(project,"quarkus")
List<String> commands = new JavaProcessCommandBuilder(project, "quarkus")
.setJar(lsp4mpServerPath.getAbsolutePath())
.setCp(quarkusServerPath.getAbsolutePath())
.create();
commands.add("-DrunAsync=true");
super.setCommands(commands);

TelemetryService.instance().action(TelemetryService.LSP_PREFIX + "start").send();
try {
TelemetryService.instance().action(TelemetryService.LSP_PREFIX + "start").send();
} catch (Exception e) {
LOGGER.error("Error while consuming telemetry service", e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.Project;
import com.redhat.devtools.intellij.lsp4mp4ij.settings.UserDefinedMicroProfileSettings;
import com.redhat.devtools.intellij.quarkus.TelemetryService;
import com.redhat.devtools.intellij.lsp4ij.server.JavaProcessCommandBuilder;
import com.redhat.devtools.intellij.lsp4ij.server.ProcessStreamConnectionProvider;
import com.redhat.devtools.intellij.qute.settings.QuteInspectionsInfo;
import com.redhat.devtools.intellij.quarkus.TelemetryService;
import com.redhat.devtools.intellij.qute.settings.UserDefinedQuteSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.URI;
Expand All @@ -33,6 +33,8 @@
*/
public class QuteServer extends ProcessStreamConnectionProvider {

private static final Logger LOGGER = LoggerFactory.getLogger(QuteServer.class);

private final Project project;

public QuteServer(Project project) {
Expand All @@ -46,7 +48,12 @@ public QuteServer(Project project) {
commands.add("-DrunAsync=true");
super.setCommands(commands);

TelemetryService.instance().action(TelemetryService.LSP_PREFIX + "startQute").send();
try {
TelemetryService.instance().action(TelemetryService.LSP_PREFIX + "startQute").send();
}
catch(Exception e) {
LOGGER.error("Error while consuming telemetry service", e);
}
}

@Override
Expand Down

0 comments on commit 1fef847

Please sign in to comment.