auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private ImmutableListMultimap<String, Availability> availabilities(List<Episode> episodes) throws GlycerinException { List<ListenableFuture<ImmutableList<Availability>>> futures = Lists.newArrayList(); AvailabilityQuery query = AvailabilityQuery.builder() .withDescendantsOf(toPids(episodes)) .withPageSize(pageSize) .withMediaSet("apple-iphone4-ipad-hls-3g", "apple-iphone4-hls", "pc", "iptv-all", "captions") .build(); futures.add(executor.submit(exhaustingAvailabilityCallable(query))); ListenableFuture<List<ImmutableList<Availability>>> all = Futures.allAsList(futures); <START> Iterable<Availability> list = null; <END> try { list = Iterables.concat(all.get()); } catch (InterruptedException | ExecutionException e) { if (e.getCause() instanceof GlycerinException) { throw (GlycerinException) e.getCause(); } throw Throwables.propagate(e); } return Multimaps.index(list, new Function<Availability, String>() { @Override public String apply(Availability input) { return NitroUtil.programmePid(input); } }); }</code><technical_language>Leaving this uninitialised is clearer nice compiler errors if messes this in future</technical_language>

Target:
private ImmutableListMultimap<String, Availability> availabilities(List<Episode> episodes) throws GlycerinException { List<ListenableFuture<ImmutableList<Availability>>> futures = Lists.newArrayList(); AvailabilityQuery query = AvailabilityQuery.builder() .withDescendantsOf(toPids(episodes)) .withPageSize(pageSize) .withMediaSet("apple-iphone4-ipad-hls-3g", "apple-iphone4-hls", "pc", "iptv-all", "captions") .build(); futures.add(executor.submit(exhaustingAvailabilityCallable(query))); ListenableFuture<List<ImmutableList<Availability>>> all = Futures.allAsList(futures); Iterable<Availability> list; try { list = Iterables.concat(all.get()); } catch (InterruptedException | ExecutionException e) { if (e.getCause() instanceof GlycerinException) { throw (GlycerinException) e.getCause(); } throw Throwables.propagate(e); } return Multimaps.index(list, new Function<Availability, String>() { @Override public String apply(Availability input) { return NitroUtil.programmePid(input); } }); }
Source:
<code>public void respondWith404__IfChargeIdDoNotBelongToAccount() { String chargeId = createNewInPastChargeWithStatus(CREATED); String expectedMessage = format("Charge with id [%s] not found.", chargeId); <START> connectorRestApi <END> .withAccountId("12345") .withChargeId(chargeId) .postChargeCancellation() .statusCode(NOT_FOUND.getStatusCode()) .and() .contentType(JSON) .body("message", is(expectedMessage)); }</code><technical_language>rebase anyway, rename this connectorRestApiClient</technical_language>

Target:
public void respondWith404__IfChargeIdDoNotBelongToAccount() { String chargeId = createNewInPastChargeWithStatus(CREATED); String expectedMessage = format("Charge with id [%s] not found.", chargeId); connectorRestApiClient .withAccountId("12345") .withChargeId(chargeId) .postChargeCancellation() .statusCode(NOT_FOUND.getStatusCode()) .and() .contentType(JSON) .body("message", is(expectedMessage)); }
Source:
<code>public VersionTypeValidation validateWorkflowSet(String initialPath, String contents, Map<String, Pair<String, GenericFileType>> indexedFiles) { Map<String, String> validationMessageObject = new HashMap<>(); Yaml yaml = new Yaml(); List<String> files; boolean isValid = true; try { Map<String, Object> map = yaml.load(contents); Map<String, Object> serviceObject = (Map<String, Object>)map.get("service"); if (serviceObject == null) { validationMessageObject.put(initialPath, "The key 'service' does not exist."); isValid = false; } else { files = (List<String>)serviceObject.get("files"); if (files == null) { validationMessageObject.put(initialPath, "The key 'files' does not exist."); isValid = false; } else { <START> ArrayList<String> missingFiles = new ArrayList<String>(); <END> for (String file : files) { String absolutePath = "/" + file; if (indexedFiles.get(absolutePath) == null) { missingFiles.add(String.format("'%s'", file)); } } if (!missingFiles.isEmpty()) { validationMessageObject.put(initialPath, String.format("The following file(s) are missing: %s.", String.join(", ", missingFiles))); isValid = false; } } } } catch (YAMLException | ClassCastException ex) { validationMessageObject.put(initialPath, ex.getMessage()); isValid = false; } VersionTypeValidation validation = new VersionTypeValidation(isValid, validationMessageObject); return validation; }</code><technical_language>If inclined, rewrite this for loop map filter. fine is. Feel free ignore this; personally liking FP style more</technical_language>

Target:
public VersionTypeValidation validateWorkflowSet(String initialPath, String contents, Map<String, Pair<String, GenericFileType>> indexedFiles) { Map<String, String> validationMessageObject = new HashMap<>(); Yaml yaml = new Yaml(); List<String> files; boolean isValid = true; try { Map<String, Object> map = yaml.load(contents); Map<String, Object> serviceObject = (Map<String, Object>)map.get("service"); if (serviceObject == null) { validationMessageObject.put(initialPath, "The key 'service' does not exist."); isValid = false; } else { files = (List<String>)serviceObject.get("files"); if (files == null) { validationMessageObject.put(initialPath, "The key 'files' does not exist."); isValid = false; } else { String missingFiles = files.stream().filter(file -> indexedFiles.get("/" + file) == null).map(file -> String.format("'%s'", file)) .collect(Collectors.joining(", ")); if (!missingFiles.isEmpty()) { validationMessageObject.put(initialPath, String.format("The following file(s) are missing: %s.", missingFiles)); isValid = false; } } } } catch (YAMLException | ClassCastException ex) { validationMessageObject.put(initialPath, ex.getMessage()); isValid = false; } VersionTypeValidation validation = new VersionTypeValidation(isValid, validationMessageObject); return validation; }
Source:
<code>protected boolean canDoAction() { if (!super.canDoAction()) { return false; } for (DiskImage dit : getVmTemplate().getDiskTemplateMap().values()) { DiskImage diskImage = diskInfoDestinationMap.get(dit.getId()); if (!ImagesHandler.checkImageConfiguration( destStorages.get(diskImage.getStorageIds().get(0)).getStorageStaticData(), <START> diskImage, <END> getReturnValue().getCanDoActionMessages())) { return false; } } return true; }</code><technical_language>please separate code refactoring code changes (use differenct patches)</technical_language>

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } for (DiskImage dit : getVmTemplate().getDiskTemplateMap().values()) { if (!ImagesHandler.checkImageConfiguration(destStorages.get(diskInfoDestinationMap.get(dit.getId()).getStorageIds().get(0)) .getStorageStaticData(), diskInfoDestinationMap.get(dit.getId()), getReturnValue().getCanDoActionMessages())) { return false; } } return true; }
Source:
<code>public void init() { setLabel("Download job execution"); setExtends(jobExecutionMetaData); setPackage(jobPackage); addAttribute(RESOURCES) <START> .setLabel(RESOURCES) <END> .setDescription("List of resources to be downloaded.") .setNillable(true); }</code><technical_language>suggestion addAttribute(RESOURCES).setDataType(TEXT)</technical_language>

