$ show w3stling/rssreader
The w3stling/rssreader repository is a mature Java library for reading and parsing RSS 2.0, Atom, and RDF feeds, as well as many common extensions (iTunes Podcast, Media RSS, Dublin Core, GeoRSS, OpenSearch, Podcast Index 2.0, YouTube, Spotify, and others). It is published on Maven Central as com.apptasticsoftware:rssreader with zero runtime dependencies. The library uses StAX for streaming XML parsing and provides a modular extension registration system via FeedExtensionRegistry. It supports reading from URLs, InputStreams, or lists of URLs, with configurable timeouts and HTTP headers, and returns lazy Java Streams of Channel/Item objects. The codebase demonstrates high craftsmanship with robust XML sanitisation (InvalidXmlCharacterFilter), flexible date/time parsing (DateTime), and careful resource management (AutoCloseStream). Notable components include the abstract base reader AbstractRssReader, the Mapper utility for null-safe type conversions, and a well-structured extension pattern that can be extracted for similar parsing tasks. However, the library suffers from some code duplication across many extension modules and very verbose test fixtures. Overall it is a reliable and feature-rich library suitable for production use in feed aggregation and podcast applications.
The LLM identified 5 files worth highlighting for reuse:
Abstract base class for all feed readers. Implements the template method pattern: subclasses only need to create Channel and Item instances and register tag handlers. Contains the core StAX-based streaming parsing loop (RssItemIterator), HTTP client setup with configurable timeouts/gzip/headers, XXE prevention via XMLInputFactorySecurity, and extension maps for channel-level and item-level tag/attribute callbacks. Highly reusable as a pattern for building custom XML feed parsers.
A wrapper for Java Streams that ensures the underlying closeable resource (e.g., HTTP connection) is closed after a terminal operation completes. Provides a generic Stream<T> wrapper with onClose handlers that run exactly once. This pattern is reusable for any library that returns streams backed by resources. The same pattern is reused for Int, Long, and Double primitive streams.
Functional interface for parsing date/time strings into ZonedDateTime. The default implementation (DateTime class) handles dozens of real-world RSS/Atom date formats including RFC 1123, RFC 822, ISO 8601, US timezone abbreviations, and edge cases like missing timezone or incorrect day-of-week. This interface allows consumers to inject custom parsers. The DateTime implementation is an example of robust, lenient parsing that can be extracted for other projects dealing with heterogeneous date strings.
An InputStream filter that removes invalid XML characters (control characters except tab/CR/LF) and replaces problematic Unicode characters (e.g., curly quotes, em dashes) with their XML entity equivalents in attribute contexts. Also handles edge cases like CDATA sections and invalid escape strings. This is a reusable component for any system that must parse potentially malformed XML from untrusted sources. The filtering logic is stateful and handles escaping inside quoted attributes.
A collection of static helper methods for common conversion patterns: mapBoolean, mapInteger, mapLong, mapDouble, mapIfEmpty, createIfNull, emptyListIfNull, emptyMapIfNull, and isNullOrEmpty. These are used throughout extension registrations to avoid null check boilerplate and to provide null-safe default values. This utility is generic and can be extracted into any Java project dealing with nullable data fields.