auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private Description convertMethodInvocations( Symbol.MethodSymbol methodSymbol, MethodInvocationTree methodInvocation, LambdaExpressionTree root, VisitorState state) { List<Symbol> methodParams = getSymbols(methodInvocation.getArguments()); List<Symbol> lambdaParam = getSymbols(root.getParameters()); if (!methodParams.equals(lambdaParam)) { return Description.NO_MATCH; } boolean isLocal = ASTHelpers.getReceiver(methodInvocation) == null; return buildDescription(root) .setMessage(MESSAGE) .addFix(buildFix(methodSymbol, methodInvocation, root, state, isLocal)) .build(); }

Target:
private Description convertMethodInvocations( Symbol.MethodSymbol methodSymbol, MethodInvocationTree methodInvocation, LambdaExpressionTree root, VisitorState state) { List<Symbol> methodParams = getSymbols(methodInvocation.getArguments()); List<Symbol> lambdaParam = getSymbols(root.getParameters()); if (!methodParams.equals(lambdaParam)) { return Description.NO_MATCH; } return buildFix(methodSymbol, methodInvocation, root, state, isLocal(methodInvocation)) .map(fix -> buildDescription(root).setMessage(MESSAGE).addFix(fix).build()) .orElse(Description.NO_MATCH); }
Source:
public void addError(AuditEvent event) { final String xpathQuery = XpathFileGeneratorAstFilter.findCorrespondingXpathQuery(event); if (xpathQuery != null) { printXmlHeader(); final File file = new File(event.getFileName()); writer.println("<suppress-xpath"); writer.print(" files=\""); writer.print(file.getName()); writer.println(QUOTE_CHAR); final String checkName = PackageObjectFactory.getShortFromFullModuleNames(event.getSourceName()); writer.print(" checks=\""); writer.print(checkName); writer.println(QUOTE_CHAR); if (event.getModuleId() != null) { writer.print(" id=\""); writer.print(event.getModuleId()); writer.println(QUOTE_CHAR); } writer.print(" query=\""); writer.print(xpathQuery); writer.println("\"/>"); } }

Target:
public void addError(AuditEvent event) { final String xpathQuery = XpathFileGeneratorAstFilter.findCorrespondingXpathQuery(event); if (xpathQuery != null) { printXmlHeader(); final File file = new File(event.getFileName()); writer.println("<suppress-xpath"); writer.print(" files=\""); writer.print(file.getName()); writer.println(QUOTE_CHAR); if (event.getModuleId() == null) { final String checkName = PackageObjectFactory.getShortFromFullModuleNames(event.getSourceName()); writer.print(" checks=\""); writer.print(checkName); } else { writer.print(" id=\""); writer.print(event.getModuleId()); } writer.println(QUOTE_CHAR); writer.print(" query=\""); writer.print(xpathQuery); writer.println("\"/>"); } }
Source:
@Test void testFilterWithProject() { assertModel(MODEL) .with(CalciteConnectionProperty.TOP_DOWN_OPT.camelName(), false) .query("SELECT STREAM MSG_PARTITION,MSG_OFFSET,MSG_VALUE_BYTES FROM KAFKA.MOCKTABLE" + " WHERE MSG_OFFSET>0") .limit(1) .returnsUnordered( "MSG_PARTITION=0; MSG_OFFSET=1; MSG_VALUE_BYTES=myvalue1") .explainContains( "PLAN=EnumerableCalc(expr#0..4=[{inputs}], expr#5=[0], expr#6=[>($t2, $t5)], MSG_PARTITION=[$t0], MSG_OFFSET=[$t2], MSG_VALUE_BYTES=[$t4], $condition=[$t6])\n" + " EnumerableInterpreter\n" + " BindableTableScan(table=[[KAFKA, MOCKTABLE, (STREAM)]])"); }

Target:
@Test void testFilterWithProject() { assertModel(MODEL) .with(CalciteConnectionProperty.TOPDOWN_OPT.camelName(), false) .query("SELECT STREAM MSG_PARTITION,MSG_OFFSET,MSG_VALUE_BYTES FROM KAFKA.MOCKTABLE" + " WHERE MSG_OFFSET>0") .limit(1) .returnsUnordered( "MSG_PARTITION=0; MSG_OFFSET=1; MSG_VALUE_BYTES=myvalue1") .explainContains( "PLAN=EnumerableCalc(expr#0..4=[{inputs}], expr#5=[0], expr#6=[>($t2, $t5)], MSG_PARTITION=[$t0], MSG_OFFSET=[$t2], MSG_VALUE_BYTES=[$t4], $condition=[$t6])\n" + " EnumerableInterpreter\n" + " BindableTableScan(table=[[KAFKA, MOCKTABLE, (STREAM)]])"); }
Source:
public void dump(Protocol protocol) { TP tp = (TP) protocol; boolean dump = false; dump = checkThreadPool((ThreadPoolExecutor) tp.getThreadPool(), "Regular") || dump; try { Field f = TP.class.getDeclaredField("internal_pool"); f.setAccessible(true); dump = checkThreadPool((ThreadPoolExecutor) f.get(tp), "Internal") || dump; } catch (Exception e) { log.error("Failed to get internal pool"); } TimeScheduler timer = tp.getTimer(); try { Field f = timer.getClass().getDeclaredField("pool"); f.setAccessible(true); dump = checkThreadPool((ThreadPoolExecutor) f.get(timer), "Timer") || dump; } catch (Exception e) { log.error("Failed to get timer thread pool: " + timer.getClass()); } if (dump) Utils.threadDump(); }

Target:
public void dump(Protocol protocol) { TP tp = (TP) protocol; boolean dump = false; dump = checkThreadPool((ThreadPoolExecutor) tp.getThreadPool(), "JGroups") || dump; try { Field f = TP.class.getDeclaredField("internal_pool"); f.setAccessible(true); dump = checkThreadPool((ThreadPoolExecutor) f.get(tp), "Internal") || dump; } catch (Exception e) { log.error("Failed to get internal pool"); } TimeScheduler timer = tp.getTimer(); try { Field f = timer.getClass().getDeclaredField("pool"); f.setAccessible(true); dump = checkThreadPool((ThreadPoolExecutor) f.get(timer), "Timer") || dump; } catch (Exception e) { log.error("Failed to get timer thread pool: " + timer.getClass()); } if (dump) Utils.threadDump(); }
Source:
public void write(CorfuPayloadMsg<WriteRequest> msg, ChannelHandlerContext ctx, IServerRouter r) { log.trace("log write: global: {}, streams: {}", msg.getPayload().getToken(), msg.getPayload().getData().getBackpointerMap()); try { LogData logData = (LogData) msg.getPayload().getData(); logData.setEpoch(msg.getEpoch()); dataCache.put(msg.getPayload().getGlobalAddress(), logData); r.sendResponse(ctx, msg, CorfuMsgType.WRITE_OK.msg()); } catch (OverwriteException ex) { r.sendResponse(ctx, msg, CorfuMsgType.ERROR_OVERWRITE.payloadMsg(ex.getOverWriteCause().getId())); } catch (DataOutrankedException e) { r.sendResponse(ctx, msg, CorfuMsgType.ERROR_DATA_OUTRANKED.msg()); } catch (ValueAdoptedException e) { r.sendResponse(ctx, msg, CorfuMsgType.ERROR_VALUE_ADOPTED.payloadMsg(e .getReadResponse())); } }

