Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSS reader never stops #171

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.apptasticsoftware.rssreader;

import com.apptasticsoftware.rssreader.util.Mapper;
import com.apptasticsoftware.rssreader.util.DaemonThreadFactory;

import javax.net.ssl.SSLContext;
import javax.xml.stream.XMLInputFactory;
Expand Down Expand Up @@ -64,7 +65,7 @@
*/
public abstract class AbstractRssReader<C extends Channel, I extends Item> {
private static final String LOG_GROUP = "com.apptasticsoftware.rssreader";
private static final ScheduledThreadPoolExecutor EXECUTOR = new ScheduledThreadPoolExecutor(1);
private static final ScheduledExecutorService EXECUTOR = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("RssReaderWorker"));
private final HttpClient httpClient;
private DateTimeParser dateTimeParser = new DateTime();
private String userAgent = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.apptasticsoftware.rssreader.util;

import java.util.concurrent.ThreadFactory;

/**
* Thread factory that creates daemon threads
*/
public class DaemonThreadFactory implements ThreadFactory {
private final String name;
private int counter;

public DaemonThreadFactory(String name) {
this.name = name;
}

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r, name + "-" + counter++);
t.setDaemon(true);
return t;
}

}