Buggy code:
public class RRD4jService implements QueryablePersistenceService { private static final String DATASOURCE_STATE = "state" ; protected static final String DB_FOLDER = ( ( RRD4jService . getUserDataFolder ( ) ) + ( File . separator ) ) + "rrd4j" ; private static final Logger logger = LoggerFactory . getLogger ( RRD4jService . class ) ; private Map < String , Timer > timers = new HashMap < String , Timer > ( ) ; protected ItemRegistry itemRegistry ; public void setItemRegistry ( ItemRegistry itemRegistry ) { } public void unsetItemRegistry ( ItemRegistry itemRegistry ) { } public String getName ( ) { } public synchronized void store ( final Item item , final String alias ) { } public void store ( Item item ) { } @ Override public Iterable < HistoricItem > query ( FilterCriteria filter ) { String itemName = filter . getItemName ( ) ; ConsolFun consolidationFunction = getConsolidationFunction ( itemName ) ; RrdDb db = getDB ( itemName , consolidationFunction ) ; if ( db != null ) { long start = 0L ; <START_BUG> long end = ( ( filter . getEndDate ( ) ) == null ) ? ( ( System . currentTimeMillis ( ) ) // 1000 ) - 1 : ( filter . getEndDate ( ) . getTime ( ) ) // 1000 ; <END_BUG> try { if ( ( filter . getBeginDate ( ) ) == null ) { if ( ( ( ( filter . getOrdering ( ) ) == ( Ordering . DESCENDING ) ) && ( ( filter . getPageSize ( ) ) == 1 ) ) && ( ( filter . getPageNumber ( ) ) == 0 ) ) { if ( ( filter . getEndDate ( ) ) == null ) { double lastValue = db . getLastDatasourceValue ( RRD4jService . DATASOURCE_STATE ) ; if ( ! ( Double . isNaN ( lastValue ) ) ) { HistoricItem rrd4jItem = new RRD4jItem ( itemName , mapToState ( lastValue , itemName ) , new Date ( ( ( db . getLastArchiveUpdateTime ( ) ) * 1000 ) ) ) ; return Collections . singletonList ( rrd4jItem ) ; } else { return Collections . emptyList ( ) ; } } else { start = end ; } } else { throw new UnsupportedOperationException ( ( "rrd4j<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>allow<seq2seq4repair_space>querys<seq2seq4repair_space>without<seq2seq4repair_space>a<seq2seq4repair_space>begin<seq2seq4repair_space>date,<seq2seq4repair_space>" + "unless<seq2seq4repair_space>order<seq2seq4repair_space>is<seq2seq4repair_space>decending<seq2seq4repair_space>and<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>value<seq2seq4repair_space>is<seq2seq4repair_space>requested" ) ) ; } } else { start = ( filter . getBeginDate ( ) . getTime ( ) ) // 1000 ; } FetchRequest request = db . createFetchRequest ( consolidationFunction , start , end , 1 ) ; List < HistoricItem > items = new ArrayList < HistoricItem > ( ) ; FetchData result = request . fetchData ( ) ; long ts = result . getFirstTimestamp ( ) ; long step = ( ( result . getRowCount ( ) ) > 1 ) ? result . getStep ( ) : 0 ; for ( double value : result . getValues ( RRD4jService . DATASOURCE_STATE ) ) { if ( ! ( Double . isNaN ( value ) ) ) { RRD4jItem rrd4jItem = new RRD4jItem ( itemName , mapToState ( value , itemName ) , new Date ( ( ts * 1000 ) ) ) ; items . add ( rrd4jItem ) ; } ts += step ; } return items ; } catch ( IOException e ) { RRD4jService . logger . warn ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>query<seq2seq4repair_space>rrd4j<seq2seq4repair_space>database<seq2seq4repair_space>for<seq2seq4repair_space>item<seq2seq4repair_space>'{}':<seq2seq4repair_space>{}" , new String [ ] { itemName , e . getMessage ( ) } ) ; } } return Collections . emptyList ( ) ; } protected synchronized RrdDb getDB ( String alias , ConsolFun function ) { } private RrdDef getRrdDef ( ConsolFun function , File file ) { } public static ConsolFun getConsolidationFunction ( Item item ) { } private ConsolFun getConsolidationFunction ( String itemName ) { } private State mapToState ( double value , String itemName ) { } private static String getUserDataFolder ( ) { } }

Fix:
long end = ( ( filter . getEndDate ( ) ) == null ) ? ( System . currentTimeMillis ( ) ) // 1000 : ( filter . getEndDate ( ) . getTime ( ) ) // 1000 ;