auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void queueBackwardsCompatibility() { CorfuQueue oldQueueInstance1 = new CorfuQueue(getDefaultRuntime(), "test", Serializers.JSON); CorfuRuntime rt2 = getNewRuntime(getDefaultNode()).connect(); CorfuQueue oldQueueInstance2 = new CorfuQueue(rt2, "test", Serializers.QUEUE_SERIALIZER); final int numItemsToProduce = 10; IntStream.range(0, numItemsToProduce).forEach(itemIdx -> { if (itemIdx % 2 == 0) { oldQueueInstance1.enqueue(getByteString(String.valueOf(itemIdx))); } else { oldQueueInstance2.enqueue(getByteString(String.valueOf(itemIdx))); } }); CorfuRuntime rt3 = getNewRuntime(getDefaultNode()).connect(); CorfuQueue newQueueInstance= new CorfuQueue(rt3, "test"); assertThat(newQueueInstance.size()).isEqualTo(numItemsToProduce); IntStream.range(0, numItemsToProduce).forEach(itemIdx -> { assertThat(newQueueInstance.entryList().get(itemIdx).getEntry().toStringUtf8()) .isEqualTo(String.valueOf(itemIdx)); }); }

Target:
public void queueBackwardsCompatibility() { CorfuQueue oldQueueInstance1 = new CorfuQueue(getDefaultRuntime(), "test", Serializers.JSON); CorfuRuntime rt2 = getNewRuntime(getDefaultNode()).connect(); CorfuQueue oldQueueInstance2 = new CorfuQueue(rt2, "test", Serializers.QUEUE_SERIALIZER); final int numItemsToProduce = 10; IntStream.range(0, numItemsToProduce).forEach(itemIdx -> { if (itemIdx % 2 == 0) { executeTxn(getDefaultRuntime(), () -> oldQueueInstance1.enqueue(getByteString(String.valueOf(itemIdx)))); } else { executeTxn(rt2, () -> oldQueueInstance2.enqueue(getByteString(String.valueOf(itemIdx)))); } }); CorfuRuntime rt3 = getNewRuntime(getDefaultNode()).connect(); CorfuQueue newQueueInstance= new CorfuQueue(rt3, "test"); assertThat(newQueueInstance.size()).isEqualTo(numItemsToProduce); IntStream.range(0, numItemsToProduce).forEach(itemIdx -> { assertThat(newQueueInstance.entryList().get(itemIdx).getEntry().toStringUtf8()) .isEqualTo(String.valueOf(itemIdx)); }); }
Source:
public void translate(final LogicalFilter filter, final TranslatorContext context) { MessageStream<SamzaSqlRelMessage> inputStream = context.getMessageStream(filter.getInput().getId()); MessageStream<SamzaSqlRelMessage> outputStream = inputStream.filter(message -> { Expression expr = context.getExpressionCompiler().compile(filter.getInputs(), Collections.singletonList(filter.getCondition())); Object[] result = new Object[1]; expr.execute(message.getValue(), result); if (result.length > 0 && result[0] instanceof Boolean) { boolean retVal = (Boolean) result[0]; log.info( String.format("return value for input %s is %s", Arrays.asList(message.getValue()).toString(), retVal)); return retVal; } else { log.error("return value is not boolean"); return false; } }); context.registerMessageStream(filter.getId(), outputStream); }

Target:
public void translate(final LogicalFilter filter, final TranslatorContext context) { MessageStream<SamzaSqlRelMessage> inputStream = context.getMessageStream(filter.getInput().getId()); Expression expr = context.getExpressionCompiler().compile(filter.getInputs(), Collections.singletonList(filter.getCondition())); MessageStream<SamzaSqlRelMessage> outputStream = inputStream.filter(message -> { Object[] result = new Object[1]; expr.execute(context.getExecutionContext(), context.getDataContext(), message.getRelFieldValues().toArray(), result); if (result.length > 0 && result[0] instanceof Boolean) { boolean retVal = (Boolean) result[0]; log.debug( String.format("return value for input %s is %s", Arrays.asList(message.getFieldValues()).toString(), retVal)); return retVal; } else { log.error("return value is not boolean"); return false; } }); context.registerMessageStream(filter.getId(), outputStream); }
Source:
Map<String, Integer> parallelismDelta(Map<String, Integer> componentCounts, Map<String, Integer> changeRequests) { for (String component : changeRequests.keySet()) { if (!componentCounts.containsKey(component)) { throw new IllegalArgumentException( "Invalid component name in update request: " + component); } Integer newValue = changeRequests.get(component); Integer delta = newValue - componentCounts.get(component); if (delta == 0) { changeRequests.remove(component); } else { changeRequests.put(component, delta); } } return changeRequests; }

Target:
Map<String, Integer> parallelismDelta(Map<String, Integer> componentCounts, Map<String, Integer> changeRequests) { Map<String, Integer> componentDeltas = new HashMap<>(); for (String component : changeRequests.keySet()) { if (!componentCounts.containsKey(component)) { throw new IllegalArgumentException( "Invalid component name in update request: " + component); } Integer newValue = changeRequests.get(component); Integer delta = newValue - componentCounts.get(component); if (delta != 0) { componentDeltas.put(component, delta); } } return componentDeltas; }
Source:
public boolean shouldExecuteOnProject(Project project) { boolean x1 = fileSystem.hasFiles(fileSystem.predicates().hasLanguage(Python.KEY)), x2 = !profile.getActiveRulesByRepository(PylintRuleRepository.REPOSITORY_KEY).isEmpty(); return fileSystem.hasFiles(fileSystem.predicates().hasLanguage(Python.KEY)) && !profile.getActiveRulesByRepository(PylintRuleRepository.REPOSITORY_KEY).isEmpty(); }

Target:
public boolean shouldExecuteOnProject(Project project) { FilePredicates p = fileSystem.predicates(); boolean hasFiles = fileSystem.hasFiles(p.and(p.hasType(InputFile.Type.MAIN), p.hasLanguage(Python.KEY))); boolean hasRules = !profile.getActiveRulesByRepository(PylintRuleRepository.REPOSITORY_KEY).isEmpty(); return hasFiles && hasRules && settings.getString(REPORT_PATH_KEY) == null; }
Source:
public Response<Set<String>> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException, BadRequestException { if (input == null || Strings.isNullOrEmpty(input.hashtags)) { throw new BadRequestException("Hashtags are required"); } ChangeControl control = req.getControl(); ChangeUpdate update = updateFactory.create(control); ChangeNotes notes = control.getNotes().load(); Set<String> hashtags = new HashSet<String>(); Set<String> oldHashtags = notes.getHashtags(); if (oldHashtags != null) { hashtags.addAll(oldHashtags); } hashtags.removeAll(Arrays.asList(input.hashtags.split(","))); update.setHashtags(hashtags); update.commit(); return Response.ok(hashtags); }

