auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public Double getMinimumWidth() { double minimumWidth = super.getMinimumWidth(); final GridData model = gridWidget.getModel(); final int columnIndex = getLogicalColumnIndex(model); if (columnIndex != -1) { for (GridRow row : model.getRows()) { final GridCell<?> cell = row.getCells().get(columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; final Optional<BaseExpressionGrid> editor = ecv.getValue(); final double padding = editor.map(BaseExpressionGrid::getPadding).orElse(0.0); minimumWidth = Math.max(minimumWidth, ecv.getMinimumWidth().orElse(0.0) + padding * 2); } } } } return minimumWidth; }

Target:
public Double getMinimumWidth() { double minimumWidth = super.getMinimumWidth(); final GridData model = gridWidget.getModel(); final int columnIndex = getLogicalColumnIndex(model); if (columnIndex != -1) { for (GridRow row : model.getRows()) { final GridCell<?> cell = row.getCells().get(columnIndex); if (cell != null) { final GridCellValue<?> value = cell.getValue(); if (value instanceof ExpressionCellValue) { final ExpressionCellValue ecv = (ExpressionCellValue) value; final Optional<BaseExpressionGrid> editor = ecv.getValue(); final double padding = editor.map(BaseExpressionGrid::getPadding).get(); minimumWidth = Math.max(minimumWidth, ecv.getMinimumWidth().orElse(0.0) + padding * 2); } } } } return minimumWidth; }
Source:
public void verifyTableRemoved() { checkIfElementOnPage(table); PageObjectLogging.log("verifyTableRemoved", "table was removedcd", true); }

Target:
public void verifyTableRemoved() { Assertion.assertTrue(!checkIfElementOnPage(table)); PageObjectLogging.log("verifyTableRemoved", "table was removed", true); }
Source:
public void testCountNumUnfiltered() { final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2VcfMore)); final List<VariantContext> variantContexts = new ArrayList<>(); for (final VariantContext vc : featureDataSource) { variantContexts.add(vc); } Assert.assertEquals(OrientationBiasUtils.calculateUnfilteredNonRefGenotypeCount(variantContexts, "TUMOR"), 9); Assert.assertEquals(OrientationBiasUtils.calculateUnfilteredNonRefGenotypeCount(variantContexts, "NORMAL"), 0); }

Target:
public void testCountNumUnfiltered() { final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2VcfMore)); final List<VariantContext> variantContexts = getVariantContexts(featureDataSource); Assert.assertEquals(OrientationBiasUtils.calculateUnfilteredNonRefGenotypeCount(variantContexts, "TUMOR"), 9); Assert.assertEquals(OrientationBiasUtils.calculateUnfilteredNonRefGenotypeCount(variantContexts, "NORMAL"), 0); }
Source:
public List<Writable> map(List<Writable> writables){ PythonVariables pyInputs = getPyInputsFromWritables(writables); try{ PythonVariables pyOutputs = PythonExecutioner.getInstance().exec(this, pyInputs); return getWritablesFromPyOutputs(pyOutputs); } catch (Exception e){ throw new RuntimeException(e); } }

Target:
public List<Writable> map(List<Writable> writables){ PythonVariables pyInputs = getPyInputsFromWritables(writables); try{ PythonExecutioner.exec(code, pyInputs, pyOutputs); return getWritablesFromPyOutputs(pyOutputs); } catch (Exception e){ throw new RuntimeException(e); } }
Source:
public void toJson(Object src, Type typeOfSrc, JsonWriter writer) throws JsonIOException { TypeAdapter<?> adapter = getAdapter(TypeToken.get(typeOfSrc)); boolean oldLenient = writer.isLenient(); writer.setLenient(true); boolean oldHtmlSafe = writer.isHtmlSafe(); writer.setHtmlSafe(htmlSafe); boolean oldSerializeNulls = writer.getSerializeNulls(); writer.setSerializeNulls(serializeNulls); try { ((TypeAdapter<Object>) adapter).write(writer, src); } catch (IOException e) { throw new JsonIOException(e); } catch (AssertionError e) { throw new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage()); } finally { writer.setLenient(oldLenient); writer.setHtmlSafe(oldHtmlSafe); writer.setSerializeNulls(oldSerializeNulls); } }

Target:
public void toJson(Object src, Type typeOfSrc, JsonWriter writer) throws JsonIOException { TypeAdapter<?> adapter = getAdapter(TypeToken.get(typeOfSrc)); boolean oldLenient = writer.isLenient(); writer.setLenient(true); boolean oldHtmlSafe = writer.isHtmlSafe(); writer.setHtmlSafe(htmlSafe); boolean oldSerializeNulls = writer.getSerializeNulls(); writer.setSerializeNulls(serializeNulls); try { ((TypeAdapter<Object>) adapter).write(writer, src); } catch (IOException e) { throw new JsonIOException(e); } catch (AssertionError e) { AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage()); error.initCause(e); throw error; } finally { writer.setLenient(oldLenient); writer.setHtmlSafe(oldHtmlSafe); writer.setSerializeNulls(oldSerializeNulls); } }
Source:
public List<RichMember> getRichMembersWithAttributesByNames(PerunSession sess, Group group, Resource resource, List<String> attrsNames) throws InternalErrorException, AttributeNotExistsException, MemberResourceMismatchException { List<Member> members = new ArrayList<Member>(); members.addAll(perunBl.getGroupsManagerBl().getGroupMembers(sess, group)); List<RichMember> richMembers = this.convertMembersToRichMembers(sess, members); List<AttributeDefinition> attrsDef = new ArrayList<AttributeDefinition>(); for(String atrrName: attrsNames) { AttributeDefinition attrDef = perunBl.getAttributesManagerBl().getAttributeDefinition(sess, atrrName); attrsDef.add(attrDef); } List<RichMember> richMembersWithAttributes = this.convertMembersToRichMembersWithAttributes(sess, group, resource, richMembers, attrsDef); return richMembersWithAttributes; }