Target:
public void init() { setLabel("Download job execution"); setExtends(jobExecutionMetaData); setPackage(jobPackage); addAttribute(RESOURCES) .setLabel(RESOURCES) .setDataType(TEXT) .setDescription("List of resources to be downloaded.") .setNillable(true); }
Source:
<code>private void processParseException(Exception e, SensorContext context, InputFile inputFile) { reportAnalysisError(e, context, inputFile); logError(String.format("Unable to analyse file %s", inputFile.uri()), e); if (reportingParsingErrors) { <START> reportParsingException(e, context, inputFile); <END> } }</code><technical_language>rename createParsingErrorIssue more explicit</technical_language>

Target:
private void processParseException(Exception e, SensorContext context, InputFile inputFile) { reportAnalysisError(e, context, inputFile); LOG.warn(String.format("Unable to analyse file %s;", inputFile.uri())); LOG.debug("Cause: {}", e.getMessage()); if (parsingErrorCheckEnabled) { createParsingErrorIssue(e, context, inputFile); } }
Source:
<code>private int getFreePort() throws IOException { try { <START> ServerSocket s = new ServerSocket(0); <END> int port = s.getLocalPort(); s.close(); return port; } catch (IOException e) { throw new IOException("Failed to find a free port", e); } }</code><technical_language>ServerSocket implements AutoClosable, try (ServerSocket s = ...) stylistically better</technical_language>

Target:
private int getFreePort() throws IOException { try(ServerSocket s = new ServerSocket(0)) { return s.getLocalPort(); } catch (IOException e) { throw new IOException("Failed to find a free port", e); } }
Source:
<code>private static void buildPlatformList() { <START> platformList = new ArrayList<>(); <END> platformList.add("win,8"); platformList.add("win,11"); platformList.add("mac,8"); platformList.add("mac,11"); platformList.add("linux,8"); platformList.add("linux,11"); }</code><technical_language>this map is null, need recreate call. calendarMap below</technical_language>

Target:
private static List<String> buildPlatformList() { List<String> platformList = new ArrayList<>(); try (Stream<String> stream = Files.lines(Paths.get(PLATFORM_LIST_CONFIG_FILE_PATH))) { platformList.addAll(stream.collect(toList())); } catch (IOException e) { e.printStackTrace(); } return platformList; }
Source:
<code>protected void renderStats(HunterMinionEntity.HunterMinionData data) { renderLevelRow(data.getLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL + 1); renderStatRow(0, inventoryLevel, new StringTextComponent("" + data.getInventorySize()), data.getInventoryLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_INVENTORY + 1); renderStatRow(1, healthLevel, new StringTextComponent("" + entity.getAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue()), data.getHealthLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_HEALTH + 1); renderStatRow(2, strengthLevel, new StringTextComponent("" + entity.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue()), data.getStrengthLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_STRENGTH + 1); <START> renderStatRow(3, resourceLevel, new StringTextComponent(""), data.getResourceEfficiencyLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_RESOURCES + 1); <END> }</code><technical_language>suggestion renderStatRow(3, resourceLevel, new StringTextComponent("" + (int)(Math.ceil((float)(data.getResourceEfficiencyLevel() + 1) / (HunterMinionEntity.HunterMinionData.MAX_LEVEL_RESOURCES + 1) * 100)) + "%")), data.getResourceEfficiencyLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_RESOURCES + 1);</technical_language>

Target:
protected void renderStats(HunterMinionEntity.HunterMinionData data) { renderLevelRow(data.getLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL + 1); renderStatRow(0, inventoryLevel, new StringTextComponent("" + data.getInventorySize()), data.getInventoryLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_INVENTORY + 1); renderStatRow(1, healthLevel, new StringTextComponent("" + entity.getAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue()), data.getHealthLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_HEALTH + 1); renderStatRow(2, strengthLevel, new StringTextComponent("" + entity.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue()), data.getStrengthLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_STRENGTH + 1); renderStatRow(3, resourceLevel, new StringTextComponent("" + (int) (Math.ceil((float) (data.getResourceEfficiencyLevel() + 1) / (HunterMinionEntity.HunterMinionData.MAX_LEVEL_RESOURCES + 1) * 100)) + "%"), data.getResourceEfficiencyLevel() + 1, HunterMinionEntity.HunterMinionData.MAX_LEVEL_RESOURCES + 1); }
Source:
<code><START> public void handleNewSession() throws Exception { <END> final String zkClientHexSession = _zkclient.getHexSessionId(); if (!zkClientHexSession.equals(_sessionId)) { throw new HelixException( "Failed to handle new session for participant. There is a session mismatch: " + "participant manager session = " + _sessionId + ", zk client session = " + zkClientHexSession); } joinCluster(); for (PreConnectCallback callback : _preConnectCallbacks) { callback.onPreConnect(); } createLiveInstance(); carryOverPreviousCurrentState(); setupMsgHandler(); }</code><technical_language>I confused, a new handleNewSession method takes a session Id parameter</technical_language>

