auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void setupPropertiesForPySpark(Properties sparkProperties) { Object pysparkBaseProperty = new DefaultInterpreterProperty("SPARK_HOME", null, null).getValue(); String pysparkBasePath = pysparkBaseProperty != null ? pysparkBaseProperty.toString() : null; File pysparkPath; if (null == pysparkBasePath) { pysparkBasePath = new DefaultInterpreterProperty("ZEPPELIN_HOME", "zeppelin.home", "../") .getValue().toString(); pysparkPath = new File(pysparkBasePath, "interpreter" + File.separator + "spark" + File.separator + "pyspark"); } else { pysparkPath = new File(pysparkBasePath, "python" + File.separator + "lib"); } String[] pythonLibs = new String[]{"pyspark.zip", "py4j-0.9-src.zip", "py4j-0.8.2.1-src.zip", "py4j-0.10.1-src.zip", "py4j-0.10.3-src.zip", "py4j-0.10.4-src.zip"}; ArrayList<String> pythonLibUris = new ArrayList<>(); for (String lib : pythonLibs) { File libFile = new File(pysparkPath, lib); if (libFile.exists()) { pythonLibUris.add(libFile.toURI().toString()); } } pythonLibUris.trimToSize(); if (pythonLibUris.size() == 2) { String confValue = sparkProperties.getProperty("spark.yarn.dist.files"); if (confValue == null) { sparkProperties.setProperty("spark.yarn.dist.files", Joiner.on(",").join(pythonLibUris)); } else { sparkProperties.setProperty("spark.yarn.dist.files", confValue + "," + Joiner.on(",").join(pythonLibUris)); } sparkProperties.setProperty("spark.files", sparkProperties.getProperty("spark.yarn.dist.files")); sparkProperties.setProperty("spark.submit.pyArchives", Joiner.on(":").join(pythonLibs)); sparkProperties.setProperty("spark.submit.pyFiles", Joiner.on(",").join(pythonLibUris)); } }

Target:
private void setupPropertiesForPySpark(Properties sparkProperties) { if (isYarnMode()) { sparkProperties.setProperty("spark.yarn.isPython", "true"); } }
Source:
private boolean checkIfUserHasPermissionToManageStudentsInCourse() { boolean canManageStudents=false; String url = Utils.urlConstructor(Utils.URL_CHUNK_COURSES, courseId,"/permissions?as_user_id=",canvasUserId); ApiResultWrapper arw = Utils.makeApiCall(new HttpGet(url)); String errMsg=String.format("The Permission check to grant access to the tool failed with status code %s due to %s in the course %s for the user %s" ,arw.getStatus(),(arw.getApiResp().isEmpty()) ? arw.getMessage() : arw.getApiResp(),courseId,canvasUserId); if (!Utils.didApiReturnedWithOutErrors(errMsg, arw)) { return canManageStudents; } JSONObject permissionJson = new JSONObject(arw.getApiResp()); if (!permissionJson.isNull("manage_students")) { canManageStudents = (boolean) permissionJson.get("manage_students"); } return canManageStudents; }

Target:
private boolean checkIfUserHasPermissionToManageStudentsInCourse() { boolean canManageStudents = false; String url = Utils.urlConstructor(Utils.URL_CHUNK_COURSES, courseId, "/permissions?as_user_id=", canvasUserId); ApiResultWrapper arw = Utils.makeApiCall(new HttpGet(url)); String errMsgString = "The Permission check to grant access to the tool failed with status code %s due to %s in the course %s for the user %s"; String apiResp = arw.getApiResp(); String errMsg = String.format(errMsgString, arw.getStatus(), (apiResp.isEmpty()) ? arw.getMessage() : apiResp, courseId, canvasUserId); if (!Utils.didApiReturnedWithOutErrors(errMsg, arw)) { return canManageStudents; } JSONObject permissionJson = new JSONObject(apiResp); if (!permissionJson.isNull("manage_students")) { canManageStudents = (boolean) permissionJson.get("manage_students"); } return canManageStudents; }
Source:
private static String unescapeJavaAndTrim(String resourceUrl) { int startInclusiveIndex = 0; while (startInclusiveIndex < resourceUrl.length() && resourceUrl.charAt(startInclusiveIndex) == Paths.ROOT_CHAR) { startInclusiveIndex++; } if (startInclusiveIndex == resourceUrl.length()) { return ""; } int endExclusiveIndex = resourceUrl.length(); while (endExclusiveIndex > startInclusiveIndex && resourceUrl.charAt(endExclusiveIndex - 1) == Paths.ROOT_CHAR) { endExclusiveIndex--; } for (int startLoopIndex = startInclusiveIndex; startLoopIndex < endExclusiveIndex; startLoopIndex++) { if (resourceUrl.charAt(startLoopIndex)== Paths.ESCAPE_CHAR) { return StringEscapeUtils.unescapeJava(StringUtils.strip(resourceUrl, Paths.ROOT)); } } if (startInclusiveIndex == 0 && endExclusiveIndex == resourceUrl.length()) { return resourceUrl; } return resourceUrl.substring(startInclusiveIndex, endExclusiveIndex); }

Target:
public static String unescapeJavaAndTrim(String resourceUrl) { if (resourceUrl == null) { return null; } int startInclusiveIndex = 0; while (startInclusiveIndex < resourceUrl.length() && resourceUrl.charAt(startInclusiveIndex) == Paths.ROOT_CHAR) { startInclusiveIndex++; } if (startInclusiveIndex == resourceUrl.length()) { return ""; } int endExclusiveIndex = resourceUrl.length(); while (endExclusiveIndex > startInclusiveIndex && resourceUrl.charAt(endExclusiveIndex - 1) == Paths.ROOT_CHAR) { endExclusiveIndex--; } for (int startLoopIndex = startInclusiveIndex; startLoopIndex < endExclusiveIndex; startLoopIndex++) { if (resourceUrl.charAt(startLoopIndex)== Paths.ESCAPE_CHAR) { return StringEscapeUtils.unescapeJava(StringUtils.strip(resourceUrl, Paths.ROOT)); } } if (startInclusiveIndex == 0 && endExclusiveIndex == resourceUrl.length()) { return resourceUrl; } return resourceUrl.substring(startInclusiveIndex, endExclusiveIndex); }
Source:
public static Object getMappingSource(final MutableTable table) { if (table.getColumnByName(FIELD_ID) == null) { final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey( true); table.addColumn(0, idColumn); } final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>(); for (Column column : table.getColumns()) { final String columnName = column.getName(); if (FIELD_ID.equals(columnName)) { continue; } final String fieldName = getValidatedFieldName(columnName); final Map<String, String> propertyMap = new HashMap<>(); final String type = getType(column); propertyMap.put("type", type); propertiesMap.put(fieldName, propertyMap); } HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>(); docTypeMap.put("properties", propertiesMap); final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>(); mapping.put(table.getName(), docTypeMap); return mapping; }