Target:
public List<RichMember> getRichMembersWithAttributesByNames(PerunSession sess, Group group, Resource resource, List<String> attrsNames) throws InternalErrorException, AttributeNotExistsException, GroupResourceMismatchException { getPerunBl().getAttributesManagerBl().checkGroupIsFromTheSameVoLikeResource(sess, group, resource); List<Member> members = new ArrayList<Member>(); members.addAll(perunBl.getGroupsManagerBl().getGroupMembers(sess, group)); List<RichMember> richMembers = this.convertMembersToRichMembers(sess, members); List<AttributeDefinition> attrsDef = new ArrayList<AttributeDefinition>(); for(String atrrName: attrsNames) { AttributeDefinition attrDef = perunBl.getAttributesManagerBl().getAttributeDefinition(sess, atrrName); attrsDef.add(attrDef); } List<RichMember> richMembersWithAttributes = null; try { richMembersWithAttributes = this.convertMembersToRichMembersWithAttributes(sess, group, resource, richMembers, attrsDef); } catch (MemberResourceMismatchException ex) { throw new ConsistencyErrorException(ex); } return richMembersWithAttributes; }
Source:
public FoursquareAttributesDefinition() { String[] names = new String[] { FIRST_NAME,LAST_NAME,GENDER, HOME_CITY, BIO, EMAIL, PHOTO }; for (final String name : names) { addAttribute(name, Converters.stringConverter); } addAttribute(GENDER, Converters.genderConverter); addAttribute(FIRENDS,FoursquareConverters.friendsConverter); }

Target:
public FoursquareAttributesDefinition() { String[] names = new String[]{ FIRST_NAME, LAST_NAME, GENDER, HOME_CITY, BIO, EMAIL, PHOTO }; for (final String name : names) { addAttribute(name, Converters.stringConverter); } addAttribute(GENDER, Converters.genderConverter); addAttribute(FIRENDS, FoursquareConverters.friendsConverter); addAttribute(CONTACT, FoursquareConverters.contactConverter); addAttribute(PHOTO, FoursquareConverters.photoConverter); }
Source:
private void init() { if (jp == null) { try { jp = objectMapper.getFactory().createParser(future.get()); final JsonToken nextToken = jp.nextToken(); if (nextToken == JsonToken.START_OBJECT) { QueryInterruptedException e = jp.getCodec().readValue(jp, QueryInterruptedException.class); throw e; } else if (nextToken != JsonToken.START_ARRAY) { throw new IAE("Next token wasn't a START_ARRAY, was[%s] from url [%s]", jp.getCurrentToken(), url); } else { jp.nextToken(); objectCodec = jp.getCodec(); } } catch (IOException | InterruptedException | ExecutionException e) { log.error(e, "Failure getting results from[%s]. Likely a timeout occurred.", url); } catch (CancellationException e) { throw new QueryInterruptedException("Query cancelled"); } } }

Target:
private void init() { if (jp == null) { try { jp = objectMapper.getFactory().createParser(future.get()); final JsonToken nextToken = jp.nextToken(); if (nextToken == JsonToken.START_OBJECT) { QueryInterruptedException e = jp.getCodec().readValue(jp, QueryInterruptedException.class); throw e; } else if (nextToken != JsonToken.START_ARRAY) { throw new IAE("Next token wasn't a START_ARRAY, was[%s] from url [%s]", jp.getCurrentToken(), url); } else { jp.nextToken(); objectCodec = jp.getCodec(); } } catch (IOException | InterruptedException | ExecutionException e) { throw new RE(e, "Failure getting results from[%s] because of [%s]", url, e.getMessage()); } catch (CancellationException e) { throw new QueryInterruptedException("Query cancelled"); } } }
Source:
public void setClockConfiguration(final DlmsConnectionHolder conn, final DlmsDevice device, final SetClockConfigurationRequestDto clockConfiguration) throws ProtocolAdapterException { try { this.clockConfigurationCommandExecutor.execute(conn, device, clockConfiguration); } catch (final ProtocolAdapterException e) { LOGGER.error("Unexpected exception during replaceKeys.", e); throw e; } }

Target:
public void setClockConfiguration(final DlmsConnectionHolder conn, final DlmsDevice device, final SetClockConfigurationRequestDto clockConfiguration) throws ProtocolAdapterException { try { this.setClockConfigurationCommandExecutor.execute(conn, device, clockConfiguration); } catch (final ProtocolAdapterException e) { LOGGER.error("Unexpected exception while setting clock configuration.", e); throw e; } }
Source:
private int compareMetrics ( InternalRenderMetrics o1, InternalRenderMetrics o2 ){ int first = -1; int last = 1; int perferredMapRenderer = rateUsingBlackboardSettings(o1, o1.getRenderContext().getLayer() .getBlackboard()); if (perferredMapRenderer == 0) { perferredMapRenderer = rateUsingBlackboardSettings(o1, o1.getRenderContext().getLayer() .getStyleBlackboard()); } int perferredMapRenderer2 = rateUsingBlackboardSettings(o2, o2.getRenderContext().getLayer() .getBlackboard()); if (perferredMapRenderer2 == 0) { perferredMapRenderer2 = rateUsingBlackboardSettings(o2, o2.getRenderContext().getLayer() .getStyleBlackboard()); } if (perferredMapRenderer > perferredMapRenderer2) { return first; } if (perferredMapRenderer < perferredMapRenderer2) { return last; } perferredMapRenderer = rateUsingBlackboardSettings(o1, o1.getRenderContext().getMap() .getBlackboard()); perferredMapRenderer2 = rateUsingBlackboardSettings(o2, o2.getRenderContext().getMap() .getBlackboard()); if (perferredMapRenderer > perferredMapRenderer2) { return first; } if (perferredMapRenderer < perferredMapRenderer2) { return last; } double r1 = rate(o1); double r2 = rate(o2); if (r1 > r2) return last; if (r1 < r2) return first; return 0; }

