Feed Reader Fix

Posted by Geertjan on Oracle Blogs See other posts from Oracle Blogs or by Geertjan
Published on Thu, 5 Jul 2012 18:08:48 +0000 Indexed on 2012/07/05 21:21 UTC
Read the original article Hit count: 206

Filed under:

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.

© Oracle Blogs or respective owner

Related posts about /NetBeans IDE