Target:
public void write(CorfuPayloadMsg<WriteRequest> msg, ChannelHandlerContext ctx, IServerRouter r) { log.debug("log write: global: {}, streams: {}", msg.getPayload().getToken(), msg.getPayload().getData().getBackpointerMap()); try { LogData logData = (LogData) msg.getPayload().getData(); logData.setEpoch(msg.getEpoch()); dataCache.put(msg.getPayload().getGlobalAddress(), logData); r.sendResponse(ctx, msg, CorfuMsgType.WRITE_OK.msg()); } catch (OverwriteException ex) { r.sendResponse(ctx, msg, CorfuMsgType.ERROR_OVERWRITE.payloadMsg(ex.getOverWriteCause().getId())); } catch (DataOutrankedException e) { r.sendResponse(ctx, msg, CorfuMsgType.ERROR_DATA_OUTRANKED.msg()); } catch (ValueAdoptedException e) { r.sendResponse(ctx, msg, CorfuMsgType.ERROR_VALUE_ADOPTED.payloadMsg(e .getReadResponse())); } }
Source:
private static ExpressionEvaluator getExpressionEvaluator(String transformExpression) { ExpressionEvaluator expressionEvaluator = null; if (transformExpression != null && !transformExpression.isEmpty()) { if (transformExpression.startsWith(GroovyExpressionEvaluator.getGroovyExpressionPrefix())) { expressionEvaluator = new GroovyExpressionEvaluator(transformExpression); } } return expressionEvaluator; }

Target:
private static ExpressionEvaluator getExpressionEvaluator(String transformExpression) { ExpressionEvaluator expressionEvaluator = null; if (transformExpression.startsWith(GroovyExpressionEvaluator.getGroovyExpressionPrefix())) { expressionEvaluator = new GroovyExpressionEvaluator(transformExpression); } return expressionEvaluator; }
Source:
void close() { isOpen.set(false); Iterator<DeleteOperation> iter = operationIdTodeleteOperation.values().iterator(); while (iter.hasNext()) { DeleteOperation deleteOperation = iter.next(); NonBlockingRouter.completeOperation(deleteOperation.getFutureResult(), deleteOperation.getCallback(), null, new RouterException("Cannot process operation because Router is closed.", RouterErrorCode.RouterClosed)); iter.remove(); } }

Target:
void close() { if (isOpen.compareAndSet(true, false)) { Iterator<DeleteOperation> iter = deleteOperations.iterator(); while (iter.hasNext()) { DeleteOperation deleteOperation = iter.next(); NonBlockingRouter.completeOperation(deleteOperation.getFutureResult(), deleteOperation.getCallback(), null, new RouterException("Aborted operation because Router is closed.", RouterErrorCode.RouterClosed)); iter.remove(); } } }
Source:
public Double getDouble() { if (byteBuffer.position() + 8 > limit) { throw new LimitReachedException(); } long aLong = byteBuffer.getLong(); return Double.longBitsToDouble(aLong); }

Target:
public Double getDouble() { if (byteBuffer.position() + 8 > limit) { throw new LimitReachedException(); } return byteBuffer.getDouble(); }
Source:
public void testNotEnoughForMultipleDiskAndDomainsAllDomainsFail() { ArrayList<DiskImage> imagesDisks = mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID, 4); imagesDisks.addAll(mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID2, 4)); doReturn(imagesDisks).when(cmd).getSourceImages(); mockStorageDomainDAOGetForStoragePool(10, STORAGE_DOMAIN_ID); mockStorageDomainDAOGetForStoragePool(10, STORAGE_DOMAIN_ID2); assertFalse("Validation should fail. Second domain should not have enough free space for request.", cmd.isEnoughSpaceToMergeSnapshots()); }

Target:
public void testNotEnoughForMultipleDiskAndDomainsAllDomainsFail() { List<DiskImage> imagesDisks = mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID, IMAGE_ACTUAL_SIZE_GB); imagesDisks.addAll(mockMultipleSourceImagesForDomain(4, STORAGE_DOMAIN_ID2, IMAGE_ACTUAL_SIZE_GB)); doReturn(imagesDisks).when(cmd).getSourceImages(); mockStorageDomainDAOGetForStoragePool(10, STORAGE_DOMAIN_ID); mockStorageDomainDAOGetForStoragePool(10, STORAGE_DOMAIN_ID2); assertFalse("Validation should fail. Second domain should not have enough free space for request.", cmd.isEnoughSpaceToMergeSnapshots()); }
Source:
public MappingProject cloneMappingProject(String mappingProjectId) { MappingProject mappingProject = mappingProjectRepository.getMappingProject(mappingProjectId); if (mappingProject == null) { throw new UnknownMappingProjectException(mappingProjectId); } String mappingProjectName = mappingProject.getName(); String clonedMappingProjectName; for (int i = 1; ; ++i) { if (i == 1) { clonedMappingProjectName = mappingProjectName + " - Copy"; } else { clonedMappingProjectName = mappingProjectName + " - Copy (" + i + ")"; } if (mappingProjectRepository.getMappingProjects(new QueryImpl<>().eq(NAME, clonedMappingProjectName)) .isEmpty()) { break; } } return cloneMappingProject(mappingProject, clonedMappingProjectName); }

