props.setProperty(PROPERTY_PROCESS_INDEX, Integer.toString(javaCommand.getProcessId().getIpcIndex()));
props.setProperty(PROPERTY_TERMINATION_TIMEOUT, String.valueOf(timeouts.getTerminationTimeout()));
props.setProperty(PROPERTY_SHARED_PATH, tempDir.getAbsolutePath());
- OutputStream out = new FileOutputStream(propertiesFile);
- props.store(out, String.format("Temporary properties file for command [%s]", javaCommand.getProcessId().getKey()));
- out.close();
+ try (OutputStream out = new FileOutputStream(propertiesFile)) {
+ props.store(out, String.format("Temporary properties file for command [%s]", javaCommand.getProcessId().getKey()));
+ }
return propertiesFile;
} catch (Exception e) {
throw new IllegalStateException("Cannot write temporary settings to " + propertiesFile, e);
BulkIndexer bulk = new BulkIndexer(esClient, ActivityIndexDefinition.INDEX);
bulk.setLarge(lastUpdatedAt == 0L);
- DbSession dbSession = dbClient.openSession(false);
- try {
- ActivityResultSetIterator it = ActivityResultSetIterator.create(dbClient, dbSession, lastUpdatedAt);
+ try (
+ DbSession dbSession = dbClient.openSession(false);
+ ActivityResultSetIterator it = ActivityResultSetIterator.create(dbClient, dbSession, lastUpdatedAt)) {
+
bulk.start();
while (it.hasNext()) {
bulk.add(it.next());
}
bulk.stop();
- it.close();
return it.getMaxRowDate();
- } finally {
- dbSession.close();
}
}
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.scanner.bootstrap.BatchWsClient;
-import org.sonar.scanner.platform.DefaultServer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;