auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void set(@NonNull final RandomCard card) { setTitle(getString(R.string.view_random_card_title)); setSubtitle(String.format(getString(R.string.view_random_card_subtitle), WikipediaApp.getInstance().getAppLanguageLocalizedName(card.site().languageCode()))); setIcon(R.drawable.icon_feed_random); setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new RandomSummaryService(card.site(), new RandomSummaryService.RandomSummaryCallback() { @Override public void onSuccess(PageTitle title) { if (callback != null) { callback.onSelectPage(title); } } @Override public void onError(Throwable t) { L.w("Failed to get random card", t); } }).get(); } }); }

Target:
public void set(@NonNull final RandomCard card) { setTitle(getString(R.string.view_random_card_title)); setSubtitle(String.format(getString(R.string.view_random_card_subtitle), WikipediaApp.getInstance().getAppLanguageLocalizedName(card.site().languageCode()))); setIcon(R.drawable.icon_random_48_x_48_dprandom_icon); setOnClickListener(new CallbackAdapter(card, callback)); }
Source:
private boolean tryBuildPage() { if (pageBuilder.isEmpty()) { return false; } if (finished || pageBuilder.isFull()) { buildPage(); return true; } return false; }

Target:
private boolean tryBuildPage() { if (pageBuilder.isFull()) { buildPage(); return true; } return false; }
Source:
public Object visit(BBOX filter, Object extraData) { BoundingBox boundaries = filter.getBounds(); CoordinateReferenceSystem crs = boundaries.getCoordinateReferenceSystem(); if (crs == null) return super.visit(filter, extraData); PropertyName propertyName = null; if (filter.getExpression1() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression2(); } CoordinateReferenceSystem targetCrs = this.targetCrs; if (targetCrs == null) { targetCrs = findPropertyCRS(propertyName); } if (crs != null && targetCrs != null && !CRS.equalsIgnoreMetadata(crs, targetCrs)) { ReferencedEnvelope envelope = ReferencedEnvelope.reference(boundaries); try { envelope = envelope.transform(targetCrs, true); } catch (TransformException e) { throw new RuntimeException(e); } catch (FactoryException e) { throw new RuntimeException(e); } boundaries = envelope; } return getFactory(extraData).bbox(propertyName, boundaries); }

Target:
public Object visit(BBOX filter, Object extraData) { BoundingBox boundaries = filter.getBounds(); CoordinateReferenceSystem crs = boundaries.getCoordinateReferenceSystem(); if (crs == null) return super.visit(filter, extraData); PropertyName propertyName = null; if (filter.getExpression1() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression2(); } CoordinateReferenceSystem targetCrs = findPropertyCRS(propertyName); if (crs != null && targetCrs != null && !CRS.equalsIgnoreMetadata(crs, targetCrs)) { ReferencedEnvelope envelope = ReferencedEnvelope.reference(boundaries); try { envelope = envelope.transform(targetCrs, true); } catch (TransformException e) { throw new RuntimeException(e); } catch (FactoryException e) { throw new RuntimeException(e); } boundaries = envelope; } return getFactory(extraData).bbox(propertyName, boundaries); }
Source:
private boolean isSelected() { if (selection.choice.get() == this) { return true; } else { if (selection.choice.compareAndSet(null, this)) { selection.unsubscribeOthers(this); return true; } else { unsubscribe(); selection.unsubscribeLosers(); return false; } } }

Target:
private boolean isSelected() { if (selection.choice.get() == this) { return true; } else { if (selection.choice.compareAndSet(null, this)) { selection.unsubscribeOthers(this); return true; } else { selection.unsubscribeLosers(); return false; } } }
Source:
private void setupMock() throws Exception { IConfigUtilsInterface confInstance = new DefaultValuesConfigUtil(); Config.setConfigUtils(confInstance); when(wrapper.getServerKeyFingerprint(serverName)).thenReturn(fingerPrint); }

Target:
private void setupMock() throws Exception { query = spy(new GetServerFingerprintQuery<ServerParameters>(new ServerParameters(serverName))); IConfigUtilsInterface confInstance = new DefaultValuesConfigUtil(); Config.setConfigUtils(confInstance); when(query.getServerFingerprint(serverName)).thenReturn(fingerPrint); }
Source:
public String getName() throws IOException { String title = selectSingleValue(getPom(), "/project/name"); if (title == null) { title = artifactId; } else { title = StringUtils.removeStart(title.trim(), "Jenkins "); title = StringUtils.removeStart(title, "Hudson "); title = StringUtils.removeEnd(title, " for Jenkins"); title = StringUtils.removeEnd(title, " Plugin"); title = StringUtils.removeEnd(title, " plugin"); title = StringUtils.removeEnd(title, " Plug-In"); title = StringUtils.removeEnd(title, " Plug-in"); title = StringUtils.removeEnd(title, " plug-in"); title = StringUtils.removeEnd(title, " Jenkins"); } return title; }

Target:
public String getName() throws IOException { String title = selectSingleValue(getPom(), "/project/name"); if (title == null) { title = artifactId; } else { title = simplifyPluginName(title); } return title; }
Source:
public boolean setEndOffsets( final String id, final Map<Integer, Long> endOffsets, final boolean finalize ) { log.debug("SetEndOffsets task[%s] endOffsets[%s] finalize[%s]", id, endOffsets, finalize); try { final FullResponseHolder response = submitJsonRequest( id, HttpMethod.POST, "offsets/end", StringUtils.format("finish=%s", finalize), serialize(endOffsets), true ); return isSuccess(response); } catch (NoTaskLocationException e) { return false; } catch (IOException e) { throw Throwables.propagate(e); } }

