mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
handle nulls correctly
This commit is contained in:
@@ -82,10 +82,11 @@ public class FeedEntryFilteringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JexlContext context = new MapContext();
|
JexlContext context = new MapContext();
|
||||||
context.set("title", Jsoup.parse(entry.getContent().getTitle()).text().toLowerCase());
|
context.set("title", entry.getContent().getTitle() == null ? "" : Jsoup.parse(entry.getContent().getTitle()).text().toLowerCase());
|
||||||
context.set("author", entry.getContent().getAuthor().toLowerCase());
|
context.set("author", entry.getContent().getAuthor() == null ? "" : entry.getContent().getAuthor().toLowerCase());
|
||||||
context.set("content", Jsoup.parse(entry.getContent().getContent()).text().toLowerCase());
|
context.set("content", entry.getContent().getContent() == null ? "" : Jsoup.parse(entry.getContent().getContent()).text()
|
||||||
context.set("url", entry.getUrl().toLowerCase());
|
.toLowerCase());
|
||||||
|
context.set("url", entry.getUrl() == null ? "" : entry.getUrl().toLowerCase());
|
||||||
|
|
||||||
Callable<Object> callable = script.callable(context);
|
Callable<Object> callable = script.callable(context);
|
||||||
Future<Object> future = executor.submit(callable);
|
Future<Object> future = executor.submit(callable);
|
||||||
|
|||||||
@@ -65,4 +65,10 @@ public class FeedEntryFilteringServiceTest {
|
|||||||
service.filterMatchesEntry("while(true) {}", entry);
|
service.filterMatchesEntry("while(true) {}", entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void handlesNullCorrectly() throws FeedEntryFilterException {
|
||||||
|
entry.setContent(new FeedEntryContent());
|
||||||
|
service.filterMatchesEntry("author eq 'athou'", entry);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user