auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static boolean hasWaterBottle(Player player) { if (hasAbility(player, WaterReturn.class) || isBending(player)) { return false; } PlayerInventory inventory = player.getInventory(); if (inventory.contains(Material.POTION)) { ItemStack item = inventory.getItem(inventory.first(Material.POTION)); PotionMeta meta = (PotionMeta) item.getItemMeta(); return meta.getBasePotionData().getType() == PotionType.WATER); } return false; }

Target:
public static boolean hasWaterBottle(Player player) { if (hasAbility(player, WaterReturn.class) || isBending(player)) { return false; } PlayerInventory inventory = player.getInventory(); if (inventory.contains(Material.POTION)) { ItemStack item = inventory.getItem(inventory.first(Material.POTION)); PotionMeta meta = (PotionMeta) item.getItemMeta(); return meta.getBasePotionData().getType() == PotionType.WATER; } return false; }
Source:
public static float getDensityScalar() { if (DENSITY_SCALAR == null) { DENSITY_SCALAR = getDisplayMetrics().density; } return DENSITY_SCALAR; }

Target:
public static float getDensityScalar() { return getDisplayMetrics().density; }
Source:
private boolean isRelevant(EntityRef entity, Vector3f position) { return entity.isAlwaysRelevant() || worldProvider.isBlockRelevant(position); }

Target:
private boolean isRelevant(EntityRef entity, Vector3f position) { return worldProvider.isBlockRelevant(position) || entity.isAlwaysRelevant(); }
Source:
private void populateListOfDates(ArrayList<Date> dateList, Calendar populator, int totalDays) { while(dateList.size() < totalDays){ dateList.add(populator.getTime()); populator.add(Calendar.DAY_OF_MONTH, 1); } int remainingDays = ((DAYSINWEEK + 1)-(populator.get(Calendar.DAY_OF_WEEK)))%DAYSINWEEK; for(int i = 0; i < remainingDays; i ++){ dateList.add(populator.getTime()); populator.add(Calendar.DAY_OF_MONTH, 1); } }

Target:
private static void populateListOfDates(ArrayList<Date> dateList, Calendar populator, int totalDays) { while(dateList.size() < totalDays){ dateList.add(populator.getTime()); populator.add(Calendar.DAY_OF_MONTH, 1); } int remainingDays = ((DAYSINWEEK + 1)-(populator.get(Calendar.DAY_OF_WEEK)))%DAYSINWEEK; for(int i = 0; i < remainingDays; i ++){ dateList.add(populator.getTime()); populator.add(Calendar.DAY_OF_MONTH, 1); } }
Source:
public Context(Object key, Object value) { if (key == null) { throw new IllegalArgumentException("key cannot be null."); } this.parent = null; this.key = key; this.value = value; }

Target:
public Context(Object key, Object value) { this.parent = null; this.key = Objects.requireNonNull(key, "'key' cannot be null."); this.value = value; }
Source:
void writeTo(final OutputStream out) throws IOException { writeEnum(out, getChangeType()); writeEnum(out, getPatchType()); writeString(out, oldName); writeString(out, newName); writeBytes(out, header); writeVarInt32(out, edits.size()); for (final BaseEdit e : edits) { write(out, e); if (e instanceof LineEdit) { List<BaseEdit> intlEdits = ((LineEdit) e).getEdits(); writeVarInt32(out, intlEdits.size()); for (BaseEdit i : intlEdits) { write(out, i); } } else { writeVarInt32(out, 0); } } }

Target:
void writeTo(final OutputStream out) throws IOException { writeEnum(out, getChangeType()); writeEnum(out, getPatchType()); writeString(out, oldName); writeString(out, newName); writeBytes(out, header); writeVarInt32(out, edits.size()); for (final LineEdit e : edits) { write(out, e); if (e.getEdits() != null) { List<BaseEdit> intlEdits = e.getEdits(); writeVarInt32(out, intlEdits.size()); for (BaseEdit i : intlEdits) { write(out, i); } } else { writeVarInt32(out, 0); } } }
Source:
public static void toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifacts, Collection<? extends DependencyNode> nodes, List<String> trail, DependencyFilter filter ) { Map<Integer, List<org.apache.maven.artifact.Artifact>> artifactsByDepth = new TreeMap<Integer, List<org.apache.maven.artifact.Artifact>>(); ArrayList<org.apache.maven.artifact.Artifact> firstLevelArtifacts = new ArrayList<org.apache.maven.artifact.Artifact>( nodes.size() ); artifactsByDepth.put( 1, firstLevelArtifacts ); toArtifacts( artifactsByDepth, 1, nodes, trail, filter ); for ( List<org.apache.maven.artifact.Artifact> artifactsInDepth : artifactsByDepth.values() ) { artifacts.addAll( artifactsInDepth ); } }

Target:
public static void toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifacts, Collection<? extends DependencyNode> nodes, List<String> trail, DependencyFilter filter ) { Map<Integer, List<org.apache.maven.artifact.Artifact>> artifactsByDepth = new TreeMap<>(); List<org.apache.maven.artifact.Artifact> firstLevelArtifacts = new ArrayList<>( nodes.size() ); artifactsByDepth.put( 1, firstLevelArtifacts ); toArtifacts( artifactsByDepth, 1, nodes, trail, filter ); for ( List<org.apache.maven.artifact.Artifact> artifactsInDepth : artifactsByDepth.values() ) { artifacts.addAll( artifactsInDepth ); } }
Source:
public RelDataType deriveRowType() { if (m_program == null) { return table.getRowType(); } else { RelDataType rowDataType = m_program.getOutputRowType(); if (rowDataType.getFieldCount() > 0) { return rowDataType; } else { return table.getRowType(); } } }

Target:
public RelDataType deriveRowType() { if (m_program == null) { return table.getRowType(); } else { RelDataType rowDataType = m_program.getOutputRowType(); if (rowDataType.getFieldCount() > 0) { return rowDataType; } else { throw new IllegalStateException("Column count can not be 0."); } } }
Source:
public void showLives(int lives, int playerNumber) { livesText.setVisible(true); if (playerNumber == 1) { livesTextPlayer1.setVisible(true); if (StartController.getLimitOfPlayers() == 1) { livesTextPlayer1.setText(String.format("%d", lives)); } else { livesTextPlayer1.setText(String.format("%d (Player 1)", lives)); } } if (playerNumber == 2) { livesTextPlayer2.setVisible(true); livesTextPlayer2.setText(String.format("%d (Player 2)", lives)); } }