Target:
public boolean setEndOffsets( final String id, final Map<Integer, Long> endOffsets, final boolean finalize ) throws IOException { log.debug("SetEndOffsets task[%s] endOffsets[%s] finalize[%s]", id, endOffsets, finalize); try { final FullResponseHolder response = submitJsonRequest( id, HttpMethod.POST, "offsets/end", StringUtils.format("finish=%s", finalize), serialize(endOffsets), true ); return isSuccess(response); } catch (NoTaskLocationException e) { return false; } }
Source:
public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection == null || part instanceof GenericHistoryView) { return; } IStructuredSelection structuredSelection = SelectionUtils .getStructuredSelection(selection); System.out.println("selectionChanged[" + part + "]: " + structuredSelection.size()); if (structuredSelection.isEmpty()) { return; } setSelection(structuredSelection); }

Target:
public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection == null || part instanceof GenericHistoryView) { return; } IStructuredSelection structuredSelection = SelectionUtils .getStructuredSelection(selection); if (structuredSelection.isEmpty()) { return; } setSelection(structuredSelection); }
Source:
private int possibleLongJvmPauseDuration(CheckpointMetricsTracker tracker) { if (pauseDetectorEnabled) { if (tracker.lockWaitDuration() + tracker.lockHoldDuration() > longJvmPauseThreshold) { long now = System.currentTimeMillis(); long wakeUpTime = pauseDetector.getLastWakeUpTime(); Map<Long, Long> pauseEvents = pauseDetector.longPauseEvents(); for(Long eventTime : pauseEvents.keySet()) { if(tracker.checkpointStartTime() < eventTime) return pauseEvents.get(eventTime).intValue(); } if(now - wakeUpTime > longJvmPauseThreshold) return (int)(now - wakeUpTime); } } return -1; }

Target:
private long possibleLongJvmPauseDuration(CheckpointMetricsTracker tracker) { if (LongJVMPauseDetector.enabled()) { if (tracker.lockWaitDuration() + tracker.lockHoldDuration() > longJvmPauseThreshold) { long now = System.currentTimeMillis(); long wakeUpTime = pauseDetector.getLastWakeUpTime(); IgniteBiTuple<Long, Long> lastLongPause = pauseDetector.getLastLongPause(); if (lastLongPause != null && tracker.checkpointStartTime() < lastLongPause.get1()) return lastLongPause.get2(); if (now - wakeUpTime > longJvmPauseThreshold) return now - wakeUpTime; } } return -1L; }
Source:
protected void finalize() throws IOException { if (guard != null) { guard.warnIfOpen(); } if (fd != null) close(); }

Target:
protected void finalize() throws IOException { if (guard != null) { guard.warnIfOpen(); } if (fd != null) close(); END Android-changed: Integrate upstream fix to DatagramChannelImpl's }
Source:
protected boolean checkContinuationAccountsForNewSubAccounts(MaintenanceDocument maintenanceDocument) { SubAccountGlobal subAccountGlobal = (SubAccountGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); subAccountGlobal.getSubAccountGlobalNewAccountDetails().stream() .forEach(this::updateDetailToUseContinuationAccountIfNecessary); return true; }

Target:
protected boolean checkContinuationAccountsForNewSubAccounts(MaintenanceDocument maintenanceDocument) { SubAccountGlobal subAccountGlobal = (SubAccountGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); subAccountGlobal.getSubAccountGlobalNewAccountDetails() .forEach(this::updateDetailToUseContinuationAccountIfNecessary); return true; }
Source:
boolean hasChanged() { return configFile.lastModified() != lastModified; }

Target:
synchronized boolean hasChanged() { return configFile.lastModified() != lastModified; }
Source:
public static EhcacheEntityResponse decode(byte[] payload) { ByteBuffer buffer = ByteBuffer.wrap(payload); byte opCode = buffer.get(); byte[] payArr = new byte[buffer.remaining()]; buffer.get(payArr); switch (opCode) { case 0: return EhcacheEntityResponse.success(); case 1: Exception exception = (Exception)LifeCycleOpCodec.unmarshall(payArr); return EhcacheEntityResponse.failure(exception); case 2: return EhcacheEntityResponse.response(ChainCodec.decode(payArr)); default: throw new UnsupportedOperationException("The operation is not supported"); } }

Target:
public static EhcacheEntityResponse decode(byte[] payload) { ByteBuffer buffer = ByteBuffer.wrap(payload); byte opCode = buffer.get(); EhcacheEntityResponse.Type type = EhcacheEntityResponse.Type.responseType(opCode); byte[] payArr = new byte[buffer.remaining()]; buffer.get(payArr); switch (type) { case SUCCESS: return EhcacheEntityResponse.success(); case FAILURE: Exception exception = (Exception)LifeCycleOpCodec.unmarshall(payArr); return EhcacheEntityResponse.failure(exception); case GET_RESPONSE: return EhcacheEntityResponse.response(ChainCodec.decode(payArr)); default: throw new UnsupportedOperationException("The operation is not supported with opCode : " + opCode); } }
Source:
void updateMaxResolution(QueuedStreamContext context, long newMaxResolution) { if (newMaxResolution != Address.MAX &&context.maxResolution < newMaxResolution) { context.maxResolution = newMaxResolution; log.trace("Read_Fill_Queue[{}] maxResolution set to {}", context.maxResolution); } }

Target:
void updateMaxResolution(QueuedStreamContext context, long newMaxResolution) { if (newMaxResolution != Address.MAX && context.maxResolution < newMaxResolution) { context.maxResolution = newMaxResolution; log.trace("updateMaxResolution: maxResolution set to {}", context.maxResolution); } }
Source:
public static void putObject_test15() throws Exception { if (!mintEnv) { System.out.println("Test: putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS."); } long startTime = System.currentTimeMillis(); ServerSideEncryption sse = ServerSideEncryption.withManagedKeys("key-id",null); try { String objectName = getRandomName(); try (final InputStream is = new ContentInputStream(1 * MB)) { client.putObject(bucketName, objectName, is, 1 * MB, sse); } client.removeObject(bucketName, objectName); mintSuccessLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse)", "size: 13 MB", startTime); } catch (Exception e) { mintFailedLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse)", "size: 13 MB", startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } }

Target:
public static void putObject_test15() throws Exception { if (!mintEnv) { System.out.println("Test: putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS."); } long startTime = System.currentTimeMillis(); Map<String,String> myContext = new HashMap<>(); myContext.put("key1","value1"); String keyId = ""; keyId = System.getenv("MINT_KEY_ID"); if (keyId.equals("")) { mintIgnoredLog("getBucketPolicy(String bucketName)", null, startTime); } ServerSideEncryption sse = ServerSideEncryption.withManagedKeys("keyId", myContext); try { String objectName = getRandomName(); try (final InputStream is = new ContentInputStream(1 * MB)) { client.putObject(bucketName, objectName, is, 1 * MB, sse); } client.removeObject(bucketName, objectName); mintSuccessLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS.", "size: 1 MB", startTime); } catch (Exception e) { mintFailedLog("putObject(String bucketName, String objectName, InputStream stream, " + "long size, ServerSideEncryption sse) using SSE_KMS.", "size: 1 MB", startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } }
Source:
public void setup() { mUiModeManagerShadow = shadowOf((UiModeManager) mContext.getSystemService(UI_MODE_SERVICE)); mUiModeManagerShadow.currentModeType = UI_MODE_TYPE_NORMAL; mDisplayManager = (DisplayManager) mContext.getSystemService(DISPLAY_SERVICE); mWindowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); mDefaultDisplay = mWindowManager.getDefaultDisplay(); ShadowSystemProperties.reset(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { ShadowSystemProperties.override( "sys.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR, DISPLAY_HEIGHT_VENDOR)); } else { ShadowSystemProperties.override( "vendor.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR, DISPLAY_HEIGHT_VENDOR)); } }

Target:
public void setup() { mUiModeManagerShadow = shadowOf((UiModeManager) mContext.getSystemService(UI_MODE_SERVICE)); mUiModeManagerShadow.currentModeType = UI_MODE_TYPE_NORMAL; mDisplayManager = (DisplayManager) mContext.getSystemService(DISPLAY_SERVICE); mWindowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); mDefaultDisplay = mWindowManager.getDefaultDisplay(); ShadowSystemProperties.reset(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { ShadowSystemProperties.override( "sys.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR, DISPLAY_HEIGHT_VENDOR)); } else { ShadowSystemProperties.override( "vendor.display-size", String.format("%dx%d", DISPLAY_WIDTH_VENDOR_P, DISPLAY_HEIGHT_VENDOR_P)); } }
Source:
public void execute(IProgressMonitor m) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(m); IWorkspaceRunnable action = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor actMonitor) throws CoreException { String taskName; if (branches.size() == 1) taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, branches .iterator().next().getName()); else { StringBuilder names = new StringBuilder(); for (Iterator<Ref> it = branches.iterator(); it.hasNext(); ) { Ref ref = it.next(); names.append(ref.getName()); if (it.hasNext()) names.append(", "); } taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, names); } actMonitor.beginTask(taskName, branches.size()); for (Ref branch : branches) { if (actMonitor.isCanceled()) { throw new OperationCanceledException( "Deletion of branches canceled"); } try (Git git = new Git(repository)) { git.branchDelete().setBranchNames( branch.getName()).setForce(force).call(); status = OK; } catch (NotMergedException e) { status = REJECTED_UNMERGED; break; } catch (CannotDeleteCurrentBranchException e) { status = REJECTED_CURRENT; break; } catch (JGitInternalException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } catch (GitAPIException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } actMonitor.worked(1); } actMonitor.done(); } }; ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, subMonitor); }

Target:
public void execute(IProgressMonitor m) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(m); IWorkspaceRunnable action = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor actMonitor) throws CoreException { String taskName; if (branches.size() == 1) taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, branches .iterator().next().getName()); else { StringBuilder names = new StringBuilder(); for (Iterator<Ref> it = branches.iterator(); it.hasNext(); ) { Ref ref = it.next(); names.append(ref.getName()); if (it.hasNext()) names.append(", "); } taskName = NLS.bind( CoreText.DeleteBranchOperation_TaskName, names); } actMonitor.beginTask(taskName, branches.size()); for (Ref branch : branches) { if (actMonitor.isCanceled()) { throw new OperationCanceledException( CoreText.DeleteBranchOperation_Canceled); } try (Git git = new Git(repository)) { git.branchDelete().setBranchNames( branch.getName()).setForce(force).call(); status = OK; } catch (NotMergedException e) { status = REJECTED_UNMERGED; break; } catch (CannotDeleteCurrentBranchException e) { status = REJECTED_CURRENT; break; } catch (JGitInternalException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } catch (GitAPIException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } actMonitor.worked(1); } actMonitor.done(); } }; ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, subMonitor); }
Source:
public static <T> void verifyInvariance(String testName, BiPredicate<RoaringBitmap, RoaringBitmap> validity, int count, int maxKeys, BiFunction<RoaringBitmap, RoaringBitmap, T> left, BiFunction<RoaringBitmap, RoaringBitmap, T> right) { IntStream.range(0, count) .parallel() .forEach(i -> { RoaringBitmap one = randomBitmap(maxKeys); RoaringBitmap two = randomBitmap(maxKeys); if (validity.test(one, two)) { try { T res1 = left.apply(one, two); T res2 = right.apply(one, two); if (!res1.equals(res2)) { T res3 = left.apply(one, two); res1.equals(res2); Assert.assertEquals("Key " + i, res1, res2); } } catch (Throwable t) { Reporter.report(testName, ImmutableMap.of(), t, one, two); throw t; } } }); }

Target:
public static <T> void verifyInvariance(String testName, BiPredicate<RoaringBitmap, RoaringBitmap> validity, int count, int maxKeys, BiFunction<RoaringBitmap, RoaringBitmap, T> left, BiFunction<RoaringBitmap, RoaringBitmap, T> right) { IntStream.range(0, count) .parallel() .forEach(i -> { RoaringBitmap one = randomBitmap(maxKeys); RoaringBitmap two = randomBitmap(maxKeys); if (validity.test(one, two)) { try { Assert.assertEquals(left.apply(one, two), right.apply(one, two)); } catch (Throwable t) { Reporter.report(testName, ImmutableMap.of(), t, one, two); throw t; } } }); }
Source:
public static synchronized void updateCache(AttestationValue value){ if (exists(value.getHostName())){ AttestationValue cacheValue = getValueFromCache(value.getHostName()); cacheValue.setTrustLevel(value.getTrustLevel()); cacheValue.setVtime(value.getVtime()); } }