Target:
private int compareMetrics ( InternalRenderMetrics o1, InternalRenderMetrics o2 ){ int first = -1; int last = 1; int preferredLayerRenderer = rateUsingBlackboardSettings(o1, o1.getRenderContext().getLayer() .getBlackboard()); if (preferredLayerRenderer == 0) { preferredLayerRenderer = rateUsingBlackboardSettings(o1, o1.getRenderContext().getLayer() .getStyleBlackboard()); } int preferredLayerRenderer2 = rateUsingBlackboardSettings(o2, o2.getRenderContext().getLayer() .getBlackboard()); if (preferredLayerRenderer2 == 0) { preferredLayerRenderer2 = rateUsingBlackboardSettings(o2, o2.getRenderContext().getLayer() .getStyleBlackboard()); } if (preferredLayerRenderer > preferredLayerRenderer2) { return first; } if (preferredLayerRenderer < preferredLayerRenderer2) { return last; } int preferredMapRenderer = rateUsingBlackboardSettings(o1, o1.getRenderContext().getMap() .getBlackboard()); int preferredMapRenderer2 = rateUsingBlackboardSettings(o2, o2.getRenderContext().getMap() .getBlackboard()); if (preferredMapRenderer > preferredMapRenderer2) { return first; } if (preferredMapRenderer < preferredMapRenderer2) { return last; } double r1 = rate(o1); double r2 = rate(o2); if (r1 > r2) return last; if (r1 < r2) return first; return 0; }
Source:
void createSubgroupsFromCommaSeparatedLastNames() { BibEntry bibEntry = new BibEntry().withField(StandardField.AUTHOR, "Turing, Alan and Hopper, Grace"); var subgroups = new AutomaticPersonsGroup("", GroupHierarchyType.INDEPENDENT, StandardField.AUTHOR).createSubgroups(bibEntry); assertEquals(2, subgroups.size()); for (GroupTreeNode group : subgroups) { String groupName = group.getGroup().getName(); assertTrue(groupName.equals("Turing") || groupName.equals("Hopper")); } }

Target:
void createSubgroupsFromCommaSeparatedLastNames() { BibEntry bibEntry = new BibEntry().withField(StandardField.AUTHOR, "Turing, Alan and Hopper, Grace"); var subgroups = new AutomaticPersonsGroup("", GroupHierarchyType.INDEPENDENT, StandardField.AUTHOR).createSubgroups(bibEntry); var expectedSubgroups = createPersonSubGroupFrom("Turing", "Hopper"); assertEquals(expectedSubgroups, subgroups); }
Source:
public void handleMessage (Message message) { try { byte[] body = base64.decode(message.getBody()); ByteArrayInputStream bais = new ByteArrayInputStream(body); Origin origin = Origin.read(bais); if (buffer != null && origin.samples.length != this.nIterations) { LOG.error("Origin {}, has iterations, expected {}", origin.x, origin.y, origin.samples.length, this.nIterations); error = true; } ByteArrayOutputStream pixelByteOutputStream = new ByteArrayOutputStream(origin.samples.length * 4); LittleEndianDataOutputStream pixelDataOutputStream = new LittleEndianDataOutputStream(pixelByteOutputStream); for (int i = 0, prev = 0; i < origin.samples.length; i++) { int current = origin.samples[i]; pixelDataOutputStream.writeInt(current - prev); prev = current; } pixelDataOutputStream.close(); synchronized (this) { if (buffer == null) this.initialize(origin.samples.length); int index1d = origin.y * request.width + origin.x; long offset = DATA_OFFSET + index1d * 4 * nIterations; buffer.seek(offset); buffer.write(pixelByteOutputStream.toByteArray()); if (!originsReceived.get(index1d)) { originsReceived.set(index1d); nComplete += 1; } if (nComplete == nTotal && !error) finish(); } } catch (Exception e) { error = true; LOG.error("Error assembling results for query {}", request.jobId, e); return; } }

Target:
public void handleMessage (Message message) { try { byte[] body = base64.decode(message.getBody()); ByteArrayInputStream bais = new ByteArrayInputStream(body); Origin origin = Origin.read(bais); if (buffer != null && origin.samples.length != this.nIterations) { LOG.error("Origin {}, has samples, expected {}", origin.x, origin.y, origin.samples.length, this.nIterations); error = true; } ByteArrayOutputStream pixelByteOutputStream = new ByteArrayOutputStream(origin.samples.length * 4); LittleEndianDataOutputStream pixelDataOutputStream = new LittleEndianDataOutputStream(pixelByteOutputStream); for (int i = 0, prev = 0; i < origin.samples.length; i++) { int current = origin.samples[i]; pixelDataOutputStream.writeInt(current - prev); prev = current; } pixelDataOutputStream.close(); synchronized (this) { if (buffer == null) this.initialize(origin.samples.length); int index1d = origin.y * request.width + origin.x; long offset = DATA_OFFSET + index1d * 4 * nIterations; buffer.seek(offset); buffer.write(pixelByteOutputStream.toByteArray()); if (!originsReceived.get(index1d)) { originsReceived.set(index1d); nComplete += 1; } if (nComplete == nTotal && !error) finish(); } } catch (Exception e) { error = true; LOG.error("Error assembling results for query {}", request.jobId, e); return; } }
Source:
void start() throws IOException { RefTree tree = queuedTree; queuedTree = null; for (Proposal p : todo) { p.notifyState(RUNNING); } begin(tree); }

Target:
void start() throws IOException { for (Proposal p : todo) { p.notifyState(RUNNING); } try { ObjectId id; try (Repository git = leader.openRepository()) { id = insertProposals(git); } acceptAsync(id); } catch (NoOp e) { for (Proposal p : todo) { p.success(); } leader.lock.lock(); try { leader.nextRound(); } finally { leader.lock.unlock(); } } catch (IOException e) { abort(JGitText.get().transactionAborted); throw e; } }
Source:
private ProtocolVersion getVersionFromString(String version) { if (version.equals("1.0")) { return ProtocolVersion.DTLSv10; } else if (version.equals("1.2")) { return ProtocolVersion.DTLSv12; } else { throw new IllegalArgumentException("Invalid DTLS version"); } }