Target:
public Response<Set<String>> apply(ChangeResource req, Input input) throws OrmException, IOException, BadRequestException { if (input == null || Strings.isNullOrEmpty(input.hashtags)) { throw new BadRequestException("Hashtags are required"); } ChangeControl control = req.getControl(); ChangeUpdate update = updateFactory.create(control); ChangeNotes notes = control.getNotes().load(); Set<String> hashtags = new HashSet<String>(); Set<String> oldHashtags = notes.getHashtags(); if (oldHashtags != null) { hashtags.addAll(oldHashtags); } hashtags.removeAll(Arrays.asList(input.hashtags.split(","))); update.setHashtags(hashtags); update.commit(); ChangeUtil.bumpRowVersionNotLastUpdatedOn(req.getChange().getId(), db.get()); return Response.ok(hashtags); }
Source:
public ODataDataHandler createODataHandler() throws ODataServiceFault { return new MongoDataHandler(getConfigId(),getJongo()); }

Target:
public ODataDataHandler createODataHandler() { return new MongoDataHandler(getConfigId(), getJongo()); }
Source:
public void onOpen() { final String currentPerspectiveIdentifier = perspectiveManager.getCurrentPerspective().getIdentifier(); final Collection<UberfireDock> stunnerDocks = stunnerDocksHandler.provideDocks(currentPerspectiveIdentifier); stunnerDocks.stream() .filter(dock -> dock.getPlaceRequest().getIdentifier().compareTo(DiagramEditorPropertiesScreen.SCREEN_ID) == 0) .forEach(uberfireDocks::open); super.doOpen(); }

Target:
public void onOpen() { final String currentPerspectiveIdentifier = perspectiveManager.getCurrentPerspective().getIdentifier(); final Collection<UberfireDock> stunnerDocks = stunnerDocksHandler.provideDocks(currentPerspectiveIdentifier); stunnerDocks.stream() .filter(dock -> Objects.equals(dock.getPlaceRequest().getIdentifier(), DiagramEditorPropertiesScreen.SCREEN_ID)) .forEach(uberfireDocks::open); super.doOpen(); }
Source:
private GitUser getCommitCommitter(RevCommit commit) { PersonIdent committerIdentity = commit.getCommitterIdent(); GitUser committer = createDto(GitUser.class).withName(committerIdentity.getName()) .withEmail(committerIdentity.getEmailAddress()); return committer; }

Target:
private GitUser getCommitCommitter(RevCommit commit) { PersonIdent committerIdentity = commit.getCommitterIdent(); return newDto(GitUser.class).withName(committerIdentity.getName()) .withEmail(committerIdentity.getEmailAddress()); }
Source:
public BinaryResult apply(RevisionResource rsrc) throws BadRequestException, IOException { if (Strings.isNullOrEmpty(format)) { throw new BadRequestException("format is not specified"); } final ArchiveFormat f = allowedFormats.extensions.get("." + format); if (f == null || f == ArchiveFormat.ZIP) { throw new BadRequestException("unknown archive format"); } boolean close = true; final Repository repo = repoManager .openRepository(rsrc.getControl().getProject().getNameKey()); try { final RevWalk rw = new RevWalk(repo); try { final RevCommit commit = rw.parseCommit(ObjectId.fromString(rsrc.getPatchSet() .getRevision().get())); BinaryResult bin = new BinaryResult() { @Override public void writeTo(OutputStream out) throws IOException { try { new ArchiveCommand(repo) .setFormat(f.name()) .setTree(commit.getTree()) .setOutputStream(out).call(); } catch (GitAPIException e) { throw new IOException(e); } } @Override public void close() throws IOException { rw.close(); repo.close(); } }; bin.disableGzip() .setContentType(f.getMimeType()) .setAttachmentName(name(f, rw, commit)); close = false; return bin; } finally { if (close) { rw.close(); } } } finally { if (close) { repo.close(); } } }