Target:
public void showLives(int lives, int playerNumber) { livesText.setVisible(true); if (playerNumber == 1) { livesTextPlayer1.setVisible(true); if (StartController.getLimitOfPlayers() == 1) { livesTextPlayer1.setText(String.format("%d", lives)); } else { livesTextPlayer1.setText(String.format("P1: %d", lives)); } } else if (playerNumber == 2) { livesTextPlayer2.setVisible(true); livesTextPlayer2.setText(String.format("P2: %d", lives)); } }
Source:
public void resolvesRunningAkkaRpcActor() throws Exception { final String endpointName = "foobar"; try (SimpleRpcEndpoint simpleRpcEndpoint1 = new SimpleRpcEndpoint(akkaRpcService, AkkaRpcServiceUtils.createRandomName(endpointName)); SimpleRpcEndpoint simpleRpcEndpoint2 = new SimpleRpcEndpoint(akkaRpcService, AkkaRpcServiceUtils.createRandomName(endpointName))) { simpleRpcEndpoint1.closeAsync().join(); final String wildcardName = AkkaRpcServiceUtils.createWildcardName(endpointName); final String wildcardAddress = AkkaRpcServiceUtils.getLocalRpcUrl(wildcardName); final RpcGateway rpcGateway = akkaRpcService.connect(wildcardAddress, RpcGateway.class).join(); assertThat(rpcGateway.getAddress(), is(equalTo(simpleRpcEndpoint2.getAddress()))); } }

Target:
public void resolvesRunningAkkaRpcActor() throws Exception { final String endpointName = "foobar"; try (RpcEndpoint simpleRpcEndpoint1 = createRpcEndpointWithRandomNameSuffix(endpointName); RpcEndpoint simpleRpcEndpoint2 = createRpcEndpointWithRandomNameSuffix(endpointName)) { simpleRpcEndpoint1.closeAsync().join(); final String wildcardName = AkkaRpcServiceUtils.createWildcardName(endpointName); final String wildcardAddress = AkkaRpcServiceUtils.getLocalRpcUrl(wildcardName); final RpcGateway rpcGateway = akkaRpcService.connect(wildcardAddress, RpcGateway.class).join(); assertThat(rpcGateway.getAddress(), is(equalTo(simpleRpcEndpoint2.getAddress()))); } }
Source:
public void revertCharacter(CharacterFacade character) { if (character.isDirty()) { int ret = JOptionPane.showConfirmDialog(this, LanguageBundle .getFormattedString("in_revertPcChoice", character .getNameRef().getReference()), Constants.APPLICATION_NAME, JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return; } if (ret == JOptionPane.YES_OPTION) { CharacterManager.removeCharacter(character); CharacterManager.openCharacter(character.getFileRef().getReference(), PCGenFrame.this, currentDataSetRef.getReference()); } } }

Target:
public void revertCharacter(CharacterFacade character) { if (character.isDirty()) { int ret = JOptionPane.showConfirmDialog(this, LanguageBundle .getFormattedString("in_revertPcChoice", character .getNameRef().getReference()), Constants.APPLICATION_NAME, JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.YES_OPTION) { CharacterManager.removeCharacter(character); if (character.getFileRef().getReference() == null || StringUtils.isEmpty(character.getFileRef().getReference().getName())) { CharacterManager.openCharacter(character.getFileRef().getReference(), PCGenFrame.this, currentDataSetRef.getReference()); } else { createNewCharacter(); } } } }
Source:
public void initModelTranslator(ModelTranslator modelTranslator) { modelTranslator.registerTranslator(this.capabilityTranslator, ConsumerCapability.class, CapabilityDTO.class); }

Target:
protected void initModelTranslator(ModelTranslator modelTranslator) { modelTranslator.registerTranslator(this.capabilityTranslator, ConsumerCapability.class, CapabilityDTO.class); }
Source:
public static void getPropertyValues(Object obj, Set<String> properties, Map<String, String> values) { try { PropertyDescriptor[] pds = Introspector.getBeanInfo(obj.getClass()).getPropertyDescriptors(); int hitCount = 0; hitCount = values.size(); for (PropertyDescriptor pd : pds) { String propertyName = pd.getName().toLowerCase(); if (properties.contains(propertyName) && !values.containsKey(propertyName)) { Object value = null; hitCount++; try { value = pd.getReadMethod().invoke(obj); String stringValue = value != null ? value.toString() : null; values.put(propertyName, stringValue); } catch (Exception e) { log.warn("Unable to get value of property: " + pd.getDisplayName() + " for class " + obj.getClass().getName()); } if (hitCount == properties.size()) { break; } } } } catch (Exception e) { throw new RuntimeException(e); } }

Target:
public static void getPropertyValues(Object obj, Set<String> properties, Map<String, String> values) { try { PropertyDescriptor[] pds = Introspector.getBeanInfo(obj.getClass()).getPropertyDescriptors(); int hitCount = 0; for (PropertyDescriptor pd : pds) { String propertyName = pd.getName().toLowerCase(); if (properties.contains(propertyName)) { Object value = null; hitCount++; if(!values.containsKey(propertyName)) { try { value = pd.getReadMethod().invoke(obj); String stringValue = value != null ? value.toString() : null; values.put(propertyName, stringValue); } catch (Exception e) { log.warn("Unable to get value of property: " + pd.getDisplayName() + " for class " + obj.getClass().getName()); } } if (hitCount == properties.size()) { break; } } } } catch (Exception e) { throw new RuntimeException(e); } }
Source:
public static Sensor processRateSensor(final String threadId, final StreamsMetricsImpl streamsMetrics) { final Sensor sensor = streamsMetrics.threadLevelSensor(threadId, PROCESS, RecordingLevel.INFO); final Map<String, String> tagMap = streamsMetrics.threadLevelTagMap(threadId); final String threadLevelGroup = threadLevelGroup(streamsMetrics); sensor.add( new MetricName( PROCESS + StreamsMetricsImpl.RATE_SUFFIX, threadLevelGroup, PROCESS_RATE_DESCRIPTION, tagMap ), new Rate(TimeUnit.SECONDS, new WindowedSum()) ); sensor.add( new MetricName( PROCESS + StreamsMetricsImpl.TOTAL_SUFFIX, threadLevelGroup, PROCESS_TOTAL_DESCRIPTION, tagMap ), new CumulativeCount() ); return sensor; }