Target:
public void handleNewSession() throws Exception { final String zkClientHexSession = ZKUtil.toHexSessionId(_zkclient.getSessionId()); if (!zkClientHexSession.equals(_sessionId)) { throw new HelixException( "Failed to handle new session for participant. There is a session mismatch: " + "participant manager session = " + _sessionId + ", zk client session = " + zkClientHexSession); } joinCluster(); for (PreConnectCallback callback : _preConnectCallbacks) { callback.onPreConnect(); } createLiveInstance(); carryOverPreviousCurrentState(); setupMsgHandler(); }
Source:
<code>public void tearDown() throws Exception { <START> RocksDBClientCache.getInstance().closeAll(); <END> FileUtils.deleteDirectory(new File(DEFAULT_DB_DIRECTORY)); }</code><technical_language>RocksDB reference</technical_language>

Target:
public void tearDown() throws Exception { FileUtils.deleteDirectory(new File(DEFAULT_DB_DIRECTORY)); }
Source:
<code><START> public void stop() throws Throwable <END> { if (currentJob != null) { currentJob.stop(); } }</code><technical_language>synchronize this</technical_language>

Target:
public synchronized void stop() throws Throwable { if (currentJob != null) { currentJob.stop(); } }
Source:
<code>public void listKeyVersions() { KeyClient keyClient = createClient(); for (KeyBase key : keyClient.listKeyVersions("keyName")) { Key keyWithMaterial = keyClient.getKey(key); System.out.printf("Received key's version with name %s, type %s and version %s", keyWithMaterial.name(), keyWithMaterial.keyMaterial().kty(), keyWithMaterial.version()); } END: com.azure.keyvault.keys.keyclient.listKeyVersions for (KeyBase key : keyClient.listKeyVersions("keyName", new Context(key2, value2))) { Key keyWithMaterial = keyClient.getKey(key); System.out.printf("Received key's version with name %s, type %s and version %s", keyWithMaterial.name(), keyWithMaterial.keyMaterial().kty(), keyWithMaterial.version()); } END: com.azure.keyvault.keys.keyclient.listKeyVersions#Context keyClient.listKeyVersions("keyName").iterableByPage().forEach(resp -> { System.out.printf("Got response headers . Url: %s, Status code: %d %n", resp.request().url(), resp.statusCode()); resp.items().forEach(value -> { <START> System.out.printf("Response value is %d %n", value); <END> }); }); END: com.azure.keyvault.keys.keyclient.listKeyVersions.iterableByPage }</code><technical_language>"Response value" "Key name %s, Key Version %s" here</technical_language>

Target:
public void listKeyVersions() { KeyClient keyClient = createClient(); for (KeyBase key : keyClient.listKeyVersions("keyName")) { Key keyWithMaterial = keyClient.getKey(key); System.out.printf("Received key's version with name %s, type %s and version %s", keyWithMaterial.name(), keyWithMaterial.keyMaterial().kty(), keyWithMaterial.version()); } END: com.azure.keyvault.keys.keyclient.listKeyVersions for (KeyBase key : keyClient.listKeyVersions("keyName", new Context(key2, value2))) { Key keyWithMaterial = keyClient.getKey(key); System.out.printf("Received key's version with name %s, type %s and version %s", keyWithMaterial.name(), keyWithMaterial.keyMaterial().kty(), keyWithMaterial.version()); } END: com.azure.keyvault.keys.keyclient.listKeyVersions#Context keyClient.listKeyVersions("keyName").iterableByPage().forEach(resp -> { System.out.printf("Got response headers . Url: %s, Status code: %d %n", resp.request().url(), resp.statusCode()); resp.items().forEach(value -> { System.out.printf("Key name: %s, Key version: %s %n", value.name(), value.version()); }); }); END: com.azure.keyvault.keys.keyclient.listKeyVersions.iterableByPage }
Source:
<code>public void testInit_displayUrl_absolute() throws Exception { config.overrideKey("filenet.displayUrlPattern", <START> "https://localhost:8080/getContent?os=ObjStore&vs={1}&guid={0}"); <END> adaptor.init(context); Id guid = new Id("{AAAAAAAA-0000-0000-0000-000000000001}"); Id vsId = new Id("{AAAAAAAA-0000-0000-0000-000000000002}"); String expected = "https://localhost:8080/getContent?os=ObjStore&vs=" + percentEscape(vsId) + "&guid=" + percentEscape(guid); assertEquals(expected, getConfigOptions().getDisplayUrl(guid, vsId).toString()); }</code><technical_language>s{getContent?os=ObjStore}{whatever?objStore=NotObjectStore}, signal WorkplaceXT URLs required</technical_language>

Target:
public void testInit_displayUrl_absolute() throws Exception { config.overrideKey("filenet.displayUrlPattern", "https://localhost:8080/whatever?os=NotObjectStore&vs={1}&guid={0}"); adaptor.init(context); Id guid = new Id("{AAAAAAAA-0000-0000-0000-000000000001}"); Id vsId = new Id("{AAAAAAAA-0000-0000-0000-000000000002}"); String expected = "https://localhost:8080/whatever?os=NotObjectStore&vs=" + percentEscape(vsId) + "&guid=" + percentEscape(guid); assertEquals(expected, getConfigOptions().getDisplayUrl(guid, vsId).toString()); }
Source:
<code><START> public <T> T[] toArray(T[] paramArrayOfT) { <END> if(paramArrayOfT.length < totalCount()) paramArrayOfT = (T[]) java.lang.reflect.Array.newInstance(paramArrayOfT.getClass().getComponentType(), totalCount()); int i = 0; for (List<TileEntity> values : content.values()) { for (int j = 0; j < values.size(); j++) { paramArrayOfT[i] = (T) values.get(j); i++; } } return paramArrayOfT; }</code><technical_language>Replace <T> TileEntity</technical_language>

Target:
public <T> T[] toArray(T[] paramArrayOfT) { if (paramArrayOfT.length < totalCount) paramArrayOfT = (T[]) Array.newInstance(paramArrayOfT.getClass().getComponentType(), totalCount); int i = 0; for (List<TileEntity> values : content.values()) { for (TileEntity te : values) paramArrayOfT[i++] = (T) te; } return paramArrayOfT; }
Source:
<code>protected Task<GameData> createTask() { return new Task<>() { @Override protected GameData call() throws GameParseException { return gameChooserEntry .getCompleteGameData() <START> .orElseThrow(() -> new GameParseException("Missing file!")); <END> } }; }</code><technical_language>changing FileNotFound a IllegalState? GameParseException AFAIK is more invalid syntax missing game file</technical_language>

Target:
protected Task<GameData> createTask() { return new Task<>() { @Override protected GameData call() throws GameParseException, FileNotFoundException { return gameChooserEntry .getCompleteGameData() .orElseThrow(() -> new FileNotFoundException("Missing file!")); } }; }
Source:
<code>public Node[] createContent() { final Button startButton = createButton("START!", 4, 22); final Button settingsButton = createButton("SETTINGS", 0, 24); final Button exitButton = createButton("EXIT", 0, 0); final Button loadButton = createButton("LOAD GAME", 2, 24); final Button shopButton = createButton("SHOP", 4, 24); final Label nameLabel = createLabel("NEW PLAYER:", 0, 22); exitButton.setMaxWidth(EXIT_BUTTON_WIDTH); setButtonFunction(exitButton, BType.EXIT); setButtonFunction(startButton, BType.START); setButtonFunction(settingsButton, BType.SETTINGS); setButtonFunction(loadButton, BType.LOAD); setButtonFunction(shopButton, BType.SHOP); startButton.setTooltip(new Tooltip("Start the game!")); exitButton.setTooltip(new Tooltip("Are you sure?")); settingsButton.setTooltip(new Tooltip("Change game settings")); loadButton.setTooltip(new Tooltip("Continue a game")); <START> INPUT.setTooltip(new Tooltip("Enter your name")); <END> INPUT.setFont(Style.getFont(FONT_SIZE)); return new Node[]{startButton, settingsButton, exitButton, loadButton, nameLabel, INPUT, shopButton}; }</code><technical_language>Indent 68-75 is wrong < review, layout</technical_language>

Target:
public Node[] createContent() { apMainMenu.play(true); final Button startButton = createButton("START!", 4, 22); final Button settingsButton = createButton("SETTINGS", 0, 24); final Button exitButton = createButton("EXIT", 0, 0); final Button loadButton = createButton("LOAD GAME", 2, 24); final Button shopButton = createButton("SHOP", 4, 24); final Label nameLabel = createLabel("NEW PLAYER:", 0, 22); exitButton.setMaxWidth(EXIT_BUTTON_WIDTH); setButtonFunction(exitButton, BType.EXIT); setButtonFunction(startButton, BType.START); setButtonFunction(settingsButton, BType.SETTINGS); setButtonFunction(loadButton, BType.LOAD); setButtonFunction(shopButton, BType.SHOP); startButton.setTooltip(new Tooltip("Start the game!")); exitButton.setTooltip(new Tooltip("Are you sure?")); settingsButton.setTooltip(new Tooltip("Change game settings")); loadButton.setTooltip(new Tooltip("Continue a game")); INPUT.setTooltip(new Tooltip("Enter your name")); INPUT.setFont(Style.getFont(FONT_SIZE)); return new Node[]{startButton, settingsButton, exitButton, loadButton, nameLabel, INPUT, shopButton}; }
Source:
<code>@Override protected void subscribeActual(CompletableObserver observer) { <START> super.subscribeActual(new DisposeAwareCompletableObserver(observer)); <END> }</code><technical_language>add this DisposeAwareCompletableObserver</technical_language>

Target:
@Override protected void subscribeActual(CompletableObserver observer) { source.subscribe(new DisposeAwareCompletableObserver(observer)); }
Source:
<code>private void fillEnv(EnvVars env) { final StringBuilder depKeys = new StringBuilder(); for (String dependency : deps) { String[] tokens = dependency.split("#"); String originalName = tokens[0]; String number = tokens[1]; String result = tokens[2]; String keyName = originalName.replaceAll("[^a-zA-Z0-9]+", "_"); String prefix = "DEP_" + keyName; env.put(prefix + "_BUILD_NAME", originalName); env.put(prefix + "_BUILD_NUMBER", number); env.put(prefix + "_BUILD_RESULT", result); depKeys.append(keyName); depKeys.append(" "); } <START> env.put("DEP_KEYS", depKeys.toString().trim()); <END> }</code><technical_language>is DEP_KEYS a good name</technical_language>

Target:
private void fillEnv(EnvVars env) { final StringBuilder depKeys = new StringBuilder(); for (String dependency : deps) { String[] tokens = dependency.split("#"); String originalName = tokens[0]; String number = tokens[1]; String result = tokens[2]; String keyName = originalName.replaceAll("[^a-zA-Z0-9]+", "_"); String prefix = "TRIGGER_" + keyName; env.put(prefix + "_BUILD_NAME", originalName); env.put(prefix + "_BUILD_NUMBER", number); env.put(prefix + "_BUILD_RESULT", result); depKeys.append(keyName); depKeys.append(" "); } env.put("TRIGGER_DEPENDENCY_KEYS", depKeys.toString().trim()); }
Source:
<code>private void MoveVdssToGoingToMaintenanceMode() { <START> Iterator<Guid> it = vdssToMaintenance.keySet().iterator(); <END> while (it.hasNext()) { VDSReturnValue result = setVdsStatusToPrepareForMaintenance(vdssToMaintenance.get(it.next())); if (!result.getSucceeded()) { it.remove(); } } cancelIncommingMigrations(); freeLock(); }</code><technical_language>please revert changes - issues. spms moved prepare maintenance last, in case move prepare maintenance hosts pool spm role of hsms start "flipping" hosts, causing unneeded operations, spm need change status last</technical_language>

Target:
private void MoveVdssToGoingToMaintenanceMode() { List<VDS> nonSpms = new LinkedList<>(); List<VDS> spms = new LinkedList<>(); for(VDS vds : vdssToMaintenance.values()) { if (vds.getSpmStatus() == VdsSpmStatus.SPM) { spms.add(0, vds); } else { nonSpms.add(0, vds); } } setVdssStatusToPrepareForMaintenance(nonSpms); setVdssStatusToPrepareForMaintenance(spms); cancelIncommingMigrations(); freeLock(); }
Source:
<code>private void setParentIdIfApplicable(Message<?> carrier, SpanBuilder spanBuilder) { try { String parentId = getHeader(carrier, Span.PARENT_ID_NAME); if (parentId != null) { spanBuilder.parent(Span.hexToId(parentId)); } } catch (Exception e) { <START> throw new IllegalStateException("Malformed id", e); <END> } }</code><technical_language>prefer IllegalArgumentException IllegalStateException is more temporal in nature (ex a state issue resolve itself) catch Exception is a bit wide, too.. Span.hexToId throw IllegalArgumentException, propagate IllegalArgumentExceptions instead of wrapping</technical_language>

Target:
private void setParentIdIfApplicable(Message<?> carrier, SpanBuilder spanBuilder) { String parentId = getHeader(carrier, Span.PARENT_ID_NAME); if (parentId != null) { spanBuilder.parent(Span.hexToId(parentId)); } }
Source:
<code>private void clearTomcatCache() { ClassLoader loader = getCurrentThreadContextClassLoader(); Class cl = loader.getClass(); Class superCl = cl.getSuperclass(); try { <START> if ( (TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) && <END> (superCl != null && TOMCAT_WEBAPP_CLASSLOADER_BASE.equals(superCl.getName())) ) { clearMap(superCl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD); LOG.debug("Cleared tomcat cache via classloader's parent class."); } else { LOG.debug("Class loader is not tomcat loader.", cl.getName()); } } catch (NoSuchFieldException nsfe) { LOG.debug("Parent class doesn't contain '{}' field, trying with base!", superCl.getName(), TOMCAT_RESOURCE_ENTRIES_FIELD, nsfe); try { clearMap(cl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD); LOG.debug("Cleared tomcat cache via classloader's class."); } catch (Exception e) { LOG.warn("Couldn't clear tomcat cache using {}", cl.getName(), e); } } catch (Exception e) { LOG.warn("Couldn't clear tomcat cache using {}", superCl.getName(), e); } }</code><technical_language>suggestion if ((TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) && consistent formatting</technical_language>

Target:
private void clearTomcatCache() { ClassLoader loader = getCurrentThreadContextClassLoader(); Class cl = loader.getClass(); Class superCl = cl.getSuperclass(); try { if ((TOMCAT_WEBAPP_CLASSLOADER.equals(cl.getName()) || TOMCAT_PARALLEL_WEBAPP_CLASSLOADER.equals(cl.getName())) && (superCl != null && TOMCAT_WEBAPP_CLASSLOADER_BASE.equals(superCl.getName()))) { clearMap(superCl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD); LOG.debug("Cleared tomcat cache via classloader's parent class."); } else { LOG.debug("Class loader is not tomcat loader.", cl.getName()); } } catch (NoSuchFieldException nsfe) { LOG.debug("Parent class doesn't contain '{}' field, trying with base!", superCl.getName(), TOMCAT_RESOURCE_ENTRIES_FIELD, nsfe); try { clearMap(cl, loader, TOMCAT_RESOURCE_ENTRIES_FIELD); LOG.debug("Cleared tomcat cache via classloader's class."); } catch (Exception e) { LOG.warn("Couldn't clear tomcat cache using {}", cl.getName(), e); } } catch (Exception e) { LOG.warn("Couldn't clear tomcat cache using {}", (superCl != null ? superCl.getName() : null), e); } }
Source:
<code>public void testInsufficientWorkerNodes() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of(), ImmutableMap.of("query.min-worker-nodes", "5"))) { queryRunner.execute("SELECT 1"); <START> fail("Expect to throw a PrestoException"); <END> } }</code><technical_language>more specific error message</technical_language>