Target:
public BinaryResult apply(RevisionResource rsrc) throws BadRequestException, IOException, MethodNotAllowedException { if (Strings.isNullOrEmpty(format)) { throw new BadRequestException("format is not specified"); } final ArchiveFormat f = allowedFormats.extensions.get("." + format); if (f == null) { throw new BadRequestException("unknown archive format"); } if (f == ArchiveFormat.ZIP) { throw new MethodNotAllowedException("zip format is disabled"); } boolean close = true; final Repository repo = repoManager .openRepository(rsrc.getControl().getProject().getNameKey()); try { final RevWalk rw = new RevWalk(repo); try { final RevCommit commit = rw.parseCommit(ObjectId.fromString(rsrc.getPatchSet() .getRevision().get())); BinaryResult bin = new BinaryResult() { @Override public void writeTo(OutputStream out) throws IOException { try { new ArchiveCommand(repo) .setFormat(f.name()) .setTree(commit.getTree()) .setOutputStream(out).call(); } catch (GitAPIException e) { throw new IOException(e); } } @Override public void close() throws IOException { rw.close(); repo.close(); } }; bin.disableGzip() .setContentType(f.getMimeType()) .setAttachmentName(name(f, rw, commit)); close = false; return bin; } finally { if (close) { rw.close(); } } } finally { if (close) { repo.close(); } } }
Source:
private String rewritePropsFile(String masterHosts, String originalFileName) { Properties kuduConnectionProperties = new Properties(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream kuduPropsFileAsStream = loader.getResourceAsStream(originalFileName); File tempPropertiesFile = null; try { tempPropertiesFile = File.createTempFile(System.getProperty("java.io.tmpdir"),".properties"); LOG.info(tempPropertiesFile.getAbsolutePath() + " is being used as a temporary props file"); } catch (IOException e) { LOG.error("Not able to create temp file",e); return originalFileName; } if (kuduPropsFileAsStream != null) { try { kuduConnectionProperties.load(kuduPropsFileAsStream); kuduPropsFileAsStream.close(); FileOutputStream toBeModifiedFileHandle = new FileOutputStream(tempPropertiesFile); kuduConnectionProperties.put(BaseKuduOutputOperator.MASTER_HOSTS,masterHosts); kuduConnectionProperties.store(toBeModifiedFileHandle,"updated by unit test"); toBeModifiedFileHandle.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return tempPropertiesFile.getAbsolutePath(); }

Target:
private String rewritePropsFile(String masterHosts, String originalFileName) { Properties kuduConnectionProperties = new Properties(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream kuduPropsFileAsStream = loader.getResourceAsStream(originalFileName); File tempPropertiesFile = null; try { tempPropertiesFile = File.createTempFile("kuduclusterconfig-" + System.currentTimeMillis(), ".properties"); LOG.info(tempPropertiesFile.getAbsolutePath() + " is being used as a temporary props file"); } catch (IOException e) { LOG.error("Not able to create temp file",e); return originalFileName; } if (kuduPropsFileAsStream != null) { try { kuduConnectionProperties.load(kuduPropsFileAsStream); kuduPropsFileAsStream.close(); FileOutputStream toBeModifiedFileHandle = new FileOutputStream(tempPropertiesFile); kuduConnectionProperties.put(BaseKuduOutputOperator.MASTER_HOSTS,masterHosts); kuduConnectionProperties.store(toBeModifiedFileHandle,"updated by unit test"); toBeModifiedFileHandle.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } return tempPropertiesFile.getAbsolutePath(); }
Source:
protected void buildVmNetworkInterfaces() { Boolean useRtl8139_pv = Config.<Boolean> GetValue( ConfigValues.UseRtl8139_pv, vm .getvds_group_compatibility_version() .toString()); for (VmNetworkInterface vmInterface : vm.getInterfaces()) { VmDevice vmDevice = DbFacade.getInstance() .getVmDeviceDAO() .get(new VmDeviceId(vmInterface.getId(), vmInterface.getVmId().getValue())); if (vmDevice.getIsManaged() && vmDevice.getIsPlugged()) { XmlRpcStruct struct = new XmlRpcStruct(); VmInterfaceType ifaceType = VmInterfaceType.rtl8139; if (vmInterface.getType() != null) { ifaceType = VmInterfaceType.forValue(vmInterface.getType()); } if (ifaceType == VmInterfaceType.rtl8139_pv) { if (!useRtl8139_pv) { if (vm.getHasAgent()) { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, VmInterfaceType.pv.name()); } else { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, VmInterfaceType.rtl8139.name()); } } else { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, VmInterfaceType.pv.name()); XmlRpcStruct rtl8139Struct = new XmlRpcStruct(); addNetworkInterfaceProperties(rtl8139Struct, vmInterface, vmDevice, VmInterfaceType.rtl8139.name()); devices.add(rtl8139Struct); } } else { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, ifaceType.toString()); } devices.add(struct); addToManagedDevices(vmDevice); } } }

Target:
protected void buildVmNetworkInterfaces() { Boolean useRtl8139_pv = Config.<Boolean> GetValue( ConfigValues.UseRtl8139_pv, vm .getvds_group_compatibility_version() .toString()); Map<VmDeviceId, VmDevice> devicesByDeviceId = Entities.businessEntitiesById(DbFacade.getInstance().getVmDeviceDAO().getVmDeviceByVmId(vm.getId())); for (VmNetworkInterface vmInterface : vm.getInterfaces()) { VmDevice vmDevice = devicesByDeviceId.get(new VmDeviceId(vmInterface.getId(), vmInterface.getVmId().getValue())); if (vmDevice != null && vmDevice.getIsManaged() && vmDevice.getIsPlugged()) { XmlRpcStruct struct = new XmlRpcStruct(); VmInterfaceType ifaceType = VmInterfaceType.rtl8139; if (vmInterface.getType() != null) { ifaceType = VmInterfaceType.forValue(vmInterface.getType()); } if (ifaceType == VmInterfaceType.rtl8139_pv) { if (!useRtl8139_pv) { if (vm.getHasAgent()) { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, VmInterfaceType.pv.name()); } else { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, VmInterfaceType.rtl8139.name()); } } else { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, VmInterfaceType.pv.name()); XmlRpcStruct rtl8139Struct = new XmlRpcStruct(); addNetworkInterfaceProperties(rtl8139Struct, vmInterface, vmDevice, VmInterfaceType.rtl8139.name()); devices.add(rtl8139Struct); } } else { addNetworkInterfaceProperties(struct, vmInterface, vmDevice, ifaceType.toString()); } devices.add(struct); addToManagedDevices(vmDevice); } } }
Source:
private boolean compareSequenceDictionaries(final SAMFileHeader h1, final SAMFileHeader h2) { final List<SAMSequenceRecord> s1 = h1.getSequenceDictionary().getSequences(); final List<SAMSequenceRecord> s2 = h2.getSequenceDictionary().getSequences(); if (s1.size() != s2.size()) { reportDifference(s1.size(), s2.size(), "Length of sequence dictionaries"); return false; } boolean ret = true; for (int i = 0; i < s1.size(); ++i) { ret = compareSequenceRecord(s1.get(i), s2.get(i), i + 1) && ret; } return ret; }

Target:
private static boolean compareSequenceDictionaries(final SAMFileHeader h1, final SAMFileHeader h2) { final List<SAMSequenceRecord> s1 = h1.getSequenceDictionary().getSequences(); final List<SAMSequenceRecord> s2 = h2.getSequenceDictionary().getSequences(); if (s1.size() != s2.size()) { reportDifference(s1.size(), s2.size(), "Length of sequence dictionaries"); return false; } boolean ret = true; for (int i = 0; i < s1.size(); ++i) { ret = compareSequenceRecord(s1.get(i), s2.get(i), i + 1) && ret; } return ret; }
Source:
public PoolDTO setBranding(Set<BrandingDTO> branding) { if (branding != null) { if (this.branding == null) { this.branding = new HashSet<BrandingDTO>(); } else { this.branding.clear(); } for (BrandingDTO dto : branding) { if (isNullOrIncomplete(dto)) { throw new IllegalArgumentException("collection contains null " + "or incomplete branding objects"); } } this.branding.addAll(branding); } else { this.branding = null; } return this; }

Target:
public PoolDTO setBranding(Set<BrandingDTO> branding) { if (branding != null) { if (this.branding == null) { this.branding = new HashSet<BrandingDTO>(); } else { this.branding.clear(); } for (BrandingDTO dto : branding) { if (isNullOrIncomplete(dto)) { throw new IllegalArgumentException( "collection contains null or incomplete branding objects"); } } this.branding.addAll(branding); } else { this.branding = null; } return this; }
Source:
public void recognizesExcludedPaths() { ErrorProneOptions options = ErrorProneOptions.processArgs( new String[] {"-XepExcludedPaths:build/generated,other_output"}); Pattern excludedPattern = options.getExcludedPattern(); assertThat(excludedPattern).isNotNull(); assertThat(excludedPattern.matcher("fizz/build/generated/Gen.java").matches()).isTrue(); assertThat(excludedPattern.matcher("fizz/bazz/generated/Gen.java").matches()).isFalse(); assertThat(excludedPattern.matcher("other_output/Gen.java").matches()).isTrue(); assertThat(excludedPattern.matcher("foo/other_output/subdir/Gen.java").matches()).isTrue(); }

