auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void addComponentChangeListener(ComponentChangeListener l) { checkState(); if( ! listenerList.contains(l)) { listenerList.add(l); } log.trace("Added ComponentChangeListener " + l + ", current number of listeners is " + listenerList.size()); }

Target:
public void addComponentChangeListener(ComponentChangeListener l) { checkState(); listenerList.add(l); log.trace("Added ComponentChangeListener " + l + ", current number of listeners is " + listenerList.size()); }
Source:
public Map<Integer, UploadPartDetail> getUploadStatePartDetails(String objectId, String uploadId) { val uploadStateKey = getUploadStateKey(objectId, uploadId, PART); val details = Maps.<Integer, UploadPartDetail> newHashMap(); eachObjectSummary(objectId, uploadStateKey, (objectSummary) -> { CompletedPart part = readCompletedPart(objectId, uploadId, objectSummary); UploadPartDetail detail = new UploadPartDetail(); PartETag etag = new PartETag(part.getPartNumber(), part.getEtag()); detail.setEtag(etag); detail.setPartNumber(part.getPartNumber()); detail.setMd5(part.getMd5()); details.put(part.getPartNumber(), detail); }); return details; }

Target:
public Map<Integer, UploadPartDetail> getUploadStatePartDetails(String objectId, String uploadId) { val uploadStateKey = getUploadStateKey(objectId, uploadId, PART); val details = Maps.<Integer, UploadPartDetail> newHashMap(); eachObjectSummary(objectId, uploadStateKey, (objectSummary) -> { CompletedPart part = readCompletedPart(objectId, uploadId, objectSummary); PartETag etag = new PartETag(part.getPartNumber(), part.getEtag()); UploadPartDetailBuilder detailBuilder = UploadPartDetail.builder().etag(etag).partNumber(part.getPartNumber()).md5(part.getMd5()); details.put(part.getPartNumber(), detailBuilder.build()); }); return details; }
Source:
private Optional<Set<String>> getFilteredStringObjectMap( final IndexEdge indexEdge ) { Id mapOwner = new SimpleId( indexEdge.getNodeId().getUuid(), TYPE_APPLICATION ); final MapScope ms = CpNamingUtils.getEntityTypeMapScope( mapOwner ); MapManager mm = mapManagerFactory.createMapManager( ms ); Set<String> defaultProperties; ArrayList fieldsToKeep; String collectionName = CpNamingUtils.getCollectionNameFromEdgeName( indexEdge.getEdgeName() ); String jsonSchemaMap = mm.getString( collectionName ); if ( jsonSchemaMap != null ) { Map jsonMapData = ( Map ) JsonUtils.parse( jsonSchemaMap ); Schema schema = Schema.getDefaultSchema(); defaultProperties = schema.getRequiredProperties( collectionName ); fieldsToKeep = ( ArrayList ) jsonMapData.get( "fields" ); defaultProperties.addAll( fieldsToKeep ); } else { return Optional.empty(); } return Optional.of(defaultProperties); }

Target:
private Optional<Set<String>> getFilteredStringObjectMap( final IndexEdge indexEdge ) { Id mapOwner = new SimpleId( indexEdge.getNodeId().getUuid(), TYPE_APPLICATION ); final MapScope ms = CpNamingUtils.getEntityTypeMapScope( mapOwner ); MapManager mm = mapManagerFactory.createMapManager( ms ); Set<String> defaultProperties; ArrayList fieldsToKeep; String collectionName = CpNamingUtils.getCollectionNameFromEdgeName( indexEdge.getEdgeName() ); IndexSchemaCache indexSchemaCache = indexSchemaCacheFactory.getInstance( mm ); Optional<Map> collectionIndexingSchema = indexSchemaCache.getCollectionSchema( collectionName ); if ( collectionIndexingSchema.isPresent()) { Map jsonMapData = collectionIndexingSchema.get(); Schema schema = Schema.getDefaultSchema(); defaultProperties = schema.getRequiredProperties( collectionName ); fieldsToKeep = ( ArrayList ) jsonMapData.get( "fields" ); if(fieldsToKeep.contains( "*" )){ return Optional.absent(); } defaultProperties.addAll( fieldsToKeep ); } else { return Optional.absent(); } return Optional.of(defaultProperties); }
Source:
private void lockImageInDb() { final DiskImage diskImage = getDiskImage(); TransactionSupport.executeInNewTransaction(() -> { getCompensationContext().snapshotEntityStatus(diskImage.getImage()); getCompensationContext().stateChanged(); diskImage.setImageStatus(ImageStatus.LOCKED); ImagesHandler.updateImageStatus(diskImage.getImageId(), ImageStatus.LOCKED); return null; }); }

Target:
private void lockImageInDb() { final DiskImage diskImage = getDiskImage(); TransactionSupport.executeInNewTransaction(() -> { getCompensationContext().snapshotEntityStatus(diskImage.getImage()); diskImage.setImageStatus(ImageStatus.LOCKED); ImagesHandler.updateImageStatus(diskImage.getImageId(), ImageStatus.LOCKED); getCompensationContext().stateChanged(); return null; }); }
Source:
public void scroll(boolean up) { LinearLayoutManager listLayout = getCurrentFragment().recyclerViewLayoutManager; int numberOfVisibleItems = listLayout.findLastCompletelyVisibleItemPosition() - listLayout.findFirstCompletelyVisibleItemPosition() + 1; int oldPositionOnTop = listLayout.findFirstCompletelyVisibleItemPosition(); int newPositionOnTop; if (up) { newPositionOnTop = oldPositionOnTop - numberOfVisibleItems + 1; } else { newPositionOnTop = oldPositionOnTop + numberOfVisibleItems - 1; } if (newPositionOnTop >= listLayout.getItemCount()) { newPositionOnTop = listLayout.getItemCount() - numberOfVisibleItems - 1; } else if (newPositionOnTop < 0) { newPositionOnTop = 0; } Log.v(TAG, " scrolling to position: " + newPositionOnTop); listLayout.scrollToPositionWithOffset(newPositionOnTop, 0); }