Target:
public void testInsufficientWorkerNodes() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner( ImmutableMap.of(), ImmutableMap.of("query-manager.initialization-required-workers", "5"), 4)) { queryRunner.execute("SELECT 1"); fail("Expected exception due to insufficient active worker nodes"); } }
Source:
<code>public void invalidStorageDomain() { <START> when(storageDomainDao.getAllForStorageDomain(any(Guid.class))).thenReturn(Collections.EMPTY_LIST); <END> assertFalse(cmd.validate()); }</code><technical_language>This is redundant AFAIK - Mockito's default behavior. If isn't, Collections.emptyList(), raw EMPTY_LIST</technical_language>

Target:
public void invalidStorageDomain() { assertFalse(cmd.validate()); }
Source:
<code>public Properties getKafkaProducerProperties() { final Properties producerProps = (Properties) kafkaProperties.clone(); producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); producerProps.put(ProducerConfig.ACKS_CONFIG, "all"); producerProps.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, kafkaSettings.getRequestTimeoutMs()); producerProps.put(ProducerConfig.BATCH_SIZE_CONFIG, kafkaSettings.getBatchSize()); producerProps.put(ProducerConfig.LINGER_MS_CONFIG, kafkaSettings.getLingerMs()); producerProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "lz4"); producerProps.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, kafkaSettings.getMaxRequestSize()); producerProps.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, kafkaSettings.getDeliveryTimeoutMs()); producerProps.put(ProducerConfig.RETRIES_CONFIG, 3); <START> producerProps.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, 1); <END> producerProps.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, kafkaSettings.getMaxBlockMs()); return producerProps; }</code><technical_language>Why? I know, 1 producer. 1 request connection is a strange thing</technical_language>