Target:
public void recognizesExcludedPaths() { ErrorProneOptions options = ErrorProneOptions.processArgs( new String[] {"-XepExcludedPaths:(.*/)?(build/generated|other_output)/.*\\.java"}); Pattern excludedPattern = options.getExcludedPattern(); assertThat(excludedPattern).isNotNull(); assertThat(excludedPattern.matcher("fizz/build/generated/Gen.java").matches()).isTrue(); assertThat(excludedPattern.matcher("fizz/bazz/generated/Gen.java").matches()).isFalse(); assertThat(excludedPattern.matcher("fizz/abuild/generated/Gen.java").matches()).isFalse(); assertThat(excludedPattern.matcher("other_output/Gen.java").matches()).isTrue(); assertThat(excludedPattern.matcher("foo/other_output/subdir/Gen.java").matches()).isTrue(); assertThat(excludedPattern.matcher("foo/other_output/subdir/Gen.cpp").matches()).isFalse(); }
Source:
public boolean addLocationInformation(final String readName, final PhysicalLocation loc) { if (this.readNameRegex == this.DEFAULT_READ_NAME_REGEX) { final int fields = ReadNameParsingUtils.getRapidDefaultReadNameRegexSplit(readName, ':', tmpLocationFields); if (!(fields == 5 || fields == 7)) { throw new PicardException(String.format(" READ_NAME_REGEX '%s' did not match read name '%s'. " , this.readNameRegex, readName)); } final int offset = fields == 7 ? 2 : 0; loc.setTile((short) tmpLocationFields[offset + 2]); loc.setX(tmpLocationFields[offset + 3]); loc.setY(tmpLocationFields[offset + 4]); return true; } else if (this.readNameRegex == null) { return false; } else { if (this.readNamePattern == null) this.readNamePattern = Pattern.compile(this.readNameRegex); final Matcher m = this.readNamePattern.matcher(readName); if (m.matches()) { loc.setTile((short) Integer.parseInt(m.group(1))); loc.setX(Integer.parseInt(m.group(2))); loc.setY(Integer.parseInt(m.group(3))); return true; } else { throw new PicardException(String.format("READ_NAME_REGEX '%s' did not match read name '%s'. ", this.readNameRegex, readName)); } } }

Target:
public boolean addLocationInformation(final String readName, final PhysicalLocation loc) { if (readNameRegex == DEFAULT_READ_NAME_REGEX) { final int fields = ReadNameParsingUtils.getRapidDefaultReadNameRegexSplit(readName, ':', tmpLocationFields); if (!(fields == 5 || fields == 7)) { throw new PicardException(String.format(" READ_NAME_REGEX '%s' did not match read name '%s'. " , this.readNameRegex, readName)); } final int offset = fields == 7 ? 2 : 0; loc.setTile((short) tmpLocationFields[offset + 2]); loc.setX(tmpLocationFields[offset + 3]); loc.setY(tmpLocationFields[offset + 4]); return true; } else if (readNameRegex == null) { return false; } else { if (readNamePattern == null) readNamePattern = Pattern.compile(readNameRegex); final Matcher m = readNamePattern.matcher(readName); if (m.matches()) { loc.setTile((short) Integer.parseInt(m.group(1))); loc.setX(Integer.parseInt(m.group(2))); loc.setY(Integer.parseInt(m.group(3))); return true; } else { throw new PicardException(String.format("READ_NAME_REGEX '%s' did not match read name '%s'. ", readNameRegex, readName)); } } }
Source:
private static String getRobolectricVersion() { try { final Properties properties = new Properties(); properties.load(SdkVersion.class.getClassLoader().getResourceAsStream("robolectric.version.properties")); return properties.getProperty("robolectric.version"); } catch (IOException e) { throw new RuntimeException("Error determining Robolectric version: " + e.getMessage()); } }

Target:
private static String getRobolectricVersion() { ClassLoader classLoader = SdkVersion.class.getClassLoader(); try (InputStream is = classLoader.getResourceAsStream("robolectric-version.properties")) { final Properties properties = new Properties(); properties.load(is); return properties.getProperty("robolectric.version"); } catch (IOException e) { throw new RuntimeException("Error determining Robolectric version: " + e.getMessage()); } }
Source:
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) { if (extensionPoint.equals(AVRO_SCHEMA)) { AvroSchemaDescriptor descriptor = (AvroSchemaDescriptor) contribution; InputStream stream = getClass().getClassLoader().getResourceAsStream(descriptor.file); if (stream == null) { log.error(String.format("Could not load stream for file %s.", descriptor.file)); return; } try { schemaStoreService.addSchema(new Schema.Parser().parse(stream)); } catch (IOException e) { log.error(String.format("Could not load stream for file %s. Error message: %s", descriptor.file, e.getMessage())); } } }

Target:
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) { if (extensionPoint.equals(SCHEMA_XP)) { AvroSchemaDescriptor descriptor = (AvroSchemaDescriptor) contribution; try { URL url = contributor.getRuntimeContext().getResource(descriptor.file); InputStream stream = url == null ? null : url.openStream(); if (stream == null) { log.error(String.format("Could not load stream for file %s.", descriptor.file)); return; } schemaStoreService.addSchema(new Schema.Parser().parse(stream)); } catch (IOException e) { log.error(String.format("Could not load stream for file %s. Error message: %s", descriptor.file, e.getMessage())); } } else { throw new RuntimeServiceException("Unknown extension point: " + extensionPoint); } }
Source:
public void shouldSendLargeMessage() throws DotDataException, DotSecurityException, InterruptedException { final ReindexEntry reindexEntry = mock(ReindexEntry.class); final String cause = "cause"; final IndiciesInfo indiciesInfo = APILocator.getIndiciesAPI().loadIndicies(); final Role adminRole = mock(Role.class); when(roleAPIMock.loadCMSAdminRole()).thenReturn(adminRole); final User user = mock(User.class); when(user.getUserId()).thenReturn("1"); when(roleAPIMock.findUsersForRole(adminRole)).thenReturn(list(user)); try { putReadOnly(indiciesInfo.getWorking(), true); putReadOnly(indiciesInfo.getLive(), false); esReadOnlyMonitor.start(reindexEntry, cause); Thread.sleep(100); checkLargeMessageSent(indiciesInfo, user); assertEquals(false, ESIndexUtil.isReadOnly(indiciesInfo.getWorking(), indiciesInfo.getLive())); } finally { putReadOnly(indiciesInfo.getWorking(), false); } }