Target:
public static Map<String, ?> getMappingSource(final MutableTable table) { if (table.getColumnByName(FIELD_ID) == null) { final MutableColumn idColumn = new MutableColumn(FIELD_ID, ColumnType.STRING).setTable(table).setPrimaryKey( true); table.addColumn(0, idColumn); } final Map<String, Map<String, String>> propertiesMap = new LinkedHashMap<>(); for (Column column : table.getColumns()) { final String columnName = column.getName(); if (FIELD_ID.equals(columnName)) { continue; } final String fieldName = getValidatedFieldName(columnName); final Map<String, String> propertyMap = new HashMap<>(); final String type = getType(column); propertyMap.put("type", type); propertiesMap.put(fieldName, propertyMap); } HashMap<String, Map<String, Map<String, String>>> docTypeMap = new HashMap<>(); docTypeMap.put("properties", propertiesMap); final Map<String, Map<String, Map<String, Map<String, String>>>> mapping = new HashMap<>(); mapping.put(table.getName(), docTypeMap); return mapping; }
Source:
public void updateExternalStatus(Guid id, ExternalStatus status) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("vds_guid", id) .addValue("external_status", status); getCallsHandler().executeModification("UpdateVdsDynamiciExternalStatus", parameterSource); }

Target:
public void updateExternalStatus(Guid id, ExternalStatus status) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("vds_guid", id) .addValue("external_status", status); getCallsHandler().executeModification("UpdateExternalStatus", parameterSource); }
Source:
public RepositoryPath fetchPath(RepositoryPath repositoryPath) throws IOException { RepositoryPath result = resolvePathDirectlyFromGroupPathIfPossible(repositoryPath); if (result == null || RepositoryFiles.hasExpired(result)) { RepositoryPath resolvedTraversal = resolvePathTraversal(repositoryPath); if (result == null) { result = resolvedTraversal; } } return result; }

Target:
public RepositoryPath fetchPath(RepositoryPath repositoryPath) throws IOException { eventPublisher.publishEvent(new GroupRepositoryPathFetchEvent(repositoryPath)); RepositoryPath result = resolvePathDirectlyFromGroupPathIfPossible(repositoryPath); if (result != null) { return result; } return resolvePathTraversal(repositoryPath); }
Source:
@Override public ClientClusterGroup forNodeId(UUID id, UUID ... ids) { Collection<UUID> nodeIds = U.newHashSet(1 + (ids == null ? 0 : ids.length)); nodeIds.add(id); if (ids != null) nodeIds.addAll(Arrays.asList(ids)); return new ClientClusterGroupImpl(nodeIds); }

Target:
@Override public ClientClusterGroup forNodeId(UUID id, UUID ... ids) { Collection<UUID> nodeIds = U.newHashSet(1 + (ids == null ? 0 : ids.length)); nodeIds.add(id); if (!F.isEmpty(ids)) nodeIds.addAll(Arrays.asList(ids)); return new ClientClusterGroupImpl(nodeIds); }
Source:
public static void main(final String[] args) { checkNotNull(args); checkState( !GraphicsEnvironment.isHeadless(), "UI client launcher invoked from headless environment. This is currently " + "prohibited by design to avoid UI rendering errors in the headless environment."); Thread.setDefaultUncaughtExceptionHandler( (t, e) -> log.log(Level.SEVERE, e.getLocalizedMessage(), e)); ClientSetting.initialize(); LoggerManager.setLogLevel( ClientSetting.loggingVerbosity.getValue().map(Level::parse).orElse(Level.INFO)); Interruptibles.await(() -> SwingAction.invokeAndWait(LookAndFeel::initialize)); if (!ClientSetting.useExperimentalJavaFxUi.getValueOrThrow()) { Interruptibles.await( () -> SwingAction.invokeAndWait( () -> { ConsoleConfiguration.initialize(); ErrorMessage.initialize(); })); } ArgParser.handleCommandLineArgs(args); if (SystemProperties.isMac()) { MacOsIntegration.setOpenUriHandler( uri -> { final String mapName = URLDecoder.decode( uri.toString().substring(ArgParser.TRIPLEA_PROTOCOL.length()), StandardCharsets.UTF_8); SwingUtilities.invokeLater( () -> DownloadMapsWindow.showDownloadMapsWindowAndDownload(mapName)); }); MacOsIntegration.setOpenFilesHandler( list -> list.stream() .findAny() .ifPresent( file -> { System.setProperty(CliProperties.TRIPLEA_GAME, file.getAbsolutePath()); GameRunner.showMainFrame(); })); } if (HttpProxy.isUsingSystemProxy()) { HttpProxy.updateSystemProxy(); } if (ClientSetting.useExperimentalJavaFxUi.getValueOrThrow()) { Application.launch(TripleA.class, args); } else { GameRunner.start(); } }

Target:
public static void main(final String[] args) { checkNotNull(args); checkState( !GraphicsEnvironment.isHeadless(), "UI client launcher invoked from headless environment. This is currently " + "prohibited by design to avoid UI rendering errors in the headless environment."); Thread.setDefaultUncaughtExceptionHandler( (t, e) -> log.log(Level.SEVERE, e.getLocalizedMessage(), e)); ClientSetting.initialize(); LoggerManager.setLogLevel( ClientSetting.loggingVerbosity.getValue().map(Level::parse).orElse(Level.INFO)); Interruptibles.await(() -> SwingAction.invokeAndWait(LookAndFeel::initialize)); if (!ClientSetting.useExperimentalJavaFxUi.getValueOrThrow()) { Interruptibles.await( () -> SwingAction.invokeAndWait( () -> { ConsoleConfiguration.initialize(); ErrorMessage.initialize(); })); } ArgParser.handleCommandLineArgs(args); if (SystemProperties.isMac()) { MacOsIntegration.setOpenUriHandler( uri -> { final String mapName = URLDecoder.decode( uri.toString().substring(ArgParser.TRIPLEA_PROTOCOL.length()), StandardCharsets.UTF_8); SwingUtilities.invokeLater( () -> DownloadMapsWindow.showDownloadMapsWindowAndDownload(mapName)); }); MacOsIntegration.setOpenFileHandler( file -> { System.setProperty(CliProperties.TRIPLEA_GAME, file.getAbsolutePath()); GameRunner.showMainFrame(); }); } if (HttpProxy.isUsingSystemProxy()) { HttpProxy.updateSystemProxy(); } if (ClientSetting.useExperimentalJavaFxUi.getValueOrThrow()) { Application.launch(TripleA.class, args); } else { GameRunner.start(); } }
Source:
private List<String> getCurrentLocks() { List<String> currentLocks = new ArrayList<>(); int i=0; short lockSetVal = lockSet.get(); for (Resource value : Resource.values()) { if ((lockSetVal & value.setMask) == value.setMask) { currentLocks.add(value.name); } } return currentLocks; }

