Source:
public void store(Item item, String alias) { long storeStart = System.currentTimeMillis(); String uuid = UUID.randomUUID().toString(); if (item.getState() instanceof UnDefType) { logger.debug("Undefined item state received. Not storing item {}.", item.getName()); return; } if (!isReadyToStore()) { return; } if (buffer == null) { throw new IllegalStateException("Buffer not initialized with resetWithBufferSize. Bug?"); } Date time = new Date(storeStart); String realName = item.getName(); String name = (alias != null) ? alias : realName; State state = item.getState(); T persistenceItem = persistenceItemFromState(name, state, time); logger.trace("store() called with item {}, which was converted to [{}]", item, persistenceItem, uuid); if (writeImmediately) { logger.debug("Writing immediately item [{}]", realName, uuid); synchronized (this) { boolean buffered = addToBuffer(persistenceItem); assert buffered; flushBufferedData(); } } else { long bufferStart = System.currentTimeMillis(); boolean buffered = addToBuffer(persistenceItem); if (buffered) { logger.debug("Buffered item in ms. Total time for store(): [{}]", realName, System.currentTimeMillis() - bufferStart, System.currentTimeMillis() - storeStart, uuid); } else { logger.debug( "Buffer is full. Writing buffered data immediately and trying again. Consider increasing bufferSize"); flushBufferedData(); boolean buffered2 = addToBuffer(persistenceItem); if (buffered2) { logger.debug("Buffered item in ms (2nd try, flushed buffer in-between) [{}]", System.currentTimeMillis() - bufferStart, uuid); } else { logger.error("Buffering failed for the second time -- Too small bufferSize? Discarding data [{}]", uuid); } } } }

Target:
public void store(Item item, String alias) { long storeStart = System.currentTimeMillis(); String uuid = UUID.randomUUID().toString(); if (item.getState() instanceof UnDefType) { logger.debug("Undefined item state received. Not storing item {}.", item.getName()); return; } if (!isReadyToStore()) { return; } if (buffer == null) { throw new IllegalStateException("Buffer not initialized with resetWithBufferSize. Bug?"); } Date time = new Date(storeStart); String realName = item.getName(); String name = (alias != null) ? alias : realName; State state = item.getState(); T persistenceItem = persistenceItemFromState(name, state, time); logger.trace("store() called with item {}, which was converted to [{}]", item, persistenceItem, uuid); if (writeImmediately) { logger.debug("Writing immediately item [{}]", realName, uuid); synchronized (this) { boolean buffered = addToBuffer(persistenceItem); assert buffered; flushBufferedData(); } } else { long bufferStart = System.currentTimeMillis(); boolean buffered = addToBuffer(persistenceItem); if (buffered) { logger.debug("Buffered item in ms. Total time for store(): [{}]", realName, System.currentTimeMillis() - bufferStart, System.currentTimeMillis() - storeStart, uuid); } else { logger.debug( "Buffer is full. Writing buffered data immediately and trying again. Consider increasing bufferSize"); flushBufferedData(); boolean buffered2 = addToBuffer(persistenceItem); if (buffered2) { logger.debug("Buffered item in ms (2nd try, flushed buffer in-between) [{}]", System.currentTimeMillis() - bufferStart, uuid); } else { logger.warn("Buffering failed for the second time -- Too small bufferSize? Discarding data [{}]", uuid); } } } }