Target:
public MappingProject cloneMappingProject(String mappingProjectId) { MappingProject mappingProject = mappingProjectRepository.getMappingProject(mappingProjectId); if (mappingProject == null) { throw new UnknownEntityException(mappingProjectMetaData, mappingProjectId); } String mappingProjectName = mappingProject.getName(); String clonedMappingProjectName; for (int i = 1; ; ++i) { if (i == 1) { clonedMappingProjectName = mappingProjectName + " - Copy"; } else { clonedMappingProjectName = mappingProjectName + " - Copy (" + i + ")"; } if (mappingProjectRepository.getMappingProjects(new QueryImpl<>().eq(NAME, clonedMappingProjectName)) .isEmpty()) { break; } } return cloneMappingProject(mappingProject, clonedMappingProjectName); }
Source:
public void testGetStartingSequenceNumberWhereCrossSettingStartNumberIsNull() { this.crossSetting.getCrossNameSetting().setStartNumber(null); final CrossNameSetting setting = new CrossNameSetting(); setting.setStartNumber(0); setting.setPrefix("A"); final int startingSequenceNumber = this.crossingService.getStartingSequenceNumber(setting); Assert.assertEquals("The starting sequence number should be " + startingSequenceNumber, CrossingServiceImplTest.NEXT_NUMBER.intValue(), startingSequenceNumber); }

Target:
public void testGetStartingSequenceNumberWhereCrossSettingStartNumberIsNull() { final CrossNameSetting setting = new CrossNameSetting(); setting.setStartNumber(null); setting.setPrefix("A"); final int startingSequenceNumber = this.crossingService.getStartingSequenceNumber(setting); Assert.assertEquals("The starting sequence number should be " + startingSequenceNumber, CrossingServiceImplTest.NEXT_NUMBER.intValue(), startingSequenceNumber); }
Source:
public void cloneForRevision_shouldSetAllTheRelevantFields() throws Exception { DrugOrder drugOrder = new DrugOrder(); Drug drug = new Drug(); drug.setConcept(new Concept()); drugOrder.setDrug(drug); OrderTest.assertThatAllFieldsAreCopied(drugOrder, "cloneForRevision", "creator", "dateCreated", "action", "changedBy", "dateChanged", "voided", "dateVoided", "voidedBy", "voidReason", "encounter", "orderNumber", "orderer", "previousOrder", "dateActivated", "dateStopped", "accessionNumber", "orderGroup", "sortWeight"); }

Target:
public void cloneForRevision_shouldSetAllTheRelevantFields() throws Exception { DrugOrder drugOrder = new DrugOrder(); Drug drug = new Drug(); drug.setConcept(new Concept()); drugOrder.setDrug(drug); OrderTest.assertThatAllFieldsAreCopied(drugOrder, "cloneForRevision", "creator", "dateCreated", "action", "changedBy", "dateChanged", "voided", "dateVoided", "voidedBy", "voidReason", "encounter", "orderNumber", "orderer", "previousOrder", "dateActivated", "dateStopped", "accessionNumber"); }
Source:
private void logFormStartEvent(boolean isFormReload){ try { JSONObject eventDetails = new JSONObject(); eventDetails.put("patientuuid", formData.getPatientUuid()); eventDetails.put("formDataUuid", formData.getUuid()); if (isEncounterForm()) { if(isFormReload) { logEvent("RESUME_ENCOUNTER_FORM", eventDetails.toString()); } else { logEvent("OPEN_ENCOUNTER_FORM", eventDetails.toString()); } } else { if(isFormReload) { logEvent("RESUME_REGISTRATION_FORM", eventDetails.toString()); } else { logEvent("OPEN_REGISTRATION_FORM", eventDetails.toString()); } } } catch (JSONException e) { Log.e(getClass().getSimpleName(),"Cannot create log",e); } }

Target:
private void logFormStartEvent(boolean isFormReload){ try { JSONObject eventDetails = new JSONObject(); eventDetails.put("patientuuid", formData.getPatientUuid()); eventDetails.put("formDataUuid", formData.getUuid()); eventDetails.put("formDiscriminator", formData.getDiscriminator()); if(isFormReload) { logEvent("RESUME_FORM", eventDetails.toString()); } else { logEvent("OPEN_FORM", eventDetails.toString()); } } catch (JSONException e) { Log.e(getClass().getSimpleName(),"Cannot create event log",e); } }
Source:
public void onUserRestrictionsChanged() { final Bundle restrictions = mUserManager.getUserRestrictions(); final boolean newlyDisallowed = restrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING); final boolean prevDisallowed = mDisallowTethering; mDisallowTethering = newlyDisallowed; final boolean tetheringDisallowedChanged = (newlyDisallowed != prevDisallowed); if (!tetheringDisallowedChanged) { return; } if (!newlyDisallowed) { mNotificationUpdater.tetheringRestrictionLifted(); return; } mNotificationUpdater.notifyTetheringDisabledByRestriction(); if (mWrapper.getTetheredIfaces().length != 0) { mWrapper.untetherAll(); } }

Target:
public void onUserRestrictionsChanged() { final Bundle restrictions = mUserManager.getUserRestrictions(); final boolean newlyDisallowed = restrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING); final boolean prevDisallowed = mDisallowTethering; mDisallowTethering = newlyDisallowed; final boolean tetheringDisallowedChanged = (newlyDisallowed != prevDisallowed); if (!tetheringDisallowedChanged) { return; } if (!newlyDisallowed) { mNotificationUpdater.tetheringRestrictionLifted(); return; } mNotificationUpdater.notifyTetheringDisabledByRestriction(); mWrapper.untetherAll(); }
Source:
public StartupErrorFilterModel(Throwable t) { errorAtStartup = t; StringWriter sw = new StringWriter(); log.error(t); stacktrace = sw.toString(); }

