fixed concurent exception when the list of articles is updated and requested
[pnews.git] / war / src / main / java / pnews / servlet / ArticleProvider.java
index aae0c87..55e098a 100644 (file)
@@ -1,7 +1,6 @@
 package pnews.servlet;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -41,14 +40,12 @@ public class ArticleProvider {
         }
         
         private static SyndFeed getSyndFeed(String u) throws IllegalArgumentException, FeedException, MalformedURLException, IOException {
-                InputStream is;
                 XmlReader r;
                 
                 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() {
@@ -87,8 +84,7 @@ public class ArticleProvider {
                 
                 result.put(Category.ESSONNE,
                                 new String[] { "http://www.tourisme-essonne.com/rss/actus/",
-                                               "http://www.ville-palaiseau.fr/rss/actualites.htm"
-                                                /*"https://www.essonneinfo.fr/feed/"*/ });
+                                               "http://www.ville-palaiseau.fr/rss/actualites.htm" });
                 
                 result.put(Category.PEOPLE,
                                 new String[] { "http://www.premiere.fr/rss/actu-live",
@@ -201,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));
                 }
         }