Target:
private ProtocolVersion getVersionFromString(String version) { if ("1.0".equals(version)) { return ProtocolVersion.DTLSv10; } else if ("1.2".equals(version)) { return ProtocolVersion.DTLSv12; } else { throw new IllegalArgumentException("Invalid DTLS version"); } }
Source:
public HashMap<UUID, Object> readMapFromJson() { try { Type mapType = new TypeToken<HashMap<UUID, Object>>() { }.getType(); return new Gson().fromJson(new FileReader(deviceFile), mapType); } catch (FileNotFoundException e) { if (deviceFile.exists()) { Log.e(TAG, "Device Variable File corrupted!"); deviceFile.delete(); } return null; } }

Target:
public Map<UUID, Object> readMapFromJson() { try { Type mapType = new TypeToken<HashMap<UUID, Object>>() { }.getType(); return new Gson().fromJson(new FileReader(deviceFile), mapType); } catch (FileNotFoundException e) { if (deviceFile.exists()) { Log.e(TAG, "Device Variable File corrupted!"); deviceFile.delete(); } return null; } }
Source:
CalciteAdHocCompilerCache(int maxLiteralEntries, int maxCoreEntries) { MAX_LITERAL_ENTRIES = maxLiteralEntries; MAX_CORE_ENTRIES = maxCoreEntries; m_literalCache = new AdHocStatementCache(MAX_LITERAL_ENTRIES, MAX_LITERAL_MEM); m_coreCache = new LinkedHashMap<String, CorePlan>(MAX_CORE_ENTRIES * 2, .75f, true) { private static final long serialVersionUID = 1L; @Override public boolean removeEldestEntry(Map.Entry<String, CorePlan> eldest) { if (size() > MAX_CORE_ENTRIES) { ++m_planEvictions; return true; } return false; } }; }

Target:
CalciteAdHocCompilerCache(int maxLiteralEntries, int maxCoreEntries) { m_literalCache = new AdHocStatementCache(maxLiteralEntries, MAX_LITERAL_MEM) { private static final long serialVersionUID = 1L; @Override public boolean removeEldestEntry(final Map.Entry<String, AdHocPlannedStatement> eldest) { if ((size() > maxEntries) || (this.currentMemory > this.maxMemory)) { ++m_literalEvictions; this.currentMemory -= eldest.getValue().getSerializedSize(); return true; } return false; } }; m_coreCache = new LinkedHashMap<String, CorePlan>(maxCoreEntries, .75f, true) { private static final long serialVersionUID = 1L; @Override public boolean removeEldestEntry(Map.Entry<String, CorePlan> eldest) { if (size() > maxCoreEntries) { ++m_planEvictions; return true; } return false; } }; }
Source:
public void cleanup() { cleanupSingletonSessionId(); if (units != null && !units.isEmpty()) { for (DeploymentUnit unit : units) { try { deploymentService.undeploy(unit); } catch (Exception e) { logger.error("---------------------------" + e.getLocalizedMessage()); logger.error("--do nothing in case of some failed tests to avoid next test to fail as well-------------------------" + unit.getIdentifier()); } } units.clear(); } close(); }

Target:
public void cleanup() { cleanupSingletonSessionId(); if (units != null && !units.isEmpty()) { for (DeploymentUnit unit : units) { try { deploymentService.undeploy(unit); } catch (Exception e) { } } units.clear(); } close(); }
Source:
public static Boolean isPython(String[] programArguments){ return CollectionUtils.containsAny(Arrays.asList(programArguments), Arrays.asList("-py", "-pym", "--python", "--pyModule")); }

Target:
public static boolean isPython(String[] programArguments){ return CollectionUtils.containsAny(Arrays.asList(programArguments), Arrays.asList("-py", "-pym", "--python", "--pyModule")); }
Source:
private ProviderNetwork getExternalNetwork() { if (externalNetwork == null) { Network network = getNetworkDAO().get(getParameters().getNetworkId()); externalNetwork = network.getProvidedBy(); } return externalNetwork; }

Target:
private ProviderNetwork getExternalNetwork() { if (externalNetwork == null) { Network network = getNetworkDAO().get(getParameters().getNetworkId()); if (network != null) { externalNetwork = network.getProvidedBy(); } } return externalNetwork; }
Source:
private DependencyAttribute newDependsOn(Change c, PatchSet ps) { DependencyAttribute d = newDependencyAttribute(c, ps); d.isCurrentPatchSet = new Boolean(c.currPatchSetId().equals(ps.getId())); return d; }

Target:
private DependencyAttribute newDependsOn(Change c, PatchSet ps) { DependencyAttribute d = newDependencyAttribute(c, ps); d.isCurrentPatchSet = c.currPatchSetId().equals(ps.getId()); return d; }
Source:
private void setOurs() throws IOException { if (baseCommit != null) { ours = NoteMap.read(db.newObjectReader(), baseCommit); } else { ours = NoteMap.newEmptyMap(); } StringBuilder message = new StringBuilder("Submitted the following changes:"); for (CodeReviewCommit c : commits) { if (ours.contains(c)) { throw new IllegalStateException( "Review summary note already exists for commit: " + c + ". Merging of notes not yet supported"); } ObjectId id = inserter.insert(Constants.OBJ_BLOB, createNoteContent(c)); inserter.flush(); RevBlob blob = revWalk.lookupBlob(id); ours.set(c, blob); message.append(" "); message.append(c.change.getId()); } message.append("\n"); if (baseCommit != null) { oursCommit = createCommit(ours, author, message.toString(), baseCommit); } else { oursCommit = createCommit(ours, author, message.toString()); } }

