Source:
<code>public void testPRGatherCancellationWhileGatheringResults() { final VM server1 = VM.getVM(0); final VM server2 = VM.getVM(1); final VM client = VM.getVM(2); final int numObjects = 200; try { final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(2); startCacheServer(server1, port[0], false, -1, true); startCacheServer(server2, port[1], true, -1, true); startClient(client, port[0]); populateData(server2); createCancelDuringGatherTestHook(server1, VM.getController()); client.invoke("executing query to be canceled by gather", () -> { QueryService qs; try { qs = getCache().getQueryService(); Query query = qs.newQuery("Select * From /" + "portfolios"); query.execute(); } catch (ServerOperationException soe) { if (soe.getRootCause() instanceof QueryException) { QueryException e = (QueryException) soe.getRootCause(); if (!isExceptionDueToLowMemory(e)) { throw new CacheException(soe) {}; } else { return 0; } } } catch (Exception e) { throw new CacheException(e) {}; } throw new CacheException("should have hit low memory") {}; }); verifyRejectedObjects(server1); vmRecoversFromCriticalHeap(server1); client.invoke("Executing query when system is 'Normal'", () -> { try { QueryService qs = getCache().getQueryService(); Query query = qs.newQuery("Select * From /" + "portfolios"); SelectResults results = (SelectResults) query.execute(); assertThat(results.size()).isEqualTo(numObjects); <START> } catch (QueryInvocationTargetException | FunctionDomainException | TypeMismatchException <END> | NameResolutionException e) { fail(""); } }); vmRecoversFromCriticalHeap(server1); } finally { stopServer(server1); stopServer(server2); } }</code><technical_language>Another useless catch-block deleted</technical_language>

Target:
public void testPRGatherCancellationWhileGatheringResults() { final VM server1 = VM.getVM(0); final VM server2 = VM.getVM(1); final VM client = VM.getVM(2); final int numObjects = 200; try { final int[] port = AvailablePortHelper.getRandomAvailableTCPPorts(2); startCacheServer(server1, port[0], false, -1, true); startCacheServer(server2, port[1], true, -1, true); startClient(client, port[0]); populateData(server2); createCancelDuringGatherTestHook(server1, VM.getController()); client.invoke("executing query to be canceled by gather", () -> { QueryService qs; try { qs = getCache().getQueryService(); Query query = qs.newQuery("Select * From /" + "portfolios"); query.execute(); } catch (ServerOperationException soe) { if (soe.getRootCause() instanceof QueryException) { QueryException e = (QueryException) soe.getRootCause(); if (!isExceptionDueToLowMemory(e)) { throw new CacheException(soe) {}; } else { return 0; } } } catch (Exception e) { throw new CacheException(e) {}; } throw new CacheException("should have hit low memory") {}; }); verifyRejectedObjects(server1); vmRecoversFromCriticalHeap(server1); client.invoke("Executing query when system is 'Normal'", () -> { QueryService qs = getCache().getQueryService(); Query query = qs.newQuery("Select * From /" + "portfolios"); SelectResults results = (SelectResults) query.execute(); assertThat(results.size()).isEqualTo(numObjects); }); vmRecoversFromCriticalHeap(server1); } finally { stopServer(server1); stopServer(server2); } }