Target:
public static Sensor processRateSensor(final String threadId, final StreamsMetricsImpl streamsMetrics) { final Sensor sensor = streamsMetrics.threadLevelSensor(threadId, PROCESS + RATE_SUFFIX, RecordingLevel.INFO); final Map<String, String> tagMap = streamsMetrics.threadLevelTagMap(threadId); final String threadLevelGroup = threadLevelGroup(streamsMetrics); addRateOfSumAndSumMetricsToSensor( sensor, threadLevelGroup, tagMap, PROCESS, PROCESS_RATE_DESCRIPTION, PROCESS_TOTAL_DESCRIPTION ); return sensor; }
Source:
public Double getNormalizedScore() { if (myEmpiRuleCount == 0) { return 0.0; } double retVal = score / myEmpiRuleCount; if (retVal < 0) { retVal = 0.0; } else if (retVal > 1.0) { return 1.0; } return retVal; }

Target:
public Double getNormalizedScore() { if (myEmpiRuleCount == 0) { return 0.0; } return score / myEmpiRuleCount; }
Source:
public UpdateRequest(String registrationId, Long lifetime, String smsNumber, BindingMode binding, Link[] objectLinks, Map<String, String> additionalAttributes) throws InvalidRequestException { if (registrationId == null || registrationId.isEmpty()) throw new InvalidRequestException("registrationId is mandatory"); this.registrationId = registrationId; this.objectLinks = objectLinks; this.lifeTimeInSec = lifetime; this.bindingMode = binding; this.smsNumber = smsNumber; if (additionalAttributes == null) this.additionalAttributes = Collections.emptyMap(); else this.additionalAttributes = Collections.synchronizedMap(new HashMap<>(additionalAttributes)); }

Target:
public UpdateRequest(String registrationId, Long lifetime, String smsNumber, BindingMode binding, Link[] objectLinks, Map<String, String> additionalAttributes) throws InvalidRequestException { if (registrationId == null || registrationId.isEmpty()) throw new InvalidRequestException("registrationId is mandatory"); this.registrationId = registrationId; this.objectLinks = objectLinks; this.lifeTimeInSec = lifetime; this.bindingMode = binding; this.smsNumber = smsNumber; if (additionalAttributes == null) this.additionalAttributes = Collections.emptyMap(); else this.additionalAttributes = Collections.unmodifiableMap(new HashMap<>(additionalAttributes)); }
Source:
private static SortOrder sortOrder(PrimitiveType primitive) { OriginalType annotation = primitive.getOriginalType(); if (annotation != null) { switch (annotation) { case INT_8: case INT_16: case INT_32: case INT_64: case DATE: case TIME_MICROS: case TIME_MILLIS: case TIMESTAMP_MICROS: case TIMESTAMP_MILLIS: return SortOrder.SIGNED; case UINT_8: case UINT_16: case UINT_32: case UINT_64: case DECIMAL: case ENUM: case UTF8: case BSON: case JSON: return SortOrder.UNSIGNED; case LIST: case MAP: case MAP_KEY_VALUE: case INTERVAL: return SortOrder.UNKNOWN; } } return defaultSortOrder(primitive.getPrimitiveTypeName()); }

Target:
private static SortOrder sortOrder(PrimitiveType primitive) { OriginalType annotation = primitive.getOriginalType(); if (annotation != null) { switch (annotation) { case INT_8: case INT_16: case INT_32: case INT_64: case DATE: case TIME_MICROS: case TIME_MILLIS: case TIMESTAMP_MICROS: case TIMESTAMP_MILLIS: return SortOrder.SIGNED; case UINT_8: case UINT_16: case UINT_32: case UINT_64: case ENUM: case UTF8: case BSON: case JSON: return SortOrder.UNSIGNED; case DECIMAL: case LIST: case MAP: case MAP_KEY_VALUE: case INTERVAL: return SortOrder.UNKNOWN; } } return defaultSortOrder(primitive.getPrimitiveTypeName()); }
Source:
public String getArticleName() { String header = getHeader(); return header.substring(header.indexOf('"') + 1, header.length() - 1); }

Target:
private String getArticleName() { return executeScriptRet(WikiaGlobalVariables.wgPageName); }
Source:
public void onMapReady(final MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS) .withImage(ICON_ID, BitmapUtils.getBitmapFromDrawable( getResources().getDrawable(R.drawable.hurricane_icon))) .withSource(new GeoJsonSource(SOURCE_ID, loadGeoJsonFromAsset("spinning_icon.geojson"))) .withLayer(new SymbolLayer(LAYER_ID, SOURCE_ID) .withProperties(PropertyFactory.iconImage(ICON_ID), iconAllowOverlap(true)) ), new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { startIconSpinningAnimation(); } }); }

Target:
public void onMapReady(final MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS) .withImage(ICON_ID, BitmapUtils.getBitmapFromDrawable( getResources().getDrawable(R.drawable.hurricane_icon))), new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { try { style.addSource(new GeoJsonSource(SOURCE_ID, new URI("asset://spinning_icon.geojson"))); style.addLayer(new SymbolLayer(LAYER_ID, SOURCE_ID) .withProperties(PropertyFactory.iconImage(ICON_ID), iconAllowOverlap(true), iconPitchAlignment(ICON_PITCH_ALIGNMENT_MAP))); startIconSpinningAnimation(); } catch (URISyntaxException exception) { Timber.d(exception); } } }); }
Source:
private void initializeEphemeralCount() { this.ephemeralCount = new HashMap<Long, Integer>(); if (this.zks.getZKDatabase() != null) { for (Map.Entry<Long, Set<String>> entry : this.zks.getZKDatabase().getEphemerals().entrySet()) { this.ephemeralCount.put(entry.getKey(), entry.getValue().size()); } } }

Target:
private void initializeEphemeralCount() { this.ephemeralCount = new ConcurrentHashMap<>(); for (Map.Entry<Long, Set<String>> entry : this.zks.getZKDatabase().getEphemerals().entrySet()) { this.ephemeralCount.put(entry.getKey(), entry.getValue().size()); } }
Source:
private static Map<String, RemoteRefUpdate> asUpdateMap( List<RemoteCommand> cmds) { Map<String, RemoteRefUpdate> m = new LinkedHashMap<>(); for (RemoteCommand c : cmds) { m.put(c.getRemoteName(), c); } return m; }

Target:
private static Map<String, RemoteRefUpdate> asUpdateMap( List<RemoteCommand> cmds) { Map<String, RemoteRefUpdate> m = new LinkedHashMap<>(); for (RemoteCommand cmd : cmds) { m.put(cmd.getRemoteName(), cmd); } return m; }
Source:
public ExternalIdBundle withExternalId(ExternalId externalId) { ArgChecker.notNull(externalId, "externalId"); Set<ExternalId> ids = new HashSet<>(externalIds); if (ids.add(externalId) == false) { return this; } return create(ids); }