Target:
public Properties getKafkaProducerProperties() { final Properties producerProps = (Properties) kafkaProperties.clone(); producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); producerProps.put(ProducerConfig.ACKS_CONFIG, "all"); producerProps.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, kafkaSettings.getRequestTimeoutMs()); producerProps.put(ProducerConfig.BATCH_SIZE_CONFIG, kafkaSettings.getBatchSize()); producerProps.put(ProducerConfig.LINGER_MS_CONFIG, kafkaSettings.getLingerMs()); producerProps.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "lz4"); producerProps.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, kafkaSettings.getMaxRequestSize()); producerProps.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, kafkaSettings.getDeliveryTimeoutMs()); producerProps.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, kafkaSettings.getMaxBlockMs()); return producerProps; }
Source:
<code>public Block appendNull() { int[] ids = new int[positionCount + 1]; Block dictionary = value; if (value.isNull(0)) { ids[positionCount] = 0; } else { dictionary = value.appendNull(); <START> ids[positionCount] = 1; <END> } return new DictionaryBlock(dictionary, ids); }</code><technical_language>perhaps, RLE block here; need wrap in Dictionary</technical_language>

Target:
public Block appendNull() { if (value.isNull(0)) { return new RunLengthEncodedBlock(value, positionCount + 1); } else { Block dictionary = value.appendNull(); int[] ids = new int[positionCount + 1]; ids[positionCount] = 1; return new DictionaryBlock(dictionary, ids); } }
Source:
<code>public void registerAttributes(ManagementResourceRegistration registry) { for (AttributeDefinition attr : getDefinitions(ATTRIBUTES)) { if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) { if (deployed) { registry.registerReadOnlyAttribute(attr, PooledConnectionFactoryConfigurationRuntimeHandler.INSTANCE); } else { registry.registerReadWriteAttribute(attr, null, <START> new ReloadRequiredWriteAttributeHandler(getDefinitions(PooledConnectionFactoryDefinition.ATTRIBUTES))); <END> } } } }</code><technical_language>getDefinitions is created loop creation, reuse that</technical_language>