Target:
public void updateCache(AttestationValue value) { AttestationValue cacheValue = attestationValues.get(value.getHostName()); if (cacheValue != null) { cacheValue.setTrustLevel(value.getTrustLevel()); cacheValue.setVtime(value.getVtime()); } }
Source:
public SerialPortProvider getPortProviderForPortName(URI portName) { PathType pathType = PathType.fromURI(portName); synchronized (this.portCreators) { String scheme = portName.getScheme(); Optional<SerialPortProvider> first = scheme != null ? portCreators.stream() .filter(provider -> provider.getAcceptedProtocols() .filter(prot -> prot.getScheme().equals(scheme)).count() > 0) .findFirst() : Optional.empty(); if (!first.isPresent() && scheme != null) { return null; } return first.orElseGet(() -> { return portCreators.stream() .filter(provider -> provider.getAcceptedProtocols() .filter(prot -> prot.getPathType().equals(pathType)).count() > 0) .findFirst().orElse(null); }); } }

Target:
public @NonNullByDefault({}) SerialPortProvider getPortProviderForPortName(URI portName) { PathType pathType = PathType.fromURI(portName); synchronized (this.portCreators) { String scheme = portName.getScheme(); Optional<SerialPortProvider> first = scheme != null ? portCreators.stream() .filter(provider -> provider.getAcceptedProtocols() .filter(prot -> prot.getScheme().equals(scheme)).count() > 0) .findFirst() : Optional.empty(); if (!first.isPresent() && scheme != null) { return null; } return first .orElse(portCreators.stream() .filter(provider -> provider.getAcceptedProtocols() .filter(prot -> prot.getPathType().equals(pathType)).count() > 0) .findFirst().orElse(null)); } }
Source:
private void changeLanguage(String languageCode) { if (mLanguagePreference == null || TextUtils.isEmpty(languageCode)) return; Resources res = getResources(); Configuration conf = res.getConfiguration(); Locale currentLocale = conf.locale != null ? conf.locale : LanguageUtils.getCurrentDeviceLanguage(WordPress.getContext()); if (currentLocale.toString().equals(languageCode)) return; updateLanguagePreference(languageCode); Locale newLocale = WPPrefUtils.languageLocale(languageCode); conf.locale = newLocale; res.updateConfiguration(conf, res.getDisplayMetrics()); mSettings.edit().putString(LANGUAGE_PREF_KEY, newLocale.toString()).apply(); Map<String, Object> properties = new HashMap<>(); properties.put("app_locale", conf.locale.toString()); AnalyticsTracker.track(Stat.ACCOUNT_SETTINGS_LANGUAGE_CHANGED, properties); AnalyticsUtils.refreshMetadata(); Intent refresh = new Intent(getActivity(), getActivity().getClass()); startActivity(refresh); getActivity().setResult(LANGUAGE_CHANGED); getActivity().finish(); }