Target:
public ExternalIdBundle withExternalId(ExternalId externalId) { ArgChecker.notNull(externalId, "externalId"); return withExternalIds(ImmutableSortedSet.of(externalId)); }
Source:
protected void recvCommands() throws IOException { for (;;) { String line; try { line = pckIn.readStringRaw(); } catch (EOFException eof) { if (commands.isEmpty()) return; throw eof; } if (line == PacketLineIn.END) break; if (line.length() >= 48 && line.startsWith("shallow ")) { clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48))); continue; } if (commands.isEmpty()) { final FirstLine firstLine = new FirstLine(line); enabledCapabilities = firstLine.getCapabilities(); line = firstLine.getLine(); if (line.startsWith(GitProtocolConstants.OPTION_PUSH_CERT)) recvCommandsWithPushCertificate(); } if (line.length() < 83) { final String m = JGitText.get().errorInvalidProtocolWantedOldNewRef; sendError(m); throw new PackProtocolException(m); } final ObjectId oldId = ObjectId.fromString(line.substring(0, 40)); final ObjectId newId = ObjectId.fromString(line.substring(41, 81)); final String name = line.substring(82); final ReceiveCommand cmd = new ReceiveCommand(oldId, newId, name); if (name.equals(Constants.HEAD)) { cmd.setResult(Result.REJECTED_CURRENT_BRANCH); } else { cmd.setRef(refs.get(cmd.getRefName())); } commands.add(cmd); } }

Target:
protected void recvCommands() throws IOException { for (;;) { String line; try { line = pckIn.readStringRaw(); } catch (EOFException eof) { if (commands.isEmpty()) return; throw eof; } if (line == PacketLineIn.END) break; if (line.length() >= 48 && line.startsWith("shallow ")) { clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48))); continue; } if (commands.isEmpty()) { final FirstLine firstLine = new FirstLine(line); enabledCapabilities = firstLine.getCapabilities(); line = firstLine.getLine(); if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) pushCertificateParser.receiveHeader(); } if (line.equals("-----BEGIN PGP SIGNATURE-----\n")) pushCertificateParser.receiveSignature(); if (line.length() < 83) { final String m = JGitText.get().errorInvalidProtocolWantedOldNewRef; sendError(m); throw new PackProtocolException(m); } final ObjectId oldId = ObjectId.fromString(line.substring(0, 40)); final ObjectId newId = ObjectId.fromString(line.substring(41, 81)); final String name = line.substring(82); final ReceiveCommand cmd = new ReceiveCommand(oldId, newId, name); if (name.equals(Constants.HEAD)) { cmd.setResult(Result.REJECTED_CURRENT_BRANCH); } else { cmd.setRef(refs.get(cmd.getRefName())); } commands.add(cmd); } }
Source:
public static void injectSessionExpiration(ZooKeeper zooKeeper) { try { WatchedEvent event = new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState.Expired, null); ClientCnxn clientCnxn = (ClientCnxn)cnxnField.get(zooKeeper); Object eventThread = eventThreadField.get(clientCnxn); queueEventMethod.invoke(eventThread, event); queueEventOfDeathMethod.invoke(eventThread); Object sendThread = sendThreadField.get(clientCnxn); Object clientCnxnSocket = getClientCnxnSocketMethod.invoke(sendThread); wakeupCnxnMethod.invoke(clientCnxnSocket); } catch ( ReflectiveOperationException e ) { throw new RuntimeException("Could not inject session expiration using reflection", e); } }

Target:
public static void injectSessionExpiration(ZooKeeper zooKeeper) { try { WatchedEvent event = new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState.Expired, null); ClientCnxn clientCnxn = (ClientCnxn)cnxnField.get(zooKeeper); Object eventThread = eventThreadField.get(clientCnxn); queueEventMethod.invoke(eventThread, event); } catch ( ReflectiveOperationException e ) { throw new RuntimeException("Could not inject session expiration using reflection", e); } }
Source:
protected LocalizerTesterRobot() { super(); ArrayList<GpsMeasurement> waypoints = null; try { waypoints = WayPointUtil.createWayPointsFromWaypointList(RobobuggyConfigFile.getWaypointSourceLogFile()); } catch (FileNotFoundException e) { e.printStackTrace(); } nodeList.add(new LocalizerTester("localizer tester", waypoints, 1)); nodeList.add(new RobobuggyKFLocalizer(10, "localizer", new LocTuple(40.441670, -79.9416362))); RobobuggyJFrame mainWindow = new RobobuggyJFrame("MainWindow", 1.0, 1.0); Gui.getInstance().addWindow(mainWindow); RobobuggyGUITabs tabs = new RobobuggyGUITabs(); mainWindow.addComponent(tabs, 0.0, 0.0, 1.0, 1.0); tabs.addTab(new MainGuiWindow(), "Home"); tabs.add(new PathPanel(), "Path Visualizer"); tabs.addTab(new ConfigurationPanel(), "Configuration"); }

Target:
protected LocalizerTesterRobot() { super(); ArrayList<GpsMeasurement> waypoints = null; try { waypoints = WayPointUtil.createWayPointsFromWaypointList(RobobuggyConfigFile.getWaypointSourceLogFile()); } catch (FileNotFoundException e) { e.printStackTrace(); } nodeList.add(new LocalizerTester("localizer tester", waypoints)); nodeList.add(new RobobuggyKFLocalizer(10, "localizer", new LocTuple(40.441670, -79.9416362))); RobobuggyJFrame mainWindow = new RobobuggyJFrame("MainWindow", 1.0, 1.0); Gui.getInstance().addWindow(mainWindow); RobobuggyGUITabs tabs = new RobobuggyGUITabs(); mainWindow.addComponent(tabs, 0.0, 0.0, 1.0, 1.0); tabs.addTab(new MainGuiWindow(), "Home"); tabs.add(new PathPanel(), "Path Visualizer"); tabs.addTab(new ConfigurationPanel(), "Configuration"); }
Source:
public static void main(final String[] args) { try { final Arguments arguments = new Arguments(args); configureLogging(arguments.getConsoleLogLevel(), arguments.getFileLogLevel()); LOG.info("Version: {}", arguments.getVersion()); LOG.info("Command line args: {}", Joiner.on(", ").join(args)); LOG.info("Console log level: {}", arguments.getConsoleLogLevel().toString()); LOG.info("Log file log level: {}", arguments.getFileLogLevel().toString()); LOG.info(CliCommand.getPlatformInformation()); LOG.info(arguments.getArgumentLog()); if (arguments.isHelp()) { final Ds3Cli runner = new Ds3Cli(null, arguments, null); final CommandResponse response = runner.getCommandHelp(); System.out.println(response.getMessage()); System.exit(response.getReturnCode()); } final Ds3Client client = createClient(arguments); if (!Utils.isVersionSupported(client)) { System.out.println(String.format("ERROR: Minimum Black Pearl supported is %s", Utils.MINIMUM_VERSION_SUPPORTED)); System.exit(2); } final Ds3Provider provider = new Ds3ProviderImpl(client, Ds3ClientHelpers.wrap(client)); final FileUtils fileUtils = new FileUtilsImpl(); final Ds3Cli runner = new Ds3Cli(provider, arguments, fileUtils); final CommandResponse response = runner.call(); System.out.println(response.getMessage()); System.exit(response.getReturnCode()); } catch (final RuntimeException e) { System.out.println(e.getMessage()); System.exit(2); } catch (final Exception e) { EXCEPTION.handleException(Main.class.getSimpleName(), e, false); System.exit(2); } }