Target:
private void setOurs() throws IOException, CodeReviewNoteCreationException { if (baseCommit != null) { ours = NoteMap.read(db.newObjectReader(), baseCommit); } else { ours = NoteMap.newEmptyMap(); } StringBuilder message = new StringBuilder("Update notes for submitted changes\n\n"); for (CodeReviewCommit c : commits) { ObjectId noteContent = createNoteContent(c); if (ours.contains(c)) { DefaultNoteMerger noteMerger = new DefaultNoteMerger(); Note newNote = new Note(c, noteContent); noteContent = noteMerger.merge(null, newNote, base.getNote(c), reader, inserter) .getData(); } ours.set(c, noteContent); message.append("* ").append(c.getShortMessage()).append("\n"); } if (baseCommit != null) { oursCommit = createCommit(ours, author, message.toString(), baseCommit); } else { oursCommit = createCommit(ours, author, message.toString()); } }
Source:
void checkViewModelFile(IResource iResource, IProgressMonitor monitor) { if (isViewModelResource(iResource)) { final IFile file = IFile.class.cast(iResource); monitor.subTask(String.format("Checking %s", file.getName())); projectMarkerHelper.deleteMarkers(file); try { final Optional<BasicDiagnostic> diagnostics = validateView(file); if (diagnostics.isPresent()) { final Diagnostic diag = diagnostics.get(); if (diag.getSeverity() >= IMarker.SEVERITY_WARNING) { final MarkerHelper markerHelper = new ViewModelMarkerHelper(file); markerHelper.createMarkers(diag); } } } catch (final CoreException ex) { Activator.log("Errors while creating markers on file " + file, ex); } } }

Target:
void checkViewModelFile(IResource iResource, IProgressMonitor monitor) { if (isViewModelResource(iResource)) { final IFile file = IFile.class.cast(iResource); monitor.subTask(NLS.bind(Messages.ViewModelBuilder_Subtask_Label, file.getName())); projectMarkerHelper.deleteMarkers(file); try { final Optional<BasicDiagnostic> diagnostics = validateView(file); if (diagnostics.isPresent()) { final Diagnostic diag = diagnostics.get(); if (diag.getSeverity() >= IMarker.SEVERITY_WARNING) { final MarkerHelper markerHelper = new ViewModelMarkerHelper(file); markerHelper.createMarkers(diag); } } } catch (final CoreException ex) { Activator.log("Errors while creating markers on file " + file, ex); } } }
Source:
private void determineCipherSuitesFromConfig() { List<CipherSuite> ciphers = new ArrayList<>(); boolean certificates = isConfiguredWithKeyPair() || config.trustCertificateTypes != null; boolean recommendedOnly = Boolean.FALSE.equals(recommendedCipherSuitesOnly); if (certificates) { ciphers.addAll(CipherSuite.getEcdsaCipherSuites(recommendedOnly)); } if (config.pskStore != null) { ciphers.addAll(CipherSuite.getPskCipherSuites(recommendedOnly, true)); } config.supportedCipherSuites = ciphers; }

Target:
private void determineCipherSuitesFromConfig() { List<CipherSuite> ciphers = new ArrayList<>(); boolean certificates = isConfiguredWithKeyPair() || config.trustCertificateTypes != null; if (certificates) { ciphers.addAll(CipherSuite.getEcdsaCipherSuites(recommendedCipherSuitesOnly)); } if (config.pskStore != null) { ciphers.addAll(CipherSuite.getPskCipherSuites(recommendedCipherSuitesOnly, true)); } config.supportedCipherSuites = ciphers; }
Source:
private static boolean isLimitAll(String limitClause) { return Pattern.compile("all", CASE_INSENSITIVE).matcher(limitClause).matches(); }

Target:
private static boolean isLimitAll(String limitClause) { return limitClause.toLowerCase(ENGLISH).equals("all"); }
Source:
public void eventDispatched(IStartedDMEvent event) { final IMemoryDMContext memContext = DMContexts.getAncestorOfType(event.getDMContext(), IMemoryDMContext.class); final IMIExecutionDMContext execContext = DMContexts.getAncestorOfType(event.getDMContext(), IMIExecutionDMContext.class); if (memContext != null && execContext != null) { getExecutor().execute(new DsfRunnable() { @Override public void run() { readAddressSize(memContext, execContext); readEndianness(memContext, execContext); } }); } }

Target:
public void eventDispatched(IStartedDMEvent event) { if (event.getDMContext() instanceof IContainerDMContext) { IMemoryDMContext memContext = DMContexts.getAncestorOfType(event.getDMContext(), IMemoryDMContext.class); if (memContext != null) { readAddressSize(memContext); readEndianness(memContext); } } }
Source:
protected IPath getCompilationPath(ISourceContainer[] containers, String sourceName) { for (ISourceContainer container : containers) { if (container instanceof MappingSourceContainer && ((MappingSourceContainer) container).isMappingWithBackendEnabled()) { } else if (container instanceof IMappingSourceContainer) { IPath path = ((IMappingSourceContainer) container).getCompilationPath(sourceName); if (path != null) { return path; } } ISourceContainer[] childContainers = null; try { childContainers = container.getSourceContainers(); } catch (CoreException e) { } if (childContainers != null) { IPath path = getCompilationPath(childContainers, sourceName); if (path != null) { return path; } } } return null; }

Target:
protected IPath getCompilationPath(ISourceContainer[] containers, String sourceName) { for (ISourceContainer container : containers) { if (container instanceof IMappingSourceContainer) { if (container instanceof MappingSourceContainer && ((MappingSourceContainer) container).isMappingWithBackendEnabled()) { return null; } return ((IMappingSourceContainer) container).getCompilationPath(sourceName); } ISourceContainer[] childContainers = null; try { childContainers = container.getSourceContainers(); } catch (CoreException e) { } if (childContainers != null) { IPath path = getCompilationPath(childContainers, sourceName); if (path != null) { return path; } } } return null; }
Source:
public String scheduleAFixedDelayJob(Object instance, String methodName, Class<?>[] inputTypes, Object[] inputParams, long initialDelay, long taskDelay, TimeUnit timeUnit) { executor.scheduleWithFixedDelay(getRunnable(instance, methodName, inputTypes, inputParams), initialDelay, taskDelay, TimeUnit.SECONDS); return "JOB::scheduleAFixedDelayJob::" + methodName; }