Target:
private List<String> getCurrentLocks() { List<String> currentLocks = new ArrayList<>(); int i=0; short lockSetVal = lockSet.get(); for (Resource value : Resource.values()) { if (value.isLevelLocked(lockSetVal)) { currentLocks.add(value.getName()); } } return currentLocks; }
Source:
public Gun(SceletonActivity activity) { ITextureRegion gunTexture = activity.getResourceManager().getLoadedTextureRegion(R.drawable.gun); ZoomCamera camera = activity.getCamera(); PointF gunPosition = new PointF( camera.getCenterX() - gunTexture.getWidth() / 2 , camera.getYMax() - gunTexture.getHeight() * 0.6f); gunSprite = new Sprite( gunPosition.x , gunPosition.y , gunTexture , activity.getEngine().getVertexBufferObjectManager()); gunSprite.setRotationCenter(gunSprite.getWidth() / 2, gunSprite.getHeight()); }

Target:
public Gun(SceletonActivity activity) { this.activity = activity; rotationEnabled = false; ITextureRegion gunTexture = activity.getResourceManager().getLoadedTextureRegion(R.drawable.gun); ZoomCamera camera = activity.getCamera(); PointF gunPosition = new PointF( camera.getCenterX() - gunTexture.getWidth() * 0.5f , camera.getYMax() - gunTexture.getHeight() * GUN_PART_ON_SCENE); gunSprite = new Sprite( gunPosition.x , gunPosition.y , gunTexture , activity.getEngine().getVertexBufferObjectManager()) { @Override protected void onManagedUpdate(float pSecondsElapsed) { super.onManagedUpdate(pSecondsElapsed); if (!rotationEnabled) { return; } if (rotateLeft) { if (gunSprite.getRotation() > -ROTATION_MAX_ANGLE) { gunSprite.setRotation(gunSprite.getRotation() - ROTATION_VELOCITY); } } else { if (gunSprite.getRotation() < ROTATION_MAX_ANGLE) { gunSprite.setRotation(gunSprite.getRotation() + ROTATION_VELOCITY); } } } }; gunSprite.setRotationCenter(gunSprite.getWidth() * 0.5f, gunSprite.getHeight()); }
Source:
public void accumulateWithNextRowInOrder() { assertThat(RESULTS.accumulateWith(OTHER_RESULTS)).is(new HamcrestCondition<>(Matchers.equalTo(COMBINED_RESULTS_AND_OTHER))); }

Target:
public void accumulateWithNextRowInOrder() { assertThat(RESULTS.accumulateWith(OTHER_RESULTS)).isEqualTo(COMBINED_RESULTS_AND_OTHER); }
Source:
public void testCompute() { LongLeastPostAggregator greatestPostAggregator; CountAggregator agg = new CountAggregator("rows"); agg.aggregate(); agg.aggregate(); agg.aggregate(); Map<String, Object> metricValues = new HashMap<String, Object>(); metricValues.put(agg.getName(), agg.get()); List<PostAggregator> postAggregatorList = Lists.newArrayList( new ConstantPostAggregator( "roku", 6 ), new FieldAccessPostAggregator( "rows", "rows" ) ); greatestPostAggregator = new LongLeastPostAggregator("least", postAggregatorList); Assert.assertEquals(Long.valueOf(3), greatestPostAggregator.compute(metricValues)); }

Target:
public void testCompute() { final String aggName = "rows"; LongLeastPostAggregator leastPostAggregator; CountAggregator agg = new CountAggregator(); agg.aggregate(); agg.aggregate(); agg.aggregate(); Map<String, Object> metricValues = new HashMap<String, Object>(); metricValues.put(aggName, agg.get()); List<PostAggregator> postAggregatorList = Lists.newArrayList( new ConstantPostAggregator( "roku", 6D ), new FieldAccessPostAggregator( "rows", aggName ) ); leastPostAggregator = new LongLeastPostAggregator("leastPostAggregator", postAggregatorList); Assert.assertEquals(Long.valueOf(3), leastPostAggregator.compute(metricValues)); }
Source:
public String migrateIfNecessary(String rawXml) { rawXml = cleanUpUnusedNodes(rawXml); String fileVersion = extractVersion(rawXml); Function<String, String> migrator = getMigrationStrategy().start(); boolean supported; switch (fileVersion) { case "1.0": migrator = migrator.andThen(getMigrationStrategy().from1_0to1_1()); case "1.1": migrator = migrator.andThen(getMigrationStrategy().from1_1to1_2()); case "1.2": migrator = migrator.andThen(getMigrationStrategy().from1_2to1_3()); case "1.3": migrator = migrator.andThen(getMigrationStrategy().from1_3to1_4()); case "1.4": migrator = migrator.andThen(getMigrationStrategy().from1_4to1_5()); case "1.5": migrator = migrator.andThen(getMigrationStrategy().from1_5to1_6()); supported = true; break; default: supported = currentVersion.equals(fileVersion); } if (!supported) { throw new IllegalArgumentException(new StringBuilder().append("Version ").append(fileVersion) .append(" of the file is not supported. Current version is ") .append(currentVersion).toString()); } migrator = migrator.andThen(getMigrationStrategy().end()); return migrator.apply(rawXml); }