Target:
public static void main(final String[] args) { try { final Arguments arguments = new Arguments(args); configureLogging(arguments.getConsoleLogLevel(), arguments.getFileLogLevel()); LOG.info("Version: {}", arguments.getVersion()); LOG.info("Command line args: {}", Joiner.on(", ").join(args)); LOG.info("Console log level: {}", arguments.getConsoleLogLevel().toString()); LOG.info("Log file log level: {}", arguments.getFileLogLevel().toString()); LOG.info(CliCommand.getPlatformInformation()); LOG.info(arguments.getArgumentLog()); if (arguments.isHelp()) { final Ds3Cli runner = new Ds3Cli(null, arguments, null); final CommandResponse response = runner.getCommandHelp(); System.out.println(response.getMessage()); System.exit(response.getReturnCode()); } final Ds3Client client = createClient(arguments); if (!Utils.isVersionSupported(client)) { System.out.println(String.format("ERROR: Minimum Black Pearl supported is %s", Utils.MINIMUM_VERSION_SUPPORTED)); System.exit(2); } final Ds3Provider provider = new Ds3ProviderImpl(client, Ds3ClientHelpers.wrap(client)); final FileUtils fileUtils = new FileUtilsImpl(); final Ds3Cli runner = new Ds3Cli(provider, arguments, fileUtils); final CommandResponse response = runner.call(); System.out.println(response.getMessage()); System.exit(response.getReturnCode()); } catch (final Exception e) { EXCEPTION.handleException(e); System.exit(2); } }
Source:
public void start() { DynamicTasks.queue("install", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.INSTALL_LATCH); install(); }}); DynamicTasks.queue("customize", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH); customize(); }}); if (!Strings.isNullOrEmpty(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND))) { DynamicTasks.queue("pre-launch command", new Runnable() { public void run() { runPreLaunchCommand(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND)); }}); }; DynamicTasks.queue("launch", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.LAUNCH_LATCH); launch(); }}); if (!Strings.isNullOrEmpty(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND))) { DynamicTasks.queue("post-launch command", new Runnable() { public void run() { runPostLaunchCommand(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND)); }}); }; DynamicTasks.queue("post-launch", new Runnable() { public void run() { postLaunch(); }}); }

Target:
public void start() { DynamicTasks.queue("install", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.INSTALL_LATCH); install(); }}); DynamicTasks.queue("customize", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH); customize(); }}); if (Strings.isNonBlank(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND))) { DynamicTasks.queue("pre-launch command", new Runnable() { public void run() { runPreLaunchCommand(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND)); }}); }; DynamicTasks.queue("launch", new Runnable() { public void run() { waitForConfigKey(BrooklynConfigKeys.LAUNCH_LATCH); launch(); }}); if (Strings.isNonBlank(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND))) { DynamicTasks.queue("post-launch command", new Runnable() { public void run() { runPostLaunchCommand(entity.getConfig(BrooklynConfigKeys.POST_LAUNCH_COMMAND)); }}); }; DynamicTasks.queue("post-launch", new Runnable() { public void run() { postLaunch(); }}); }
Source:
private void findAllFragmentsWithViews( android.app.FragmentManager fragmentManager, ArrayMap<View, android.app.Fragment> result) { String key = "i"; int index = 0; while (true) { tempBundle.putInt(FRAGMENT_INDEX_KEY, index++); android.app.Fragment fragment = null; try { fragment = fragmentManager.getFragment(tempBundle, key); } catch (Exception e) { } if (fragment == null) { break; } if (fragment.getView() != null) { result.put(fragment.getView(), fragment); if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { findAllFragmentsWithViews(fragment.getChildFragmentManager(), result); } } } }

Target:
private void findAllFragmentsWithViews( android.app.FragmentManager fragmentManager, ArrayMap<View, android.app.Fragment> result) { int index = 0; while (true) { tempBundle.putInt(FRAGMENT_INDEX_KEY, index++); android.app.Fragment fragment = null; try { fragment = fragmentManager.getFragment(tempBundle, FRAGMENT_MANAGER_GET_FRAGMENT_KEY); } catch (Exception e) { } if (fragment == null) { break; } if (fragment.getView() != null) { result.put(fragment.getView(), fragment); if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { findAllFragmentsWithViews(fragment.getChildFragmentManager(), result); } } } }
Source:
protected AbstractTreeIterator[] mergeBases() throws IOException { final int numsourceTrees = sourceTrees.length; int commitIdx = 0; RevTree tempTrees[] = new RevTree[MAX_BASES]; AbstractTreeIterator tempIterators[] = new AbstractTreeIterator[MAX_BASES]; if (baseTrees == null) { baseTrees = new RevTree[MAX_BASES]; baseTreeIterators = new AbstractTreeIterator[MAX_BASES]; } for (int aIdx = 0; aIdx < numsourceTrees; aIdx++) { for (int bIdx = aIdx + 1; bIdx < numsourceTrees; bIdx++) { List<RevCommit> baseCommits = getBaseCommits(aIdx, bIdx); for (RevCommit baseCommit : baseCommits) { if (commitIdx < MAX_BASES) { tempTrees[commitIdx] = baseCommit.getTree(); tempIterators[commitIdx] = openTree(baseCommit .getTree()); commitIdx++; } else { throw new IOException(String.format( tooManyMergeBasesFor, "TOO_MANY_BASES", sourceCommits[aIdx].name(), sourceCommits[bIdx].name(), Integer.valueOf(commitIdx), baseCommit.name())); } } } } if (commitIdx == 0) { baseTreeIterators[commitIdx] = new EmptyTreeIterator(); commitIdx++; } else { baseTrees = Arrays.copyOf(tempTrees, commitIdx); baseTreeIterators = Arrays.copyOf(tempIterators, commitIdx); } return Arrays.copyOf(baseTreeIterators, baseTreeIterators.length); }