Target:
public StartupErrorFilterModel(Throwable t) { errorAtStartup = t; stacktrace = ExceptionUtils.getStackTrace(t); }
Source:
private void checkVersion(Object migrationMechanism, String expectedVersion) { Field field = migrationMechanism.getClass().getDeclaredFields()[0]; field.setAccessible(true); try { Object version = field.get(migrationMechanism); assertEquals("The migration mechanism doesn't have the expected version", expectedVersion, version); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }

Target:
private void checkVersion(Object migrationMechanism, String expectedVersion) { Field field = migrationMechanism.getClass().getDeclaredFields()[0]; field.setAccessible(true); try { Object version = field.get(migrationMechanism); assertEquals("The migration mechanism doesn't have the expected version", expectedVersion, version); } catch (IllegalArgumentException e) { fail("Cannot verify the migration version: " + e.getMessage()); } catch (SecurityException e) { fail("Cannot verify the migration version: " + e.getMessage()); } catch (IllegalAccessException e) { fail("Cannot verify the migration version: " + e.getMessage()); } }
Source:
public String toString() { StringBuilder sb = new StringBuilder("---------------- SyntaxContainer ---------------------"); sb.append("\n"); sb.append("mOrigText = "); sb.append(mOrigText); sb.append(LINE_SEPARATOR); sb.append("Valid = "); sb.append(Boolean.toString(mValid)); sb.append(LINE_SEPARATOR); sb.append("Error = "); sb.append(mError.toString()); sb.append(LINE_SEPARATOR); sb.append("CrossRefObjlist = "); for (String cro : getCrossRefObjList()) { sb.append(cro + ", "); } sb.append("Syntax object list:"); for (SyntaxObject obj : mObjList) { sb.append(" "); sb.append(LINE_SEPARATOR); sb.append(obj.toString()); } return sb.toString(); }

Target:
public String toString() { StringBuilder sb = new StringBuilder("---------------- SyntaxContainer ---------------------"); sb.append(LINE_SEPARATOR); sb.append("mOrigText = "); sb.append(mOrigText); sb.append(LINE_SEPARATOR); sb.append("Valid = "); sb.append(Boolean.toString(mValid)); sb.append(LINE_SEPARATOR); sb.append("Error = "); sb.append(mError.toString()); sb.append(LINE_SEPARATOR); sb.append("CrossRefObjlist = "); for (String cro : getCrossRefObjList()) { sb.append(cro).append(", "); } sb.append("Syntax object list:"); for (SyntaxObject obj : mObjList) { sb.append(" "); sb.append(LINE_SEPARATOR); sb.append(obj.toString()); } return sb.toString(); }
Source:
public static boolean isUpdateShow(String showId, long currentTime, Context context) { final Cursor show = context.getContentResolver().query(Shows.buildShowUri(showId), new String[] { Shows._ID, Shows.LASTUPDATED }, null, null, null); boolean update = false; if (show != null) { if (show.moveToFirst()) { long lastUpdateTime = show.getLong(1); if (currentTime - lastUpdateTime > DateUtils.HOUR_IN_MILLIS * 12) { update = true; } } show.close(); } return update; }

Target:
public static boolean isUpdateShow(String showId, long currentTime, Context context) { final Cursor show = context.getContentResolver().query(Shows.buildShowUri(showId), new String[] { Shows._ID, Shows.LASTUPDATED }, null, null, null); boolean isUpdate = false; if (show != null) { if (show.moveToFirst()) { long lastUpdateTime = show.getLong(1); if (currentTime - lastUpdateTime > DateUtils.HOUR_IN_MILLIS * 12) { isUpdate = true; } } show.close(); } return isUpdate; }
Source:
public List<Patient> getAll() { List<Patient> patients = new ArrayList<>(); try { session = hibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("select new Patient(p) from Patient p"); patients = query.list(); LOG.trace("DAO-getAll-patients-count: " + patients.size()); } catch (HibernateException e) { LOG.error("Could not retrieve users: {}", e.getLocalizedMessage(), e); } finally { HibernateUtil.closeSession(session, false); } return patients; }

Target:
public List<Patient> getAll() { List<Patient> patients = new ArrayList<>(); try { session = hibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("select new Patient(p) from Patient p"); patients = query.list(); LOG.trace("DAO-getAll-patients-count: {}" , patients.size()); } catch (HibernateException e) { LOG.error("Could not retrieve users: {}", e.getLocalizedMessage(), e); } finally { HibernateUtil.closeSession(session, false); } return patients; }
Source:
private boolean isValidWeightSize() { if (rubricWeightsForEachCell.size() != numOfRubricSubQuestions) { return false; } for (int i = 0; i < rubricWeightsForEachCell.size(); i++) { if (rubricWeightsForEachCell.get(i).size() != numOfRubricChoices) { return false; } } return true; }

Target:
private boolean isValidWeightSize() { if (rubricWeightsForEachCell.size() != numOfRubricSubQuestions) { return false; } return rubricWeightsForEachCell.stream().allMatch(x -> x.size() == numOfRubricChoices); }
Source:
private AuditLogable createExternalMacsAuditLog(VM vm, Set<String> externalMacs) { AuditLogable logable = new AuditLogableImpl(); logable.setVmName(vm.getName()); logable.addCustomValue("MACAddr", externalMacs.stream().collect(Collectors.joining(", "))); return logable; }

Target:
private AuditLogable createExternalMacsAuditLog(VM vm, Set<String> externalMacs) { AuditLogable logable = new AuditLogableImpl(); logable.setVmId(vm.getId()); logable.setVmName(vm.getName()); logable.addCustomValue("MACAddr", externalMacs.stream().collect(Collectors.joining(", "))); return logable; }
Source:
public @ResponseBody CacheStatus getCacheStatus() { CacheStatus response = new CacheStatus(); CacheManager manager = CacheManager.getInstance(); boolean anyPending = false; List<String> cacheNames = CacheInitializor.getPreInitializedCaches(); for(int i = 0; i < cacheNames.size(); i++) { Cache currCache = manager.getCache(cacheNames.get(i)); if(currCache == null || currCache.getKeysNoDuplicateCheck().size() == 0) { anyPending = true; } } if(anyPending) { response.setStatus(CacheStatusName.PENDING.name()); } else { response.setStatus(CacheStatusName.OK.name()); } return response; }

Target:
public @ResponseBody CacheStatus getCacheStatus() { CacheStatus response = new CacheStatus(); CacheManager manager = CacheManager.getInstance(); boolean anyPending = false; List<String> cacheNames = CacheInitializor.getPreInitializedCaches(); for (int i = 0; i < cacheNames.size(); i++) { Cache currCache = manager.getCache(cacheNames.get(i)); if (currCache == null || currCache.getKeysNoDuplicateCheck().size() == 0) { anyPending = true; } } if (anyPending) { response.setStatus(CacheStatusName.INITIALIZING.name()); } else { response.setStatus(CacheStatusName.OK.name()); } return response; }
Source:
public void testAssignable() { System.out.println("Integer.class.isAssignable: " + Integer.class.isAssignableFrom(Number.class)); System.out.println("Number.class.isAssignable : " + Number.class.isAssignableFrom(Integer.class)); System.out.println("Double.class.isAssignable : " + Double.class.isAssignableFrom(Integer.class)); System.out.println("Integer.class.isAssignable: " + Integer.class.isAssignableFrom(Double.class)); System.out.println("Number.class.isAssignable : " + Number.class.isAssignableFrom(int.class)); System.out.println("Integer.class.isAssignable: " + Integer.class.isAssignableFrom(int.class)); System.out.println("int.class.isAssignable : " + int.class.isAssignableFrom(Integer.class)); }

Target:
public void testAssignable() { assertFalse("Integer.class.isAssignable: ", Integer.class.isAssignableFrom(Number.class)); assertTrue("Number.class.isAssignable : ", Number.class.isAssignableFrom(Integer.class)); assertFalse("Double.class.isAssignable : ", Double.class.isAssignableFrom(Integer.class)); assertFalse("Integer.class.isAssignable: ", Integer.class.isAssignableFrom(Double.class)); assertFalse("Number.class.isAssignable : ", Number.class.isAssignableFrom(int.class)); assertFalse("Integer.class.isAssignable: ", Integer.class.isAssignableFrom(int.class)); assertFalse("int.class.isAssignable : ", int.class.isAssignableFrom(Integer.class)); }
Source:
private Set<Guid> getVolumeChain() { List<String> vmIds = new ArrayList<>(); vmIds.add(getParameters().getVmId().toString()); VDS vds = getVdsDAO().get(getParameters().getVdsId()); Map[] vms = (Map[]) (new FullListVDSCommand<>( new FullListVDSCommandParameters(vds, vmIds)).executeWithReturnValue()); if (vms == null || vms.length == 0) { log.error("Failed to retrieve VM information"); return null; } Map vm = (Map) vms[0]; if (vm == null || vm.get(VdsProperties.vm_guid) == null) { log.error("Received incomplete VM information"); return null; } Guid vmId = new Guid((String) vm.get(VdsProperties.vm_guid)); if (!vmId.equals(getParameters().getVmId())) { log.error("Invalid VM returned when querying status: expected '{}', got '{}'", getParameters().getVmId(), vmId); return null; } Set<Guid> images = new HashSet<>(); DiskImage activeDiskImage = getParameters().getActiveImage(); for (Object o : (Object[]) vm.get(VdsProperties.Devices)) { Map device = (Map<String, Object>) o; if (VdsProperties.Disk.equals(device.get(VdsProperties.Type)) && activeDiskImage.getId().equals(Guid.createGuidFromString( (String) device.get(VdsProperties.ImageId)))) { Object[] volumeChain = (Object[]) device.get("volumeChain"); for (Object v : volumeChain) { Map<String, Object> volume = (Map<String, Object>) v; images.add(Guid.createGuidFromString((String) volume.get(VdsProperties.VolumeId))); } break; } } return images; }

Target:
private Set<Guid> getVolumeChain() { List<String> vmIds = new ArrayList<>(); vmIds.add(getParameters().getVmId().toString()); VDS vds = getVdsDAO().get(getParameters().getVdsId()); Map[] vms = (Map[]) runVdsCommand( VDSCommandType.FullList, new FullListVDSCommandParameters(vds, vmIds)).getReturnValue(); if (vms == null || vms.length == 0) { log.error("Failed to retrieve VM information"); return null; } Map vm = (Map) vms[0]; if (vm == null || vm.get(VdsProperties.vm_guid) == null) { log.error("Received incomplete VM information"); return null; } Guid vmId = new Guid((String) vm.get(VdsProperties.vm_guid)); if (!vmId.equals(getParameters().getVmId())) { log.error("Invalid VM returned when querying status: expected '{}', got '{}'", getParameters().getVmId(), vmId); return null; } Set<Guid> images = new HashSet<>(); DiskImage activeDiskImage = getParameters().getActiveImage(); for (Object o : (Object[]) vm.get(VdsProperties.Devices)) { Map device = (Map<String, Object>) o; if (VdsProperties.Disk.equals(device.get(VdsProperties.Type)) && activeDiskImage.getId().equals(Guid.createGuidFromString( (String) device.get(VdsProperties.ImageId)))) { Object[] volumeChain = (Object[]) device.get("volumeChain"); for (Object v : volumeChain) { Map<String, Object> volume = (Map<String, Object>) v; images.add(Guid.createGuidFromString((String) volume.get(VdsProperties.VolumeId))); } break; } } return images; }
Source:
protected void calcRepulsion(N node1) { Point fvd1 = getFRData(node1); if (fvd1 == null) { return; } frNodeData.put(node1, Point.ORIGIN); ForceObject<N> nodeForceObject = new ForceObject(node1, layoutModel.apply(node1)) { @Override protected void addForceFrom(ForceObject other, Optional userData) { double dx = this.p.x - other.p.x; double dy = this.p.y - other.p.y; log.trace("dx, dy:{},{}", dx, dy); double dist = Math.sqrt(dx * dx + dy * dy); dist = Math.max(EPSILON, dist); log.trace("dist:{}", dist); double force = (repulsion_constant * repulsion_constant) / dist; log.trace("force:{}", force); f = f.add(force * (dx / dist), force * (dy / dist)); } }; tree.visit(nodeForceObject, Optional.empty()); frNodeData.put(node1, nodeForceObject.f); }

Target:
protected void calcRepulsion(N node1) { Point fvd1 = getFRData(node1); if (fvd1 == null) { return; } frNodeData.put(node1, Point.ORIGIN); ForceObject<N> nodeForceObject = new ForceObject(node1, layoutModel.apply(node1)) { @Override protected void addForceFrom(ForceObject other) { double dx = this.p.x - other.p.x; double dy = this.p.y - other.p.y; log.trace("dx, dy:{},{}", dx, dy); double dist = Math.sqrt(dx * dx + dy * dy); dist = Math.max(EPSILON, dist); log.trace("dist:{}", dist); double force = (repulsion_constant * repulsion_constant) / dist; log.trace("force:{}", force); f = f.add(force * (dx / dist), force * (dy / dist)); } }; tree.visit(nodeForceObject); frNodeData.put(node1, nodeForceObject.f); }
Source:
public void setReturnValueFailure(VDSReturnValue returnValueFailure) { setSucceeded(false); final EngineFault engineFault = new EngineFault(); engineFault.setError(returnValueFailure.getVdsError().getCode()); engineFault.setMessage(returnValueFailure.getVdsError().getMessage()); getReturnValue().setFault(engineFault); }

Target:
public void setReturnValueFailure(VDSReturnValue returnValueFailure) { final EngineFault engineFault = new EngineFault(); engineFault.setError(returnValueFailure.getVdsError().getCode()); engineFault.setMessage(returnValueFailure.getVdsError().getMessage()); getReturnValue().setFault(engineFault); }
Source:
public List<InputRow> parseBatch(Map<String, Object> theMap) { final List<String> dimensions = parseSpec.getDimensionsSpec().hasCustomDimensions() ? parseSpec.getDimensionsSpec().getDimensionNames() : new ArrayList<>( Sets.difference( theMap.keySet(), parseSpec.getDimensionsSpec() .getDimensionExclusions() ) ); final DateTime timestamp; try { timestamp = parseSpec.getTimestampSpec().extractTimestamp(theMap); if (timestamp == null) { final String input = theMap.toString(); throw new NullPointerException( StringUtils.format( "Null timestamp in input: %s", input.length() < 100 ? input : input.substring(0, 100) + "..." ) ); } } catch (Exception e) { throw new ParseException(e, "Unparseable timestamp found! Event: %s", theMap); } return ImmutableList.of(new MapBasedInputRow(timestamp.getMillis(), dimensions, theMap)); }

Target:
public List<InputRow> parseBatch(Map<String, Object> theMap) { final List<String> dimensions = parseSpec.getDimensionsSpec().hasCustomDimensions() ? parseSpec.getDimensionsSpec().getDimensionNames() : Lists.newArrayList( Sets.difference( theMap.keySet(), parseSpec.getDimensionsSpec() .getDimensionExclusions() ) ); final DateTime timestamp; try { timestamp = parseSpec.getTimestampSpec().extractTimestamp(theMap); if (timestamp == null) { final String input = theMap.toString(); throw new NullPointerException( StringUtils.format( "Null timestamp in input: %s", input.length() < 100 ? input : input.substring(0, 100) + "..." ) ); } } catch (Exception e) { throw new ParseException(e, "Unparseable timestamp found! Event: %s", theMap); } return ImmutableList.of(new MapBasedInputRow(timestamp.getMillis(), dimensions, theMap)); }
Source:
public ImmutableList<Double> values() { ImmutableList.Builder<Double> builder = ImmutableList.builder(); valueStream().forEach(builder::add); return builder.build(); }

Target:
public DoubleStream values() { return Arrays.stream(points).filter(this::isValidPoint); }
Source:
public void shouldCorrectlyPropagateDeltaToSecondaryServer_whenAppending() { String key = "key"; String baseValue = "value-"; jedis1.set(key, baseValue); for (int i = 0; i < SET_SIZE; i++) { jedis1.set(key, String.valueOf(i)); String server1LocalValue = server1.invoke(() -> { InternalCache cache = ClusterStartupRule.getCache(); Region<ByteArrayWrapper, RedisData> region = cache.getRegion("__REDIS_DATA"); Region<ByteArrayWrapper, RedisData> localRegion = PartitionRegionHelper.getLocalData(region); RedisData localValue = localRegion.get(new ByteArrayWrapper(key.getBytes())); return localValue.toString(); }); String server2LocalValue = server2.invoke(() -> { InternalCache cache = ClusterStartupRule.getCache(); Region<ByteArrayWrapper, RedisData> region = cache.getRegion("__REDIS_DATA"); Region<ByteArrayWrapper, RedisData> localRegion = PartitionRegionHelper.getLocalData(region); RedisData localValue = localRegion.get(new ByteArrayWrapper(key.getBytes())); return localValue.toString(); }); assertThat(server1LocalValue).isEqualTo(server2LocalValue); } }

Target:
public void shouldCorrectlyPropagateDeltaToSecondaryServer_whenAppending() { String key = "key"; String baseValue = "value-"; jedis1.set(key, baseValue); for (int i = 0; i < ITERATION_COUNT; i++) { jedis1.append(key, String.valueOf(i)); byte[] server1LocalValue = server1.invoke(() -> (byte[]) getLocalData(key, r -> { RedisData localValue = r.get(new ByteArrayWrapper(key.getBytes())); try { return BlobHelper.serializeToBlob(localValue); } catch (IOException e) { throw new RuntimeException(e); } })); byte[] server2LocalValue = server2.invoke(() -> (byte[]) getLocalData(key, r -> { RedisData localValue = r.get(new ByteArrayWrapper(key.getBytes())); try { return BlobHelper.serializeToBlob(localValue); } catch (IOException e) { throw new RuntimeException(e); } })); assertThat(Arrays.equals(server1LocalValue, server2LocalValue)); } }
Source:
public TaskStateModel createNewStateModel(String resourceName, String partitionKey) { if (_taskExecutor == null) { int taskThreadPoolSize = getTaskThreadPoolSize(); updateLiveInstanceWithThreadPoolSize(taskThreadPoolSize); initializeTaskExecutor(taskThreadPoolSize); initializeTaskMonitor(); } return new TaskStateModel(_manager, _taskFactoryRegistry, _taskExecutor, _timerTaskExecutor); }

Target:
public TaskStateModel createNewStateModel(String resourceName, String partitionKey) { return new TaskStateModel(_manager, _taskFactoryRegistry, _taskExecutor, _timerTaskExecutor); }
Source:
public boolean isFulfilled(@NonNull ITmfTrace trace) { if (trace instanceof ITmfTraceWithPreDefinedEvents) { @SuppressWarnings("null") Map<@NonNull String, @NonNull Collection<@NonNull String>> traceEvents = TmfEventTypeCollectionHelper.getEventFieldNames((((ITmfTraceWithPreDefinedEvents) trace).getContainedEventTypes())); Set<String> mandatoryValues = getValues(ValuePriorityLevel.MANDATORY); for (String eventType : fEventTypes) { Collection<String> fields = traceEvents.get(eventType); if (fields != null) { return fields.containsAll(mandatoryValues); } } return false; } return true; }

Target:
public boolean isFulfilled(@NonNull ITmfTrace trace) { if ((trace instanceof ITmfTraceWithPreDefinedEvents) && fEventNames.iterator().hasNext()) { Multimap<@NonNull String, @NonNull String> traceEvents = TmfEventTypeCollectionHelper.getEventFieldNames((((ITmfTraceWithPreDefinedEvents) trace).getContainedEventTypes())); Set<String> mandatoryValues = getValues(ValuePriorityLevel.MANDATORY); for (String eventType : fEventNames) { Collection<@NonNull String> fields = traceEvents.get(eventType); return fields.containsAll(mandatoryValues); } return false; } return true; }
Source:
private static void addHostBondDevices(VDS vds, Map<String, Object> xmlRpcStruct) { Map<String, Map<String, Object>> bonds = (Map<String, Map<String, Object>>) xmlRpcStruct.get(VdsProperties.NETWORK_BONDINGS); if (bonds != null) { for (Entry<String, Map<String, Object>> entry : bonds.entrySet()) { VdsNetworkInterface iface = new Bond(); updateCommonInterfaceData(iface, vds, entry); iface.setBonded(true); Map<String, Object> bond = entry.getValue(); if (bond != null) { iface.setMacAddress((String) bond.get("hwaddr")); if (bond.get("slaves") != null) { addBondDeviceToHost(vds, iface, (Object[]) bond.get("slaves")); } Object bondOptions = null; if (FeatureSupported.cfgEntriesDeprecated(vds.getVdsGroupCompatibilityVersion())) { bondOptions = bond.get("opts"); } else { Map<String, Object> config = (Map<String, Object>) bond.get("cfg"); bondOptions = (config == null) ? null : config.get("BONDING_OPTS"); } if (bondOptions != null) { iface.setBondOptions(bondOptions.toString()); } } } } }

Target:
private static void addHostBondDevices(VDS vds, Map<String, Object> xmlRpcStruct) { Map<String, Map<String, Object>> bonds = (Map<String, Map<String, Object>>) xmlRpcStruct.get(VdsProperties.NETWORK_BONDINGS); if (bonds != null) { boolean cfgEntriesDeprecated = FeatureSupported.cfgEntriesDeprecated(vds.getVdsGroupCompatibilityVersion()); for (Entry<String, Map<String, Object>> entry : bonds.entrySet()) { VdsNetworkInterface iface = new Bond(); updateCommonInterfaceData(iface, vds, entry); iface.setBonded(true); Map<String, Object> bond = entry.getValue(); if (bond != null) { iface.setMacAddress((String) bond.get("hwaddr")); if (bond.get("slaves") != null) { addBondDeviceToHost(vds, iface, (Object[]) bond.get("slaves")); } Object bondOptions = null; if (cfgEntriesDeprecated) { bondOptions = bond.get("opts"); } else { Map<String, Object> config = (Map<String, Object>) bond.get("cfg"); bondOptions = (config == null) ? null : config.get("BONDING_OPTS"); } if (bondOptions != null) { iface.setBondOptions(bondOptions.toString()); } } } } }
Source:
public void edit(final UnitVmModel model) { Driver.driver.edit(model); model.getStorageDomain().getItemsChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { addDiskAllocation(model); } }); model.getStorageDomain().getPropertyChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { boolean isDisksAllocationEnabled = model.getDisks() != null && !model.getDisks().isEmpty(); disksAllocationView.setEnabled(isDisksAllocationEnabled); disksAllocationLabel.getElement().getStyle().setColor(isDisksAllocationEnabled ? "black" : "grey"); } }); model.getPropertyChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { String propName = ((PropertyChangedEventArgs) args).PropertyName; if ("Message".equals(propName)) { VmMakeTemplatePopupWidget.this.setMessage(model.getMessage()); } } }); }