Target:
public void scroll(boolean up) { ArticleListFragment currentFragment = getCurrentFragment(); if( currentFragment != null && currentFragment.recyclerViewLayoutManager != null) { LinearLayoutManager listLayout = currentFragment.recyclerViewLayoutManager; int numberOfVisibleItems = listLayout.findLastCompletelyVisibleItemPosition() - listLayout.findFirstCompletelyVisibleItemPosition() + 1; int oldPositionOnTop = listLayout.findFirstCompletelyVisibleItemPosition(); int newPositionOnTop; if (up) { newPositionOnTop = oldPositionOnTop - numberOfVisibleItems + 1; } else { newPositionOnTop = oldPositionOnTop + numberOfVisibleItems - 1; } if (newPositionOnTop >= listLayout.getItemCount()) { newPositionOnTop = listLayout.getItemCount() - numberOfVisibleItems - 1; } else if (newPositionOnTop < 0) { newPositionOnTop = 0; } Log.v(TAG, " scrolling to position: " + newPositionOnTop); listLayout.scrollToPositionWithOffset(newPositionOnTop, 0); } }
Source:
public DataSection genesBody(Patient patient) throws Exception { String sectionName = "genes"; Set<String> present = this.enabledHeaderIdsBySection.get(sectionName); if (present == null || present.isEmpty()) { return null; } DataSection section = new DataSection(); int y = 0; PatientData<Map<String, String>> allGenes = patient.getData("genes"); if (allGenes == null || !allGenes.isIndexed()) { for (int i = 0; i < present.size(); i++) { DataCell cell = new DataCell("", i, y); section.addCell(cell); } return section; } List<String> fields = Arrays.asList("status", "strategy", "comments"); List<String> strategyTranslates = Arrays.asList("sequencing", "deletion", "familial_mutation", "common_mutations"); DataCell cell = new DataCell(this.translationManager.translate("PhenoTips.GeneClass_genes"), 0, y); section.addCell(cell); for (Map<String, String> gene : allGenes) { int x = 0; String geneName = gene.get("gene"); cell = new DataCell(geneName, x++, y); section.addCell(cell); for (String field : fields) { if (!present.contains(field)) { continue; } String value = gene.get(field); if (field.equals("strategy")) { value = parseMultivalueField(value, strategyTranslates, "PhenoTips.GeneClass_"); } else { value = "comments".equals(field) ? value : this.translationManager.translate("PhenoTips.GeneClass_" + value); } cell = new DataCell(value, x++, y); section.addCell(cell); } y++; } return section; }

Target:
public DataSection genesBody(Patient patient) throws Exception { String sectionName = "genes"; Set<String> present = this.enabledHeaderIdsBySection.get(sectionName); if (present == null || present.isEmpty()) { return null; } DataSection section = new DataSection(); int y = 0; PatientData<Map<String, String>> allGenes = patient.getData("genes"); if (allGenes == null || !allGenes.isIndexed()) { for (int i = 0; i < present.size(); i++) { DataCell cell = new DataCell("", i, y); section.addCell(cell); } return section; } List<String> fields = Arrays.asList("status", "strategy", "comments"); List<String> strategyTranslates = Arrays.asList("sequencing", "deletion", "familial_mutation", "common_mutations"); DataCell cell; for (Map<String, String> gene : allGenes) { int x = 0; String geneName = gene.get("gene"); cell = new DataCell(geneName, x++, y); section.addCell(cell); for (String field : fields) { if (!present.contains(field) || gene.get(field) == null) { continue; } String value = gene.get(field); if ("strategy".equals(field)) { value = parseMultivalueField(value, strategyTranslates, "PhenoTips.GeneClass_strategy_"); } else if ("status".equals(field)) { value = this.translationManager.translate("PhenoTips.GeneClass_status_" + value); } cell = new DataCell(value, x++, y); section.addCell(cell); } y++; } return section; }
Source:
private OperationController getOperationController() { ArrayList<OperationController> ocList = ocListRef.get(); if (ocList.size() == 0) { return null; } else { return ocList.get(ThreadLocalRandom.current().nextInt(ocList.size())); } }

Target:
private OperationController getOperationController() { return ocList.get(ThreadLocalRandom.current().nextInt(ocList.size())); }
Source:
public PlanNode makeSegmentPlanNode(IndexSegment indexSegment, QueryContext queryContext) { if (QueryContextUtils.isSelectionQuery(queryContext)) { return new SelectionPlanNode(indexSegment, queryContext); } else if (QueryContextUtils.isDistinctQuery(queryContext)) { return new DistinctPlanNode(indexSegment, queryContext); } else { assert QueryContextUtils.isAggregationQuery(queryContext); List<ExpressionContext> groupByExpressions = queryContext.getGroupByExpressions(); if (groupByExpressions != null) { QueryOptions queryOptions = new QueryOptions(queryContext.getQueryOptions()); if (queryOptions.isGroupByModeSQL()) { return new AggregationGroupByOrderByPlanNode(indexSegment, queryContext, _maxInitialResultHolderCapacity, _numGroupsLimit); } return new AggregationGroupByPlanNode(indexSegment, queryContext, _maxInitialResultHolderCapacity, _numGroupsLimit); } else { if (queryContext.getFilter() == null && indexSegment.getValidDocIndex() == null) { if (isFitForMetadataBasedPlan(queryContext)) { return new MetadataBasedAggregationPlanNode(indexSegment, queryContext); } else if (isFitForDictionaryBasedPlan(queryContext, indexSegment)) { return new DictionaryBasedAggregationPlanNode(indexSegment, queryContext); } } return new AggregationPlanNode(indexSegment, queryContext); } } }