Target:
protected AbstractTreeIterator[] mergeBases() throws IOException { final int numsourceTrees = sourceTrees.length; int commitIdx = 0; RevTree tempTrees[] = new RevTree[MAX_BASES]; AbstractTreeIterator tempIterators[] = new AbstractTreeIterator[MAX_BASES]; if (baseTrees == null) { baseTrees = new RevTree[MAX_BASES]; baseTreeIterators = new AbstractTreeIterator[MAX_BASES]; } for (int aIdx = 0; aIdx < numsourceTrees; aIdx++) { for (int bIdx = aIdx + 1; bIdx < numsourceTrees; bIdx++) { List<RevCommit> baseCommits = getBaseCommits(aIdx, bIdx); for (RevCommit baseCommit : baseCommits) { if (commitIdx < MAX_BASES) { tempTrees[commitIdx] = baseCommit.getTree(); tempIterators[commitIdx] = openTree(baseCommit .getTree()); commitIdx++; } else { throw new IOException(String.format( tooManyMergeBasesFor, "TOO_MANY_BASES", sourceCommits[aIdx].name(), sourceCommits[bIdx].name(), Integer.valueOf(commitIdx), baseCommit.name())); } } } } if (commitIdx == 0) { baseTreeIterators[commitIdx] = new EmptyTreeIterator(); commitIdx++; } else { baseTrees = copyOf(tempTrees, commitIdx); baseTreeIterators = copyOf(tempIterators, commitIdx); } return copyOf(baseTreeIterators, baseTreeIterators.length); }
Source:
public void tearDown() throws Exception { deleteIfWorkspaceExist(expectedJavaItem.getWorkspaceName()); deleteIfWorkspaceExist(expectedBlankItem.getWorkspaceName()); deleteIfWorkspaceExist(expectedNewestWorkspaceItem.getWorkspaceName()); }

Target:
public void tearDown() throws Exception { testWorkspaceServiceClient.delete( expectedNewestWorkspaceItem.getWorkspaceName(), defaultTestUser.getName()); }
Source:
private void writeAlias(VmDevice device) { writer.writeStartElement("alias"); writer.writeAttributeString("name", String.format("ua-%s", device.getId().getDeviceId().toString())); writer.writeEndElement(); }

Target:
private void writeAlias(VmDevice device) { writer.writeStartElement("alias"); writer.writeAttributeString("name", String.format("ua-%s", device.getId().getDeviceId())); writer.writeEndElement(); }
Source:
protected void delete(Context context, Integer id) throws AuthorizeException { String copyVirtual = requestService.getCurrentRequest().getServletRequest().getParameter("copyVirtualMetadata"); if (copyVirtual == null) { copyVirtual = "none"; } Relationship relationship = null; try { relationship = relationshipService.find(context, id); if (relationship != null) { try { switch (copyVirtual) { case "all": relationshipService.delete(context, relationship, true, true); break; case "left": relationshipService.delete(context, relationship, true, false); break; case "right": relationshipService.delete(context, relationship, false, true); break; case "configured": relationshipService.delete(context, relationship); break; default: relationshipService.delete(context, relationship, false, false); break; } } catch (AuthorizeException e) { throw new AccessDeniedException("You do not have write rights on this relationship's items"); } } } catch (SQLException e) { log.error("Error deleting Relationship specified by ID:" + id, e); } }

Target:
protected void delete(Context context, Integer id) throws AuthorizeException { String copyVirtual = requestService.getCurrentRequest().getServletRequest().getParameter("copyVirtualMetadata"); if (copyVirtual == null) { copyVirtual = "none"; } Relationship relationship = null; try { relationship = relationshipService.find(context, id); if (relationship != null) { try { switch (copyVirtual) { case ALL: relationshipService.delete(context, relationship, true, true); break; case LEFT: relationshipService.delete(context, relationship, true, false); break; case RIGHT: relationshipService.delete(context, relationship, false, true); break; case CONFIGURED: relationshipService.delete(context, relationship); break; default: relationshipService.delete(context, relationship, false, false); break; } } catch (AuthorizeException e) { throw new AccessDeniedException("You do not have write rights on this relationship's items"); } } } catch (SQLException e) { log.error("Error deleting Relationship specified by ID:" + id, e); } }
Source:
public IConnection createOpenshiftConnection(IServer server, ServiceManagerEnvironment adb, ConnectionsRegistry registry) { Properties dotcdkProps = new CDKServerUtility().getDotCDK(server); String authScheme = dotcdkProps.containsKey(DOTCDK_AUTH_SCHEME) ? dotcdkProps.getProperty(DOTCDK_AUTH_SCHEME) : "Basic"; String username = dotcdkProps.containsKey(DOTCDK_AUTH_USERNAME) ? dotcdkProps.getProperty(DOTCDK_AUTH_USERNAME) : "openshift-dev"; String password = null; if( dotcdkProps.containsKey(DOTCDK_AUTH_PASS) ) { password = dotcdkProps.getProperty(DOTCDK_AUTH_PASS); } else { if( "openshift-dev".equals(username)) { password = "devel"; } } String soughtHost = adb.openshiftHost + ":" + adb.openshiftPort; ConnectionsFactoryTracker connectionsFactory = new ConnectionsFactoryTracker(); connectionsFactory.open(); IConnectionFactory factory = connectionsFactory.getById(IConnectionsFactory.CONNECTIONFACTORY_OPENSHIFT_ID); IConnection con = factory.create(soughtHost); ((Connection)con).setAuthScheme(authScheme); ((Connection)con).setUsername(username); ((Connection)con).setRememberPassword(true); String defaultImageRegistry = "<LINK_0> "; ((Connection)con).setExtendedProperty(ICommonAttributes.IMAGE_REGISTRY_URL_KEY, defaultImageRegistry); if( password != null ) { ((Connection)con).setPassword(password); } if( registry != null ) registry.add(con); return con; }