Target:
private void changeLanguage(String languageCode) { if (mLanguagePreference == null || TextUtils.isEmpty(languageCode)) return; Resources res = getResources(); Configuration conf = res.getConfiguration(); Locale currentLocale = LanguageUtils.getCurrentDeviceLanguage(WordPress.getContext()); Locale newLocale = WPPrefUtils.languageLocale(languageCode); if (currentLocale.toString().equals(newLocale.getDisplayLanguage())) { return; } if (Locale.getDefault().toString().equals(newLocale.toString())) { mSettings.edit().remove(LANGUAGE_PREF_KEY).apply(); } else { mSettings.edit().putString(LANGUAGE_PREF_KEY, newLocale.toString()).apply(); } updateLanguagePreference(languageCode); conf.locale = newLocale; res.updateConfiguration(conf, res.getDisplayMetrics()); Map<String, Object> properties = new HashMap<>(); properties.put("app_locale", conf.locale.toString()); AnalyticsTracker.track(Stat.ACCOUNT_SETTINGS_LANGUAGE_CHANGED, properties); AnalyticsUtils.refreshMetadata(); Intent refresh = new Intent(getActivity(), getActivity().getClass()); startActivity(refresh); getActivity().setResult(LANGUAGE_CHANGED); getActivity().finish(); }
Source:
private void runNodes(List<T> freeNodes) { List<IWorker<T>> runnables = m_factory.createWorkers(freeNodes); CountDownLatch latch = null; if (useLatches && runnables.size() > 1) { latch = new CountDownLatch(runnables.size()); } boolean latchUsed = false; for (IWorker<T> r : runnables) { m_activeRunnables.add(r); if (latch != null && (r instanceof TestMethodWorker)) { r.setLatch(latch); latchUsed = true; } ppp("Added to active runnable"); setStatus(r, Status.RUNNING); ppp("Executing: " + r); try { execute(r); } catch(Exception ex) { ex.printStackTrace(); } } if (latch != null && latchUsed) { try { latch.await(10, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } } }

Target:
private void runNodes(List<T> freeNodes) { List<IWorker<T>> runnables = m_factory.createWorkers(freeNodes); CountDownLatch latch = null; if (useLatches && runnables.size() > 1) { latch = new CountDownLatch(runnables.size()); } boolean latchUsed = false; for (IWorker<T> r : runnables) { m_activeRunnables.add(r); if (latch != null && (r instanceof IThreadSynchronizer)) { ((IThreadSynchronizer)r).setLatch(latch); latchUsed = true; } setStatus(r, Status.RUNNING); try { execute(r); } catch(Exception ex) { ex.printStackTrace(); } } if (latch != null && latchUsed) { try { latch.await(10, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } } }
Source:
public void onFileChanged(String endpointId, FileChangedEventDto dto) { switch (dto.getStatus()) { case ADDED: break; case MODIFIED: if (alteredFiles.addFile(removeProjectName(dto.getPath()), Status.MODIFIED)) { updateChangedFiles(alteredFiles); } break; case UNTRACKED: break; case NOT_MODIFIED: if (alteredFiles.removeFile(removeProjectName(dto.getPath()))) { updateChangedFiles(alteredFiles); } break; } }

Target:
public void onFileChanged(String endpointId, FileChangedEventDto dto) { switch (dto.getStatus()) { case MODIFIED: if (alteredFiles.addFile(removeProjectName(dto.getPath()), Status.MODIFIED)) { updateChangedFiles(alteredFiles); } break; case NOT_MODIFIED: if (alteredFiles.removeFile(removeProjectName(dto.getPath()))) { updateChangedFiles(alteredFiles); } break; default: } }
Source:
private List<CourseAttributes> extractArchivedCourses(List<CourseDetailsBundle> courseBundles) { ArrayList<CourseAttributes> archivedCourses = new ArrayList<CourseAttributes>(); for (CourseDetailsBundle courseBundle : courseBundles) { CourseAttributes course = courseBundle.course; InstructorAttributes curInstructor = logic.getInstructorForGoogleId(course.id, account.googleId); boolean isCourseArchived; if (curInstructor.isArchived != null) { isCourseArchived = curInstructor.isArchived; } else { isCourseArchived = course.isArchived; } if (isCourseArchived) { archivedCourses.add(course); } } return archivedCourses; }

Target:
private List<CourseAttributes> extractArchivedCourses(List<CourseDetailsBundle> courseBundles) { ArrayList<CourseAttributes> archivedCourses = new ArrayList<CourseAttributes>(); for (CourseDetailsBundle courseBundle : courseBundles) { CourseAttributes course = courseBundle.course; InstructorAttributes curInstructor = logic.getInstructorForGoogleId(course.id, account.googleId); if (logic.isCourseArchived(course.id, curInstructor.googleId)) { archivedCourses.add(course); } } return archivedCourses; }
Source:
void drawInteriorWithFrame_inView_searchfield(long id, long sel, NSRect cellFrame, long viewid) { Control control = findBackgroundControl(); if (control == null) control = this; Image image = control.backgroundImage; if (image != null && !image.isDisposed()) { NSGraphicsContext context = NSGraphicsContext.currentContext(); control.fillBackground (view, context, cellFrame, -1); } else { double searchFieldHeight = 22.0d; cellFrame.y = (cellFrame.height - searchFieldHeight) / 2.0d; cellFrame.height = searchFieldHeight; NSColor bgColor; if(background == null) { bgColor = NSColor.textBackgroundColor(); } else { bgColor = NSColor.colorWithDeviceRed (background [0], background [1], background [2], background [3]); } bgColor.setFill(); NSBezierPath.bezierPathWithRoundedRect(cellFrame, 4.0d, 4.0d).fill(); NSSearchField searchField = ((NSSearchField)view); NSCell _cell = (NSCell) searchField.cell(); SWTSearchFieldCell cell = new SWTSearchFieldCell(_cell.id); if(cell.searchButtonCell() != null) { cell.searchButtonCell().drawInteriorWithFrame(cell.searchButtonRectForBounds(cellFrame), view); } if(cell.cancelButtonCell() != null && ((NSSearchField) view).stringValue().length() > 0) { cell.cancelButtonCell().drawInteriorWithFrame(cell.cancelButtonRectForBounds(cellFrame), view); } } super.drawInteriorWithFrame_inView(id, sel, cellFrame, viewid); }

Target:
void drawInteriorWithFrame_inView_searchfield(long id, long sel, NSRect cellFrame, long viewid) { if(background == null) { return; } cellFrame.x += 1.0; cellFrame.width -= 2.0; cellFrame.y = (cellFrame.height - 20.0) / 2.0; cellFrame.height = 20.0; NSBezierPath path = NSBezierPath.bezierPathWithRoundedRect(cellFrame, 2.0d, 2.0d); path.addClip(); NSColor bgColor = NSColor.colorWithDeviceRed (background [0], background [1], background [2], background [3]); bgColor.setFill(); path.fill(); NSSearchField searchField = ((NSSearchField)view); NSCell _cell = (NSCell) searchField.cell(); SWTSearchFieldCell cell = new SWTSearchFieldCell(_cell.id); if(cell.searchButtonCell() != null) { cell.searchButtonCell().drawInteriorWithFrame(cell.searchButtonRectForBounds(cellFrame), view); } if(cell.cancelButtonCell() != null && ((NSSearchField) view).stringValue().length() > 0) { cell.cancelButtonCell().drawInteriorWithFrame(cell.cancelButtonRectForBounds(cellFrame), view); } }
Source:
public ElasticsearchWork<Long> count(Set<URLEncodedString> indexNames, Set<String> routingKeys, JsonObject payload) { JsonObject filteredPayload = new JsonObject(); filteredPayload.add( "query", JsonAccessor.root().property( "query" ).asObject().get( payload ).get() ); ElasticsearchRequest.Builder builder = ElasticsearchRequest.post() .multiValuedPathComponent( indexNames ) .pathComponent( Paths._COUNT ) .body( filteredPayload ); if ( !routingKeys.isEmpty() ) { builder.param( "_routing", routingKeys.stream().collect( Collectors.joining( "," ) ) ); } return new ElasticsearchStubWork<>( builder.build(), JsonAccessor.root().property( "count" ).asLong() ); }

Target:
public ElasticsearchWork<Long> count(Set<URLEncodedString> indexNames, Set<String> routingKeys, JsonObject payload) { ElasticsearchRequest.Builder builder = ElasticsearchRequest.post() .multiValuedPathComponent( indexNames ) .pathComponent( Paths._COUNT ) .body( payload ); if ( !routingKeys.isEmpty() ) { builder.param( "_routing", routingKeys.stream().collect( Collectors.joining( "," ) ) ); } return new ElasticsearchStubWork<>( builder.build(), JsonAccessor.root().property( "count" ).asLong() ); }
Source:
protected final JComponent createCenterPanel() { JPanel iconPanel = new JBPanel(new BorderLayout()); iconPanel.add(new JBLabel(AllIcons.General.WarningDialog), BorderLayout.NORTH); JEditorPane messageEditorPane = new JEditorPane(); messageEditorPane.setEditorKit(UIUtil.getHTMLEditorKit()); messageEditorPane.setEditable(false); messageEditorPane.setPreferredSize(MESSAGE_EDITOR_PANE_PREFERRED_SIZE); messageEditorPane.setBorder(BorderFactory.createLineBorder(Gray._200)); String text = DIV_STYLE_MARGIN_5PX + getLegalNoticeMessage() + DIV; messageEditorPane.setText(text + "\n" + String.format(PRIVACY_POLICY)); JPanel legalNoticePanel = new JPanel(LEGAL_NOTICE_LAYOUT); legalNoticePanel.add(iconPanel, BorderLayout.WEST); legalNoticePanel.add(messageEditorPane, BorderLayout.CENTER); messageEditorPane.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { BrowserUtil.browse(KODEBEAGLE_PRIVACY_POLICY); } }); return legalNoticePanel; }