Target:
public PlanNode makeSegmentPlanNode(IndexSegment indexSegment, QueryContext queryContext) { if (QueryContextUtils.isAggregationQuery(queryContext)) { List<ExpressionContext> groupByExpressions = queryContext.getGroupByExpressions(); if (groupByExpressions != null) { QueryOptions queryOptions = new QueryOptions(queryContext.getQueryOptions()); if (queryOptions.isGroupByModeSQL()) { return new AggregationGroupByOrderByPlanNode(indexSegment, queryContext, _maxInitialResultHolderCapacity, _numGroupsLimit); } return new AggregationGroupByPlanNode(indexSegment, queryContext, _maxInitialResultHolderCapacity, _numGroupsLimit); } else { if (queryContext.getFilter() == null && indexSegment.getValidDocIndex() == null) { if (isFitForMetadataBasedPlan(queryContext)) { return new MetadataBasedAggregationPlanNode(indexSegment, queryContext); } else if (isFitForDictionaryBasedPlan(queryContext, indexSegment)) { return new DictionaryBasedAggregationPlanNode(indexSegment, queryContext); } } return new AggregationPlanNode(indexSegment, queryContext); } } else if (QueryContextUtils.isSelectionQuery(queryContext)) { return new SelectionPlanNode(indexSegment, queryContext); } else { assert QueryContextUtils.isDistinctQuery(queryContext); return new DistinctPlanNode(indexSegment, queryContext); } }
Source:
public void testFailForCheckDisksNotInBackupStorage() { final VM vm = new VM(); command.setVm(vm); when(vmDao.get(command.getParameters().getVmId())).thenReturn(vm); command.setCluster(new Cluster()); Guid storageDomainId = initDiskImage(vm); when(storageDomainStaticDao.get(storageDomainId)).thenReturn(backupStorageDomain(true)); assertFalse("checkDisksNotInBackupStorage() fails to run because one or more disk is in backup domain", command.checkDisksInBackupStorage()); }

Target:
public void testFailForCheckDisksNotInBackupStorage() { final VM vm = new VM(); command.setVm(vm); when(vmDao.get(command.getParameters().getVmId())).thenReturn(vm); command.setCluster(new Cluster()); Guid storageDomainId = initDiskImage(vm); when(storageDomainStaticDao.get(storageDomainId)).thenReturn(backupStorageDomain(true)); assertTrue("checkDisksNotInBackupStorage() fails to run because one or more disk is in backup domain", command.checkDisksInBackupStorage()); }
Source:
public boolean intersect(Shape o) { return false; }

Target:
public boolean intersect(Shape o) { throw new UnsupportedOperationException("Not supported yet."); }
Source:
public void clearAllRevisions(String siddhiAppId) { }

Target:
public void clearAllRevisions(String siddhiAppId) { List<String> revisionList = revisionMap.remove(siddhiAppId); if (revisionList == null) { log.info("No revisions were found to delete for the Siddhi App " + siddhiAppId); return; } log.info("All revisions were deleted for the Siddhi App " + siddhiAppId); }
Source:
private static BinaryResult stackBase64(HttpServletResponse res, final BinaryResult src) throws IOException { BinaryResult b64; long len = src.getContentLength(); if (0 <= len && len <= (7 << 20)) { b64 = base64(src); } else { b64 = new BinaryResult() { @Override public void writeTo(final OutputStream out) throws IOException { try (OutputStreamWriter w = new OutputStreamWriter( new OutputStream() { @Override public void write(int b) throws IOException { out.write(b); } @Override public void close() { } }, ISO_8859_1); OutputStream e = BaseEncoding.base64().encodingStream(w)) { src.writeTo(e); e.flush(); } } }; } res.setHeader("X-FYI-Content-Encoding", "base64"); res.setHeader("X-FYI-Content-Type", src.getContentType()); return b64.setContentType("text/plain").setCharacterEncoding("ISO-8859-1"); }

Target:
private static BinaryResult stackBase64(HttpServletResponse res, final BinaryResult src) throws IOException { BinaryResult b64; long len = src.getContentLength(); if (0 <= len && len <= (7 << 20)) { b64 = base64(src); } else { b64 = new BinaryResult() { @Override public void writeTo(final OutputStream out) throws IOException { try (OutputStreamWriter w = new OutputStreamWriter( new FilterOutputStream(out) { @Override public void close() { } }, ISO_8859_1); OutputStream e = BaseEncoding.base64().encodingStream(w)) { src.writeTo(e); } } }; } res.setHeader("X-FYI-Content-Encoding", "base64"); res.setHeader("X-FYI-Content-Type", src.getContentType()); return b64.setContentType("text/plain").setCharacterEncoding("ISO-8859-1"); }
Source:
public void deleteSession(Session session, MicroServiceContext microServiceContext) { String microServiceSessionDir = microServiceContext.getService().getClass().getName(); String pathname = Paths.get(SESSION_DIR + "/" + microServiceSessionDir, session.getId()).toString(); if (!new File(pathname).delete()) { throw new IllegalStateException("File " + pathname + " deletion failed"); } }

Target:
public void deleteSession(Session session, MicroServiceContext microServiceContext) { String microServiceSessionDir = microServiceContext.getService().getClass().getName(); String pathname = Paths.get(SESSION_DIR, microServiceSessionDir, session.getId()).toString(); if (!new File(pathname).delete()) { throw new IllegalStateException("File " + pathname + " deletion failed"); } }
Source:
public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) { Object userData = fixture.getBody().getUserData(); if (userData instanceof EntityRef) { userData = new SolObjectEntityWrapper((EntityRef) userData); } SolObject o = (SolObject) userData; boolean oIsMassless = o instanceof Projectile && ((Projectile) o).isMassless(); if (!oIsMassless && projectile.shouldCollide(o, fixture, game.getFactionMan())) { position.set(point); projectile.setObstacle(o, game); return 0; } return -1; }

Target:
public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) { Object userData = fixture.getBody().getUserData(); if (userData instanceof EntityRef) { userData = new SolObjectEntityWrapper((EntityRef) userData); } SolObject solObject = (SolObject) userData; boolean objectIsMassless = solObject instanceof Projectile && ((Projectile) solObject).isMassless(); if (!objectIsMassless && projectile.shouldCollide(solObject, fixture, game.getFactionMan())) { position.set(point); projectile.setObstacle(solObject, game); return 0; } return -1; }
Source:
public void update(CruiseConfig preprocessedConfig) throws Exception { preprocessedRole = findExistingRole(preprocessedConfig); if (preprocessedRole == null) { throw new RoleNotFoundException(); } removeFromServerRole(preprocessedConfig, preprocessedRole); removeFromAdmins(preprocessedConfig); removeFromAllGroups(preprocessedConfig); removeFromAllTemplates(preprocessedConfig); removeFromSecurity(preprocessedConfig); }

