Skip to content

Commit

Permalink
sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
codingPF committed Nov 1, 2023
1 parent 813935b commit 4f8060d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MServerConfigDTO extends MServerBasicConfigDTO implements ConfigDTO
/** add livestreams from external list **/
private final ImportLivestreamConfiguration importLivestreamConfiguration;
/** add additional filmlist from external **/
private final List<ImportFilmlistConfiguration> ImportFilmlistConfigurations;
private final List<ImportFilmlistConfiguration> importFilmlistConfigurations;
/** The maximum amount of cpu threads to be used. */
private Integer maximumCpuThreads;
/**
Expand Down Expand Up @@ -90,8 +90,7 @@ public MServerConfigDTO() {
filmlistIdFilePath = "filmlist.id";
ignoreFilmlistPath = "ignoreFilmlist.txt";
importLivestreamConfiguration = new ImportLivestreamConfiguration(false, "live-streams.json", FilmlistFormats.OLD_JSON);
ImportFilmlistConfigurations = new ArrayList<ImportFilmlistConfiguration>();
//ImportFilmlistConfigurations.add(new ImportFilmlistConfiguration(false, "https://verteiler1.mediathekview.de/Filmliste-akt.xz", FilmlistFormats.OLD_JSON_COMPRESSED_XZ, true));
importFilmlistConfigurations = new ArrayList<>();

Arrays.stream(Sender.values())
.forEach(sender -> senderConfigurations.put(sender, new MServerBasicConfigDTO(this)));
Expand Down Expand Up @@ -254,7 +253,7 @@ public ImportLivestreamConfiguration getImportLivestreamConfiguration() {
}

public List<ImportFilmlistConfiguration> getImportFilmlistConfigurations() {
return ImportFilmlistConfigurations;
return importFilmlistConfigurations;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CheckUrlAvailability {
private static final Logger LOG = LogManager.getLogger(CheckUrlAvailability.class);
private Long minFileSize = 2048L;
private int removedCounter = 0;
private long timeoutInMS = 1*60*1000;
private long timeoutInMS = 1*60*1000L;
private boolean timeout = false;
private long start = 0;
private FileSizeDeterminer fsd = new FileSizeDeterminer();
Expand All @@ -32,7 +32,7 @@ public Filmlist getAvaiableFilmlist(final Filmlist importList) {
Filmlist filteredFilmlist = new Filmlist();
filteredFilmlist.setCreationDate(importList.getCreationDate());
filteredFilmlist.setListId(importList.getListId());
importList.getFilms().values().stream().parallel().filter(e -> { return isAvailable(e);}).forEach(filteredFilmlist::add);
importList.getFilms().values().stream().parallel().filter(this::isAvailable).forEach(filteredFilmlist::add);
LOG.debug("checked {} urls and removed {} in {} sec and timeout was reached: {}", importList.getFilms().size(), removedCounter, ((System.currentTimeMillis()-start)/1000), timeout);
return filteredFilmlist;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import java.time.Duration;
import java.time.LocalDateTime;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import de.mediathekview.mserver.crawler.arte.ArteCrawler;

public abstract class TimeoutTask extends Thread {
private static final Logger LOG = LogManager.getLogger(ArteCrawler.class);
private final long maxTime;
private boolean isRun;

Expand All @@ -24,7 +30,9 @@ public void run() {
shutdown();
stopTimeout();
}
try {Thread.sleep(60*1000);} catch (InterruptedException e) {}
try {Thread.sleep(60*1000L);} catch (InterruptedException e) {
LOG.error(e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import de.mediathekview.mlib.daten.FilmUrl;
import de.mediathekview.mlib.daten.GeoLocations;
import de.mediathekview.mlib.daten.Resolution;
import de.mediathekview.mlib.tool.FileSizeDeterminer;
import de.mediathekview.mserver.base.utils.UrlUtils;
import de.mediathekview.mserver.crawler.basic.AbstractCrawler;
import de.mediathekview.mserver.crawler.basic.AbstractJsonRestTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static Stream<Arguments> getTestArgumentForFilmlistsInDifferentFormats() {
@ParameterizedTest
@Execution(ExecutionMode.SAME_THREAD)
@MethodSource("getTestArgumentForFilmlistsInDifferentFormats")
public void testSaveAndImport(final ImportFilmlistConfiguration initialList, final ImportFilmlistConfiguration additionalList, final int expectedSize, final int expectedDiffListSize) {
void testSaveAndImport(final ImportFilmlistConfiguration initialList, final ImportFilmlistConfiguration additionalList, final int expectedSize, final int expectedDiffListSize) {
CrawlerManager crawlerManagerForEachRun = createEmptyCrawlerManager();
crawlerManagerForEachRun.addMessageListener(this);
crawlerManagerForEachRun.importFilmlist(initialList);
Expand Down

0 comments on commit 4f8060d

Please sign in to comment.