Target:
public void registerAttributes(ManagementResourceRegistration registry) { AttributeDefinition[] definitions = getDefinitions(ATTRIBUTES); ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(definitions); for (AttributeDefinition attr : definitions) { if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) { if (deployed) { registry.registerReadOnlyAttribute(attr, PooledConnectionFactoryConfigurationRuntimeHandler.INSTANCE); } else { registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler); } } } }
Source:
<code>public Map<String, String> createVdsmNameMapping(Guid clusterId) { <START> Map<String, String> vdsmNameMap = new HashMap<>(); <END> for (Network network : networkDao.getAllForCluster(clusterId)) { vdsmNameMap.put(network.getVdsmName(), network.getName()); } return vdsmNameMap; }</code><technical_language>Please stream. networkDao.getAllForCluster(clusterId).stream() .collect(Collectors.toMap(VdsNetworkInterface::getVdsmName, VdsNetworkInterface::Name));</technical_language>

Target:
public Map<String, String> createVdsmNameMapping(Guid clusterId) { Map<String, String> vdsmNameMap = networkDao.getAllForCluster(clusterId).stream() .collect(Collectors.toMap(network -> network.getVdsmName(), network -> network.getName())); return vdsmNameMap; }
Source:
<code>private void updateVmAfterMigrationToDifferentCluster() { if (getParameters().getTargetClusterId() != null <START> || getVm().getClusterId().equals(getParameters().getTargetClusterId())) { <END> return; } ChangeVMClusterParameters params = new ChangeVMClusterParameters( getParameters().getTargetClusterId(), getVmId(), getVm().getCustomCompatibilityVersion()); setSucceeded(getBackend().runInternalAction(VdcActionType.ChangeVMCluster, params).getSucceeded()); }</code><technical_language>'== null'</technical_language>

Target:
private void updateVmAfterMigrationToDifferentCluster() { if (getParameters().getTargetClusterId() == null || getVm().getClusterId().equals(getParameters().getTargetClusterId())) { return; } ChangeVMClusterParameters params = new ChangeVMClusterParameters( getParameters().getTargetClusterId(), getVmId(), getVm().getCustomCompatibilityVersion()); setSucceeded(getBackend().runInternalAction(VdcActionType.ChangeVMCluster, params).getSucceeded()); }
Source:
<code><START> void switchToCompactModeInternal(boolean auto) { <END> setPresentation(Presentation.COMPACT_TREE, auto); listPresentationAction.setChecked(false); treePresentationAction.setChecked(false); if (auto) { setExpandCollapseActionsVisible(false); } else { setExpandCollapseActionsVisible(isExpandAllowed()); } }</code><technical_language>this method declared private</technical_language>

Target:
private void switchToCompactModeInternal(boolean auto) { setPresentation(Presentation.COMPACT_TREE, auto); listPresentationAction.setChecked(false); treePresentationAction.setChecked(false); if (auto) { setExpandCollapseActionsVisible(false); } else { setExpandCollapseActionsVisible(isExpandAllowed()); } }
Source:
<code>public Map<String, AttributeValue> createDynamoDBItemFromWifiInfo(final WifiInfo wifiInfo) { <START> final Map<String, AttributeValue> attributes = new HashMap<>(); <END> attributes.put(SENSE_ATTRIBUTE_NAME, new AttributeValue().withS(wifiInfo.senseId)); attributes.put(SSID_ATTRIBUTE_NAME, new AttributeValue().withS(wifiInfo.ssid)); attributes.put(RSSI_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(wifiInfo.rssi))); attributes.put(LAST_UPDATED_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(wifiInfo.lastUpdated))); return attributes; }</code><technical_language>Please, prefer Guava style Maps.newHashMap()</technical_language>