Target:
public void shouldSendLargeMessage() throws DotDataException, DotSecurityException, InterruptedException, IOException { final String message = "message"; final IndiciesInfo indiciesInfo = APILocator.getIndiciesAPI().loadIndicies(); final Role adminRole = mock(Role.class); when(roleAPIMock.loadCMSAdminRole()).thenReturn(adminRole); final User user = mock(User.class); when(user.getUserId()).thenReturn("1"); when(roleAPIMock.findUsersForRole(adminRole)).thenReturn(list(user)); try { setReadOnly(indiciesInfo.getWorking(), true); setReadOnly(indiciesInfo.getLive(), false); esReadOnlyMonitor.start(message); Thread.sleep(100); checkLargeMessageSent(user); assertEquals(false, ElasticsearchUtil.isAnyReadOnly(indiciesInfo.getWorking(), indiciesInfo.getLive())); } finally { setReadOnly(indiciesInfo.getWorking(), false); } }
Source:
public static void recurseDir(File root, TreeSet<String> strings, IProgressMonitor monitor) { if (!root.exists() || !root.isDirectory()) { return; } File[] children = root.listFiles(); for (File child : children) { if (monitor.isCanceled()) { return; } if (child.exists() && child.isDirectory() && child.getName().equals(".git")) { strings.add(child.getAbsolutePath()); return; } if (child.isDirectory()) { monitor.setTaskName(child.getPath()); recurseDir(child, strings, monitor); } } }

Target:
public static void recurseDir(File root, TreeSet<String> strings, IProgressMonitor monitor) { if (!root.exists() || !root.isDirectory()) { return; } File[] children = root.listFiles(); for (File child : children) { if (monitor.isCanceled()) { return; } if (child.exists() && child.isDirectory() && RepositoryCache.FileKey.isGitRepository(child)) { strings.add(child.getAbsolutePath()); return; } if (child.isDirectory()) { monitor.setTaskName(child.getPath()); recurseDir(child, strings, monitor); } } }
Source:
public AsmInstrumentingClassLoader(Setup setup, URL... urls) { super(AsmInstrumentingClassLoader.class.getClassLoader()); this.setup = setup; this.urls = new URLClassLoader(urls, null); classesToRemap = convertToSlashes(setup.classNameTranslations()); methodsToIntercept = convertToSlashes(setup.methodsToIntercept()); for (URL url : urls) { System.out.println("DEBUG: Loading android sdk from " + url); } }

Target:
public AsmInstrumentingClassLoader(Setup setup, URL... urls) { super(AsmInstrumentingClassLoader.class.getClassLoader()); this.setup = setup; this.urls = new URLClassLoader(urls, null); classesToRemap = convertToSlashes(setup.classNameTranslations()); methodsToIntercept = convertToSlashes(setup.methodsToIntercept()); }
Source:
public TestThriftDistributedQueriesIndexed() throws Exception { super(() -> createThriftQueryRunner(2, 2, true)); Logging.initialize().setLevel("com.facebook.nifty.core.NiftyExceptionLogger", OFF); }

Target:
public TestThriftDistributedQueriesIndexed() throws Exception { super(() -> createThriftQueryRunner(2, 2, true)); Logging logging = Logging.initialize(); previousLogLevel = logging.getLevel(NIFTY_LOGGER_NAME); logging.setLevel(NIFTY_LOGGER_NAME, OFF); }
Source:
protected int parseWithoutValidation(final String flag) { SamFlagField.validate(flag, STRING); int value = 0; for (int i = 0; i < flag.length(); i++) { switch (flag.charAt(i)) { case 'p': value |= SAMFlag.READ_PAIRED.flag; break; case 'P': value |= SAMFlag.PROPER_PAIR.flag; break; case 'u': value |= SAMFlag.READ_UNMAPPED.flag; break; case 'U': value |= SAMFlag.MATE_UNMAPPED.flag; break; case 'r': value |= SAMFlag.READ_REVERSE_STRAND.flag; break; case 'R': value |= SAMFlag.MATE_REVERSE_STRAND.flag; break; case '1': value |= SAMFlag.FIRST_OF_PAIR.flag; break; case '2': value |= SAMFlag.SECOND_OF_PAIR.flag; break; case 's': value |= SAMFlag.NOT_PRIMARY_ALIGNMENT.flag; break; case 'q': value |= SAMFlag.READ_FAILS_VENDOR_QUALITY_CHECK.flag; break; case 'd': value |= SAMFlag.DUPLICATE_READ.flag; break; case 'S': value |= SAMFlag.SUPPLEMENTARY_ALIGNMENT.flag; break; case 'f': case 'F': case 'm': case 'M': case '_': break; default: throw new SAMFormatException("Unknown flag character '" + flag.charAt(i) + "' in flag '" + flag + "'"); } } return value; }

Target:
protected int parseWithoutValidation(final String flag) { throw new SAMFormatException("NONE not allowed for the SamFlagField when reading the SAM flag field."); }
Source:
private void setListeners() { fabPlus.setOnClickListener(view -> animateFAB(isFabOpen)); fabCamera.setOnClickListener(view -> controller.initiateCameraPick(getActivity(), CAMERA_UPLOAD_REQUEST_CODE)); fabGallery.setOnClickListener(view -> controller.initiateGalleryPick(getActivity(), 5, GALLERY_UPLOAD_REQUEST_CODE)); }

Target:
private void setListeners() { fabPlus.setOnClickListener(view -> animateFAB(isFabOpen)); fabCamera.setOnClickListener(view -> controller.initiateCameraPick(this, CAMERA_UPLOAD_REQUEST_CODE)); fabGallery.setOnClickListener(view -> controller.initiateGalleryPick(this, MULTIPLE_UPLOAD_IMAGE_LIMIT, GALLERY_UPLOAD_REQUEST_CODE)); }
Source:
public RawBytes value( long seed ) { RawBytes value = newValue(); value.bytes = ByteBuffer.allocate( 17 ).putLong( seed ).putLong( seed ).array(); return value; }

