Source:
<code>public void shouldCloseSideEffectsUsingWithRemote() throws Exception { final Graph graph = EmptyGraph.instance(); final GraphTraversalSource g = graph.traversal().withRemote(conf); g.addV("person").property("age", 20).iterate(); g.addV("person").property("age", 10).iterate(); final GraphTraversal traversal = g.V().aggregate("a").aggregate("b"); traversal.iterate(); final DriverRemoteTraversalSideEffects se = (DriverRemoteTraversalSideEffects) traversal.asAdmin().getSideEffects(); final BulkSet sideEffects = se.get("a"); assertThat(sideEffects.isEmpty(), is(false)); se.close(); assertNull(se.get("b")); final Set<String> localSideEffectKeys = se.keys(); assertEquals(1, localSideEffectKeys.size()); final BulkSet localSideEffects = se.get("a"); assertThat(localSideEffects.isEmpty(), is(false)); final Cluster cluster = Cluster.build("localhost").create(); final Client client = cluster.connect(); <START> Field field = DriverRemoteTraversalSideEffects.class.getDeclaredField("serverSideEffect"); <END> field.setAccessible(true); UUID serverSideEffectId = (UUID) field.get(se); final Map<String, String> aliases = new HashMap<>(); aliases.put("g", "g"); final RequestMessage msg = RequestMessage.build(Tokens.OPS_GATHER) .addArg(Tokens.ARGS_SIDE_EFFECT, serverSideEffectId) .addArg(Tokens.ARGS_SIDE_EFFECT_KEY, "b") .addArg(Tokens.ARGS_ALIASES, aliases) .processor("traversal").create(); boolean error; try { client.submitAsync(msg).get().one(); error = false; } catch (Exception ex) { error = true; } assertThat(error, is(true)); }</code><technical_language>please final Field UUID variables. glad reflection trick worked for this test</technical_language>

Target:
public void shouldCloseSideEffectsUsingWithRemote() throws Exception { final Graph graph = EmptyGraph.instance(); final GraphTraversalSource g = graph.traversal().withRemote(conf); g.addV("person").property("age", 20).iterate(); g.addV("person").property("age", 10).iterate(); final GraphTraversal traversal = g.V().aggregate("a").aggregate("b"); traversal.iterate(); final DriverRemoteTraversalSideEffects se = (DriverRemoteTraversalSideEffects) traversal.asAdmin().getSideEffects(); final BulkSet sideEffects = se.get("a"); assertThat(sideEffects.isEmpty(), is(false)); se.close(); assertNull(se.get("b")); final Set<String> localSideEffectKeys = se.keys(); assertEquals(1, localSideEffectKeys.size()); final BulkSet localSideEffects = se.get("a"); assertThat(localSideEffects.isEmpty(), is(false)); final Cluster cluster = Cluster.build("localhost").create(); final Client client = cluster.connect(); final Field field = DriverRemoteTraversalSideEffects.class.getDeclaredField("serverSideEffect"); field.setAccessible(true); final UUID serverSideEffectId = (UUID) field.get(se); final Map<String, String> aliases = new HashMap<>(); aliases.put("g", "g"); final RequestMessage msg = RequestMessage.build(Tokens.OPS_GATHER) .addArg(Tokens.ARGS_SIDE_EFFECT, serverSideEffectId) .addArg(Tokens.ARGS_SIDE_EFFECT_KEY, "b") .addArg(Tokens.ARGS_ALIASES, aliases) .processor("traversal").create(); boolean error; try { client.submitAsync(msg).get().one(); error = false; } catch (Exception ex) { error = true; } assertThat(error, is(true)); }