Source:
public CacheScheduler.VersionedCache populateCache( final JDBCExtractionNamespace namespace, final CacheScheduler.EntryImpl<JDBCExtractionNamespace> entryId, final String lastVersion, final CacheScheduler scheduler ) { final long lastCheck = lastVersion == null ? JodaUtils.MIN_INSTANT : Long.parseLong(lastVersion); final Long lastDBUpdate = lastUpdates(entryId, namespace); if (lastDBUpdate != null && lastDBUpdate <= lastCheck) { return null; } final long dbQueryStart = System.currentTimeMillis(); final DBI dbi = ensureDBI(entryId, namespace); final String table = namespace.getTable(); final String valueColumn = namespace.getValueColumn(); final String keyColumn = namespace.getKeyColumn(); LOG.debug("Updating %s", entryId); final List<Pair<String, String>> pairs = dbi.withHandle( new HandleCallback<List<Pair<String, String>>>() { @Override public List<Pair<String, String>> withHandle(Handle handle) throws Exception { final String query; query = String.format( "SELECT %s, %s FROM %s", keyColumn, valueColumn, table ); return handle .createQuery( query ).map( new ResultSetMapper<Pair<String, String>>() { @Override public Pair<String, String> map( final int index, final ResultSet r, final StatementContext ctx ) throws SQLException { return new Pair<>(r.getString(keyColumn), r.getString(valueColumn)); } } ).list(); } } ); final String newVersion; if (lastDBUpdate != null) { newVersion = lastDBUpdate.toString(); } else { newVersion = String.format("%d", dbQueryStart); } final CacheScheduler.VersionedCache versionedCache = scheduler.createVersionedCache(newVersion); final Map<String, String> cache = versionedCache.getCache(); for (Pair<String, String> pair : pairs) { cache.put(pair.lhs, pair.rhs); } LOG.info("Finished loading %d values for %s", cache.size(), entryId); return versionedCache; }

Target:
public CacheScheduler.VersionedCache populateCache( final JDBCExtractionNamespace namespace, final CacheScheduler.EntryImpl<JDBCExtractionNamespace> entryId, final String lastVersion, final CacheScheduler scheduler ) { final long lastCheck = lastVersion == null ? JodaUtils.MIN_INSTANT : Long.parseLong(lastVersion); final Long lastDBUpdate = lastUpdates(entryId, namespace); if (lastDBUpdate != null && lastDBUpdate <= lastCheck) { return null; } final long dbQueryStart = System.currentTimeMillis(); final DBI dbi = ensureDBI(entryId, namespace); final String table = namespace.getTable(); final String valueColumn = namespace.getValueColumn(); final String keyColumn = namespace.getKeyColumn(); LOG.debug("Updating %s", entryId); final List<Pair<String, String>> pairs = dbi.withHandle( new HandleCallback<List<Pair<String, String>>>() { @Override public List<Pair<String, String>> withHandle(Handle handle) throws Exception { final String query; query = String.format( "SELECT %s, %s FROM %s", keyColumn, valueColumn, table ); return handle .createQuery( query ).map( new ResultSetMapper<Pair<String, String>>() { @Override public Pair<String, String> map( final int index, final ResultSet r, final StatementContext ctx ) throws SQLException { return new Pair<>(r.getString(keyColumn), r.getString(valueColumn)); } } ).list(); } } ); final String newVersion; if (lastDBUpdate != null) { newVersion = lastDBUpdate.toString(); } else { newVersion = String.format("%d", dbQueryStart); } final CacheScheduler.VersionedCache versionedCache = scheduler.createVersionedCache(entryId, newVersion); try { final Map<String, String> cache = versionedCache.getCache(); for (Pair<String, String> pair : pairs) { cache.put(pair.lhs, pair.rhs); } LOG.info("Finished loading %d values for %s", cache.size(), entryId); return versionedCache; } catch (Throwable t) { try { versionedCache.close(); } catch (Exception e) { t.addSuppressed(e); } throw t; } }