Source:
<code>void doTestPutAndGetMixedServers(String oldVersion) throws Exception { VM currentServer1 = VM.getVM(VersionManager.CURRENT_VERSION, 0); VM oldServerAndLocator = VM.getVM(oldVersion, 1); VM currentServer2 = VM.getVM(VersionManager.CURRENT_VERSION, 2); VM oldServer2 = VM.getVM(oldVersion, 3); String regionName = "aRegion"; final String serverHostName = NetworkUtils.getServerHostName(); final int port = AvailablePortHelper.getRandomAvailableTCPPort(); oldServerAndLocator.invoke(() -> DistributedTestUtils.deleteLocatorStateFile(port)); try { final Properties props = getSystemProperties(); props.remove(DistributionConfig.LOCATORS_NAME); oldServerAndLocator.invoke(() -> { props.put(DistributionConfig.START_LOCATOR_NAME, "" + serverHostName + "[" + port + "]"); props.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false"); cache = createCache(props); Thread.sleep(5000); }); props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); for (VM vm : Arrays.asList(oldServer2, currentServer1, currentServer2)) { vm.invoke(() -> { cache = createCache(props); }); } for (VM vm : Arrays.asList(currentServer1, currentServer2)) { vm.invoke( () -> assertVersion(cache, VersionManager.getInstance().getCurrentVersionOrdinal())); } for (VM vm : Arrays.asList(currentServer1, currentServer2, oldServerAndLocator, oldServer2)) { vm.invoke(() -> createRegion(cache, regionName)); } putDataSerializableAndVerify(currentServer1, regionName, currentServer2, oldServerAndLocator, oldServer2); currentServer1.invoke(() -> { assertRegionExists(cache, regionName); PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionName); <START> Throwable thrown = catchThrowable(region::clear); <END> assertThat(thrown).isInstanceOf(PartitionedRegionVersionException.class); }); } finally { for (VM vm : Arrays.asList(currentServer1, currentServer2, oldServerAndLocator, oldServer2)) { vm.invoke( () -> closeCache(RollingUpgradePartitionRegionClearMixedServerPartitionedRegion.cache)); } } }</code><technical_language>nice exception servers outdated a verification</technical_language>

Target:
void doTestPutAndGetMixedServers(String oldVersion) throws Exception { VM currentServer1 = VM.getVM(VersionManager.CURRENT_VERSION, 0); VM oldServerAndLocator = VM.getVM(oldVersion, 1); VM currentServer2 = VM.getVM(VersionManager.CURRENT_VERSION, 2); VM oldServer2 = VM.getVM(oldVersion, 3); String regionName = "aRegion"; final String serverHostName = NetworkUtils.getServerHostName(); final int port = AvailablePortHelper.getRandomAvailableTCPPort(); oldServerAndLocator.invoke(() -> DistributedTestUtils.deleteLocatorStateFile(port)); try { final Properties props = getSystemProperties(); props.remove(DistributionConfig.LOCATORS_NAME); oldServerAndLocator.invoke(() -> { props.put(DistributionConfig.START_LOCATOR_NAME, "" + serverHostName + "[" + port + "]"); props.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false"); cache = createCache(props); Thread.sleep(5000); }); props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); for (VM vm : Arrays.asList(oldServer2, currentServer1, currentServer2)) { vm.invoke(() -> { cache = createCache(props); }); } for (VM vm : Arrays.asList(currentServer1, currentServer2)) { vm.invoke( () -> assertVersion(cache, VersionManager.getInstance().getCurrentVersionOrdinal())); } for (VM vm : Arrays.asList(currentServer1, currentServer2, oldServerAndLocator, oldServer2)) { vm.invoke(() -> createRegion(cache, regionName)); } putDataSerializableAndVerify(currentServer1, regionName, currentServer2, oldServerAndLocator, oldServer2); currentServer1.invoke(() -> { assertRegionExists(cache, regionName); PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionName); Throwable thrown = catchThrowable(region::clear); assertThat(thrown).isInstanceOf(ServerVersionMismatchException.class); }); } finally { for (VM vm : Arrays.asList(currentServer1, currentServer2, oldServerAndLocator, oldServer2)) { vm.invoke( () -> closeCache(RollingUpgradePartitionRegionClearMixedServerPartitionedRegion.cache)); } } }