Target:
public void update(CruiseConfig preprocessedConfig) throws Exception { preprocessedRole = findExistingRole(preprocessedConfig); if (preprocessedRole == null) { throw new RoleNotFoundException(); } removeFromServerRole(preprocessedConfig, preprocessedRole); removeFromServerAdmins(preprocessedConfig); removeFromAllGroups(preprocessedConfig); removeFromAllTemplates(preprocessedConfig); removeFromSecurity(preprocessedConfig); }
Source:
void shouldSetTransactionTimeout() { session.run( "CREATE (:Node)" ).consume(); try ( Session otherSession = session.driver().session() ) { try ( Transaction otherTx = otherSession.beginTransaction() ) { otherTx.run( "MATCH (n:Node) SET n.prop = 1" ).consume(); TransactionConfig config = TransactionConfig.builder() .withTimeout( ofSeconds( 1 ) ) .build(); TransientException error = assertThrows( TransientException.class, () -> { try ( Transaction tx = session.beginTransaction( config ) ) { tx.run( "MATCH (n:Node) SET n.prop = 2" ); tx.success(); } } ); assertThat( error.getMessage(), containsString( "terminated" ) ); } } }

Target:
void shouldSetTransactionTimeout() { session.run( "CREATE (:Node)" ).consume(); try ( Session otherSession = session.driver().session() ) { try ( Transaction otherTx = otherSession.beginTransaction() ) { otherTx.run( "MATCH (n:Node) SET n.prop = 1" ).consume(); TransactionConfig config = TransactionConfig.builder() .withTimeout( ofMillis( 1 ) ) .build(); TransientException error = assertThrows( TransientException.class, () -> { try ( Transaction tx = session.beginTransaction( config ) ) { tx.run( "MATCH (n:Node) SET n.prop = 2" ); tx.success(); } } ); assertThat( error.getMessage(), containsString( "terminated" ) ); } } }
Source:
public JsonPattern() { pattern = new ArrayList<Integer>(); }

Target:
public JsonPattern() { this(new ArrayList<Integer>()); }
Source:
public void testSerializeAndDeserialize() { testSerializeAndDeserialize("Hello", S(0, 0)); testSerializeAndDeserialize(1, S(0, 1), CM("package", "name", 0, 10, "Bad")); testSerializeAndDeserialize("What", S(0, 1), CM("package", "name", 0, 10, "Bad"), CM("package", "b", 10, 20, "Very Bad")); }

Target:
public void testSerializeAndDeserialize() throws IOException { assertSerializeAndDeserialize("Hello", S(0, 0)); assertSerializeAndDeserialize(1, S(0, 1), CM("package", "name", S(0, 10), "Bad")); assertSerializeAndDeserialize("What", S(0, 1), CM("package", "name", S(0, 10), "Bad"), CM("package", "b", S(10, 20), "Very Bad")); }
Source:
public void testPatchRequestScope() { DataStoreTransaction tx = mock(DataStoreTransaction.class); PatchRequestScope parentScope = new PatchRequestScope(null, tx, new User(1), elideSettings); PatchRequestScope scope = new PatchRequestScope( parentScope.getPath(), parentScope.getJsonApiDocument(), parentScope); Parent parent = newParent(7); PersistentResource<Parent> parentResource = new PersistentResource<>(parent, null, "1", scope); parentResource.updateAttribute("firstName", "foobar"); verify(tx, times(1)).setAttribute(parent, "firstName", "foobar", scope); }

Target:
public void testPatchRequestScope() { DataStoreTransaction tx = mock(DataStoreTransaction.class); PatchRequestScope parentScope = new PatchRequestScope(null, tx, new User(1), elideSettings); PatchRequestScope scope = new PatchRequestScope( parentScope.getPath(), parentScope.getJsonApiDocument(), parentScope); assertEquals(parentScope.isUseFilterExpressions(), scope.isUseFilterExpressions()); assertEquals(parentScope.getSorting(), scope.getSorting()); assertEquals(parentScope.getUpdateStatusCode(), scope.getUpdateStatusCode()); assertEquals(parentScope.getObjectEntityCache(), scope.getObjectEntityCache()); Parent parent = newParent(7); PersistentResource<Parent> parentResource = new PersistentResource<>(parent, null, "1", scope); parentResource.updateAttribute("firstName", "foobar"); verify(tx, times(1)).setAttribute(parent, "firstName", "foobar", scope); }
Source:
private String getCacheKey(String kind, String name) { return NLS.bind("{0}/{1}", new Object[] { kind, name }); }

Target:
private String getCacheKey(String kind, String name) { return kind+"/"+name; }
Source:
public void onBootstrap() { String historyToken = History.getToken(); PlaceRequest currentPlaceRequest = tokenFormatter.toPlaceRequest(historyToken.isEmpty() ? NameTokens.HOME : historyToken); String nameToken = currentPlaceRequest.getNameToken(); if (localeHelper.isEnglish()) { if (!Strings.isNullOrEmpty(nameToken) && !NameTokens.isEnglish(nameToken)) { revealTranslatedNameToken(currentPlaceRequest); return; } } else if (localeHelper.isFrench()) { if (NameTokens.isEnglish(nameToken)) { revealTranslatedNameToken(currentPlaceRequest); return; } } placeManager.revealCurrentPlace(); }

Target:
public void onBootstrap() { String historyToken = History.getToken(); PlaceRequest currentPlaceRequest = tokenFormatter.toPlaceRequest(historyToken.isEmpty() ? NameTokens.HOME : historyToken); String nameToken = currentPlaceRequest.getNameToken(); if (nameTokenInWrongLanguage(nameToken)) { revealTranslatedNameToken(currentPlaceRequest); } else { placeManager.revealCurrentPlace(); } }
Source:
private TestResult runAll4x() throws Exception { List<String> testClassNames = new ArrayList<>(); Files.walk(Paths.get(projectPath, "target", "test-classes")).forEach(filePath -> { if (Files.isRegularFile(filePath) && filePath.toString().toLowerCase().endsWith(".class")) { String path = Paths.get(projectPath, "target", "test-classes").relativize(filePath).toString(); String className = path.replace('/', '.'); className = className.replace('\\', '.'); className = className.substring(0, className.length() - 6); testClassNames.add(className); } }); List<Class> testableClasses = new ArrayList<>(); for (String className : testClassNames) { Class<?> clazz = Class.forName(className, false, projectClassLoader); if (isTestable4x(clazz)) { testableClasses.add(clazz); } } return run4xTestClasses(testableClasses.toArray(new Class[testableClasses.size()])); }

