BuildService extends AbstractService { public void save(final BuildDetails buildDetails) { buildDetails.setSequence(sequence.incrementAndGet()); uuid2buildResult.put(buildDetails.getUuid(), buildDetails); logger.info("New build detected: {}", buildDetails); uuids.addFirst(buildDetails.getUuid()); while (100 < uuids.size()) { final String uuid = uuids.removeLast(); uuid2buildResult.remove(uuid); } for (final DangerousConsumer<BuildSummary> listener : listeners) { try { listener.accept(buildDetails.getSummary()); } catch (final Throwable ex) { logger.trace("Ignore exception: {}", ex.getClass()); } } }  void addListener(final DangerousConsumer<BuildSummary> listener); void save(final BuildDetails buildDetails); Optional<BuildDetails> get(final String uuid); List<BuildSummary> list(final String from, final int requestSize);  }
@Test public void testSave() { for (int i = 0 ; i<10000 ; ++i) { buildService.save(new BuildDetails()); } }