Target:
protected final JComponent createCenterPanel() { JPanel iconPanel = new JBPanel(new BorderLayout()); iconPanel.add(new JBLabel(AllIcons.General.WarningDialog), BorderLayout.NORTH); JEditorPane messageEditorPane = new JEditorPane(); messageEditorPane.setEditorKit(UIUtil.getHTMLEditorKit()); messageEditorPane.setEditable(false); messageEditorPane.setPreferredSize(MESSAGE_EDITOR_PANE_PREFERRED_SIZE); messageEditorPane.setBorder(BorderFactory.createLineBorder(Gray._200)); String text = DIV_STYLE_MARGIN_5PX + getLegalNoticeMessage() + "\n" + KODEBEAGLE_PRIVACY_POLICY + DIV; messageEditorPane.setText(text); JPanel legalNoticePanel = new JPanel(LEGAL_NOTICE_LAYOUT); legalNoticePanel.add(iconPanel, BorderLayout.WEST); legalNoticePanel.add(messageEditorPane, BorderLayout.CENTER); messageEditorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(final HyperlinkEvent he) { if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { BrowserUtil.browse(he.getURL()); } } }); return legalNoticePanel; }
Source:
private void commit() { if (getEntity() != null) { if (getWindow() != null) { return; } Snapshot snapshot = getSelectedItem(); ConfirmationModel model = new ConfirmationModel(); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().commitSnapshotTitle()); model.setHelpTag(HelpTag.commit_snapshot); model.setHashName("commit_snapshot"); model.setMessage(ConstantsManager.getInstance() .getMessages() .areYouSureYouWantToCommitSanpshot( DateTimeFormat.getFormat(DATE_FORMAT).format(snapshot.getCreationDate()), snapshot.getDescription())); UICommand tempVar = UICommand.createDefaultOkUiCommand("OnCommit", this); model.getCommands().add(tempVar); UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this); model.getCommands().add(tempVar2); } }

Target:
private void commit() { if (getEntity() != null) { if (getWindow() != null) { return; } Snapshot snapshot = getSelectedItem(); ConfirmationModel model = new ConfirmationModel(); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().commitSnapshotTitle()); model.setHelpTag(HelpTag.commit_snapshot); model.setHashName("commit_snapshot"); model.setMessage(ConstantsManager.getInstance() .getMessages() .areYouSureYouWantToCommitSnapshot( DateTimeFormat.getFormat(DATE_FORMAT).format(snapshot.getCreationDate()), snapshot.getDescription())); model.getCommands().add(UICommand.createDefaultOkUiCommand("OnCommit", this)); model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); } }
Source:
public void addField() { if (addFieldNameProperty.getValue() == null) { return; } if (filterListProperty.getValue().stream().filter(item -> item.getField().equals(addFieldNameProperty.getValue())).findAny().isEmpty()) { filterListProperty.add(new XmpPrivacyItemModel(addFieldNameProperty.getValue())); addFieldNameProperty.setValue(null); } }

Target:
public void addField() { if (addFieldProperty.getValue() == null) { return; } if (xmpFilterListProperty.getValue().stream().filter(item -> item.equals(addFieldProperty.getValue())).findAny().isEmpty()) { xmpFilterListProperty.add(addFieldProperty.getValue()); addFieldProperty.setValue(null); } }
Source:
private Range findRangeByBoundaries(long rangeStart, long rangeEnd) { return ranges.stream().filter(range -> range.isSameRange(rangeStart, rangeEnd)).findFirst().orElse(null); }

Target:
private Range findRangeByBoundaries(long rangeStart, long rangeEnd) { return ranges.stream().filter(range -> range.isSameBoundaries(rangeStart, rangeEnd)).findFirst().orElse(null); }
Source:
Integer getShapeIndex() { if ((getShape() instanceof CaseManagementDiagramShapeView)) { return 0; } if (!(getParent() instanceof CaseManagementShapeView) || getShape() == null) { return null; } int index = ((CaseManagementShapeView) getParent()).getIndex(getShape()); return index >= 0 ? index : null; }

Target:
OptionalInt getShapeIndex() { if ((getShape() instanceof CaseManagementDiagramShapeView)) { return OptionalInt.of(0); } if (!(getParent() instanceof CaseManagementShapeView) || getShape() == null) { return OptionalInt.empty(); } int index = ((CaseManagementShapeView) getParent()).getIndex(getShape()); return index >= 0 ? OptionalInt.of(index) : OptionalInt.empty(); }
Source:
public void specFailsWhenHostnameVerifierCannotVerify() { httpUrl = server.url("<LINK_0>"); mockApi = new XingApi.Builder().custom() .apiEndpoint(httpUrl) .build(); HostnameVerifier noGoogleVerifier = new HostnameVerifier() { @Override public boolean verify(String host, SSLSession sslSession) { return !host.contains("google"); } }; server.enqueue(new MockResponse().setResponseCode(200)); this.<Void, Void>builder(HttpMethod.GET, "/", false) .responseAs(Void.class) .errorAs(Void.class) .hostnameVerifier(noGoogleVerifier) .build() .completableResponse() .test() .assertError(SSLPeerUnverifiedException.class); }

