Buggy code:
public final class RICacheConfiguration implements CacheConfiguration { private final AtomicBoolean readThrough ; private final AtomicBoolean writeThrough ; private final AtomicBoolean storeByValue ; private final AtomicBoolean statisticsEnabled ; private volatile IsolationLevel isolationLevel ; private volatile Mode transactionMode ; private final Duration [ ] timeToLive ; private volatile RICache riCache ; private RICacheConfiguration ( boolean readThrough , boolean writeThrough , boolean storeByValue , boolean statisticsEnabled , IsolationLevel isolationLevel , Mode transactionMode , Duration [ ] timeToLive ) { } @ Override public boolean isReadThrough ( ) { } @ Override public boolean isWriteThrough ( ) { } @ Override public boolean isStoreByValue ( ) { } @ Override public boolean isStatisticsEnabled ( ) { } @ Override public void setStatisticsEnabled ( boolean enableStatistics ) { } @ Override public boolean isTransactionEnabled ( ) { } @ Override public IsolationLevel getTransactionIsolationLevel ( ) { } @ Override public Mode getTransactionMode ( ) { } void setRiCache ( RICache riCache ) { } @ Override public CacheLoader getCacheLoader ( ) { } @ Override public CacheWriter getCacheWriter ( ) { } @ Override public Duration getExpiry ( ExpiryType type ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } public static class Builder { private static final boolean DEFAULT_READ_THROUGH = false ; private static final boolean DEFAULT_WRITE_THROUGH = false ; private static final boolean DEFAULT_STORE_BY_VALUE = true ; private static final boolean DEFAULT_STATISTICS_ENABLED = false ; private static final Duration DEFAULT_TIME_TO_LIVE = Duration . ETERNAL ; private static final IsolationLevel DEFAULT_TRANSACTION_ISOLATION_LEVEL = null ; private static final Mode DEFAULT_TRANSACTION_MODE = null ; private boolean readThrough = RICacheConfiguration . Builder . DEFAULT_READ_THROUGH ; private boolean writeThrough = RICacheConfiguration . Builder . DEFAULT_WRITE_THROUGH ; private boolean storeByValue = RICacheConfiguration . Builder . DEFAULT_STORE_BY_VALUE ; private boolean statisticsEnabled = RICacheConfiguration . Builder . DEFAULT_STATISTICS_ENABLED ; private IsolationLevel isolationLevel = RICacheConfiguration . Builder . DEFAULT_TRANSACTION_ISOLATION_LEVEL ; private Mode transactionMode = RICacheConfiguration . Builder . DEFAULT_TRANSACTION_MODE ; private final Duration [ ] timeToLive ; public Builder ( ) { } public RICacheConfiguration . Builder setReadThrough ( boolean readThrough ) { } public RICacheConfiguration . Builder setWriteThrough ( boolean writeThrough ) { } public RICacheConfiguration . Builder setStoreByValue ( boolean storeByValue ) { } public RICacheConfiguration . Builder setStatisticsEnabled ( boolean statisticsEnabled ) { } public RICacheConfiguration . Builder setExpiry ( ExpiryType type , Duration duration ) { if ( type == null ) { throw new NullPointerException ( ) ; } if ( duration == null ) { throw new NullPointerException ( ) ; } <START_BUG> this . timeToLive [ type . ordinal ( ) ] = ( ( duration . getTimeToLive ( ) ) == 0 ) ? Duration . ETERNAL : duration ; <END_BUG> return this ; } public RICacheConfiguration . Builder setTransactionEnabled ( IsolationLevel isolationLevel , Mode mode ) { } public RICacheConfiguration build ( ) { } } }

Fix:
this . timeToLive [ type . ordinal ( ) ] = ( ( duration . getDurationAmount ( ) ) == 0 ) ? Duration . ETERNAL : duration ;