Target:
public void edit(final UnitVmModel model) { Driver.driver.edit(model); model.getStorageDomain().getItemsChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { addDiskAllocation(model); } }); model.getStorageDomain().getPropertyChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { boolean isDisksAllocationEnabled = model.getDisks() != null && !model.getDisks().isEmpty(); disksAllocationView.setEnabled(isDisksAllocationEnabled); disksAllocationLabel.getElement().getStyle().setColor(isDisksAllocationEnabled ? "black" : "grey"); } }); model.getPropertyChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { String propName = ((PropertyChangedEventArgs) args).PropertyName; if ("Message".equals(propName)) { appendMessage(model.getMessage()); } } }); }
Source:
protected ShoppingListUpdateCommand buildRequest(final ShoppingList wishlist, final RemoveWishlistLineItemFormData removeWishlistFormData) { final LineItem lineItemToRemove = wishlist.getLineItems().stream() .filter(lineItem -> removeWishlistFormData.lineItemId().equals(lineItem.getId())) .findFirst() .get(); final RemoveLineItem removeLineItem = RemoveLineItem.of(lineItemToRemove); return ShoppingListUpdateCommand.of(wishlist, removeLineItem); }

Target:
protected ShoppingListUpdateCommand buildRequest(final ShoppingList wishlist, final RemoveWishlistLineItemFormData removeWishlistFormData) { final RemoveLineItem removeLineItem = RemoveLineItem.of(removeWishlistFormData.lineItemId()); return ShoppingListUpdateCommand.of(wishlist, removeLineItem); }
Source:
public Map<String, Object> toObject() { final HashMap<String, Object> flowObj = new HashMap<>(); fillMapFromExecutable(flowObj); flowObj.put(EXECUTIONID_PARAM, this.executionId); flowObj.put(EXECUTIONPATH_PARAM, this.executionPath); flowObj.put(PROJECTID_PARAM, this.projectId); flowObj.put(PROJECTNAME_PARAM, this.projectName); if (this.scheduleId >= 0) { flowObj.put(SCHEDULEID_PARAM, this.scheduleId); } flowObj.put(SUBMITUSER_PARAM, this.submitUser); flowObj.put(VERSION_PARAM, this.version); flowObj.put(LASTMODIFIEDTIME_PARAM, this.lastModifiedTimestamp); flowObj.put(LASTMODIFIEDUSER_PARAM, this.lastModifiedUser); flowObj.put(AZKABANFLOWVERSION_PARAM, this.azkabanFlowVersion); flowObj.put(EXECUTIONOPTIONS_PARAM, this.executionOptions.toObject()); final ArrayList<String> proxyUserList = new ArrayList<>(this.proxyUsers); flowObj.put(PROXYUSERS_PARAM, proxyUserList); flowObj.put(SUBMITTIME_PARAM, this.submitTime); final List<Map<String, Object>> slaOptions = new ArrayList<>(); this.executionOptions.getSlaOptions().stream() .forEach((slaOption) -> slaOptions.add(slaOption.toObject())); flowObj.put(SLAOPTIONS_PARAM, slaOptions); return flowObj; }