Target:
public void specFailsWhenHostnameVerifierCannotVerify() { httpUrl = server.url("<LINK_0>"); mockApi = new XingApi.Builder().custom() .apiEndpoint(httpUrl) .build(); HostnameVerifier failingVerifier = new HostnameVerifier() { @Override public boolean verify(String host, SSLSession sslSession) { return false; } }; server.enqueue(new MockResponse().setResponseCode(200)); this.<Void, Void>builder(HttpMethod.GET, "/", false) .responseAs(Void.class) .errorAs(Void.class) .hostnameVerifier(failingVerifier) .build() .completableResponse() .test() .assertError(SSLPeerUnverifiedException.class); }
Source:
public void testIntegerRetrievalFromHexadecimalProperty() { int hexaValue = 0x3000000; String wrongValue = "0xwel"; int defaultValue = 100; ZKClientConfig zkClientConfig = new ZKClientConfig(); zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, Integer.toString(hexaValue)); int result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); assertEquals(result, hexaValue); zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, wrongValue); try { result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); fail("NumberFormatException is expected"); } catch (NumberFormatException exception) { } zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, " " + hexaValue + " "); zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); assertEquals(result, hexaValue); zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, " " + hexaValue); zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); assertEquals(result, hexaValue); zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, hexaValue + " "); zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); assertEquals(result, hexaValue); }

Target:
public void testIntegerRetrievalFromHexadecimalProperty() { int hexaValue = 0x3000000; String wrongValue = "0xwel"; int defaultValue = 100; ZKClientConfig zkClientConfig = new ZKClientConfig(); zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, Integer.toString(hexaValue)); int result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); assertEquals(result, hexaValue); zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, wrongValue); try { result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); fail("NumberFormatException is expected"); } catch (NumberFormatException exception) { } zkClientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, " " + hexaValue + " "); result = zkClientConfig.getInt(ZKConfig.JUTE_MAXBUFFER, defaultValue); assertEquals(result, hexaValue); }
Source:
public int compare(SolverBenchmarkResult a, SolverBenchmarkResult b) { return Comparator .comparing(SolverBenchmarkResult::getFailureCount, Comparator.reverseOrder()) .thenComparing(SolverBenchmarkResult::getTotalScore, new ResilientScoreComparator()) .thenComparing(new WorstScoreSolverRankingComparator()) .compare(a, b); }

Target:
public int compare(SolverBenchmarkResult a, SolverBenchmarkResult b) { return Comparator .comparing(SolverBenchmarkResult::getFailureCount, Comparator.reverseOrder()) .thenComparing(SolverBenchmarkResult::getTotalScore, resilientScoreComparator) .thenComparing(worstScoreSolverRankingComparator) .compare(a, b); }
Source:
private Pair<Account, Container> getContainer() throws RestServiceException { String accountName = RestUtils.getHeader(restRequest.getArgs(), RestUtils.Headers.TARGET_ACCOUNT_NAME, true); String containerName = RestUtils.getHeader(restRequest.getArgs(), RestUtils.Headers.TARGET_CONTAINER_NAME, true); Container container; Account account = accountService.getAccountByName(accountName); if (account == null) { throw new RestServiceException("Account " + accountName + " is not found.", RestServiceErrorCode.NotFound); } try { container = accountService.getContainer(accountName, containerName); } catch (AccountServiceException e) { throw new RestServiceException("Failed to get container " + containerName + " from account " + accountName, RestServiceErrorCode.getRestServiceErrorCode(e.getErrorCode())); } if (container == null) { throw new RestServiceException("Container " + containerName + " in account " + accountName + " is not found.", RestServiceErrorCode.NotFound); } return new Pair<>(account, container); }

Target:
private Container getContainer() throws RestServiceException { String accountName = RestUtils.getHeader(restRequest.getArgs(), RestUtils.Headers.TARGET_ACCOUNT_NAME, true); String containerName = RestUtils.getHeader(restRequest.getArgs(), RestUtils.Headers.TARGET_CONTAINER_NAME, true); Container container; try { container = accountService.getContainer(accountName, containerName); } catch (AccountServiceException e) { throw new RestServiceException("Failed to get container " + containerName + " from account " + accountName, RestServiceErrorCode.getRestServiceErrorCode(e.getErrorCode())); } if (container == null) { throw new RestServiceException("Container " + containerName + " in account " + accountName + " is not found.", RestServiceErrorCode.NotFound); } return container; }
Source:
public List<String> validateQuestionDetails(String courseId) { List<String> errors = new ArrayList<>(); if (generateOptionsFor == FeedbackParticipantType.NONE) { if (numOfMcqChoices < Const.FeedbackQuestion.MCQ_MIN_NUM_OF_CHOICES) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_NOT_ENOUGH_CHOICES + Const.FeedbackQuestion.MCQ_MIN_NUM_OF_CHOICES + "."); } if (hasAssignedWeights && mcqChoices.size() != mcqWeights.size()) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_INVALID_WEIGHT); } } return errors; }

Target:
public List<String> validateQuestionDetails(String courseId) { List<String> errors = new ArrayList<>(); if (generateOptionsFor == FeedbackParticipantType.NONE) { if (numOfMcqChoices < Const.FeedbackQuestion.MCQ_MIN_NUM_OF_CHOICES) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_NOT_ENOUGH_CHOICES + Const.FeedbackQuestion.MCQ_MIN_NUM_OF_CHOICES + "."); } if (hasAssignedWeights && mcqChoices.size() != mcqWeights.size()) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_INVALID_WEIGHT); } if (!hasAssignedWeights && (!mcqWeights.isEmpty() || mcqOtherWeight != 0)) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_INVALID_WEIGHT); } if (hasAssignedWeights && !otherEnabled && mcqOtherWeight != 0) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_INVALID_WEIGHT); } if (hasAssignedWeights && !mcqWeights.isEmpty()) { for (double weight : mcqWeights) { if (weight < 0) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_INVALID_WEIGHT); } } if (otherEnabled && mcqOtherWeight < 0) { errors.add(Const.FeedbackQuestion.MCQ_ERROR_INVALID_WEIGHT); } } } return errors; }
Source:
private static String scriptFor(JdbcSinkProperties properties) { StringBuilder result = new StringBuilder("DROP TABLE "); result.append(properties.getTableName()).append(";\n\n"); result.append("CREATE TABLE ").append(properties.getTableName()).append('('); int i = 0; for (String column : properties.getColumns().keySet()) { if (i++ > 0) { result.append(", "); } result.append(column).append(" VARCHAR(2000)"); } result.append(");\n"); System.out.println(result); return result.toString(); }

