ERROR: Unable to run check class org.sonar.java.checks.TryWithResourcesCheck - S2093 on file

Hi all! I have the issues:
ERROR: Unable to run check class org.sonar.java.se.SymbolicExecutionVisitor - on file

ERROR: Unable to run check class org.sonar.java.checks.TryWithResourcesCheck - S2093 on file

INFO: SonarScanner 4.6.0.2311
INFO: Java 11.0.10 AdoptOpenJDK (64-bit)
INFO: Linux 4.12.14-150.47-default amd64
INFO: Project root configuration file: /config/sonar-project.properties
INFO: Analyzing on SonarQube server 8.9.6

Could you please help me fix them?

Hi,

Would you be able to share the file in question? Or a minimal set of code from the file that will reproduce the error?

 
Thx,
Ann

Hi! Thanks

<package com.cp.udr.mbm.leader.monitor;

import com.cp.udr.mbm.MessageBusMonitor;
import com.cp.udr.monitors.leader.MonitorTask;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class builds the monitor tasks to be checked by the {@link MessageBusMonitor} object.
 *
 * <p>The {@link PublisherConsumerMonitor} is a monitor task.
 *
 * @author ecebgl
 */
public final class MonitorsFactory {

  private static final Logger LOG = LoggerFactory.getLogger(MonitorsFactory.class);

  private MonitorsFactory() {
    throw new RuntimeException();
  }

  /**
   * Build the monitors to be checked by the Message Bus Monitor.
   *
   * @param messageBusM Message Bus Monitor object
   * @return the list of monitor tasks checked by Message Bus Monitor
   * @throws Exception .
   */
  public static List<MonitorTask> getMonitors(final MessageBusMonitor messageBusM)
      throws Exception {
    final Builder<MonitorTask> bldr = ImmutableList.builder();
    if (messageBusM.getMessageBusTopicTest() != null) {
      bldr.add(new PublisherConsumerMonitor(messageBusM));
      LOG.info("Created '{}' monitor", messageBusM.getMessageBusMonitorProps().getMonitorName());
    }
    if (messageBusM.getQueryPmMetrics() != null) {
      bldr.add(new PmMetricsMonitor(messageBusM));
      LOG.info(
          "Created '{}' monitor",
          messageBusM.getMessageBusMonitorProps().getPmMetricsMonitorName());
    }
    return bldr.build();
  }
}
1 Like

Hi @Banshchykova
Thanks for sharing that bit of code. Unfortunately, I cannot reproduce the issue with this sample.

To be able to able the confirm the bug, you could either:

  • Share a self-contained example (with the minimal amount of dependencies possible)
  • Point to the project where the file lives so that we can analyze in context
  • Provide all the dependencies imported in this file

Thanks

Hi!
Unfortunately can’t share more details due to NDA.
But, after testing on SonarQube Server 9.5 with SonarScanner version 4.6.0.2311 issues are not reproduced. So, the issue may be closed.
Thanks for you help!

1 Like