OpenNTF / XPagesToolkit

Apache License 2.0
7 stars 5 forks source link

MalformedURLException if xpt:rssFeed's feedURL property is blank #10

Closed paulswithers closed 9 years ago

paulswithers commented 10 years ago

I'm dynamically passing feeds based on the localfeedcontent.nsf database. If no feeds have been set up, the code throws a MalformedURLException in FeedReaderService.getAllEntriesFromURL(String). This can be resolved by adding a check for whether the String parameter passed is blank, in which case just returning an empty ArrayList, as below:

public List getAllEntriesFromURL(String strURL) { List lstRC = new ArrayList(); if (!"".equals(strURL)) { Thread currentThread = Thread.currentThread(); ClassLoader clCurrent = currentThread.getContextClassLoader();

        try {
            currentThread.setContextClassLoader(XPTRSSActivator.class.getClassLoader());

            URL feedUrl = new URL(strURL);
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(feedUrl));
            lstRC = processFeed2List(feed);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            currentThread.setContextClassLoader(clCurrent);
        }
    }
    return lstRC;
}
guedeWebGate commented 10 years ago

Thanks for the suggestion, will be fixed