Target:
public IConnection createOpenshiftConnection(IServer server, ServiceManagerEnvironment adb, ConnectionsRegistry registry) { Properties dotcdkProps = new CDKServerUtility().getDotCDK(server); String authScheme = dotcdkProps.containsKey(DOTCDK_AUTH_SCHEME) ? dotcdkProps.getProperty(DOTCDK_AUTH_SCHEME) : "Basic"; String username = dotcdkProps.containsKey(DOTCDK_AUTH_USERNAME) ? dotcdkProps.getProperty(DOTCDK_AUTH_USERNAME) : "openshift-dev"; String password = null; if( dotcdkProps.containsKey(DOTCDK_AUTH_PASS) ) { password = dotcdkProps.getProperty(DOTCDK_AUTH_PASS); } else { if( "openshift-dev".equals(username)) { password = "devel"; } } String soughtHost = adb.openshiftHost + ":" + adb.openshiftPort; ConnectionsFactoryTracker connectionsFactory = new ConnectionsFactoryTracker(); connectionsFactory.open(); IConnectionFactory factory = connectionsFactory.getById(IConnectionsFactory.CONNECTIONFACTORY_OPENSHIFT_ID); IConnection con = factory.create(soughtHost); ((Connection)con).setAuthScheme(authScheme); ((Connection)con).setUsername(username); ((Connection)con).setRememberPassword(true); ((Connection)con).setExtendedProperty(ICommonAttributes.IMAGE_REGISTRY_URL_KEY, DEFAULT_IMAGE_REGISTRY_URL); if( password != null ) { ((Connection)con).setPassword(password); } if( registry != null ) registry.add(con); return con; }
Source:
public static int mapDPIToZoom (int dpi) { int zoom; zoom = dpi * 100 / DPI_ZOOM_100; zoom = (int) (Math.round (zoom / MIN_ZOOM_INTERVAL) * MIN_ZOOM_INTERVAL); return zoom; }

Target:
public static int mapDPIToZoom (int dpi) { double zoom = dpi * 100 / DPI_ZOOM_100; int roundedZoom = (int) (Math.round (zoom / MIN_ZOOM_INTERVAL) * MIN_ZOOM_INTERVAL); return roundedZoom; }
Source:
static protected Tuple combine(DataBag values) throws ExecException { Tuple output = mTupleFactory.newTuple(2); boolean sawNonNull = false; double sumOfCxLogCx = 0; long sumOfCx = 0; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); Double scxlogcx = (Double)t.get(0); Long scx = (Long)t.get(1); sumOfCxLogCx += (scxlogcx == null ? 0 : scxlogcx.doubleValue()); sumOfCx += (scx == null ? 0 : scx.longValue()); if(scxlogcx != null && scx != null) { sawNonNull = true; } } if(sawNonNull) { output.set(0, sumOfCxLogCx); output.set(1, sumOfCx); } else { output.set(0, null); output.set(1, null); } return output; }

Target:
static protected Tuple combine(DataBag values) throws ExecException { Tuple output = mTupleFactory.newTuple(2); boolean sawNonNull = false; double sumOfCxLogCx = 0; long sumOfCx = 0; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); Double scxlogcx = (Double)t.get(0); Long scx = (Long)t.get(1); if(scxlogcx != null && scx != null) { sumOfCxLogCx += scxlogcx.doubleValue(); sumOfCx += scx.longValue(); sawNonNull = true; } } if (sawNonNull) { output.set(0, sumOfCxLogCx); output.set(1, sumOfCx); } else { output.set(0, null); output.set(1, null); } return output; }
Source:
public void formLoginSecurityContextRepository() { ServerSecurityContextRepository defaultSecContextRepository = mock(ServerSecurityContextRepository.class); ServerSecurityContextRepository formLoginSecContextRepository = mock(ServerSecurityContextRepository.class); TestingAuthenticationToken token = new TestingAuthenticationToken("rob", "rob", "ROLE_USER"); given(defaultSecContextRepository.save(any(), any())).willReturn(Mono.empty()); given(defaultSecContextRepository.load(any())).willReturn(authentication(token)); given(formLoginSecContextRepository.save(any(), any())).willReturn(Mono.empty()); given(formLoginSecContextRepository.load(any())).willReturn(authentication(token)); SecurityWebFilterChain securityWebFilter = this.http .authorizeExchange() .anyExchange().authenticated() .and() .securityContextRepository(defaultSecContextRepository) .formLogin() .securityContextRepository(formLoginSecContextRepository) .and() .build(); WebTestClient webTestClient = WebTestClientBuilder .bindToWebFilters(securityWebFilter) .build(); WebDriver driver = WebTestClientHtmlUnitDriverBuilder .webTestClientSetup(webTestClient) .build(); DefaultLoginPage loginPage = DefaultLoginPage.to(driver) .assertAt(); HomePage homePage = loginPage.loginForm() .username("user") .password("password") .submit(HomePage.class); homePage.assertAt(); verify(defaultSecContextRepository, times(3)).load(any()); verify(formLoginSecContextRepository).save(any(), any()); }

Target:
public void formLoginSecurityContextRepository() { ServerSecurityContextRepository defaultSecContextRepository = mock(ServerSecurityContextRepository.class); ServerSecurityContextRepository formLoginSecContextRepository = mock(ServerSecurityContextRepository.class); TestingAuthenticationToken token = new TestingAuthenticationToken("rob", "rob", "ROLE_USER"); given(defaultSecContextRepository.save(any(), any())).willReturn(Mono.empty()); given(defaultSecContextRepository.load(any())).willReturn(authentication(token)); given(formLoginSecContextRepository.save(any(), any())).willReturn(Mono.empty()); given(formLoginSecContextRepository.load(any())).willReturn(authentication(token)); SecurityWebFilterChain securityWebFilter = this.http .authorizeExchange() .anyExchange().authenticated() .and() .securityContextRepository(defaultSecContextRepository) .formLogin() .securityContextRepository(formLoginSecContextRepository) .and() .build(); WebTestClient webTestClient = WebTestClientBuilder .bindToWebFilters(securityWebFilter) .build(); WebDriver driver = WebTestClientHtmlUnitDriverBuilder .webTestClientSetup(webTestClient) .build(); DefaultLoginPage loginPage = DefaultLoginPage.to(driver) .assertAt(); HomePage homePage = loginPage.loginForm() .username("user") .password("password") .submit(HomePage.class); homePage.assertAt(); verify(defaultSecContextRepository, atLeastOnce()).load(any()); verify(formLoginSecContextRepository).save(any(), any()); }
Source:
public String toString() { return MoreObjects.toStringHelper("") .add("ClientType", getStringFromOptional(mClientType)) .add("ServerAddress", mServerAddress) .add("ChannelId", mChannelId) .add("KeepAliveTime", getStringFromOptional(mKeepAliveTime)) .add("KeepAliveTimeout", getStringFromOptional(mKeepAliveTimeout)) .add("FlowControlWindow", getStringFromOptional(mFlowControlWindow)) .add("MaxInboundMessageSize", getStringFromOptional(mMaxInboundMessageSize)) .add("ChannelType", getStringFromOptional(mChannelType)) .omitNullValues() .toString(); }