Target:
public String migrateIfNecessary(String rawXml) { rawXml = cleanUpUnusedNodes(rawXml); String fileVersion = extractVersion(rawXml); Function<String, String> migrator = getMigrationStrategy().start(); boolean supported; switch (fileVersion) { case "1.0": migrator = migrator.andThen(getMigrationStrategy().from1_0to1_1()); case "1.1": migrator = migrator.andThen(getMigrationStrategy().from1_1to1_2()); case "1.2": migrator = migrator.andThen(getMigrationStrategy().from1_2to1_3()); case "1.3": migrator = migrator.andThen(getMigrationStrategy().from1_3to1_4()); case "1.4": migrator = migrator.andThen(getMigrationStrategy().from1_4to1_5()); case "1.5": migrator = migrator.andThen(getMigrationStrategy().from1_5to1_6()); supported = true; break; default: supported = currentVersion.equals(fileVersion); break; } if (!supported) { throw new IllegalArgumentException(new StringBuilder().append("Version ").append(fileVersion) .append(" of the file is not supported. Current version is ") .append(currentVersion).toString()); } migrator = migrator.andThen(getMigrationStrategy().end()); return migrator.apply(rawXml); }
Source:
public void getProjectBlogEntryDetailsTest() throws QuadrigaStorageException { IProjectBlogEntry projectBlogEntry = new ProjectBlogEntry(); projectBlogEntry.setTitle(TITLE_NEW); projectBlogEntry.setDescription(DESCRIPTION_NEW); projectBlogEntry.setProjectBlogEntryId(BLGE_ID_1); ProjectBlogEntryDTO projectBlogEntryDTO = createProjectBlogEntryDTO(UNIQUE_BLGE_ID, TITLE_NEW, DESCRIPTION_NEW); Mockito.when(projectBlogEntryDAO.getDTO(BLGE_ID_1)).thenReturn(projectBlogEntryDTO); Mockito.when(projectBlogEntryDTOMapper.getProjectBlogEntry(projectBlogEntryDTO)).thenReturn(projectBlogEntry); IProjectBlogEntry resultProjectBlogEntry = projectBlogEntryManagerUnderTest .getProjectBlogEntryDetails(BLGE_ID_1); assertEquals(resultProjectBlogEntry.getProjectBlogEntryId(), BLGE_ID_1); assertEquals(resultProjectBlogEntry.getTitle(), TITLE_NEW); assertEquals(resultProjectBlogEntry.getDescription(), DESCRIPTION_NEW); IProjectBlogEntry resultProjectBlogEntryWhenIdNotExist = projectBlogEntryManagerUnderTest .getProjectBlogEntryDetails(BLGE_ID_2); assertEquals(resultProjectBlogEntryWhenIdNotExist, null); }

Target:
public void getProjectBlogEntryDetailsTest() throws QuadrigaStorageException { IProjectBlogEntry projectBlogEntry = new ProjectBlogEntry(); projectBlogEntry.setTitle(TITLE_NEW); projectBlogEntry.setDescription(DESCRIPTION_NEW); projectBlogEntry.setProjectBlogEntryId(BLGE_ID_1); ProjectBlogEntryDTO projectBlogEntryDTO = createProjectBlogEntryDTO(UNIQUE_BLGE_ID, TITLE_NEW, DESCRIPTION_NEW); Mockito.when(projectBlogEntryDAO.getDTO(BLGE_ID_1)).thenReturn(projectBlogEntryDTO); Mockito.when(projectBlogEntryDTOMapper.getProjectBlogEntry(projectBlogEntryDTO)).thenReturn(projectBlogEntry); IProjectBlogEntry resultProjectBlogEntry = projectBlogEntryManagerUnderTest .getProjectBlogEntryDetails(BLGE_ID_1); assertEquals(resultProjectBlogEntry.getProjectBlogEntryId(), BLGE_ID_1); assertEquals(resultProjectBlogEntry.getTitle(), TITLE_NEW); assertEquals(resultProjectBlogEntry.getDescription(), DESCRIPTION_NEW); }
Source:
public boolean supports(SCMSourceDescriptor descriptor) { return false; }

Target:
public final boolean supports(SCMSourceDescriptor descriptor) { if (Util.isOverridden(SCMFileSystem.Builder.class, getClass(), "supportsDescriptor", SCMSourceDescriptor.class)) { return supportsDescriptor(descriptor); } else { return descriptor.clazz.isAssignableFrom((getClass().getEnclosingClass())) || getClass().getPackage().equals(descriptor.clazz.getPackage()) || getClass().getPackage().getName().startsWith(descriptor.clazz.getPackage().getName()); } }
Source:
public String setEncryptionKeyExchangeOnGMeter(final DlmsConnectionHolder conn, final DlmsDevice device, final GMeterInfoDto gMeterInfo) throws ProtocolAdapterException, FunctionalException { LOGGER.info("Device for Set Encryption Key Exchange On G-Meter is: {}", device); DlmsDevice gMeterDevice; try { gMeterDevice = this.domainHelperService.findDlmsDevice(gMeterInfo.getDeviceIdentification()); } catch (final FunctionalException e) { throw new ProtocolAdapterException("Error while looking up G-Meter", e); } final ProtocolMeterInfo protocolMeterInfo = new ProtocolMeterInfo(gMeterInfo.getChannel(), gMeterInfo.getDeviceIdentification(), gMeterDevice.getValidSecurityKey(SecurityKeyType.G_METER_ENCRYPTION).getKey(), gMeterDevice.getValidSecurityKey(SecurityKeyType.G_METER_MASTER).getKey()); this.setEncryptionKeyExchangeOnGMeterCommandExecutor.execute(conn, device, protocolMeterInfo); return "Set Encryption Key Exchange On G-Meter Result is OK for device id: " + device.getDeviceIdentification(); }

Target:
public String setEncryptionKeyExchangeOnGMeter(final DlmsConnectionHolder conn, final DlmsDevice device, final GMeterInfoDto gMeterInfo) throws ProtocolAdapterException, FunctionalException { LOGGER.info("Device for Set Encryption Key Exchange On G-Meter is: {}", device); DlmsDevice gMeterDevice; gMeterDevice = this.domainHelperService.findDlmsDevice(gMeterInfo.getDeviceIdentification()); final ProtocolMeterInfo protocolMeterInfo = new ProtocolMeterInfo(gMeterInfo.getChannel(), gMeterInfo.getDeviceIdentification(), gMeterDevice.getValidSecurityKey(SecurityKeyType.G_METER_ENCRYPTION).getKey(), gMeterDevice.getValidSecurityKey(SecurityKeyType.G_METER_MASTER).getKey()); this.setEncryptionKeyExchangeOnGMeterCommandExecutor.execute(conn, device, protocolMeterInfo); return "Set Encryption Key Exchange On G-Meter Result is OK for device id: " + device.getDeviceIdentification(); }
Source:
public String getRelativePathFrom(TestObject it) { if (it==this) { return "."; } StringBuilder buf = new StringBuilder(); TestObject next = this; TestObject cur = this; while (next!=null && it!=next) { cur = next; buf.insert(0,'/'); buf.insert(0,cur.getSafeName()); next = cur.getParent(); } if (it==next) { return buf.toString(); } else { AbstractTestResultAction action = getTestResultAction(); if (action==null) { LOGGER.warning("trying to get relative path, but we can't determine the action that owns this result."); return ""; } buf.insert(0,'/'); buf.insert(0,action.getUrlName()); Run<?,?> myBuild = cur.getRun(); if (myBuild ==null) { LOGGER.warning("trying to get relative path, but we can't determine the build that owns this result."); return ""; } buf.insert(0,'/'); buf.insert(0,myBuild.getUrl()); StaplerRequest req = Stapler.getCurrentRequest(); if (req!=null && myBuild instanceof Item) { buf.insert(0, '/'); Item myBuildAsItem = (Item) myBuild; buf.insert(0, Functions.getRelativeLinkTo(myBuildAsItem)); } else { LOGGER.fine(() -> "trying to get relative path, but it is not my ancestor, and we are not in a stapler request. Trying absolute jenkins url..."); String jenkinsUrl = Jenkins.get().getRootUrl(); if (jenkinsUrl == null || jenkinsUrl.length() == 0) { LOGGER.warning("Can't find anything like a decent hudson url. Punting, returning empty string."); return ""; } buf.insert(0, '/'); buf.insert(0, jenkinsUrl); } LOGGER.log(Level.FINE, "Here is our relative path: {0}", buf); return buf.toString(); } }

