Skip to content

Commit

Permalink
Delete unnecessary IOException and JOBS_SETTINGS_FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
jonx8 committed Sep 9, 2023
1 parent 6124280 commit 2595a41
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/main/java/ru/etu/petci/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.logging.Logger;

public class Main {
public static final String JOBS_SETTINGS_FILE = "jobs.properties";
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());

static {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/ru/etu/petci/configuration/Configurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ru.etu.petci.jobs.Job;
import ru.etu.petci.observers.RepositoryObserver;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -37,7 +36,7 @@ public void saveRepositoryConfig(String repoPath, String branchName) {
}


public List<Job> readJobsConfig() throws IOException, BackingStoreException {
public List<Job> readJobsConfig() throws BackingStoreException {
List<Job> jobsList = new ArrayList<>();
var jobsPreferences = Preferences.userRoot().node(JOBS_PREFERENCES);
for (String jobName : jobsPreferences.keys()) {
Expand All @@ -48,7 +47,7 @@ public List<Job> readJobsConfig() throws IOException, BackingStoreException {
}


public void saveJobsConfig(String jobName, String scriptPath) throws IOException {
public void saveJobsConfig(String jobName, String scriptPath) {
var jobsPreferences = Preferences.userRoot().node(JOBS_PREFERENCES);

if (jobsPreferences.get(jobName, null) == null) {
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/ru/etu/petci/handlers/AddCommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import ru.etu.petci.configuration.Configurator;

import java.io.IOException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -35,14 +34,8 @@ public int handle(String arg) {
return 1;
}

configurator.saveJobsConfig(jobName, scriptPath);
scanner.close();

try {
configurator.saveJobsConfig(jobName, scriptPath);
} catch (IOException e) {
LOGGER.severe(e.getMessage());
return 1;
}
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ru.etu.petci.jobs.JobsExecutor;
import ru.etu.petci.observers.RepositoryObserver;

import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
Expand Down Expand Up @@ -35,7 +34,7 @@ public int handle(String arg) {
} catch (InterruptedException e) {
LOGGER.log(Level.SEVERE, "The program was interrupted");
Thread.currentThread().interrupt();
} catch (RepositoryNotFoundException | BackingStoreException | IOException e) {
} catch (RepositoryNotFoundException | BackingStoreException e) {
LOGGER.log(Level.SEVERE, e.getMessage());
}
return 1;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/ru/etu/petci/handlers/InitCommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

import ru.etu.petci.configuration.Configurator;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

import static ru.etu.petci.Main.JOBS_SETTINGS_FILE;

public class InitCommandHandler implements CommandHandler {
private static final Logger LOGGER = Logger.getLogger(InitCommandHandler.class.getName());

Expand Down

0 comments on commit 2595a41

Please sign in to comment.