Target:
public String scheduleAFixedDelayJob(Object instance, String methodName, Class<?>[] inputTypes, Object[] inputParams, long initialDelay, long taskDelay, TimeUnit timeUnit) { executor.scheduleWithFixedDelay(getRunnable(instance, methodName, inputTypes, inputParams), initialDelay, taskDelay, TimeUnit.SECONDS); return generateUniqueNameForInstance(instance, methodName); }
Source:
public boolean login() throws LoginException { boolean loginOk = false; final CredentialsCallback cb = new CredentialsCallback(); try { callbackHandler.handle(new Callback[]{cb}); credentials = cb.getCredentials(); } catch (Exception e) { throw new LoginException(e.getClass().getName() + ":" + e.getMessage()); } if(credentials == null) { logger.log(Level.WARNING, "Credentials could not be retrieved!"); return false; } logger.log(Level.INFO, "Authenticating " + SecurityUtil.getCredentialsFullName(credentials)); if (credentials instanceof UsernamePasswordCredentials){ loginOk = doLoginCheck((UsernamePasswordCredentials) credentials); } return loginOk; }

Target:
public boolean login() throws LoginException { boolean loginOk = true; final CredentialsCallback cb = new CredentialsCallback(); try { callbackHandler.handle(new Callback[]{cb}); credentials = cb.getCredentials(); } catch (Exception e) { logger.log(Level.WARNING, e.getClass().getName() + ":" + e.getMessage()); return false; } if (credentials == null) { logger.log(Level.WARNING, "Credentials could not be retrieved!"); return false; } logger.log(Level.INFO, "Authenticating " + SecurityUtil.getCredentialsFullName(credentials)); if (credentials instanceof UsernamePasswordCredentials) { doLoginCheck((UsernamePasswordCredentials) credentials); } else { logger.log(Level.WARNING, "Credentials were not of expected class type of " + UsernamePasswordCredentials.class.getName()); return false; } return loginOk; }
Source:
protected final String getPropertyFromInitParams(final FilterConfig filterConfig, final String propertyName, final String defaultValue) { String value = retrieveParameterValueFromWebOrJNDIConfiguration(filterConfig, propertyName); if (CommonUtils.isNotBlank(value)) { return value; } value = retrieveParameterValueFromConfigFile(filterConfig, propertyName, "/etc/cas/client.properties"); if (CommonUtils.isNotBlank(value)) { return value; } logger.info("Property not found. Using default value [{}]", propertyName, defaultValue); return defaultValue; }

Target:
protected final String getPropertyFromInitParams(final FilterConfig filterConfig, final String propertyName, final String defaultValue) { String value = retrieveParameterValueFromWebOrJNDIConfiguration(filterConfig, propertyName); if (CommonUtils.isNotBlank(value)) { return value; } value = retrieveParameterValueFromConfigFile(filterConfig, propertyName, PARAM_VALUE_DEFAULT_CONFIG_FILE); if (CommonUtils.isNotBlank(value)) { return value; } logger.info("Property not found. Using default value [{}]", propertyName, defaultValue); return defaultValue; }
Source:
protected void revertTask() { Guid targetStorageDomainId = getEnclosingCommand().getParameters().getTargetStorageDomainId(); Guid destinationImageId = getEnclosingCommand().getParameters().getDestinationImageId(); DiskImage diskImage = getDiskImageDao().get(destinationImageId); if (diskImage != null && diskImage.getStorageIds().get(0) == targetStorageDomainId) { getEnclosingCommand().getParameters().setExecutionIndex(0); } }

