title: Modify HashMap when CompletableFuture is finished
body: <p>I have a multi-module system, where one module handles my database storage. This is the method which saves a document:</p>
  <pre><code>    public CompletableFuture&lt;?&gt; runTransaction() {
          return CompletableFuture.runAsync(() -&gt; {
              TransactionBody txnBody = (TransactionBody&lt;String&gt;) () -&gt; {
                  MongoCollection&lt;Document&gt; collection = transaction.getDatabase().getCollection(transaction.getCollection().toString());
                  collection.insertOne(session, Document.parse(json));
                  return &quot;Completed&quot;;
              };
              try {
                  session.withTransaction(txnBody);
              } catch (MongoException ex) {
                  throw new UncheckedMongoException(ex);
              }
          });
      }
  </code></pre>
  <p>the json instance is passed down in the object constructor. However, since this will be used by several modules, with each individual caching system, I'm trying to figure out how the caller can modify data structure, if this method completed without any errors.</p>
  <p>For example</p>
  <pre><code>public void createClan(Transaction transaction, int id, int maxPlayers) {
                  MongoTransaction mongoTransaction = (MongoTransaction) transaction;
                  Clan clan = new Clan(id, maxPlayers);
                  String json = gson.toJson(clan);
  
                  TransactionExecutor executor = new MongoTransactionExecutor(mongoTransaction, json);
                  executor.runTransaction(); //Returns the completableFuture instance generated by the method. Modify hashmap here.
          }
  </code></pre>
  <p>I've tried reading the docs, however it was a bit confusing, any help is appreciated!</p>