Target:
public String getRelativePathFrom(TestObject it) { if (it==this) { return "."; } StringBuilder buf = new StringBuilder(); TestObject next = this; TestObject cur = this; while (next!=null && it!=next) { cur = next; buf.insert(0,'/'); buf.insert(0,cur.getSafeName()); next = cur.getParent(); } if (it==next) { return buf.toString(); } else { AbstractTestResultAction action = getTestResultAction(); if (action==null) { LOGGER.warning("trying to get relative path, but we can't determine the action that owns this result."); return ""; } buf.insert(0,'/'); buf.insert(0,action.getUrlName()); Run<?,?> myBuild = cur.getRun(); if (myBuild ==null) { LOGGER.warning("trying to get relative path, but we can't determine the build that owns this result."); return ""; } buf.insert(0,'/'); buf.insert(0,myBuild.getUrl()); StaplerRequest req = Stapler.getCurrentRequest(); if (req!=null && myBuild instanceof Item) { buf.insert(0, '/'); Item myBuildAsItem = (Item) myBuild; buf.insert(0, Functions.getRelativeLinkTo(myBuildAsItem)); } else { LOGGER.fine("trying to get relative path, but it is not my ancestor, and we are not in a stapler request. Trying absolute jenkins url..."); String jenkinsUrl = Jenkins.get().getRootUrl(); if (jenkinsUrl == null || jenkinsUrl.length() == 0) { LOGGER.warning("Can't find anything like a decent hudson url. Punting, returning empty string."); return ""; } buf.insert(0, '/'); buf.insert(0, jenkinsUrl); } LOGGER.log(Level.FINE, "Here is our relative path: {0}", buf); return buf.toString(); } }
Source:
public void setTablePrefix(String tablePrefix) { this.tablePrefix = tablePrefix; }

Target:
public void setTablePrefix(String tablePrefix) { Assert.notNull(tablePrefix, "Null is not allowed as a tablePrfix (use an empty string if you don't want a prefix at all)."); this.tablePrefix = tablePrefix; }
Source:
public void addWithExistingMacAddress() { VmNetworkInterface iface = createNewInterface(); try { runAddAndVerify(iface, false, times(1)); } catch (VdcBLLException e) { assertEquals(VdcBllErrors.MAC_ADDRESS_IS_IN_USE, e.getErrorCode()); } catch (Exception e) { fail(String.format("Expected to catch %s, but caught %s instead.", VdcBLLException.class.getSimpleName(), e.getClass().getSimpleName())); } verify(vmInterfaceManager).auditLogMacInUse(iface); }

Target:
public void addWithExistingMacAddress() { VmNetworkInterface iface = createNewInterface(); try { runAddAndVerify(iface, false, times(1)); fail(String.format("Expected to catch %s, but didn't.", VdcBLLException.class.getSimpleName())); } catch (VdcBLLException e) { assertEquals(VdcBllErrors.MAC_ADDRESS_IS_IN_USE, e.getErrorCode()); } catch (Exception e) { fail(String.format("Expected to catch %s, but caught %s instead.", VdcBLLException.class.getSimpleName(), e.getClass().getSimpleName())); } verify(vmInterfaceManager).auditLogMacInUse(iface); }
Source:
public static boolean isDeviceRooted() { String buildTags = android.os.Build.TAGS; if (buildTags != null && buildTags.contains("test-keys")) { return true; } try { File file = new File("/system/app/Superuser.apk"); if (file.exists()) { return true; } } catch (Throwable e1) { } return false; }

Target:
public static boolean isDeviceRooted() { String buildTags = android.os.Build.TAGS; if (buildTags != null && buildTags.contains(TEST_KEYS)) { return true; } try { File file = new File(PATH_SUPERUSER_APK); if (file.exists()) { return true; } } catch (Throwable e1) { } return false; }
Source:
public List<IndexEntry> getValidEntry(IndexSegment indexSegment, FileSpan duplicateSearchSpan, boolean checkAlreadyCopied) throws StoreException { List<IndexEntry> copyCandidates = getValidIndexEntries(indexSegment); int validEntriesSize = copyCandidates.size(); copyCandidates.removeIf( copyCandidate -> isDuplicate(copyCandidate, duplicateSearchSpan, indexSegment.getStartOffset(), checkAlreadyCopied)); copyCandidates.removeIf( copyCandidate -> isDeleteRequested(copyCandidate, selectedContainers)); copyCandidates.sort(PersistentIndex.INDEX_ENTRIES_OFFSET_COMPARATOR); logger.debug("Out of entries, are valid and will be copied in this round", validEntriesSize, copyCandidates.size()); logger.trace("For index segment with start offset in - Entries to copy: {}", indexSegment.getStartOffset(), storeId, copyCandidates); return copyCandidates; }

Target:
public List<IndexEntry> getValidEntry(IndexSegment indexSegment, FileSpan duplicateSearchSpan, boolean checkAlreadyCopied) throws StoreException { List<IndexEntry> copyCandidates = getValidIndexEntries(indexSegment); int validEntriesSize = copyCandidates.size(); copyCandidates.removeIf( copyCandidate -> isDuplicate(copyCandidate, duplicateSearchSpan, indexSegment.getStartOffset(), checkAlreadyCopied) || (config.storeContainerDeletionEnabled && isFromDeprecatedContainer(copyCandidate))); copyCandidates.sort(PersistentIndex.INDEX_ENTRIES_OFFSET_COMPARATOR); logger.debug("Out of entries, are valid and will be copied in this round", validEntriesSize, copyCandidates.size()); logger.trace("For index segment with start offset in - Entries to copy: {}", indexSegment.getStartOffset(), storeId, copyCandidates); return copyCandidates; }
Source:
public List<PartitionStatistics> loadTopicStatistics(final Collection<Timeline> timelines) throws ServiceTemporarilyUnavailableException { try { return Retryer.executeWithRetry(() -> { return loadTopicStatisticsInternal(timelines); }, new RetryForSpecifiedCountStrategy(3) .withWaitBetweenEachTry(5000) .withExceptionsThatForceRetry(org.apache.kafka.common.errors.TimeoutException.class)); } catch (final Exception e) { throw new ServiceTemporarilyUnavailableException("Error occurred when fetching partitions offsets", e); } }