Target:
public Map<String, Object> toObject() { final HashMap<String, Object> flowObj = new HashMap<>(); fillMapFromExecutable(flowObj); flowObj.put(EXECUTIONID_PARAM, this.executionId); flowObj.put(EXECUTIONPATH_PARAM, this.executionPath); flowObj.put(PROJECTID_PARAM, this.projectId); flowObj.put(PROJECTNAME_PARAM, this.projectName); if (this.scheduleId >= 0) { flowObj.put(SCHEDULEID_PARAM, this.scheduleId); } flowObj.put(SUBMITUSER_PARAM, this.submitUser); flowObj.put(VERSION_PARAM, this.version); flowObj.put(LASTMODIFIEDTIME_PARAM, this.lastModifiedTimestamp); flowObj.put(LASTMODIFIEDUSER_PARAM, this.lastModifiedUser); flowObj.put(AZKABANFLOWVERSION_PARAM, this.azkabanFlowVersion); flowObj.put(EXECUTIONOPTIONS_PARAM, this.executionOptions.toObject()); final ArrayList<String> proxyUserList = new ArrayList<>(this.proxyUsers); flowObj.put(PROXYUSERS_PARAM, proxyUserList); flowObj.put(SUBMITTIME_PARAM, this.submitTime); final List<Map<String, Object>> slaOptions = new ArrayList<>(); this.executionOptions.getSlaOptions().stream() .forEach((slaOption) -> slaOptions.add(slaOption.toObject())); flowObj.put(SLAOPTIONS_PARAM, slaOptions); flowObj.put(IS_LOCKED_PARAM, this.isLocked); return flowObj; }
Source:
public boolean start() throws Exception { Cloud cloud = Jenkins.getActiveInstance().getCloud(step.getCloud()); if (cloud == null) { throw new AbortException(String.format("Cloud does not exist: %s", step.getCloud())); } if (!(cloud instanceof KubernetesCloud)) { throw new AbortException(String.format("Cloud is not a Kubernetes cloud: %s (%s)", step.getCloud(), cloud.getClass().getName())); } KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud; String name = String.format(NAME_FORMAT, UUID.randomUUID().toString().replaceAll("-", "")); PodTemplateAction action = new PodTemplateAction(step.getRun()); PodTemplate newTemplate = new PodTemplate(); newTemplate.setName(name); newTemplate.setInheritFrom(!Strings.isNullOrEmpty( action.getParentTemplates()) ? action.getParentTemplates() : step.getInheritFrom()); newTemplate.setInstanceCap(step.getInstanceCap()); newTemplate.setLabel(step.getLabel()); newTemplate.setVolumes(step.getVolumes()); newTemplate.setCustomWorkspaceVolumeEnabled(step.getWorkspaceVolume() != null); newTemplate.setWorkspaceVolume(step.getWorkspaceVolume()); newTemplate.setContainers(step.getContainers()); newTemplate.setNodeSelector(step.getNodeSelector()); newTemplate.setServiceAccount(step.getServiceAccount()); newTemplate.setAnnotations(step.getAnnotations()); kubernetesCloud.addTemplate(newTemplate); getContext().newBodyInvoker() .withCallback(new PodTemplateCallback(newTemplate)) .start(); action.push(step.getLabel()); return false; }