Target:
protected void revertTask() { Guid targetStorageDomainId = getEnclosingCommand().getParameters().getTargetStorageDomainId(); Guid destinationImageId = getEnclosingCommand().getParameters().getDestinationImageId(); DiskImage diskImage = getDiskImageDao().get(destinationImageId); if (diskImage != null && targetStorageDomainId.equals(diskImage.getStorageIds().get(0))) { getEnclosingCommand().getParameters().setExecutionIndex(0); } }
Source:
private String token() throws IOException { final String uri = new Href("<LINK_0>") .with("grant_type", "client_credentials") .toString(); return new JdkRequest(uri) .method("POST") .header( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" ) .header( "Authorization", "Basic ".concat( PsTwitter.prepareAuthKey( this.app, this.key ) ) ) .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(JsonResponse.class) .json().readObject().getString("access_token"); }

Target:
private String token() throws IOException { final String uri = new Href("<LINK_0>") .with("grant_type", "client_credentials") .toString(); return new JdkRequest(uri) .method("POST") .header( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" ) .header( "Authorization", String.format( "Basic %s", DatatypeConverter.printBase64Binary( String.format("%s:%s", this.app, this.key).getBytes() ) ) ) .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(JsonResponse.class) .json().readObject().getString("access_token"); }
Source:
public List<? extends Node> getChildren() { return ImmutableList.<Node>builder() .addAll(properties).build(); }

Target:
public List<? extends Node> getChildren() { return properties; }
Source:
static ReadExecutionController forCommand(ReadCommand command) { ColumnFamilyStore baseCfs = Keyspace.openAndGetStore(command.metadata()); ColumnFamilyStore indexCfs = maybeGetIndexCfs(baseCfs, command); ReadExecutionController result; if (indexCfs == null) { result = new ReadExecutionController(command, baseCfs.readOrdering.start(), baseCfs.metadata(), null, null); } else { OpOrder.Group baseOp = null; WriteContext writeContext = null; ReadExecutionController indexController = null; try { baseOp = baseCfs.readOrdering.start(); indexController = new ReadExecutionController(command, indexCfs.readOrdering.start(), indexCfs.metadata(), null, null); writeContext = baseCfs.keyspace.getWriteHandler().createContextForRead(); result = new ReadExecutionController(command, baseOp, baseCfs.metadata(), indexController, writeContext); } catch (RuntimeException e) { assert writeContext == null; try { if (baseOp != null) baseOp.close(); } finally { if (indexController != null) indexController.close(); } throw e; } } if (baseCfs.metric.topLocalReadQueryTime.isEnabled()) { result.startTime = System.nanoTime(); } return result; }

Target:
static ReadExecutionController forCommand(ReadCommand command) { ColumnFamilyStore baseCfs = Keyspace.openAndGetStore(command.metadata()); ColumnFamilyStore indexCfs = maybeGetIndexCfs(baseCfs, command); ReadExecutionController result; if (indexCfs == null) { result = new ReadExecutionController(command, baseCfs.readOrdering.start(), baseCfs.metadata(), null, null); } else { OpOrder.Group baseOp = null; WriteContext writeContext = null; ReadExecutionController indexController = null; try { baseOp = baseCfs.readOrdering.start(); indexController = new ReadExecutionController(command, indexCfs.readOrdering.start(), indexCfs.metadata(), null, null); writeContext = baseCfs.keyspace.getWriteHandler().createContextForRead(); result = new ReadExecutionController(command, baseOp, baseCfs.metadata(), indexController, writeContext); } catch (RuntimeException e) { assert writeContext == null; try { if (baseOp != null) baseOp.close(); } finally { if (indexController != null) indexController.close(); } throw e; } } if (baseCfs.metric.topLocalReadQueryTime.isEnabled()) result.startTimeNanos = clock.nanoTime(); return result; }
Source:
public void simple() throws Exception { Path tmpDir = Files.createTempDirectory("bookie"); String path = tmpDir.toAbsolutePath().toString(); try { PersistentEntryLogMetadataMap entryMetadataMap = new PersistentEntryLogMetadataMap(path, configuration); List<EntryLogMetadata> metadatas = Lists.newArrayList(); int totalMetadata = 1000; for (int i = 1; i <= totalMetadata; i++) { EntryLogMetadata entryLogMeta = createEntryLogMetadata(i, i); metadatas.add(entryLogMeta); entryMetadataMap.put(i, entryLogMeta); } for (int i = 1; i <= totalMetadata; i++) { assertTrue(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), totalMetadata); entryMetadataMap.forEach((logId, metadata) -> { assertEquals(metadatas.get(logId.intValue() - 1).getTotalSize(), metadata.getTotalSize()); for (int i = 0; i < logId.intValue(); i++) { assertTrue(metadata.containsLedger(i)); } }); for (int i = 1; i <= totalMetadata; i++) { entryMetadataMap.remove(i); } for (int i = 1; i <= totalMetadata; i++) { assertFalse(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), 0); entryMetadataMap.close(); } finally { FileUtils.deleteDirectory(new File(tmpDir.toAbsolutePath().toString())); } }

Target:
public void simple() throws Exception { File tmpDir = tempFolder.newFolder(); String path = tmpDir.getAbsolutePath().toString(); PersistentEntryLogMetadataMap entryMetadataMap = new PersistentEntryLogMetadataMap(path, configuration); List<EntryLogMetadata> metadatas = Lists.newArrayList(); int totalMetadata = 1000; for (int i = 1; i <= totalMetadata; i++) { EntryLogMetadata entryLogMeta = createEntryLogMetadata(i, i); metadatas.add(entryLogMeta); entryMetadataMap.put(i, entryLogMeta); } for (int i = 1; i <= totalMetadata; i++) { assertTrue(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), totalMetadata); entryMetadataMap.forEach((logId, metadata) -> { assertEquals(metadatas.get(logId.intValue() - 1).getTotalSize(), metadata.getTotalSize()); for (int i = 0; i < logId.intValue(); i++) { assertTrue(metadata.containsLedger(i)); } }); for (int i = 1; i <= totalMetadata; i++) { entryMetadataMap.remove(i); } for (int i = 1; i <= totalMetadata; i++) { assertFalse(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), 0); entryMetadataMap.close(); }
Source:
private JMethod findImplementation(@Nonnull JMethodIdWide methodId, @Nonnull JType returnType, @Nonnull JDefinedClassOrInterface receiverType) { JMethod foundMethod = findMethod(methodId, receiverType, returnType); if (foundMethod != null) { return foundMethod; } JClass currentType = receiverType.getSuperClass(); while (currentType instanceof JDefinedClass) { foundMethod = findMethod(methodId, currentType, returnType); if (foundMethod != null) { return foundMethod; } currentType = ((JDefinedClass) currentType).getSuperClass(); } findImplementationInInterfaces(methodId, returnType, receiverType); return null; }

Target:
private JMethod findImplementation(@Nonnull JMethodIdWide methodId, @Nonnull JType returnType, @Nonnull JDefinedClassOrInterface receiverType) { JMethod foundMethod = findMethod(methodId, receiverType, returnType); if (foundMethod != null) { return foundMethod; } JClass currentType = receiverType.getSuperClass(); while (currentType instanceof JDefinedClass) { foundMethod = findMethod(methodId, currentType, returnType); if (foundMethod != null) { return foundMethod; } currentType = ((JDefinedClass) currentType).getSuperClass(); } foundMethod = findImplementationInInterfaces(methodId, returnType, receiverType); return foundMethod; }
Source:
public CcAES(final Codec codec, final String key){ this.origin = codec; this.key = key; }

Target:
public CcAES(final Codec codec, final String key) { this(codec, key.getBytes(Charset.defaultCharset())); }
Source:
public void testRemoveTopLevelDataTypes() { final DataType dataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataType3 = mock(DataType.class); when(listItem.getDataType()).thenReturn(dataType); when(dataType0.getName()).thenReturn("tPerson"); when(dataType0.isTopLevel()).thenReturn(true); when(dataType1.getType()).thenReturn("tPerson"); when(dataType1.isTopLevel()).thenReturn(false); when(dataType2.getType()).thenReturn("tCity"); when(dataType2.isTopLevel()).thenReturn(true); when(dataType3.getName()).thenReturn("tCity"); when(dataType3.isTopLevel()).thenReturn(false); final List<DataType> actualDataTypes = listItem.removeTopLevelDataTypes(asList(dataType0, dataType1, dataType2, dataType3)); final List<DataType> expectedDataTypes = asList(dataType0, dataType2); verify(dataTypeList).removeItem(dataType0); verify(dataTypeList).removeItem(dataType2); assertEquals(expectedDataTypes, actualDataTypes); }

Target:
public void testRemoveTopLevelDataTypes() { final DataType dataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataType3 = mock(DataType.class); when(listItem.getDataType()).thenReturn(dataType); when(dataType.getName()).thenReturn("tPerson"); when(dataType0.getName()).thenReturn("tPerson"); when(dataType0.isTopLevel()).thenReturn(true); when(dataType1.getType()).thenReturn("tPerson"); when(dataType1.isTopLevel()).thenReturn(false); when(dataType2.getType()).thenReturn("tCity"); when(dataType2.isTopLevel()).thenReturn(true); when(dataType3.getName()).thenReturn("tCity"); when(dataType3.isTopLevel()).thenReturn(false); final List<DataType> actualDataTypes = listItem.removeTopLevelDataTypes(asList(dataType0, dataType1, dataType2, dataType3)); final List<DataType> expectedDataTypes = singletonList(dataType0); verify(dataTypeList).removeItem(dataType0); assertEquals(expectedDataTypes, actualDataTypes); }
Source:
public void testClassesMatch() throws SQLException { Statement stmt = conn.createStatement(); stmt.executeUpdate( "INSERT INTO alltypes (bool, i2, i4, i8, num, re, fl, ch, vc, tx, d, t, tz, ts, tsz, bt) VALUES ('t', 2, 4, 8, 3.1, 3.14, 3.141, 'c', 'vc', 'tx', '2004-04-09', '09:01:00', '11:11:00-01','2004-04-09 09:01:00','1999-09-19 14:23:12-09', '\\\\123')"); ResultSet rs = stmt.executeQuery("SELECT * FROM alltypes"); ResultSetMetaData rsmd = rs.getMetaData(); assertTrue(rs.next()); for (int i = 0; i < rsmd.getColumnCount(); i++) { assertEquals("types mismatched on column " + i, rs.getObject(i + 1).getClass().getName(), rsmd.getColumnClassName(i + 1)); } }

Target:
public void testClassesMatch() throws SQLException { Statement stmt = conn.createStatement(); stmt.executeUpdate( "INSERT INTO alltypes (bool, i2, i4, i8, num, re, fl, ch, vc, tx, d, t, tz, ts, tsz, bt) VALUES ('t', 2, 4, 8, 3.1, 3.14, 3.141, 'c', 'vc', 'tx', '2004-04-09', '09:01:00', '11:11:00-01','2004-04-09 09:01:00','1999-09-19 14:23:12-09', '\\\\123')"); ResultSet rs = stmt.executeQuery("SELECT * FROM alltypes"); ResultSetMetaData rsmd = rs.getMetaData(); assertTrue(rs.next()); for (int i = 0; i < rsmd.getColumnCount(); i++) { assertEquals("types mismatched on column " + i + 1 + " " + rsmd.getColumnName(i + 1), rs.getObject(i + 1).getClass().getName(), rsmd.getColumnClassName(i + 1)); } }
Source:
public DeletedAccount delete(RequestOptions options) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { return request(RequestMethod.DELETE, instanceURL(Account.class, this.id), null, DeletedAccount.class, options); }

Target:
public DeletedAccount delete(RequestOptions options) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { return delete(null, (RequestOptions) null); }
Source:
public void testBug() throws Exception { if (!canCreateSymLinks()) return; String fileName = "file.txt"; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject(getUniqueString()); IFile file = project.getFile(fileName); try { project.create(getMonitor()); project.open(getMonitor()); } catch (CoreException e) { fail("1.0", e); } IFileStore tempFileStore = getTempStore().getChild(fileName); createFileInFileSystem(tempFileStore); IPath fileInTempDirPath = URIUtil.toPath(tempFileStore.toURI()); symLinkAndRefresh(project, fileName, fileInTempDirPath); IFile[] files = root.findFilesForLocation(file.getLocation()); assertEquals("7.0", 1, files.length); assertEquals("7.1", file, files[0]); }

Target:
public void testBug() { if (!canCreateSymLinks()) return; String fileName = "file.txt"; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject(getUniqueString()); IFile file = project.getFile(fileName); try { project.create(getMonitor()); project.open(getMonitor()); } catch (CoreException e) { fail("1.0", e); } IFileStore tempFileStore = getTempStore().getChild(fileName); createFileInFileSystem(tempFileStore); IPath fileInTempDirPath = URIUtil.toPath(tempFileStore.toURI()); symLinkAndRefresh(project, fileName, fileInTempDirPath); IFile[] files = root.findFilesForLocation(file.getLocation()); assertEquals("7.0", 1, files.length); assertEquals("7.1", file, files[0]); }
Source:
public Map<TopicPartition, String> partitionDirs() { Map<TopicPartition, String> result = new HashMap<>(); for (AlterReplicaLogDirsRequestData.AlterReplicaLogDir alter : data.dirs()) { alter.topics().stream().flatMap(t -> { Stream<TopicPartition> objectStream = t.partitions().stream().map( p -> new TopicPartition(t.name(), p.intValue())); return objectStream; }).forEach(tp -> result.put(tp, alter.path())); } return result; }

Target:
public Map<TopicPartition, String> partitionDirs() { Map<TopicPartition, String> result = new HashMap<>(); data.dirs().forEach(alterDir -> alterDir.topics().forEach(topic -> topic.partitions().forEach(partition -> result.put(new TopicPartition(topic.name(), partition.intValue()), alterDir.path()))) ); return result; }
Source:
public static FloatColumnSelector getFloatColumnSelector( ColumnSelectorFactory metricFactory, String fieldName, String fieldExpression ) { if (fieldName != null) { return metricFactory.makeFloatColumnSelector(fieldName); } final NumericColumnSelector numeric = metricFactory.makeMathExpressionSelector(fieldExpression); return new FloatColumnSelector() { @Override public float get() { return numeric.get().floatValue(); } }; }

Target:
public static FloatColumnSelector getFloatColumnSelector( ColumnSelectorFactory metricFactory, String fieldName, String fieldExpression ) { if (fieldName != null && fieldExpression == null) { return metricFactory.makeFloatColumnSelector(fieldName); } if (fieldName == null && fieldExpression != null) { final NumericColumnSelector numeric = metricFactory.makeMathExpressionSelector(fieldExpression); return new FloatColumnSelector() { @Override public float get() { return numeric.get().floatValue(); } }; } throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); }