Target:
public List<PartitionStatistics> loadTopicStatistics(final Collection<Timeline> timelines) throws ServiceTemporarilyUnavailableException { try { return Retryer.executeWithRetry(() -> { return loadTopicStatisticsInternal(timelines); }, new RetryForSpecifiedCountStrategy(3) .withWaitBetweenEachTry(5000) .withExceptionsThatForceRetry(org.apache.kafka.common.errors.TimeoutException.class)); } catch (final RuntimeException e) { throw new ServiceTemporarilyUnavailableException("Error occurred when fetching partitions offsets", e); } }
Source:
public AbstractBigtableAdmin(CommonConnection connection) throws IOException { LOG.debug("Creating BigtableAdmin"); configuration = connection.getConfiguration(); options = connection.getOptions(); this.connection = connection; bigtableTableAdminClient = connection.getSession().getTableAdminClient(); disabledTables = connection.getDisabledTables(); bigtableInstanceName = options.getInstanceName(); tableAdapter = new TableAdapter(bigtableInstanceName); this.instanceName = InstanceName.of(bigtableInstanceName.getProjectId(), bigtableInstanceName.getInstanceId()); String clusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null); if (clusterId != null) { bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId); } }

Target:
public AbstractBigtableAdmin(CommonConnection connection) throws IOException { LOG.debug("Creating BigtableAdmin"); configuration = connection.getConfiguration(); options = connection.getOptions(); this.connection = connection; bigtableTableAdminClient = connection.getSession().getTableAdminClient(); disabledTables = connection.getDisabledTables(); bigtableInstanceName = options.getInstanceName(); tableAdapter = new TableAdapter(bigtableInstanceName); String clusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null); if (clusterId != null) { bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId); } }
Source:
private Optional<RowColumn> fillSiblingBatch(TransactionBase tx, Span siblingSpan, Column siblingColumn, Set<VisibilityBindingSet> bsSet, int batchSize) throws Exception { RowScanner rs = tx.scanner().over(siblingSpan).fetch(siblingColumn).byRow().build(); Iterator<ColumnScanner> colScannerIter = rs.iterator(); boolean batchLimitMet = false; Bytes row = siblingSpan.getStart().getRow(); while (colScannerIter.hasNext() && !batchLimitMet) { ColumnScanner colScanner = colScannerIter.next(); row = colScanner.getRow(); Iterator<ColumnValue> iter = colScanner.iterator(); while (iter.hasNext()) { if (bsSet.size() >= batchSize) { batchLimitMet = true; break; } bsSet.add(BS_SERDE.deserialize(iter.next().getValue())); } } if (batchLimitMet) { return Optional.of(new RowColumn(row, siblingColumn)); } else { return Optional.absent(); } }

Target:
private Optional<RowColumn> fillSiblingBatch(TransactionBase tx, Span siblingSpan, Column siblingColumn, Set<VisibilityBindingSet> bsSet, int batchSize) throws Exception { RowScanner rs = tx.scanner().over(siblingSpan).fetch(siblingColumn).byRow().build(); Iterator<ColumnScanner> colScannerIter = rs.iterator(); boolean batchLimitMet = false; Bytes row = siblingSpan.getStart().getRow(); while (colScannerIter.hasNext() && !batchLimitMet) { ColumnScanner colScanner = colScannerIter.next(); row = colScanner.getRow(); Iterator<ColumnValue> iter = colScanner.iterator(); while (iter.hasNext() && !batchLimitMet) { bsSet.add(BS_SERDE.deserialize(iter.next().getValue())); if (bsSet.size() >= batchSize) { batchLimitMet = true; } } } if (batchLimitMet) { return Optional.of(new RowColumn(row, siblingColumn)); } else { return Optional.absent(); } }
Source:
private void zoomInAction(ActionEvent e) { if (strainView != null) { strainView.zoomIn(); } }

Target:
private void zoomInAction(ActionEvent e) { strainView.zoomIn(); }
Source:
private void assertTransactionOpen( KernelTransaction transaction ) { Optional<Status> terminationReason = transaction.getReasonIfTerminated(); if ( terminationReason.isPresent() ) { throw new TransactionTerminatedException( terminationReason.get() ); } }

Target:
private void assertTransactionOpen( KernelTransaction transaction ) { if ( transaction.isTerminated() ) { Status terminationReason = transaction.getReasonIfTerminated().orElse( Status.Transaction.Terminated ); throw new TransactionTerminatedException( terminationReason ); } }
Source:
public void afterPropertiesSet() throws Exception { node = new TestNode(Settings.builder().put(loadConfig()).put("transport.type", "netty4").put("http.type", "netty4") .put("path.home", this.pathHome).put("path.data", this.pathData).put("cluster.name", this.clusterName) .put("node.max_local_storage_nodes", 100).build(), Collections.singletonList(Netty4Plugin.class)); nodeClient = (NodeClient) node.start().client(); }

Target:
public void afterPropertiesSet() throws Exception { Settings settings = Settings.builder() .put(loadConfig()) .put("transport.type", "netty4") .put("http.type", "netty4") .put("path.home", this.pathHome) .put("path.data", this.pathData) .put("cluster.name", this.clusterName) .put("node.max_local_storage_nodes", 100) .build(); node = new TestNode(settings, Collections.singletonList(Netty4Plugin.class)); nodeClient = (NodeClient) node.start().client(); }
Source:
public static String[] resourceToScopes(String resource) { Objects.requireNonNull(resource); return new String[] { resource + "/.default" }; }

Target:
public static String[] resourceToScopes(String resource) { Objects.requireNonNull(resource); return new String[] { resource + DEFAULT_SUFFIX }; }
Source:
void setUp() { this.builder = EventEnricher.newBuilder(); this.function = new BiFunction<Timestamp, Int32Value, StringValue>() { @Override public @Nullable StringValue apply(@Nullable Timestamp input, Int32Value context) { if (input == null) { return null; } return toMessage(Timestamps.toString(input)); } }; this.fieldEnrichment = FieldEnrichment.of(Timestamp.class, StringValue.class, function); }