Target:
private static String scriptFor(JdbcSinkProperties properties) { StringBuilder result = new StringBuilder("DROP TABLE "); result.append(properties.getTableName()).append(";\n\n"); result.append("CREATE TABLE ").append(properties.getTableName()).append('('); int i = 0; for (String column : properties.getColumns().keySet()) { if (i++ > 0) { result.append(", "); } result.append(column).append(" VARCHAR(2000)"); } result.append(");\n"); logger.debug("Generated the following initializing script for table {}:\n{}", properties.getTableName(), result); return result.toString(); }
Source:
public Integer evaluate(String string, String sub, Integer fromIndex) { return string.indexOf(sub, fromIndex) + 1; }

Target:
public Integer evaluate(String string, String sub, Integer fromIndex) { return string.indexOf(sub, fromIndex - 1) + 1; }
Source:
public PageSet<? extends StorageMetadata> apply(PaginatedVaultCollection vaults) { return new PageSetImpl<StorageMetadata>(Iterables.transform(vaults, new VaultMetadataToStorageMetadata()), vaults.nextMarker().isPresent() ? (String) vaults.nextMarker().get() : null); }

Target:
public PageSet<? extends StorageMetadata> apply(PaginatedVaultCollection vaults) { return new PageSetImpl<StorageMetadata>(Iterables.transform(vaults, new VaultMetadataToStorageMetadata()), (String) vaults.nextMarker().orNull()); }
Source:
protected Spanned doInBackground(Void... params) { Spanned contentSpannable; if (getActivity() == null) { return null; } PostModel post = ((EditPostActivity) getActivity()).getPost(); if (post == null) { return null; } String postTitle = "<h1>" + post.getTitle() + "</h1>"; String postContent = postTitle + post.getContent(); if (post.isLocalDraft()) { contentSpannable = WPHtml.fromHtml( postContent.replaceAll("\uFFFC", ""), getActivity(), post, Math.min(mTextView.getWidth(), mTextView.getHeight()) ); } else { String htmlText = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"webview.css\" /></head><body><div id=\"container\">%s</div></body></html>"; htmlText = String.format(htmlText, StringUtils.addPTags(postContent)); contentSpannable = new SpannableString(htmlText); } return contentSpannable; }

Target:
protected Spanned doInBackground(Void... params) { Spanned contentSpannable; if (getActivity() == null) { return null; } if (mPost == null) { return null; } String postTitle = "<h1>" + mPost.getTitle() + "</h1>"; String postContent = postTitle + mPost.getContent(); if (mPost.isLocalDraft()) { contentSpannable = WPHtml.fromHtml( postContent.replaceAll("\uFFFC", ""), getActivity(), mPost, Math.min(mTextView.getWidth(), mTextView.getHeight()) ); } else { String htmlText = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><html><head><link rel=\"stylesheet\" " + "type=\"text/css\" href=\"webview.css\" /></head><body><div " + "id=\"container\">%s</div></body></html>"; htmlText = String.format(htmlText, StringUtils.addPTags(postContent)); contentSpannable = new SpannableString(htmlText); } return contentSpannable; }
Source:
private String getEULAText() { try { String tfLocation = TfTool.getLocation(); if (tfLocation == null) { return null; } String path = Path.combine(Path.combine(Path.getDirectoryName(tfLocation), "lib"), "com.microsoft.tfs.client.common.jar"); JarFile jar = new JarFile(path); InputStream stream = jar.getInputStream(jar.getEntry("eula.txt")); BufferedReader rdr = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8)); StringBuilder result = new StringBuilder(); String line; while ((line = rdr.readLine()) != null) { result.append(line).append("\n"); } return result.toString(); } catch (IOException e) { System.out.println(e.getMessage()); } return null; }

Target:
private String getEULAText() { JarFile jarFile = null; InputStream eulaStream = null; String jarName = "com.microsoft.tfs.client.common.jar"; try { String tfLocation = TfTool.getLocation(); if (tfLocation == null) { return null; } String path = Path.combine(Path.combine(Path.getDirectoryName(tfLocation), "lib"), jarName); jarFile = new JarFile(path); eulaStream = jarFile.getInputStream(jarFile.getEntry("eula.txt")); return StreamUtil.readText(eulaStream, Charsets.UTF_8); } catch (IOException e) { logger.error("Cannot read EULA text from: " + jarName, e); } finally { if (eulaStream != null) { try { eulaStream.close(); } catch (IOException e) { logger.error("Cannot eulaStream properly", e); } } if (jarFile != null) { try { jarFile.close(); } catch (IOException e) { logger.error("Cannot jarFile properly", e); } } } return null; }
Source:
public boolean cancel(final Exception rootReason) { if (transitionCancel(rootReason)) { final Exception reason = new CancellationException(rootReason); try { traceFailure(reason); } catch (Throwable ex) { LOGGER.warn("Exception thrown in logging trace for failure!", ex); } getSettableDelegate().fail(reason); return true; } return false; }

Target:
public boolean cancel(final Exception rootReason) { if (transitionCancel(rootReason)) { final Exception reason = new CancellationException(rootReason); try { traceFailure(reason); } catch (Throwable ex) { LOGGER.warn("Exception thrown in logging trace for failure!", ex); } finally { getSettableDelegate().fail(reason); } return true; } return false; }