Target:
private TestResult runAll4x() throws Exception { List<String> testClassNames = new ArrayList<>(); Files.walk(Paths.get(projectPath, "target", "test-classes")).forEach(filePath -> { if (Files.isRegularFile(filePath) && filePath.toString().toLowerCase().endsWith(".class")) { String path = Paths.get(projectPath, "target", "test-classes").relativize(filePath).toString(); String className = path.replace(File.separatorChar, '.'); className = className.substring(0, className.length() - 6); testClassNames.add(className); } }); List<Class> testableClasses = new ArrayList<>(); for (String className : testClassNames) { Class<?> clazz = Class.forName(className, false, projectClassLoader); if (isTestable4x(clazz)) { testableClasses.add(clazz); } } return run4xTestClasses(testableClasses.toArray(new Class[testableClasses.size()])); }
Source:
public String render(Model model, @SiteParam Site site, @PathVariable String sourcePage, @RequestParam(value="defaultTarget", required = false) String defaultTarget) throws IOException { Map<String, Object> redirectMap = site.getTheme().getConfigMap("redirects"); JSONObject redirects = new JSONObject(); redirects.accumulateAll(redirectMap); model.addAttribute("redirects", redirects.toString()); model.addAttribute("sourcePage", sourcePage); model.addAttribute("defaultTarget", defaultTarget != null ? defaultTarget : sourcePage); return site + "/ftl/redirect"; }

Target:
public String render(Model model, @SiteParam Site site, @PathVariable String sourcePage, @RequestParam(value="defaultTarget", required = false) String defaultTarget) throws IOException { model.addAttribute("sourcePage", sourcePage); model.addAttribute("defaultTarget", defaultTarget != null ? defaultTarget : sourcePage); return site + "/ftl/redirect"; }
Source:
public List<GroupRepresentation> getGroups(@QueryParam("search") String search, @QueryParam("first") Integer firstResult, @QueryParam("max") Integer maxResults) { auth.groups().requireList(); List<GroupModel> results; if (Objects.nonNull(search)) { results = realm.searchForGroupByName(search.trim(),null, null); } else { results = realm.getTopLevelGroups(); } List<GroupRepresentation> ret = results.stream() .map(group -> ModelToRepresentation.toGroupHierarchy(group, false)) .collect(Collectors.toList()); return checkGroupsPermissions(ret); }

Target:
public List<GroupRepresentation> getGroups(@QueryParam("search") String search, @QueryParam("first") Integer firstResult, @QueryParam("max") Integer maxResults) { auth.groups().requireList(); List<GroupRepresentation> results; if (auth.users().canView()) { if (Objects.nonNull(search)) { results = ModelToRepresentation.searchForGroupByName(realm, search.trim(), firstResult, maxResults); } else if(Objects.nonNull(firstResult) && Objects.nonNull(maxResults)) { results = ModelToRepresentation.toGroupHierarchy(realm, false, firstResult, maxResults); } else { results = ModelToRepresentation.toGroupHierarchy(realm, false); } } else { Set<String> groups = auth.groups().getGroupsWithViewPermission(); Stream<String> s = groups.stream(); if (search!=null) s=s.filter(group->group.contains(search.trim())); if (firstResult != null) s=s.skip(firstResult); if (maxResults != null) s=s.limit(maxResults); results = s .map(group -> ModelToRepresentation.toGroupHierarchy(session.realms().getGroupById(group, session.getContext().getRealm()),false)) .collect(Collectors.toList()); } return results; }
Source:
public Client( final String packageName, final ImmutableList<Command> commands) { this.packageName = packageName; this.commands = commands; helper = Helper.getInstance(); javaHelper = JavaHelper.getInstance(); }

Target:
public Client( final String packageName, final ImmutableList<Command> commands) { this.packageName = packageName; this.commands = commands; }
Source:
private String serializePersistenceAdapterStatistics() { if (persistenceAdapterStatistics != null) { try { final ObjectMapper mapper = new ObjectMapper(); Map<String, Object> result = new HashMap<String, Object>(); result.put("writeTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getWriteTime())); result.put("readTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getReadTime())); return mapper.writeValueAsString(result); } catch (IOException e) { return e.toString(); } } return null; }

Target:
private String serializePersistenceAdapterStatistics() { if (persistenceAdapterStatistics != null) { try { Map<String, Object> result = new HashMap<String, Object>(); result.put("writeTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getWriteTime())); result.put("readTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getReadTime())); return mapper.writeValueAsString(result); } catch (IOException e) { return e.toString(); } } return null; }
Source:
public void testConcurrentViewCreationAndTableDrop() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl()); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SLOW_VIEWNAME_PREFIX + "_" + generateUniqueName(); latch1 = new CountDownLatch(1); latch2 = new CountDownLatch(1); String tableDdl = "CREATE TABLE " + fullTableName + " (k INTEGER NOT NULL PRIMARY KEY, v1 INTEGER, v2 INTEGER)" + tableDDLOptions; stmt.execute(tableDdl); ExecutorService executorService = Executors.newFixedThreadPool( 1, new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); t.setPriority(Thread.MIN_PRIORITY); return t; } }); slowDownAddingChildLink = true; Future<Exception> future = executorService.submit( new CreateViewRunnable(fullTableName, fullViewName1)); latch1.await(); tableDdl = "DROP TABLE " + fullTableName; slowDownAddingChildLink = false; stmt.execute(tableDdl); latch2.countDown(); Exception e = future.get(); assertTrue("Expected TableNotFoundException since drop table" + " goes through first", e instanceof TableNotFoundException && fullTableName.equals(((TableNotFoundException) e) .getTableName())); } }