Target:
void setUp() { this.builder = EventEnricher.newBuilder(); this.function = new BiFunction<Timestamp, EventContext, StringValue>() { @Override public @Nullable StringValue apply(@Nullable Timestamp input, EventContext context) { if (input == null) { return null; } return toMessage(Timestamps.toString(input)); } }; this.fieldEnrichment = FieldEnrichment.of(Timestamp.class, StringValue.class, function); }
Source:
protected void executeVdsBrokerCommand() { vmListReturn = getBroker().getExternalVmList(getParameters().getUrl(), getParameters().getUsername(), getParameters().getPassword(), getParameters().getNamesOfVms()); proceedProxyReturnValue(); List<VM> vms = new ArrayList<>(); List<VM> notDownVms = new ArrayList<>(); for (Map<String, Object> map : vmListReturn.vmList) { VM vm = VdsBrokerObjectsBuilder.buildVmsDataFromExternalProvider(map); if (vm != null) { vm.setOrigin(getParameters().getOriginType()); if (vm.getOrigin() == OriginType.KVM && vm.getStaticData().getImages().stream() .anyMatch(i -> i.getDiskVmElementForVm(vm.getId()) .getDiskInterface() == DiskInterface.VirtIO_SCSI)) { VmDeviceCommonUtils.addVirtIoScsiDevice(vm.getStaticData()); } vms.add(vm); if (!vm.isDown()) { notDownVms.add(vm); } } } logNonDownVms(notDownVms); setReturnValue(vms); }

Target:
protected void executeVdsBrokerCommand() { vmListReturn = getBroker().getExternalVmList(getParameters().getUrl(), getParameters().getUsername(), getParameters().getPassword(), getParameters().getNamesOfVms()); proceedProxyReturnValue(); List<VM> vms = new ArrayList<>(); List<VM> notDownVms = new ArrayList<>(); for (Map<String, Object> map : vmListReturn.vmList) { VM vm = VdsBrokerObjectsBuilder.buildVmsDataFromExternalProvider(map); if (vm != null) { vm.setOrigin(getParameters().getOriginType()); if (vm.getOrigin() == OriginType.KVM) { VmDeviceCommonUtils.addVirtIoScsiDevice(vm.getStaticData()); } vms.add(vm); if (!vm.isDown()) { notDownVms.add(vm); } } } logNonDownVms(notDownVms); setReturnValue(vms); }
Source:
public void putByteProperty(final SimpleString key, final byte value) { checkCreateProperties(); checkCreateProperties(); doPutValue(key, ByteValue.valueOf(value)); }

Target:
public void putByteProperty(final SimpleString key, final byte value) { checkCreateProperties(); doPutValue(key, ByteValue.valueOf(value)); }
Source:
public void metricsWithOneFilterAreFiltered() { MetricPublicationArbiter arbiter = createArbiter(ImmutableMap.of( METRIC_NAME_1, ImmutableSet.of(() -> false), METRIC_NAME_2, ImmutableSet.of(() -> true))); assertThat(arbiter.test(METRIC_NAME_1)).isFalse(); assertThat(arbiter.test(METRIC_NAME_2)).isTrue(); }

Target:
public void metricsWithOneFilterAreFiltered() { MetricPublicationArbiter arbiter = createArbiter(ImmutableMap.of( METRIC_NAME_1, ImmutableSet.of(FALSE_RETURNING_FILTER), METRIC_NAME_2, ImmutableSet.of(TRUE_RETURNING_FILTER))); assertThat(arbiter.test(METRIC_NAME_1)).isFalse(); assertThat(arbiter.test(METRIC_NAME_2)).isTrue(); }
Source:
private void setFwdBwdSpeed(EdgeIteratorState edge, int fwdSpeed, int bwdSpeed) { if (accessEnc.getBool(false, edge.getFlags())) { setSpeed(false, edge.getFlags(), fwdSpeed); } if (accessEnc.getBool(true, edge.getFlags())) { setSpeed(true, edge.getFlags(), bwdSpeed); } }

Target:
private void setFwdBwdSpeed(EdgeIteratorState edge, int fwdSpeed, int bwdSpeed) { if (edge.get(accessEnc)) edge.set(avgSpeedEnc, fwdSpeed); if (edge.getReverse(accessEnc)) edge.setReverse(avgSpeedEnc, bwdSpeed); }
Source:
public DataWord div(DataWord word) { if (word.isZero()) { return this.and(ZERO); } BigInteger result = value().divide(word.value()); return new DataWord(ByteUtil.copyToArray(result.and(MAX_VALUE))); }

Target:
public DataWord div(DataWord word) { if (word.isZero()) { return ZERO; } BigInteger result = value().divide(word.value()); return new DataWord(ByteUtil.copyToArray(result.and(MAX_VALUE))); }
Source:
public void populateItemSetChoices(QueryPrompt queryPrompt) { evaluationContext.setVariables(userAnswers); ItemsetBinding itemset = queryPrompt.getItemsetBinding(); if (itemset != null) { String instanceName = itemset.nodesetRef.getInstanceName(); if (instanceName != null) { DataInstance dataInstance = evaluationContext.getInstance(instanceName); if (dataInstance == null) { throw new XPathException("Instance " + instanceName + " not found"); } IConditionExpr nodesetExpr = itemset.nodesetExpr; Vector<TreeReference> matches = nodesetExpr.evalNodeset(dataInstance, evaluationContext); if (matches == null) { throw new XPathException("Make sure the '" + instanceName + "' lookup table is available, and that its contents are accessible to the current user."); } Vector<SelectChoice> choices = new Vector<>(); QueryContext newContext = evaluationContext.getCurrentQueryContext() .checkForDerivativeContextAndReturn(matches.size()); evaluationContext.setQueryContext(newContext); for (int i = 0; i < matches.size(); i++) { choices.addElement(buildSelectChoice(matches.elementAt(i), itemset, dataInstance, null, evaluationContext, null, i)); } itemset.setChoices(choices); } else { throw new XPathException("No items found at '" + itemset.nodesetRef + "'"); } } }

Target:
public void populateItemSetChoices(QueryPrompt queryPrompt) { EvaluationContext evalContextWithAnswers = evaluationContext.spawnWithCleanLifecycle(); evalContextWithAnswers.setVariables(userAnswers); ItemSetUtils.populateDynamicChoices(queryPrompt.getItemsetBinding(), evalContextWithAnswers); }
Source:
public SubTabDiskGeneralView(DetailModelProvider<DiskListModel, DiskGeneralModel> modelProvider) { super(modelProvider); formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); driver.initialize(this); generateIds(); formBuilder = new FormBuilder(formPanel, 1, 8); formBuilder.addFormItem(new FormItem(constants.aliasDisk(), alias, 0, 0)); formBuilder.addFormItem(new FormItem(constants.descriptionDisk(), description, 1, 0)); formBuilder.addFormItem(new FormItem(constants.idDisk(), diskId, 2, 0)); formBuilder.addFormItem(new FormItem(constants.diskAlignment(), alignment, 3, 0)); formBuilder.addFormItem(new FormItem(constants.lunIdSanStorage(), lunId, 4, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isLun(); } }); formBuilder.addFormItem(new FormItem(constants.diskProfile(), diskProfileName, 5, 0) { @Override public boolean getIsAvailable() { return !getDetailModel().isLun(); } }); formBuilder.addFormItem(new FormItem(constants.quota(), quotaName, 6, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isQuotaAvailable(); } }); formBuilder.addFormItem(new FormItem(constants.wipeAfterDelete(), wipeAfterDelete, 7, 0)); formBuilder.setRelativeColumnWidth(0, 3); }