Target:
public RawBytes value( long seed ) { RawBytes value = newValue(); value.bytes = fromSeed( seed ); return value; }
Source:
private Alert[] getAlertNodes() { ExtensionAlert extAlert = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.class); DefaultMutableTreeNode node = (DefaultMutableTreeNode) extAlert.getAlertPanel().getTreeAlert().getLastSelectedPathComponent(); TreePath[] paths = extAlert.getAlertPanel().getTreeAlert().getSelectionPaths(); Alert[] alertNodes = new Alert[paths.length]; for(int i = 0; i < paths.length; i++ ) { DefaultMutableTreeNode alertNode = (DefaultMutableTreeNode)paths[i].getLastPathComponent(); alertNodes[i] = (Alert)alertNode.getUserObject(); } return alertNodes; }

Target:
private Set<Alert> getAlertNodes() { TreePath[] paths = this.extAlert.getAlertPanel().getTreeAlert().getSelectionPaths(); HashSet<Alert> alertNodes = new HashSet<Alert>(); for(int i = 0; i < paths.length; i++ ) { DefaultMutableTreeNode alertNode = (DefaultMutableTreeNode)paths[i].getLastPathComponent(); if(alertNode.getChildCount() == 0) { alertNodes.add((Alert)alertNode.getUserObject()); continue; } for(int j = 0; j < alertNode.getChildCount(); j++ ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)alertNode.getChildAt(j); alertNodes.add((Alert)node.getUserObject()); } } return alertNodes; }
Source:
public static List<TaskRecord> queryTaskTable(Connection connection, Timestamp ts, String schema, String tableName, PTable.TaskType taskType, String tenantId, String indexName) throws SQLException { String taskQuery = "SELECT " + PhoenixDatabaseMetaData.TASK_TS + ", " + PhoenixDatabaseMetaData.TENANT_ID + ", " + PhoenixDatabaseMetaData.TABLE_SCHEM + ", " + PhoenixDatabaseMetaData.TABLE_NAME + ", " + PhoenixDatabaseMetaData.TASK_STATUS + ", " + PhoenixDatabaseMetaData.TASK_TYPE + ", " + PhoenixDatabaseMetaData.TASK_PRIORITY + ", " + PhoenixDatabaseMetaData.TASK_DATA + " FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME; taskQuery += " WHERE " + PhoenixDatabaseMetaData.TABLE_NAME + " ='" + tableName + "' AND " + PhoenixDatabaseMetaData.TASK_TYPE + "=" + taskType.getSerializedValue(); if (!Strings.isNullOrEmpty(tenantId)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TENANT_ID + "='" + tenantId + "' "; } if (!Strings.isNullOrEmpty(schema)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TABLE_SCHEM + "='" + schema + "' "; } if (!Strings.isNullOrEmpty(indexName)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TASK_DATA + " LIKE '%" + indexName + "%'"; } List<TaskRecord> result = populateTasks(connection, taskQuery); if (ts != null) { result.removeIf(p -> !p.getTimeStamp().equals(ts)); } return result; }

Target:
public static List<TaskRecord> queryTaskTable(Connection connection, Timestamp ts, String schema, String tableName, PTable.TaskType taskType, String tenantId, String indexName) throws SQLException { String taskQuery = "SELECT " + PhoenixDatabaseMetaData.TASK_TS + ", " + PhoenixDatabaseMetaData.TENANT_ID + ", " + PhoenixDatabaseMetaData.TABLE_SCHEM + ", " + PhoenixDatabaseMetaData.TABLE_NAME + ", " + PhoenixDatabaseMetaData.TASK_STATUS + ", " + PhoenixDatabaseMetaData.TASK_TYPE + ", " + PhoenixDatabaseMetaData.TASK_PRIORITY + ", " + PhoenixDatabaseMetaData.TASK_DATA + " FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME; taskQuery += " WHERE " + PhoenixDatabaseMetaData.TABLE_NAME + " ='" + tableName + "' AND " + PhoenixDatabaseMetaData.TASK_TYPE + "=" + taskType.getSerializedValue(); if (!Strings.isNullOrEmpty(tenantId)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TENANT_ID + "='" + tenantId + "' "; } if (!Strings.isNullOrEmpty(schema)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TABLE_SCHEM + "='" + schema + "' "; } if (!Strings.isNullOrEmpty(indexName)) { taskQuery += " AND " + PhoenixDatabaseMetaData.TASK_DATA + " LIKE '%" + indexName + "%'"; } List<TaskRecord> taskRecords = populateTasks(connection, taskQuery); List<TaskRecord> result = new ArrayList<TaskRecord>(); if (ts != null) { for (TaskRecord tr : taskRecords) { if (tr.getTimeStamp().equals(ts)) { result.add(tr); } } } else { result = taskRecords; } return result; }
Source:
public RetryBudgetImpl(String name, RetryConfig config) { this.name = name; this.config = config; this.maxAttempts = config.getMaxAttempts(); this.intervalFunction = config.getIntervalFunction(); this.exceptionPredicate = config.getExceptionPredicate(); this.bufferSize = config.getBufferSize(); this._bufferSize = config.getBufferSize(); this.retryThreshold = config.getRetryThreshold(); this.eventProcessor = new RetryEventProcessor(); this.succeededAfterRetryCounter = new LongAdder(); this.failedAfterRetryCounter = new LongAdder(); this.succeededWithoutRetryCounter = new LongAdder(); this.failedWithoutRetryCounter = new LongAdder(); this.metrics = new RetryMetricsImpl(succeededAfterRetryCounter, failedAfterRetryCounter, succeededWithoutRetryCounter, failedWithoutRetryCounter); this.sleepFunction = config.getSleepFunction(); this.ringBitSet = new RingBitSet(bufferSize); }

Target:
public RetryBudgetImpl(String name, RetryConfig config) { this.name = name; this.config = config; this.maxAttempts = config.getMaxAttempts(); this.intervalFunction = config.getIntervalFunction(); this.exceptionPredicate = config.getExceptionPredicate(); this.bufferSize = config.getBufferSize(); this.retryThreshold = config.getRetryThreshold(); this.eventProcessor = new RetryEventProcessor(); this.succeededAfterRetryCounter = new LongAdder(); this.failedAfterRetryCounter = new LongAdder(); this.succeededWithoutRetryCounter = new LongAdder(); this.failedWithoutRetryCounter = new LongAdder(); this.metrics = new RetryMetricsImpl(succeededAfterRetryCounter, failedAfterRetryCounter, succeededWithoutRetryCounter, failedWithoutRetryCounter); this.ringBitSet = new RingBitSet(config.getBufferSize()); this.sleepFunction = config.getSleepFunction(); }
Source:
public boolean getUseTorForBitcoinJ() { var usableLocalNodePresent = localBitcoinNode.safeIsUsable(); if ((!Config.baseCurrencyNetwork().isMainnet() || usableLocalNodePresent) && !config.useTorForBtcOptionSetExplicitly) return false; else return prefPayload.isUseTorForBitcoinJ(); }

Target:
public boolean getUseTorForBitcoinJ() { if ((!Config.baseCurrencyNetwork().isMainnet() || localBitcoinNode.shouldBeUsed()) && !config.useTorForBtcOptionSetExplicitly) return false; else return prefPayload.isUseTorForBitcoinJ(); }
Source:
private void layoutAndCenterShell() { Point prefSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT ); prefSize.y += 50; shell.setSize( prefSize ); Rectangle parentSize = parent.getDisplay().getBounds(); int locationX = ( parentSize.width - prefSize.x ) / 2 + parentSize.x; int locationY = ( parentSize.height - prefSize.y ) / 2 + parentSize.y; shell.setLocation( locationX, locationY ); }

Target:
private void layoutAndCenterShell() { Point prefSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT ); prefSize.y += 50; shell.setSize( prefSize ); Rectangle displaySize = parent.getDisplay().getBounds(); int locationX = ( displaySize.width - prefSize.x ) / 2 + displaySize.x; int locationY = ( displaySize.height - prefSize.y ) / 2 + displaySize.y; shell.setLocation( locationX, locationY ); }
Source:
public void testJsonToCSV() { String row1 = "id, query, queryType, requestId, principalName, status, createdOn, updatedOn, asyncAfterSeconds, resultType, result"; String row2 = "\"edc4a871-dff2-4054-804e-d80075cf827d\", \"/group?sort=commonName&fields%5Bgroup%5D=commonName,description\", \"GRAPHQL_V1_0\""; String row2End = "10.0, \"CSV\", null"; TableExport queryObj = new TableExport(); String query = "/group?sort=commonName&fields%5Bgroup%5D=commonName,description"; String id = "edc4a871-dff2-4054-804e-d80075cf827d"; queryObj.setId(id); queryObj.setQuery(query); queryObj.setQueryType(QueryType.GRAPHQL_V1_0); queryObj.setResultType(ResultType.CSV); PersistentResource resource = mock(PersistentResource.class); when(resource.getObject()).thenReturn(queryObj); TableExportThread queryThread = new TableExportThread(queryObj, engine, exporter); queryThread.incrementRecordCount(); String output = queryThread.convertToCSV(resource); assertEquals(true, output.startsWith(row1)); assertEquals(true, output.contains(row2)); assertEquals(true, output.endsWith(row2End)); }