Target:
public void testConcurrentViewCreationAndTableDrop() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl()); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SLOW_VIEWNAME_PREFIX + "_" + generateUniqueName(); latch1 = new CountDownLatch(1); latch2 = new CountDownLatch(1); String tableDdl = "CREATE TABLE " + fullTableName + " (k INTEGER NOT NULL PRIMARY KEY, v1 INTEGER, v2 INTEGER)" + tableDDLOptions; stmt.execute(tableDdl); ExecutorService executorService = newSingleThreadExecutor( new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); t.setPriority(Thread.MIN_PRIORITY); return t; } }); slowDownAddingChildLink = true; Future<Exception> future = executorService.submit( new CreateViewRunnable(fullTableName, fullViewName1)); latch1.await(); tableDdl = "DROP TABLE " + fullTableName; slowDownAddingChildLink = false; stmt.execute(tableDdl); latch2.countDown(); Exception e = future.get(); assertTrue("Expected TableNotFoundException since drop table" + " goes through first", e instanceof TableNotFoundException && fullTableName.equals(((TableNotFoundException) e) .getTableName())); } }
Source:
public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.MANA_PAID) { if (event.getData() != null && event.getData().equals(originalId.toString())) { spells.put(event.getTargetId(), game.getObject(event.getTargetId()).getZoneChangeCounter(game)); } } }

Target:
public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.MANA_PAID) { if (event.getData() != null && event.getData().equals(originalId.toString()) && event.getTargetId() != null) { spells.add(new MageObjectReference(game.getObject(event.getTargetId()), game)); } } }
Source:
private void initCommonParams(LogReplicationMetadataManager metadataManager, LogReplicationConfig config) { this.logReplicationMetadataManager = metadataManager; this.config = config; this.rxState = RxState.LOG_ENTRY_SYNC; logReplicationMetadataManager.setDataConsistentOnStandby(String.valueOf(dataConsistent.get())); initWriterAndBufferMgr(); }

Target:
private void initCommonParams(LogReplicationMetadataManager metadataManager, LogReplicationConfig config) { this.logReplicationMetadataManager = metadataManager; this.config = config; this.rxState = RxState.LOG_ENTRY_SYNC; setDataConsistent(dataConsistent.get()); initWriterAndBufferMgr(); }
Source:
protected void initUserGroupCache() { String userRolesCacheEnabledString = (realmConfig .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_ROLES_CACHE_ENABLED)); String userCoreCacheIdentifier = realmConfig .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USER_CORE_CACHE_IDENTIFIER); if (userCoreCacheIdentifier != null && userCoreCacheIdentifier.trim().length() > 0) { cacheIdentifier = userCoreCacheIdentifier; } else { cacheIdentifier = UserCoreConstants.DEFAULT_CACHE_IDENTIFIER; } if (userRolesCacheEnabledString != null && !userRolesCacheEnabledString.equals("")) { userRolesCacheEnabled = Boolean.parseBoolean(userRolesCacheEnabledString); if (log.isDebugEnabled()) { log.debug("User Roles Cache is configured to:" + userRolesCacheEnabledString); } } else { if (log.isDebugEnabled()) { log.info("User Roles Cache is not configured. Default value: " + userRolesCacheEnabled + " is taken."); } } if (userRolesCacheEnabled) { int timeOut = UserCoreConstants.USER_ROLE_CACHE_DEFAULT_TIME_OUT; String timeOutString = realmConfig. getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USER_ROLE_CACHE_TIME_OUT); if (timeOutString != null) { timeOut = Integer.parseInt(timeOutString); } userGroupCache = userGroupCache.getInstance(); userGroupCache.setTimeOut(timeOut); } }

Target:
protected void initUserGroupCache() { String userRolesCacheEnabledString = (realmConfig .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_ROLES_CACHE_ENABLED)); String userCoreCacheIdentifier = realmConfig .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USER_CORE_CACHE_IDENTIFIER); if (StringUtils.isNotBlank(userCoreCacheIdentifier)) { cacheIdentifier = userCoreCacheIdentifier; } else { cacheIdentifier = UserCoreConstants.DEFAULT_CACHE_IDENTIFIER; } if (StringUtils.isNotBlank(userRolesCacheEnabledString)) { userRolesCacheEnabled = Boolean.parseBoolean(userRolesCacheEnabledString); if (log.isDebugEnabled()) { log.debug("User Roles Cache is configured to:" + userRolesCacheEnabledString); } } else { if (log.isDebugEnabled()) { log.info("User Roles Cache is not configured. Default value: " + userRolesCacheEnabled + " is taken."); } } if (userRolesCacheEnabled) { int timeOut = UserCoreConstants.USER_ROLE_CACHE_DEFAULT_TIME_OUT; String timeOutString = realmConfig. getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USER_ROLE_CACHE_TIME_OUT); if (timeOutString != null) { timeOut = Integer.parseInt(timeOutString); } userGroupCache = userGroupCache.getInstance(); userGroupCache.setTimeOut(timeOut); } }
Source:
public StackedMutationContainer(final BucketCache buckets, final Set<Sequence> visibleSequences) { this.level = (int) (Math.log(buckets.getNumberBuckets()) / Math.log(2) + 1); fillStackedMutationContainer(this.level, buckets, visibleSequences); }

Target:
public StackedMutationContainer(final BucketCache buckets, final Set<Sequence> visibleSequences) { this.level = (int) Math.round(Math.log(buckets.getNumberBuckets()) / Math.log(2) + 1); fillStackedMutationContainer(this.level, buckets, visibleSequences); }
Source:
protected VDSReturnValue performImageVdsmOperation() { boolean isShouldBeLocked = getParameters().getPerformDbOperationsStage() != PerformOperationStage.NEVER && getParameters().getParentCommand() != VdcActionType.RemoveVmFromImportExport && getParameters().getParentCommand() != VdcActionType.RemoveVmTemplateFromImportExport; if (isShouldBeLocked) { getDiskImage().setImageStatus(ImageStatus.ILLEGAL); lockImageWithCompensation(); } freeLock(); VDSReturnValue returnValue = runVdsCommand(VDSCommandType.DeleteImageGroup, new DeleteImageGroupVDSCommandParameters(getDiskImage().getStoragePoolId().getValue(), getStorageDomainId().getValue(), getDiskImage().getId() .getValue(), getDiskImage().isWipeAfterDelete(), getParameters() .getForceDelete(), getStoragePool().getcompatibility_version().toString())); return returnValue; }