Target:
public static Map<String, AttributeValue> createDynamoDBItemFromWifiInfo(final WifiInfo wifiInfo) { final Map<String, AttributeValue> attributes = new HashMap<>(); attributes.put(SENSE_ATTRIBUTE_NAME, new AttributeValue().withS(wifiInfo.senseId)); attributes.put(SSID_ATTRIBUTE_NAME, new AttributeValue().withS(wifiInfo.ssid)); attributes.put(RSSI_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(wifiInfo.rssi))); attributes.put(LAST_UPDATED_ATTRIBUTE_NAME, new AttributeValue().withS(wifiInfo.lastUpdated.toString(DateTimeFormat.forPattern(DateTimeUtil.DYNAMO_DB_DATETIME_FORMAT)))); return attributes; }
Source:
<code>public static ImageTransfer map(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer entity, ImageTransfer template) { ImageTransfer model = template != null ? template : new ImageTransfer(); if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getVdsId() != null) { model.setHost(new Host()); model.getHost().setId(entity.getVdsId().toString()); } if (entity.getDiskId() != null) { model.setImage(new Image()); model.getImage().setId(entity.getDiskId().toString()); } if (entity.getProxyUri() != null && entity.getImagedTicketId() != null) { model.setProxyUrl(entity.getProxyUri() + "/" + entity.getImagedTicketId()); } if (entity.getDaemonUri() != null && entity.getImagedTicketId() != null) { <START> model.setTransferUrl(entity.getDaemonUri() + "/" + entity.getImagedTicketId()); <END> } if (entity.getSignedTicket() != null) { model.setSignedTicket(entity.getSignedTicket()); } if (entity.getPhase() != null) { model.setPhase(mapPhase(entity.getPhase())); } return model; }</code><technical_language>I logic build URIs, if is this simple, belong API. Please move backend</technical_language>

Target:
public static ImageTransfer map(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer entity, ImageTransfer template) { ImageTransfer model = template != null ? template : new ImageTransfer(); if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getVdsId() != null) { model.setHost(new Host()); model.getHost().setId(entity.getVdsId().toString()); } if (entity.getDiskId() != null) { model.setImage(new Image()); model.getImage().setId(entity.getDiskId().toString()); } if (entity.getProxyUri() != null && entity.getImagedTicketId() != null) { model.setProxyUrl(entity.getProxyURLForTransfer()); } if (entity.getDaemonUri() != null && entity.getImagedTicketId() != null) { model.setTransferUrl(entity.getDaemonURLForTransfer()); } if (entity.getSignedTicket() != null) { model.setSignedTicket(entity.getSignedTicket()); } if (entity.getPhase() != null) { model.setPhase(mapPhase(entity.getPhase())); } return model; }
Source:
<code>public PhysicalOperation visitRemoteSource(RemoteSourceNode node, LocalExecutionPlanContext context) { if (node.getOrderingScheme().isPresent()) { return createMergeSource(node, context); } <START> else { <END> return createRemoteSource(node, context); } }</code><technical_language>nit: prefer put else return in codebase</technical_language>

Target:
public PhysicalOperation visitRemoteSource(RemoteSourceNode node, LocalExecutionPlanContext context) { if (node.getOrderingScheme().isPresent()) { return createMergeSource(node, context); } return createRemoteSource(node, context); }
Source:
<code>private Resource addAirdResource() { <START> EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_RESOURCE_NAME); EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + AIRD_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + AIRD_RESOURCE_NAME); <END> TransactionalEditingDomain domain = session.getTransactionalEditingDomain(); URI airdResourceURI = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + AIRD_RESOURCE_NAME, true); Resource airdResource = domain.getResourceSet().getResource(airdResourceURI, true); final DAnalysis dAnalysis = (DAnalysis) airdResource.getContents().get(0); Command addDAnalysisCmd = new RecordingCommand(domain) { @Override protected void doExecute() { ((DAnalysisSession) session).addReferencedAnalysis(dAnalysis); } }; domain.getCommandStack().execute(addDAnalysisCmd); return airdResource; }</code><technical_language>call copyFileToTestProject</technical_language>

Target:
private Resource addAirdResource() { copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, PATH, SEMANTIC_RESOURCE_NAME, AIRD_RESOURCE_NAME); TransactionalEditingDomain domain = session.getTransactionalEditingDomain(); URI airdResourceURI = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + AIRD_RESOURCE_NAME, true); Resource airdResource = domain.getResourceSet().getResource(airdResourceURI, true); final DAnalysis dAnalysis = (DAnalysis) airdResource.getContents().get(0); Command addDAnalysisCmd = new RecordingCommand(domain) { @Override protected void doExecute() { ((DAnalysisSession) session).addReferencedAnalysis(dAnalysis); } }; domain.getCommandStack().execute(addDAnalysisCmd); return airdResource; }
Source:
<code>public int[] borrowIntArray(int positionCount) { int[] array; <START> while (intArraysTop >= 0 && intArrays[intArraysTop].length < positionCount) { <END> estimatedSizeInBytes -= sizeOfIntArray(intArrays[intArraysTop].length); --intArraysTop; } if (intArraysTop < 0) { array = new int[positionCount]; estimatedSizeInBytes += sizeOfIntArray(positionCount); } else { array = intArrays[intArraysTop]; --intArraysTop; } ++borrowedIntArrays; return array; }</code><technical_language>this loop release memory of "discarded" arrays? E.g. intArrays[intArraysTop] = null</technical_language>

Target:
public int[] borrowIntArray(int positionCount) { int[] array; while (intArraysTop >= 0 && intArrays[intArraysTop].length < positionCount) { estimatedSizeInBytes -= sizeOfIntArray(intArrays[intArraysTop].length); intArrays[intArraysTop] = null; --intArraysTop; } if (intArraysTop < 0) { array = new int[positionCount]; estimatedSizeInBytes += sizeOfIntArray(positionCount); } else { array = intArrays[intArraysTop]; --intArraysTop; } ++borrowedIntArrays; return array; }
Source:
<code>public void runMultipleActions(final VdcActionType actionType, final List<VdcActionParametersBase> parameters, final IFrontendActionAsyncCallback successCallback) { <START> runMultipleActions(actionType, parameters, successCallback, null, false); <END> }</code><technical_language>Changing this true useful solve unreported bug I described</technical_language>

Target:
public void runMultipleActions(final VdcActionType actionType, final List<VdcActionParametersBase> parameters, final IFrontendActionAsyncCallback successCallback) { runMultipleActions(actionType, parameters, successCallback, null, true); }
Source:
<code>public void checkDialogTest() { onLegoSensorPortConfigDialog().performClickOnPort(1, R.string.nxt_no_sensor); onLegoSensorPortConfigDialog().performClickOnOK(); <START> Espresso.onView(withText(R.string.formula_editor_sensor_lego_nxt_1)); <END> openDialog(); onLegoSensorPortConfigDialog().checkPortDisplayed(1, R.string.nxt_sensor_touch); }</code><technical_language>this doesnt do</technical_language>