Target:
public String toString() { return MoreObjects.toStringHelper(this) .add("ClientType", getStringFromOptional(mClientType)) .add("ServerAddress", mServerAddress) .add("ChannelId", mChannelId) .add("KeepAliveTime", getStringFromOptional(mKeepAliveTime)) .add("KeepAliveTimeout", getStringFromOptional(mKeepAliveTimeout)) .add("FlowControlWindow", getStringFromOptional(mFlowControlWindow)) .add("MaxInboundMessageSize", getStringFromOptional(mMaxInboundMessageSize)) .add("ChannelType", getStringFromOptional(mChannelType)) .omitNullValues() .toString(); }
Source:
public void testPrimaryKeyOrderIsNotAffectedIfReInsertedWithDifferentSecondaryKey() { final DualKeyLinkedMap<Integer, Integer, String> map = new DualKeyLinkedMap<>(2); final String value = "foobar"; map.put(1, 1, value); map.put(2, 2, value); map.put(1, 3, value); assertThat(map.keySetA().iterator().next(), is(1)); }

Target:
public void testPrimaryKeyOrderIsNotAffectedIfReInsertedWithDifferentSecondaryKey() { final DualKeyLinkedMap<Integer, Integer, String> map = new DualKeyLinkedMap<>(2); final String value1 = "1"; map.put(1, 1, value1); final String value2 = "2"; map.put(2, 2, value2); final String value3 = "3"; map.put(1, 3, value3); assertThat(map.keySetA().iterator().next(), is(1)); assertThat(map.values().iterator().next(), is(value3)); }
Source:
private Image getEnhancedImage(final Image image, final Viewpoint viewpoint) { if (ViewpointRegistry.getInstance().isFromPlugin(viewpoint) && image != null) { return SiriusEditPlugin.getPlugin().getImage(getOverlayedDescriptor(image, "icons/full/decorator/folder_close.gif")); } return image; }

Target:
private Image getEnhancedImage(final Image image, final Viewpoint viewpoint) { if (!ViewpointRegistry.getInstance().isFromPlugin(viewpoint) && image != null) { return SiriusEditPlugin.getPlugin().getImage(getOverlayedDescriptor(image, "icons/full/decorator/folder_close.gif")); } return image; }
Source:
private static Long parseMaxMemory( String maxMemoryString ) { if ( maxMemoryString != null ) { maxMemoryString = maxMemoryString.trim(); if ( maxMemoryString.endsWith( "%" ) ) { int percent = Integer.parseInt( maxMemoryString.substring( 0, maxMemoryString.length() - 1 ) ); long result = calculateMaxMemoryFromPercent( percent ); if ( !canDetectFreeMemory() ) { System.err.println( "WARNING: amount of free memory couldn't be detected so defaults to " + bytes( result ) + ". For optimal performance instead explicitly specify amount of " + "memory that importer is allowed to use using " + Options.MAX_MEMORY.argument() ); } } return Settings.parseLongWithUnit( maxMemoryString ); } return null; }

Target:
private static Long parseMaxMemory( String maxMemoryString ) { if ( maxMemoryString != null ) { maxMemoryString = maxMemoryString.trim(); if ( maxMemoryString.endsWith( "%" ) ) { int percent = Integer.parseInt( maxMemoryString.substring( 0, maxMemoryString.length() - 1 ) ); long result = calculateMaxMemoryFromPercent( percent ); if ( !canDetectFreeMemory() ) { System.err.println( "WARNING: amount of free memory couldn't be detected so defaults to " + bytes( result ) + ". For optimal performance instead explicitly specify amount of " + "memory that importer is allowed to use using " + Options.MAX_MEMORY.argument() ); } return result; } return Settings.parseLongWithUnit( maxMemoryString ); } return null; }
Source:
private static void zipFiles(List<File> files, String basepath, OutputStream os) throws IOException { Closer closer = Closer.create(); try { ZipOutputStream zos = new ZipOutputStream(os); closer.register(zos); for (File file : files) { if (file.isFile()) { FileInputStream inputStream = new FileInputStream(file); closer.register(inputStream); writeZipEntry(zipEntry(basepath, file), inputStream, zos); } } } catch (IOException ioe) { throw closer.rethrow(ioe); } finally { closer.close(); } }

Target:
private static void zipFiles(List<File> files, String basepath, OutputStream os) throws IOException { Closer closer = Closer.create(); try { ZipOutputStream zos = new ZipOutputStream(os); closer.register(zos); for (File file : files) { if (file.isFile()) { FileInputStream inputStream = new FileInputStream(file); closer.register(inputStream); writeZipEntry(zipEntry(basepath, file), inputStream, zos); } else { ZipEntry ze = zipEntry(basepath, file); logger.trace("Adding directory zip entry: " + ze.toString()); zos.putNextEntry(ze); } } } catch (IOException ioe) { throw closer.rethrow(ioe); } finally { closer.close(); } }
Source:
private Method findMethod(Class<?> clazz, String methodName) { return ReflectionUtils.findMethod(clazz, methodName) .orElseGet(() -> ReflectionUtils.findMethod(clazz, methodName, ExtensionContext.class) .orElseThrow(() -> new JUnitException( format("Could not find method [%s] in class [%s]", methodName, clazz.getName())))); }

Target:
private Method findMethod(Class<?> clazz, String methodName) { return ReflectionUtils.findMethod(clazz, methodName) .orElseGet(() -> ReflectionUtils.getRequiredMethod(clazz, methodName, ExtensionContext.class)); }
Source:
public void testNonExistentUrl() { WebRequestHandler request = new WebRequestHandler(); try { request.sendGet( getUrl("<LINK_0>"), null); } catch (final IOException e) { assertTrue(e instanceof UnknownHostException); assertTrue(e.getMessage().toLowerCase(Locale.US).contains("unable to resolve host")); } }

Target:
public void testNonExistentUrl() { WebRequestHandler request = new WebRequestHandler(); try { request.sendGet( getUrl("<LINK_0>"), null); fail("Unreachable host, should throw IOException"); } catch (final IOException e) { assertTrue(e instanceof UnknownHostException); assertTrue(e.getMessage().toLowerCase(Locale.US).contains("unable to resolve host")); } }