Target:
protected VDSReturnValue performImageVdsmOperation() { boolean isShouldBeLocked = getParameters().getPerformDbOperationsStage() != PerformOperationsStage.NEVER && getParameters().getParentCommand() != VdcActionType.RemoveVmFromImportExport && getParameters().getParentCommand() != VdcActionType.RemoveVmTemplateFromImportExport; if (isShouldBeLocked) { getDiskImage().setImageStatus(ImageStatus.ILLEGAL); lockImageWithCompensation(); } VDSReturnValue returnValue = runVdsCommand(VDSCommandType.DeleteImageGroup, new DeleteImageGroupVDSCommandParameters(getDiskImage().getStoragePoolId().getValue(), getStorageDomainId().getValue(), getDiskImage().getId() .getValue(), getDiskImage().isWipeAfterDelete(), getParameters() .getForceDelete(), getStoragePool().getcompatibility_version().toString())); return returnValue; }
Source:
public String getGatewayPublishedAPIArtifacts(String APIId, String gatewayLabel, String gatewayInstruction) throws APIManagementException { String gatewayRuntimeArtifacts = null; try (Connection connection = GatewayArtifactsMgtDBUtil.getArtifactSynchronizerConnection(); PreparedStatement statement = connection.prepareStatement(SQLConstants.GET_API_ARTIFACT)) { statement.setString(1, APIId); statement.setString(2, gatewayLabel); statement.setString(3, gatewayInstruction); ResultSet rs = statement.executeQuery(); if (rs.next()) { try (InputStream inputStream = rs.getBinaryStream(1)) { gatewayRuntimeArtifacts = IOUtils.toString(inputStream, APIConstants.DigestAuthConstants.CHARSET); } catch (IOException e){ handleException("Error in generating gatewayRuntimeArtifacts " + APIId, e); } } } catch (SQLException e) { handleException("Failed to get artifacts of API with ID " + APIId, e); } return gatewayRuntimeArtifacts; }

Target:
public String getGatewayPublishedAPIArtifacts(String APIId, String gatewayLabel, String gatewayInstruction) throws APIManagementException { ResultSet rs = null; String gatewayRuntimeArtifacts = null; try (Connection connection = GatewayArtifactsMgtDBUtil.getArtifactSynchronizerConnection(); PreparedStatement statement = connection.prepareStatement(SQLConstants.GET_API_ARTIFACT)) { connection.setAutoCommit(false); connection.commit(); statement.setString(1, APIId); statement.setString(2, gatewayLabel); statement.setString(3, gatewayInstruction); rs = statement.executeQuery(); if (rs.next()) { try (InputStream inputStream = rs.getBinaryStream(1)) { gatewayRuntimeArtifacts = IOUtils.toString(inputStream, APIConstants.DigestAuthConstants.CHARSET); } catch (IOException e){ handleException("Error in generating gatewayRuntimeArtifacts " + APIId, e); } } } catch (SQLException e) { handleException("Failed to get artifacts of API with ID " + APIId, e); } finally { GatewayArtifactsMgtDBUtil.closeResultSet(rs); } return gatewayRuntimeArtifacts; }
Source:
private List<Properties> createKerberosLdapConfigurations() { List<Properties> results = new ArrayList<>(); for (String domain : LdapBrokerUtils.getDomainsList(true)) { Properties authConfig = new Properties(); authConfig.put(ExtensionManager.CLASS, "org.ovirt.extensions.builtin.ldapkerberos.LdapKerberosAuthenticator"); authConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authentication"); authConfig.put(ExtensionManager.ENABLED, true); authConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); authConfig.put(ExtensionManager.NAME, String.format("builtin-authn-%1$s", domain)); authConfig.put("org.ovirt.engine.aaa.authn.profile.name", domain); authConfig.put("ovirt.engine.aaa.authn.authz.plugin", String.format("builitin-authz-%1$s", domain)); results.add(authConfig); Properties dirConfig = new Properties(); dirConfig.put(ExtensionManager.CLASS, "org.ovirt.extensions.builtin.ldapkerberos.LdapKerberosDirectory"); dirConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authorization"); dirConfig.put(ExtensionManager.ENABLED, true); dirConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); dirConfig.put(ExtensionManager.NAME, String.format("builtin-authz-%1$s", domain)); dirConfig.put("org.ovirt.engine.aaa.authz.profile.name", domain); results.add(authConfig); } return results; }

Target:
private List<Properties> createKerberosLdapConfigurations() { List<Properties> results = new ArrayList<>(); for (String domain : Config.<String> getValue(ConfigValues.DomainName).split("[,]", -1)) { Properties authConfig = new Properties(); authConfig.put(ExtensionManager.CLASS, "org.ovirt.engine.extensions.aaa.builtin.kerberosldap.KerberosLdapAuthenticator"); authConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authentication"); authConfig.put(ExtensionManager.ENABLED, "true"); authConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); authConfig.put(ExtensionManager.NAME, String.format("builtin-authn-%1$s", domain)); authConfig.put("ovirt.engine.aaa.authn.profile.name", domain); authConfig.put("ovirt.engine.aaa.authn.authz.plugin", String.format("builtin-authz-%1$s", domain)); results.add(authConfig); Properties dirConfig = new Properties(); dirConfig.put(ExtensionManager.CLASS, "org.ovirt.engine.extensions.aaa.builtin.kerberosldap.KerberosLdapDirectory"); dirConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authorization"); dirConfig.put(ExtensionManager.ENABLED, "true"); dirConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); dirConfig.put(ExtensionManager.NAME, String.format("builtin-authz-%1$s", domain)); dirConfig.put("ovirt.engine.aaa.authz.profile.name", domain); results.add(dirConfig); } return results; }
Source:
public void run() { CompoundCommand updateCmd = new CompoundCommand(); for(Object obj : getSelectedObjects()){ if (obj instanceof AbstractFBNElementEditPart) { UpdateFBTypeCommand cmd; cmd = new UpdateFBTypeCommand(((AbstractFBNElementEditPart) obj).getModel(), entry); if (cmd.canExecute()) { updateCmd.add(cmd); } } } execute(updateCmd); }

Target:
public void run() { CompoundCommand updateCmd = new CompoundCommand(); for(Object obj : getSelectedObjects()){ if (obj instanceof AbstractFBNElementEditPart) { UpdateFBTypeCommand cmd = new UpdateFBTypeCommand(((AbstractFBNElementEditPart) obj).getModel(), entry); if (cmd.canExecute()) { updateCmd.add(cmd); } } } execute(updateCmd); }
Source:
public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipmentNum", equipmentNum); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "typeName", MekHqXmlUtil.escape(type.getInternalName())); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "size", size); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipTonnage", equipTonnage); writeToXmlEnd(pw1, indent); }

