Feed Reader Fix
- by Geertjan
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.