Target:
public void checkDialogTest() { onBrickAtPosition(1).onChildView(withId(R.id.brick_change_size_by_edit_text)).perform(click()); openLegoSensorPortConfigDialog(); onLegoSensorPortConfigDialog(NXT_SENSOR_TOUCH) .performClickOnPort(PORT_1, NXT_NO_SENSOR) .performClickOnOK(); String result = UiTestUtils.getResourcesString(R.string.formula_editor_sensor_lego_nxt_1); onFormulaEditor().checkValue(result); openLegoSensorPortConfigDialog(); onLegoSensorPortConfigDialog(NXT_SENSOR_TOUCH).checkPortDisplayed(PORT_1, NXT_SENSOR_TOUCH); }
Source:
<code>public GoApiResponse submit(final GoApiRequest request) { if (processorMap.containsKey(request.api())) { <START> return processorMap.get(request.api()).process(request); <END> } return unhandledApiRequest(); }</code><technical_language>I this process method call is right place wrap exception handler, return a DefaultGoApiResponse.error() object. In case wrong in processing a request, throws up, right do. Right</technical_language>

Target:
public GoApiResponse submit(final GoApiRequest request) { if (processorMap.containsKey(request.api())) { try { return processorMap.get(request.api()).process(request); } catch (Exception e) { LOGGER.warn(String.format("Error while processing request api %s", request.api()), e); throw new RuntimeException(String.format("Error while processing request api %s", request.api()), e); } } return unhandledApiRequest(); }
Source:
<code>public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { DateTime date = (DateTime) getArguments().getSerializable(CURRENT_TIME); <START> setRetainInstance(true); <END> TimePickerDialog dialog = new TimePickerDialog(requireContext(), getArguments().getInt(TIME_PICKER_THEME), listener, date.getHourOfDay(), date.getMinuteOfHour(), DateFormat.is24HourFormat(requireContext())); dialog.setTitle(requireContext().getString(R.string.select_time)); fixSpinner(requireContext(), date.getHourOfDay(), date.getMinuteOfHour(), DateFormat.is24HourFormat(requireContext())); Window window = dialog.getWindow(); if (window != null) { window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); } setCancelable(false); return dialog; }</code><technical_language>Please create a view model for this dialog instead of a trick prevent data clearing. BTW good a vie model for CustomDatePickerDialog too</technical_language>

Target:
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { TimePickerDialog dialog = new TimePickerDialog(requireContext(), viewModel.getDialogTheme(), viewModel.getTimeSetListener(), viewModel.getLocalDateTime().getHourOfDay(), viewModel.getLocalDateTime().getMinuteOfHour(), DateFormat.is24HourFormat(requireContext())); dialog.setTitle(requireContext().getString(R.string.select_time)); fixSpinner(requireContext(), dialog, viewModel.getLocalDateTime().getHourOfDay(), viewModel.getLocalDateTime().getMinuteOfHour(), DateFormat.is24HourFormat(requireContext())); Window window = dialog.getWindow(); if (window != null) { window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); } return dialog; }
Source:
<code>public void testStartup() throws Exception { container.start(); try { client = TestSuiteEnvironment.getModelControllerClient(); try { final File deploymentOne = new File(deployDir, "deployment-one.jar"); createDeployment(deploymentOne, "org.jboss.modules"); addDeploymentScanner(); try { <START> Thread.sleep(500); <END> Assert.assertFalse(exists(DEPLOYMENT_ONE)); runScan(); long timeout = System.currentTimeMillis() + TimeoutUtil.adjust(30000); while (!exists(DEPLOYMENT_ONE) && System.currentTimeMillis() < timeout) { Thread.sleep(100); } Assert.assertTrue(exists(DEPLOYMENT_ONE)); Assert.assertEquals("OK", deploymentState(DEPLOYMENT_ONE)); final File oneDeployed = new File(deployDir, "deployment-one.jar.deployed"); Assert.assertTrue(oneDeployed.exists()); deploymentOne.delete(); Thread.sleep(500); Assert.assertTrue(exists(DEPLOYMENT_ONE)); Assert.assertEquals("OK", deploymentState(DEPLOYMENT_ONE)); runScan(); timeout = System.currentTimeMillis() + TimeoutUtil.adjust(30000); while (exists(DEPLOYMENT_ONE) && System.currentTimeMillis() < timeout) { Thread.sleep(100); } Assert.assertFalse(exists(DEPLOYMENT_ONE)); } finally { removeDeploymentScanner(); } } finally { StreamUtils.safeClose(client); } } finally { container.stop(); } }</code><technical_language>sleeping here</technical_language>

Target:
public void testStartup() throws Exception { container.start(); try { try (ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient()) { final File deploymentOne = new File(deployDir, "deployment-one.jar"); createDeployment(deploymentOne, "org.jboss.modules"); addDeploymentScanner(client); try { Assert.assertFalse(exists(client, DEPLOYMENT_ONE)); runScan(client); long timeout = System.currentTimeMillis() + TimeoutUtil.adjust(TIMEOUT); while (!exists(client, DEPLOYMENT_ONE) && System.currentTimeMillis() < timeout) { Thread.sleep(DELAY); } Assert.assertTrue(exists(client, DEPLOYMENT_ONE)); Assert.assertEquals("OK", deploymentState(client, DEPLOYMENT_ONE)); final File oneDeployed = new File(deployDir, "deployment-one.jar.deployed"); Assert.assertTrue(oneDeployed.exists()); deploymentOne.delete(); Thread.sleep(500); Assert.assertTrue(exists(client, DEPLOYMENT_ONE)); Assert.assertEquals("OK", deploymentState(client, DEPLOYMENT_ONE)); runScan(client); timeout = System.currentTimeMillis() + TimeoutUtil.adjust(TIMEOUT); while (exists(client, DEPLOYMENT_ONE) && System.currentTimeMillis() < timeout) { Thread.sleep(DELAY); } Assert.assertFalse(exists(client,DEPLOYMENT_ONE)); } finally { removeDeploymentScanner(client); } } } finally { container.stop(); } }