Target:
public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipmentNum", equipmentNum); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "typeName", type.getInternalName()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "size", size); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipTonnage", equipTonnage); writeToXmlEnd(pw1, indent); }
Source:
public void getSubstudyIds() { SUBSTUDIES.get(0).setId("substudyA"); SUBSTUDIES.get(1).setId("substudyB"); when(substudyDao.getSubstudies(TestConstants.TEST_STUDY, false)).thenReturn(SUBSTUDIES); Set<String> substudyIds = service.getSubstudyIds(TestConstants.TEST_STUDY); assertEquals(TestConstants.USER_SUBSTUDY_IDS, substudyIds); }

Target:
public void getSubstudyIds() { Substudy substudyA = Substudy.create(); substudyA.setId("substudyA"); Substudy substudyB = Substudy.create(); substudyB.setId("substudyB"); List<Substudy> substudies = ImmutableList.of(substudyA, substudyB); when(substudyDao.getSubstudies(TestConstants.TEST_STUDY, false)).thenReturn(substudies); Set<String> substudyIds = service.getSubstudyIds(TestConstants.TEST_STUDY); assertEquals(TestConstants.USER_SUBSTUDY_IDS, substudyIds); }
Source:
public long nextIvl(Card card, int ease) { if (_previewingCard(card)) { if (ease == 1) { return _previewDelay(card); } return 0; } if (card.getQueue() == 0 || card.getQueue() == 1 || card.getQueue() == 3) { return _nextLrnIvl(card, ease); } else if (ease == 1) { JSONObject conf = _lapseConf(card); if (conf.getJSONArray("delays").length() > 0) { return (long) (conf.getJSONArray("delays").getDouble(0) * 60.0); } return _lapseIvl(card, conf) * 86400L; } else { boolean early = card.getODid() != 0 && (card.getODue() > mToday); if (early) { return _earlyReviewIvl(card, ease) * 86400; } else { return _nextRevIvl(card, ease, false) * 86400L; } } }

Target:
public long nextIvl(Card card, int ease) { if (_previewingCard(card)) { if (ease == Consts.BUTTON_ONE) { return _previewDelay(card); } return 0; } if (card.getQueue() == Consts.QUEUE_TYPE_NEW || card.getQueue() == Consts.QUEUE_TYPE_LRN || card.getQueue() == Consts.QUEUE_TYPE_DAY_LEARN_RELEARN) { return _nextLrnIvl(card, ease); } else if (ease == Consts.BUTTON_ONE) { JSONObject conf = _lapseConf(card); if (conf.getJSONArray("delays").length() > 0) { return (long) (conf.getJSONArray("delays").getDouble(0) * 60.0); } return _lapseIvl(card, conf) * 86400L; } else { boolean early = card.getODid() != 0 && (card.getODue() > mToday); if (early) { return _earlyReviewIvl(card, ease) * 86400L; } else { return _nextRevIvl(card, ease, false) * 86400L; } } }
Source:
public Optimizer() { this(5,SearchMethodName.BLINDSEARCH,0.5); }

Target:
public Optimizer() { this(DEFAULT_NUMBER_OF_PLANS_GENERATED,SearchMethodName.BLINDSEARCH,DEFAULT_HYSTERESIS_PROPORTION); }
Source:
public void setUp() throws Exception { dashboard.open(); createWsFromJavaMySqlStack(); }

Target:
public void setUp() throws Exception { createMaps(); createWsFromJavaMySqlStack(); }
Source:
private void proceedDisappearedVm() { if (System.nanoTime() - getVmManager().getPowerOffTimeout() < 0) { auditVmOnDownNormal(true); clearVm(VmExitStatus.Normal, getPowerOffExitMessage(), VmExitReason.Success); resourceManager.removeAsyncRunningVm(dbVm.getId()); return; } switch (dbVm.getStatus()) { case MigratingFrom: if (dbVm.getMigratingToVds() != null) { handOverVm(); break; } abortVmMigration(VmExitStatus.Error, String.format("Could not find VM %s on host, assuming it went down unexpectedly", getVmManager().getName()), VmExitReason.GenericError); break; case PoweringDown: clearVm(VmExitStatus.Normal, String.format("VM %s shutdown complete", getVmManager().getName()), VmExitReason.Success); if (getVmManager().isColdReboot()) { setColdRebootFlag(); } break; default: clearVm(VmExitStatus.Error, String.format("Could not find VM %s on host, assuming it went down unexpectedly", getVmManager().getName()), VmExitReason.GenericError); if (resourceManager.isVmInAsyncRunningList(dbVm.getId())) { setRerunFlag(); break; } if (getVmManager().isColdReboot()) { setColdRebootFlag(); break; } if (getVmManager().isAutoStart()) { setAutoRunFlag(); break; } } }

Target:
private void proceedDisappearedVm() { if (System.nanoTime() - getVmManager().getPowerOffTimeout() < 0) { auditVmOnDownNormal(true); resourceManager.removeAsyncRunningVm(dbVm.getId()); clearVm(VmExitStatus.Normal, getPowerOffExitMessage(), VmExitReason.Success); return; } switch (dbVm.getStatus()) { case MigratingFrom: if (dbVm.getMigratingToVds() != null) { handOverVm(); break; } abortVmMigration(VmExitStatus.Error, String.format("Could not find VM %s on host, assuming it went down unexpectedly", getVmManager().getName()), VmExitReason.GenericError); break; case PoweringDown: clearVm(VmExitStatus.Normal, String.format("VM %s shutdown complete", getVmManager().getName()), VmExitReason.Success); if (getVmManager().isColdReboot()) { setColdRebootFlag(); } break; default: clearVm(VmExitStatus.Error, String.format("Could not find VM %s on host, assuming it went down unexpectedly", getVmManager().getName()), VmExitReason.GenericError); if (resourceManager.isVmInAsyncRunningList(dbVm.getId())) { setRerunFlag(); break; } if (getVmManager().isColdReboot()) { setColdRebootFlag(); break; } if (getVmManager().isAutoStart()) { setAutoRunFlag(); break; } } }