Target:
public boolean start() throws Exception { Cloud cloud = Jenkins.getInstance().getCloud(step.getCloud()); if (cloud == null) { throw new AbortException(String.format("Cloud does not exist: %s", step.getCloud())); } if (!(cloud instanceof KubernetesCloud)) { throw new AbortException(String.format("Cloud is not a Kubernetes cloud: %s (%s)", step.getCloud(), cloud.getClass().getName())); } KubernetesCloud kubernetesCloud = (KubernetesCloud) cloud; String name = String.format(NAME_FORMAT, UUID.randomUUID().toString().replaceAll("-", "")); PodTemplateAction action = new PodTemplateAction(getContext().get(Run.class)); PodTemplate newTemplate = new PodTemplate(); newTemplate.setName(name); newTemplate.setInheritFrom(!Strings.isNullOrEmpty( action.getParentTemplates()) ? action.getParentTemplates() : step.getInheritFrom()); newTemplate.setInstanceCap(step.getInstanceCap()); newTemplate.setLabel(step.getLabel()); newTemplate.setVolumes(step.getVolumes()); newTemplate.setCustomWorkspaceVolumeEnabled(step.getWorkspaceVolume() != null); newTemplate.setWorkspaceVolume(step.getWorkspaceVolume()); newTemplate.setContainers(step.getContainers()); newTemplate.setNodeSelector(step.getNodeSelector()); newTemplate.setServiceAccount(step.getServiceAccount()); newTemplate.setAnnotations(step.getAnnotations()); kubernetesCloud.addTemplate(newTemplate); getContext().newBodyInvoker().withContext(step).withCallback(new PodTemplateCallback(newTemplate)).start(); action.push(step.getLabel()); return false; }
Source:
private static void restoreViews() { for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) { for (IWorkbenchPage page : window.getPages()) { for (IViewReference ref : page.getViewReferences()) { IViewPart view = ref.getView(false); if (view instanceof TmfView && view instanceof ITmfTimeAligned) { ITmfTimeAligned alignedView = (ITmfTimeAligned) view; alignedView.performAlign(alignedView.getTimeViewAlignmentInfo().getTimeAxisOffset(), Integer.MAX_VALUE); } } } } }