Target:
public SubTabDiskGeneralView(DetailModelProvider<DiskListModel, DiskGeneralModel> modelProvider) { super(modelProvider); formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); driver.initialize(this); generateIds(); formBuilder = new FormBuilder(formPanel, 1, 8); formBuilder.addFormItem(new FormItem(constants.aliasDisk(), alias, 0, 0)); formBuilder.addFormItem(new FormItem(constants.descriptionDisk(), description, 1, 0)); formBuilder.addFormItem(new FormItem(constants.idDisk(), diskId, 2, 0)); formBuilder.addFormItem(new FormItem(constants.diskAlignment(), alignment, 3, 0)); formBuilder.addFormItem(new FormItem(constants.lunIdSanStorage(), lunId, 4, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isLun(); } }); formBuilder.addFormItem(new FormItem(constants.diskProfile(), diskProfileName, 5, 0) { @Override public boolean getIsAvailable() { return !getDetailModel().isLun(); } }); formBuilder.addFormItem(new FormItem(constants.quota(), quotaName, 6, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isQuotaAvailable(); } }); formBuilder.addFormItem(new FormItem(constants.wipeAfterDelete(), wipeAfterDelete, 7, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isImage(); } }); formBuilder.setRelativeColumnWidth(0, 3); }
Source:
private @Nullable String getColorFormulaString() { Formula formula = getFormulaWithBrickField(BrickField.COLOR); FormulaElement formulaTree = formula.getFormulaTree(); boolean formulaIsString = formulaTree.getElementType() == FormulaElement.ElementType.STRING; return formulaIsString ? formulaTree.getValue() : null; }

Target:
private @Nullable String getColorFormulaString() { Formula formula = getFormulaWithBrickField(BrickField.COLOR); FormulaElement formulaTree = formula.getFormulaTree(); if (formulaTree.getElementType() == FormulaElement.ElementType.STRING) { return formulaTree.getValue(); } else { return null; } }
Source:
private TransientLedgerInfo getOrAddLedgerInfo(long ledgerId) { TransientLedgerInfo tli = transientLedgerInfoCache.get(ledgerId); if (tli != null) { return tli; } else { TransientLedgerInfo newTli = new TransientLedgerInfo(ledgerId, ledgerIndex); tli = transientLedgerInfoCache.putIfAbsent(ledgerId, newTli); return tli != null ? tli : newTli; } }

Target:
private TransientLedgerInfo getOrAddLedgerInfo(long ledgerId) { TransientLedgerInfo tli = transientLedgerInfoCache.get(ledgerId); if (tli != null) { return tli; } else { TransientLedgerInfo newTli = new TransientLedgerInfo(ledgerId, ledgerIndex); tli = transientLedgerInfoCache.putIfAbsent(ledgerId, newTli); if (tli != null) { newTli.close(); return tli; } else { return newTli; } } }
Source:
public void addUnit(Unit unit) { if (unit == null) { return; } UUID id = unit.getId(); if (id == null) { id = UUID.randomUUID(); unit.setId(id); } units.put(id, unit); }

Target:
public void addUnit(Unit unit) { if (unit == null) { return; } if (unit.getId() == null) { unit.setId(UUID.randomUUID()); } units.put(unit.getId(), unit); }
Source:
public static int compare(CharSequence left, CharSequence right) { if (left == right) { return 0; } int minLength = Math.min(left.length(), right.length()); for (int i = 0; i < minLength; i += 1) { int cmp = Character.compare(left.charAt(i), right.charAt(i)); if (cmp != 0) { return cmp; } } return Integer.compare(left.length(), right.length()); }

Target:
public static int compare(CharSequence left, CharSequence right) { if (left == right) { return 0; } int minLength = Math.min(left.length(), right.length()); for (int i = 0; i < minLength; i += 1) { int cmp = (left.charAt(i) - right.charAt(i)); if (cmp != 0) { return cmp; } } return (left.length() - right.length()); }
Source:
public void setup() { openTSDBMessageFormatter = Mockito.mock(OpenTSDBMessageFormatter.class); writer = new TCollectorUDPWriter2(openTSDBMessageFormatter); outputWriter = Mockito.mock(Writer.class); result = Mockito.mock(Result.class); server = ServerFixtures.dummyServer(); }

Target:
public void setup() { openTSDBMessageFormatter = Mockito.mock(OpenTSDBMessageFormatter.class); writer = new TCollectorUDPWriter2(openTSDBMessageFormatter); outputWriter = Mockito.mock(Writer.class); result = Mockito.mock(Result.class); }
Source:
private void uploadToKeyserver() { long keyId = 0; try { keyId = new ProviderHelper(getActivity()) .getCachedPublicKeyRing(mDataUri) .extractOrGetMasterKeyId(); } catch (PgpKeyNotFoundException e) { Log.e(Constants.TAG, "key not found!", e); } Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); uploadIntent.setData(mDataUri); uploadIntent.putExtra(MultiUserIdsFragment.EXTRA_KEY_IDS, new long[]{keyId}); startActivityForResult(uploadIntent, 0); }

Target:
private void uploadToKeyserver() { long keyId; try { keyId = new ProviderHelper(getActivity()) .getCachedPublicKeyRing(mDataUri) .extractOrGetMasterKeyId(); } catch (PgpKeyNotFoundException e) { Log.e(Constants.TAG, "key not found!", e); Notify.create(getActivity(), "key not found", Style.ERROR).show(); return; } Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); uploadIntent.setData(mDataUri); uploadIntent.putExtra(MultiUserIdsFragment.EXTRA_KEY_IDS, new long[]{keyId}); startActivityForResult(uploadIntent, 0); }
Source:
public static boolean hasSymbolicAlleles( final List<Allele> alleles ) { for (int i = 0; i < alleles.size(); i++ ) { if (alleles.get(i).isSymbolic()) { return true; } } return false; }

Target:
public static boolean hasSymbolicAlleles( final List<Allele> alleles ) { for (int i = 0, size = alleles.size(); i < size; i++ ) { if (alleles.get(i).isSymbolic()) { return true; } } return false; }