Target:
public void testJsonToCSV() { String row1 = "id, query, queryType, requestId, principalName, status, createdOn, updatedOn, asyncAfterSeconds, resultType, result"; String row2 = "\"edc4a871-dff2-4054-804e-d80075cf827d\", \"/tableExport\", \"GRAPHQL_V1_0\""; String row2End = "10.0, \"CSV\", null"; TableExport queryObj = new TableExport(); String query = "/tableExport"; String id = "edc4a871-dff2-4054-804e-d80075cf827d"; queryObj.setId(id); queryObj.setQuery(query); queryObj.setQueryType(QueryType.GRAPHQL_V1_0); queryObj.setResultType(ResultType.CSV); PersistentResource resource = mock(PersistentResource.class); when(resource.getObject()).thenReturn(queryObj); TableExportThread queryThread = new TableExportThread(queryObj, engine, exporter); queryThread.incrementRecordCount(); String output = queryThread.convertToCSV(resource); assertEquals(true, output.startsWith(row1)); assertEquals(true, output.contains(row2)); assertEquals(true, output.endsWith(row2End)); }
Source:
public Map<Dimension, List<SchemaGraph.JoinPath>> pruneFactPaths( CubeInterface cube, final CandidateFact cfact) { Map<Dimension, List<SchemaGraph.JoinPath>> prunedPaths = new HashMap<Dimension, List<SchemaGraph.JoinPath>>(); for (Map.Entry<Dimension, List<SchemaGraph.JoinPath>> ppaths : allPaths.entrySet()) { prunedPaths.put(ppaths.getKey(), new ArrayList<SchemaGraph.JoinPath>(ppaths.getValue())); List<SchemaGraph.JoinPath> paths = prunedPaths.get(ppaths.getKey()); for (int i = 0; i < paths.size(); i++) { SchemaGraph.JoinPath jp = paths.get(i); List<String> cubeCols = jp.getColumnsForTable((AbstractCubeTable) cube); if (cubeCols != null && !cfact.getColumns().containsAll(cubeCols)) { LOG.info("Removing join path:" + jp + " as columns :" + cubeCols + " dont exist"); paths.remove(i); i--; } } } pruneEmptyPaths(prunedPaths); return prunedPaths; }

Target:
private Map<Dimension, List<SchemaGraph.JoinPath>> pruneFactPaths( CubeInterface cube, final CandidateFact cfact) { Map<Dimension, List<SchemaGraph.JoinPath>> prunedPaths = new HashMap<Dimension, List<SchemaGraph.JoinPath>>(); for (Map.Entry<Dimension, List<SchemaGraph.JoinPath>> ppaths : allPaths.entrySet()) { prunedPaths.put(ppaths.getKey(), new ArrayList<SchemaGraph.JoinPath>(ppaths.getValue())); List<SchemaGraph.JoinPath> paths = prunedPaths.get(ppaths.getKey()); for (int i = 0; i < paths.size(); i++) { SchemaGraph.JoinPath jp = paths.get(i); List<String> cubeCols = jp.getColumnsForTable((AbstractCubeTable) cube); if (cubeCols != null && !cfact.getColumns().containsAll(cubeCols)) { LOG.info("Removing join path:" + jp + " as columns :" + cubeCols + " dont exist"); paths.remove(i); i--; } } } pruneEmptyPaths(prunedPaths); return prunedPaths; }
Source:
public void afterStart() { processorLifecycleListener.afterStart(); if (numProcessorsToStart.decrementAndGet() == 0) { appStatus = ApplicationStatus.Running; } }