Target:
private static void restoreViews() { for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) { for (IWorkbenchPage page : window.getPages()) { for (IViewReference ref : page.getViewReferences()) { restoreView(ref); } } } }
Source:
public void testLargeData() { int length = 123456789; byte[] expected = new byte[length]; ThreadLocalRandom.current().nextBytes(expected); List<byte[]> buffers = new ArrayList<>(); int copyBytes = 0; while (copyBytes < length) { int currentLength = min(length - copyBytes, ThreadLocalRandom.current().nextInt(1 << 20) + 64); buffers.add(Arrays.copyOfRange(expected, copyBytes, copyBytes + currentLength)); copyBytes += currentLength; } try (GatheringByteArrayInputStream in = new GatheringByteArrayInputStream(buffers, length)) { byte[] actual = new byte[length]; copyBytes = 0; while (copyBytes < length) { int currentLength = min(length - copyBytes, ThreadLocalRandom.current().nextInt(1 << 20) + 64); assertEquals(in.read(actual, copyBytes, currentLength), currentLength); assertByteArrayEquals(actual, copyBytes, expected, copyBytes, currentLength); copyBytes += currentLength; } assertEquals(in.skip(100), 0); assertEquals(in.read(), -1); } }

Target:
public void testLargeData() { int length = 123456789; Random random = new Random(0); byte[] expected = new byte[length]; random.nextBytes(expected); List<byte[]> buffers = new ArrayList<>(); int copyBytes = 0; while (copyBytes < length) { int currentLength = min(length - copyBytes, random.nextInt(1 << 20) + 64); buffers.add(Arrays.copyOfRange(expected, copyBytes, copyBytes + currentLength)); copyBytes += currentLength; } try (GatheringByteArrayInputStream in = new GatheringByteArrayInputStream(buffers, length)) { byte[] actual = new byte[length]; copyBytes = 0; while (copyBytes < length) { int currentLength = min(length - copyBytes, random.nextInt(1 << 20) + 64); assertEquals(in.read(actual, copyBytes, currentLength), currentLength); assertByteArrayEquals(actual, copyBytes, expected, copyBytes, currentLength); copyBytes += currentLength; } assertEquals(in.skip(100), 0); assertEquals(in.read(), -1); } }
Source:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + (readOnly ? 1231 : 1237); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((appMode == null) ? ApplicationMode.VirtOnly.getValue() : appMode.getValue()); return result; }

Target:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + (readOnly ? 1231 : 1237); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((appMode == null) ? 0 : appMode.getValue()); return result; }