fixed concurent exception when the list of articles is updated and requested
[pnews.git] / war / src / main / java / pnews / servlet / ArticleProvider.java
index 4912469..55e098a 100644 (file)
@@ -45,8 +45,7 @@ public class ArticleProvider {
                 r = new XmlReader(new URL(u));
                 XmlReader.setDefaultEncoding("UTF-8");
                 
-                return new SyndFeedInput().build(r);
-                
+                return new SyndFeedInput().build(r);                
         }
         
         private static Map<Category, String[]> getFeeds() {
@@ -198,10 +197,13 @@ public class ArticleProvider {
                         LOG.severe("No feed for category " + cat);
         }
         
+        /**
+         * Returns a copy.
+         */
         public List<Article> getArticles(Category cat)
                         throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
                 synchronized (articlesByCategory) {
-                        return articlesByCategory.get(cat);
+                        return new ArrayList<>(articlesByCategory.get(cat));
                 }
         }