Thursday Jul 05, 2012

Feed Reader Fix

In the FeedReader sample (available in the New Projects window), there's this piece of code:

private static Feed getFeed(Node node) {
    InstanceCookie ck = node.getLookup().lookup(InstanceCookie.class);
    if (ck == null) {
        throw new IllegalStateException("Bogus file in feeds folder: " +
                node.getLookup().lookup(FileObject.class));
    }
    try {
        return (Feed) ck.instanceCreate();
    } catch (ClassNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    return null;
}

Since 7.1, for some reason, the above doesn't work. What does work, and is simpler, is this, instead of the above:

private static Feed getFeed(Node node) {
    Feed f = FileUtil.getConfigObject("RssFeeds/sample.instance", Feed.class);
    if (f == null) {
        throw new IllegalStateException("Bogus file in feeds folder: " +
                node.getLookup().lookup(FileObject.class));
    }
    return f;
}

So, the code needs to be fixed in the sample.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« July 2012 »
SunMonTueWedThuFriSat
14
28
29
30
31
    
       
Today