Target:
public void afterStart() { if (numProcessorsToStart.decrementAndGet() == 0) { appStatus = ApplicationStatus.Running; } userDefinedProcessorLifecycleListener.afterStart(); }
Source:
public void testOrderDocument() throws OperationException { assertEquals(Long.valueOf(0), file11.getPos()); assertEquals(Long.valueOf(1), file12.getPos()); assertEquals(Long.valueOf(2), file13.getPos()); moveBefore(file12, file11); assertEquals(Long.valueOf(1), file11.getPos()); assertEquals(Long.valueOf(0), file12.getPos()); assertEquals(Long.valueOf(2), file13.getPos()); moveBefore(file11, file13); assertEquals(Long.valueOf(1), file11.getPos()); assertEquals(Long.valueOf(0), file12.getPos()); assertEquals(Long.valueOf(2), file13.getPos()); moveBefore(file13, file11); assertEquals(Long.valueOf(2), file11.getPos()); assertEquals(Long.valueOf(0), file12.getPos()); assertEquals(Long.valueOf(1), file13.getPos()); }

Target:
public void testOrderDocument() throws OperationException { assertEquals(Long.valueOf(0), file11.getPos()); assertEquals(Long.valueOf(1), file12.getPos()); assertEquals(Long.valueOf(2), file13.getPos()); assertEquals(Long.valueOf(3), file14.getPos()); assertEquals(Long.valueOf(4), file15.getPos()); moveBefore(file12, file11); assertEquals(Long.valueOf(1), file11.getPos()); assertEquals(Long.valueOf(0), file12.getPos()); assertEquals(Long.valueOf(2), file13.getPos()); assertEquals(Long.valueOf(3), file14.getPos()); assertEquals(Long.valueOf(4), file15.getPos()); moveBefore(file11, file13); assertEquals(Long.valueOf(1), file11.getPos()); assertEquals(Long.valueOf(0), file12.getPos()); assertEquals(Long.valueOf(2), file13.getPos()); assertEquals(Long.valueOf(3), file14.getPos()); assertEquals(Long.valueOf(4), file15.getPos()); moveBefore(file13, file11); assertEquals(Long.valueOf(2), file11.getPos()); assertEquals(Long.valueOf(0), file12.getPos()); assertEquals(Long.valueOf(1), file13.getPos()); assertEquals(Long.valueOf(3), file14.getPos()); assertEquals(Long.valueOf(4), file15.getPos()); moveBefore(file12, null); assertEquals(Long.valueOf(1), file11.getPos()); assertEquals(Long.valueOf(4), file12.getPos()); assertEquals(Long.valueOf(0), file13.getPos()); assertEquals(Long.valueOf(2), file14.getPos()); assertEquals(Long.valueOf(3), file15.getPos()); }
Source:
public String createSocketBinding() throws CommandFailedException, IOException { String name = "UndertowSocketBinding_" + RandomStringUtils.randomAlphanumeric(6); try (OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient()) { client.apply(new AddSocketBinding.Builder(name) .port(AvailablePortFinder.getNextAvailable()) .build()); } return name; }

Target:
public String createSocketBinding() throws CommandFailedException, IOException { String name = "UndertowSocketBinding_" + RandomStringUtils.randomAlphanumeric(6); try (OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient()) { int port = AvailablePortFinder.getNextAvailable(1024); log.info("Obtained port for socket binding '" + name + "' is " + port); client.apply(new AddSocketBinding.Builder(name) .port(port) .build()); } return name; }
Source:
private static int runCommandDir(final File dir, final String... args) throws IOException { try { if (MOPProcessor.verbose) { System.out.println(dir.toString() + ": " + Arrays.asList(args).toString()); } final ProcessBuilder builder = new ProcessBuilder(); builder.command(args).directory(dir); if (MOPProcessor.verbose) { builder.inheritIO(); } else { builder.redirectErrorStream(true); } final Process proc = builder.start(); if (!MOPProcessor.verbose) { final StringWriter writer = new StringWriter(); new Thread(new Runnable() { public void run() { try { IOUtils.copy(proc.getInputStream(), writer); } catch (IOException e) { e.printStackTrace(); } } }).start(); } return proc.waitFor(); } catch (InterruptedException ie) { ie.printStackTrace(); return -1; } }

Target:
private static int runCommandDir(final File dir, final String... args) throws IOException { try { if (MOPProcessor.verbose) { System.out.println(dir.toString() + ": " + Arrays.asList(args).toString()); } final ProcessBuilder builder = new ProcessBuilder(); builder.command(args).directory(dir); if (MOPProcessor.verbose) { builder.inheritIO(); } else { builder.redirectErrorStream(true); } final Process proc = builder.start(); if (!MOPProcessor.verbose) { final StringWriter writer = new StringWriter(); new Thread(new Runnable() { public void run() { try { IOUtils.copy(proc.getInputStream(), writer); } catch (IOException e) { System.err.println("Exception in reading subprocess output: " + e.getMessage()); } } }).start(); } return proc.waitFor(); } catch (InterruptedException ie) { ie.printStackTrace(); return -1; } }
Source:
public Category findByVariable(final String variable, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException { final Category category = categoryFactory.findByVar(variable); if(!InodeUtils.isSet(category.getCategoryId())) return null; if(!permissionAPI.doesUserHavePermission(category, PermissionAPI.PERMISSION_USE, user, respectFrontendRoles)) throw new DotSecurityException("User doesn't have permission to use this category = " + category.getInode()); return category; }

Target:
public Category findByVariable(final String variable, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException { final Category category = categoryFactory.findByVar(variable); if(!InodeUtils.isSet(category.getCategoryId())) { return null; } if(!permissionAPI.doesUserHavePermission(category, PermissionAPI.PERMISSION_USE, user, respectFrontendRoles)) { throw new DotSecurityException("User doesn't have permission to use this category = " + category.getInode()); } return category; }
Source:
public CANEncoder(String name, int id, boolean reverseDirection, double distancePerPulse) { super(name, id); this.reverseDirection = reverseDirection; this.distancePerPulse = distancePerPulse; this.offset = 0.0; }

Target:
public CANEncoder(String name, int id, boolean reverseDirection, double distancePerPulse) { super(name, id); this.reverseDirection = reverseDirection; this.distancePerPulse = distancePerPulse; this.offset = 0.0; setCustomPIDSourceType(CustomPIDSourceType.kDisplacement); }
Source:
public void notifyChanged(Notification notification) { if (Notification.SET == notification.getEventType()) { Object feature = notification.getFeature(); if (BasePackage.Literals.NAMED_ELEMENT__NAME.equals(feature)) { suppressModifyEvent = true; nameLabel.setText(notification.getNewStringValue()); suppressModifyEvent = false; } } }

Target:
public void notifyChanged(Notification notification) { if (Notification.SET == notification.getEventType()) { if (BasePackage.Literals.NAMED_ELEMENT__NAME.equals(notification.getFeature())) { nameLabel.setText(notification.getNewStringValue()); } } }