auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void onPartitionsLost(final Collection<TopicPartition> partitions) { log.info("at state {}: partitions lost due to missed rebalance.\n" + "\tlost active tasks: {}\n" + "\tlost assigned standby tasks: {}\n", streamThread.state(), partitions, taskManager.activeTaskIds(), taskManager.standbyTaskIds()); final long start = time.milliseconds(); try { // close all active tasks as lost but don't try to commit offsets as we no longer own them taskManager.handleLostAll(); } catch (final Exception e) { throw new TaskMigratedException("Error caught during partitions lost", e); } finally { log.info("partitions lost took ms.", time.milliseconds() - start); } }

Target:
public void onPartitionsLost(final Collection<TopicPartition> partitions) { log.info("at state {}: partitions lost due to missed rebalance.\n" + "\tlost active tasks: {}\n" + "\tlost assigned standby tasks: {}\n", streamThread.state(), partitions, taskManager.activeTaskIds(), taskManager.standbyTaskIds()); final long start = time.milliseconds(); try { // close all active tasks as lost but don't try to commit offsets as we no longer own them taskManager.handleLostAll(); } finally { log.info("partitions lost took ms.", time.milliseconds() - start); } }
Source:
private void addChangelogsToRestoreConsumer(final Set<TopicPartition> partitions) { final Set<TopicPartition> assignment = new HashSet<>(restoreConsumer.assignment()); // the current assignment should not contain any of the new partitions if (assignment.removeAll(partitions)) { throw new IllegalStateException("The current assignment " + restoreConsumer.assignment() + " " + "already contains some of the new partitions " + partitions); } assignment.addAll(partitions); restoreConsumer.assign(assignment); log.debug("Added partitions to the restore consumer, current assignment is {}", partitions, assignment); }

Target:
private void addChangelogsToRestoreConsumer(final Set<TopicPartition> partitions) { final Set<TopicPartition> assignment = new HashSet<>(restoreConsumer.assignment()); // the current assignment should not contain any of the new partitions if (assignment.removeAll(partitions)) { throw new IllegalStateException("The current assignment " + restoreConsumer.assignment() + " " + "already contains some of the new partitions " + partitions); } assignment.addAll(partitions); restoreConsumer.assign(assignment); }
Source:
public void shouldThrowOnSendOffsetsToTransactionIfTransactionsNotInitialized() { buildMockProducer(true); String groupId = null; producer.sendOffsetsToTransaction(null, groupId); }

Target:
public void shouldThrowOnSendOffsetsToTransactionIfTransactionsNotInitialized() { buildMockProducer(true); producer.sendOffsetsToTransaction(null, groupId); }
Source:
public boolean hasNext() { if (this.hasPeek) { return true; } if (!this.iterator.hasNext()) { this.iterator = this.iterable.iterator(); } return true; }

Target:
public boolean hasNext() { return true; }
Source:
public Iterator<Header> iterator() { return (headers == null) ? Collections.emptyIterator() : headers.iterator(); }

Target:
public Iterator<Header> iterator() { return headers == null ? Collections.emptyIterator() : headers.iterator(); }
Source:
public void testThreadNameWithoutNumberDemon() { Thread daemonThread = ThreadUtils.createThreadFactory(THREAD_NAME, true).newThread(EMPTY_RUNNABLE); try { Assert.assertEquals(daemonThread.getName(), THREAD_NAME); Assert.assertTrue(daemonThread.isDaemon()); } finally { try { daemonThread.join(); } catch (InterruptedException e) { // can be ignored e.printStackTrace(); } } }

Target:
public void testThreadNameWithoutNumberDemon() { Thread daemonThread = ThreadUtils.createThreadFactory(THREAD_NAME, true).newThread(EMPTY_RUNNABLE); try { assertEquals(THREAD_NAME, daemonThread.getName()); assertTrue(daemonThread.isDaemon()); } finally { try { daemonThread.join(); } catch (InterruptedException e) { // can be ignored } } }
Source:
private void flushAndCheckpointState() { try { stateMgr.flush(); } catch (final ProcessorStateException e) { if (e.getCause() instanceof ProducerFencedException) { log.warn("Caught a retriable Kafka exception while flushing state. Initiating a rebalance to attempt recovery.", e); throw new TaskMigratedException(this, e); } } stateMgr.checkpoint(Collections.emptyMap()); }

Target:
private void flushAndCheckpointState() { // this could theoretically throw a ProcessorStateException caused by a ProducerFencedException, // but in practice this shouldn't happen for standby tasks, since they don't produce to changelog topics // or downstream topics. stateMgr.flush(); stateMgr.checkpoint(Collections.emptyMap()); }
Source:
public void remove(TopicPartition topicPartition) { removed.add(topicPartition); next.remove(topicPartition); sessionPartitions.remove(topicPartition); }

Target:
public void remove(TopicPartition topicPartition) { if (sessionPartitions.remove(topicPartition) != null) { removed.add(topicPartition); } // we do not need to call next.remove assuming the caller would not add and then remove // the same element within the same iteration (which is true in both Fetcher and ReplicaFetcherThread), // so saving the search here. }
Source:
private ConsumerRebalanceListener getConsumerRebalanceListener(final KafkaConsumer<String, String> consumer) { return new ConsumerRebalanceListener() { @Override public void onPartitionsRevoked(Collection<TopicPartition> partitions) { } @Override public void onPartitionsAssigned(Collection<TopicPartition> partitions) { // set initial position so we don't need a lookup for (TopicPartition partition : partitions) consumer.seek(partition, 0); } @Override public void onPartitionsLost(Collection<TopicPartition> partitions) { System.out.println("hit partitions lost " + partitions); } }; }

Target:
private ConsumerRebalanceListener getConsumerRebalanceListener(final KafkaConsumer<String, String> consumer) { return new ConsumerRebalanceListener() { @Override public void onPartitionsRevoked(Collection<TopicPartition> partitions) { } @Override public void onPartitionsAssigned(Collection<TopicPartition> partitions) { // set initial position so we don't need a lookup for (TopicPartition partition : partitions) consumer.seek(partition, 0); } }; }
Source:
private int maybeUpdateLastAckedSequence(TopicPartition topicPartition, int sequence) { if (sequence > lastAckedSequence(topicPartition).orElse(NO_LAST_ACKED_SEQUENCE_NUMBER)) { topicPartitionBookkeeper.getPartition(topicPartition).lastAckedSequence = sequence; return sequence; } return lastAckedSequence(topicPartition).orElse(NO_LAST_ACKED_SEQUENCE_NUMBER); }

Target:
private int maybeUpdateLastAckedSequence(TopicPartition topicPartition, int sequence) { int lastAckedSequence = lastAckedSequence(topicPartition).orElse(NO_LAST_ACKED_SEQUENCE_NUMBER); if (sequence > lastAckedSequence) { topicPartitionBookkeeper.getPartition(topicPartition).lastAckedSequence = sequence; return sequence; } return lastAckedSequence; }
Source:
public PluginClassLoader pluginClassLoader(String name) { if (!PluginUtils.shouldLoadInIsolation(name)) { return null; } SortedMap<PluginDesc<?>, ClassLoader> inner = pluginLoaders.get(name); if (inner == null) { return null; } ClassLoader pluginLoader = inner.get(inner.lastKey()); if (!(pluginLoader instanceof PluginClassLoader)) { return null; } return (PluginClassLoader) pluginLoader; }

Target:
public PluginClassLoader pluginClassLoader(String name) { if (!PluginUtils.shouldLoadInIsolation(name)) { return null; } SortedMap<PluginDesc<?>, ClassLoader> inner = pluginLoaders.get(name); if (inner == null) { return null; } ClassLoader pluginLoader = inner.get(inner.lastKey()); return pluginLoader instanceof PluginClassLoader ? (PluginClassLoader) pluginLoader : null; }
Source:
private void resetOffsetIfNeeded(TopicPartition partition, OffsetResetStrategy requestedResetStrategy, ListOffsetData offsetData) { SubscriptionState.FetchPosition position = new SubscriptionState.FetchPosition( offsetData.offset, offsetData.leaderEpoch, metadata.leaderAndEpoch(partition)); offsetData.leaderEpoch.ifPresent(epoch -> metadata.updateLastSeenEpochIfNewer(partition, epoch)); subscriptions.maybeSeekUnvalidated(partition, position, requestedResetStrategy); }

Target:
private void resetOffsetIfNeeded(TopicPartition partition, OffsetResetStrategy requestedResetStrategy, ListOffsetData offsetData) { SubscriptionState.FetchPosition position = new SubscriptionState.FetchPosition( offsetData.offset, Optional.empty(), // This will ensure we skip validation metadata.leaderAndEpoch(partition)); offsetData.leaderEpoch.ifPresent(epoch -> metadata.updateLastSeenEpochIfNewer(partition, epoch)); subscriptions.maybeSeekUnvalidated(partition, position, requestedResetStrategy); }
Source:
private boolean isMuted(TopicPartition tp, long now) { Long throttleUntilTime = muted.get(tp); boolean result = throttleUntilTime != null && throttleUntilTime > now; if (!result) muted.remove(tp); return result; }

Target:
private boolean isMuted(TopicPartition tp, long now) { // Take care to avoid unnecessary map look-ups because this method is a hotspot if producing to a // large number of partitions Long throttleUntilTime = muted.get(tp); if (throttleUntilTime == null) return false; if (now >= throttleUntilTime) { muted.remove(tp); return false; } return true; }
Source:
private boolean isMuted(TopicPartition tp, long now) { Long throttleUntilTime = muted.get(tp); boolean unmute = throttleUntilTime != null && now >= throttleUntilTime; if (unmute) muted.remove(tp); return unmute; }

Target:
private boolean isMuted(TopicPartition tp, long now) { // Take care to avoid unnecessary map look-ups because this method is a hotspot if producing to a // large number of partitions Long throttleUntilTime = muted.get(tp); if (throttleUntilTime == null) return false; if (now >= throttleUntilTime) { muted.remove(tp); return false; } return true; }
Source:
public KStream<K, V> repartition(final Repartitioned<K, V> repartitioned) { Objects.requireNonNull(repartitioned, "repartitioned parameter can't be null"); return doRepartition(repartitioned, null); }

Target:
public KStream<K, V> repartition(final Repartitioned<K, V> repartitioned) { return doRepartition(repartitioned); }
Source:
public boolean rejoinNeededOrPending() { if (!subscriptions.partitionsAutoAssigned()) return false; // we need to rejoin if we performed the assignment and metadata has changed if (assignmentSnapshot != null && !assignmentSnapshot.matches(metadataSnapshot)) { maybeLosePartitions("topic metadata has changed and therefore some topics may not exist any moreq"); return true; } // we need to join if our subscription has changed since the last join if (joinedSubscription != null && !joinedSubscription.equals(subscriptions.subscription())) { maybeLosePartitions("consumer subscription has changed since last joined generation"); return true; } return super.rejoinNeededOrPending(); }

Target:
public boolean rejoinNeededOrPending() { if (!subscriptions.partitionsAutoAssigned()) return false; // we need to rejoin if we performed the assignment and metadata has changed; // also for those owned-but-no-longer-existed partitions we should drop them as lost if (assignmentSnapshot != null && !assignmentSnapshot.matches(metadataSnapshot)) return true; // we need to join if our subscription has changed since the last join if (joinedSubscription != null && !joinedSubscription.equals(subscriptions.subscription())) { return true; } return super.rejoinNeededOrPending(); }
Source:
public void close(Duration timeout) { if (timeout.toMillis() < 0) throw new IllegalArgumentException("The timeout cannot be negative."); acquire(); try { if (!closed) { close(timeout.toMillis(), false); closed = true; } } finally { release(); } }

Target:
public void close(Duration timeout) { if (timeout.toMillis() < 0) throw new IllegalArgumentException("The timeout cannot be negative."); acquire(); try { if (!closed) { // need to close before setting the flag since the close function // itself may trigger rebalance callback that needs the consumer to be open still close(timeout.toMillis(), false); } } finally { closed = true; release(); } }
Source:
protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { Filter f = query.getFilter(); if (f != null && f.equals(Filter.INCLUDE)) { try { return new ReferencedEnvelope( CRS.transform(mbtiles.loadMetaData().getBounds(), DEFAULT_CRS)); } catch (TransformException e) { throw new RuntimeException("Unable to retrieve bounds from mbtiles metadata", e); } } else { // summing up all feature bounds would be expensive. // returning null return null; } }

Target:
protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { Filter f = query.getFilter(); if (f == null || f.equals(Filter.INCLUDE)) { try { return new ReferencedEnvelope( CRS.transform(mbtiles.loadMetaData().getBounds(), DEFAULT_CRS)); } catch (TransformException e) { throw new RuntimeException("Unable to retrieve bounds from mbtiles metadata", e); } } else { // summing up all feature bounds would be expensive. // returning null return null; } }
Source:
public void registerSqlTypeToSqlTypeNameOverrides(Map<Integer, String> overrides) { //Step 1 Geos-7533 put the types in dialect overrides.put(4, "int4"); overrides.put(Types.VARCHAR, "VARCHAR"); overrides.put(Types.BOOLEAN, "BOOL"); overrides.put(Types.BLOB, "BYTEA"); }

Target:
public void registerSqlTypeToSqlTypeNameOverrides(Map<Integer, String> overrides) { overrides.put(Types.VARCHAR, "VARCHAR"); overrides.put(Types.BOOLEAN, "BOOL"); overrides.put(Types.BLOB, "BYTEA"); }
Source:
public void testCreatePointStyle(){ // The following is complex, and should be built from // an SLD document and not by hand PointSymbolizer pointsym = sf.createPointSymbolizer(); pointsym.setGraphic(sf.getDefaultGraphic()); NumberRange<Double> scaleRange = NumberRange.create( 1.0,50000.0); Style2D style = sld.createPointStyle(null, pointsym, scaleRange); assertNotNull( style ); PointStyle2D ps = (PointStyle2D) style; assertEquals(0.0f, ps.getAnchorPointX(), 0.0f); assertEquals(0.5f, ps.getAnchorPointY(), 0.0f); }

Target:
public void testCreatePointStyle(){ // The following is complex, and should be built from // an SLD document and not by hand PointSymbolizer pointsym = sf.createPointSymbolizer(); pointsym.setGraphic(sf.getDefaultGraphic()); NumberRange<Double> scaleRange = NumberRange.create( 1.0,50000.0); Style2D style = sld.createPointStyle(null, pointsym, scaleRange); assertNotNull( style ); }
Source:
private CoverageSource getGridCoverageSource(final String coverageName) throws IOException { // Preliminar check on name availability checkIsSupported(coverageName); synchronized (coverages) { if (coverages.containsKey(coverageName)) { return coverages.get(coverageName); } // create, cache and return CoverageSource source = access.access(new NameImpl(coverageName), null, AccessType.READ_ONLY, null, null); if (source instanceof NetCDFSource) { } coverages.put(coverageName, source); return source; } }

Target:
private CoverageSource getGridCoverageSource(final String coverageName) throws IOException { // Preliminar check on name availability checkIsSupported(coverageName); synchronized (coverages) { if (coverages.containsKey(coverageName)) { return coverages.get(coverageName); } // create, cache and return CoverageSource source = access.access(new NameImpl(coverageName), null, AccessType.READ_ONLY, null, null); coverages.put(coverageName, source); return source; } }
Source:
private static void checkAllInserted(int[] inserts, int size) throws IOException { int sum = 0; for (int cur: inserts) { if (cur == PreparedStatement.SUCCESS_NO_INFO) { return; // cannot check } else if (cur == PreparedStatement.EXECUTE_FAILED) { throw new IOException("Failed to insert some features"); } sum += cur; } if (sum != size) { throw new IOException("Failed to insert some features"); } }

Target:
static void checkAllInserted(int[] inserts, int size) throws IOException { int sum = 0; for (int cur: inserts) { if (cur == PreparedStatement.SUCCESS_NO_INFO) { return; // cannot check } else if (cur == PreparedStatement.EXECUTE_FAILED) { throw new IOException("Failed to insert some features"); } sum += cur; } if (sum != size) { throw new IOException("Failed to insert some features"); } }
Source:
public boolean hasNext() throws IOException { if( csvWriter == null ){ throw new IOException("Writer has been closed"); } if (this.appending) { return false; // reader has no more contents } return iterator.hasNext(); }

Target:
public boolean hasNext() throws IOException { if( csvWriter == null ){ return false; } if (this.appending) { return false; // reader has no more contents } return iterator.hasNext(); }
Source:
public StringBuilder dateToText( Date date, StringBuilder output ){ DateFormat formatter; // If the Date has millisecond resolution, print the millis. if (date.getTime() % 1000 == 0) { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); } else { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"); } formatter.setTimeZone(TimeZone.getTimeZone("GMT+00:00")); String text = formatter.format(date); // GMT is not part of CQL syntax so it is removed text = text.replace("GMT", ""); output.append( text ); return output; }

Target:
public StringBuilder dateToText( Date date, StringBuilder output ){ final DateFormat formatter; // If the Date has millisecond resolution, print the millis. if (date.getTime() % 1000 == 0) { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); } else { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"); } formatter.setTimeZone(TimeZone.getTimeZone("GMT+00:00")); String text = formatter.format(date); // GMT is not part of CQL syntax so it is removed text = text.replace("GMT", ""); output.append( text ); return output; }
Source:
public void parseAssociatedNames(Job<?, ?> job, Collection<GitHubRepositoryName> result) { ParameterizedJobMixIn.ParameterizedJob p = (ParameterizedJobMixIn.ParameterizedJob) job; for (GitHubTrigger ght : Util.filter(p.getTriggers().values(),GitHubTrigger.class)) { result.addAll(ght.getGitHubRepositories()); } }

Target:
public void parseAssociatedNames(Job<?, ?> job, Collection<GitHubRepositoryName> result) { if (job instanceof ParameterizedJobMixIn.ParameterizedJob) { ParameterizedJobMixIn.ParameterizedJob p = (ParameterizedJobMixIn.ParameterizedJob) job; // TODO use standard method in 1.621+ for (GitHubTrigger ght : Util.filter(p.getTriggers().values(),GitHubTrigger.class)) { result.addAll(ght.getGitHubRepositories()); } } }
Source:
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { switch (opcode) { case Opcodes.INVOKEVIRTUAL: case Opcodes.INVOKESPECIAL: case Opcodes.INVOKESTATIC: _methodInsnName = name; _methodInsnOwner = owner; _methodInsnDesc = desc; _methodInsnOpcode = opcode; break; default: //TODO: throw an exception that couldn't infer operation LOGGER.debug("Unexpected opcode, falling back"); break; } super.visitMethodInsn(opcode, owner, name, desc, itf); }

Target:
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { switch (opcode) { case Opcodes.INVOKEVIRTUAL: case Opcodes.INVOKESPECIAL: case Opcodes.INVOKESTATIC: _methodInsnName = name; _methodInsnOwner = owner; _methodInsnDesc = desc; _methodInsnOpcode = opcode; break; default: System.out.println("Unexpected opcode, falling back"); break; } super.visitMethodInsn(opcode, owner, name, desc, itf); }
Source:
public void start() { if (stepClassWithSpringContext != null) { testContextManager = new CucumberTestContextManager(stepClassWithSpringContext); } else { if (beanFactory == null) { beanFactory = createFallbackContext(); } } notifyContextManagerAboutTestClassStarted(); if (beanFactory == null || isNewContextCreated()) { beanFactory = testContextManager.getBeanFactory(); synchronized (beanFactory) { for (Class<?> stepClass : stepClasses) { registerStepClassBeanDefinition(beanFactory, stepClass); } } } GlueCodeContext.getInstance().start(); }

Target:
public void start() { // registerStepClassBeanDefinition and // CucumberTestContextManager.registerGlueCodeScope manipulate the the // application context. These operations are not thread-safe. So the // SpringFactory must be started serially. synchronized (monitor) { if (stepClassWithSpringContext != null) { testContextManager = new CucumberTestContextManager(stepClassWithSpringContext); } else { if (beanFactory == null) { beanFactory = createFallbackContext(); } } notifyContextManagerAboutTestClassStarted(); if (beanFactory == null || isNewContextCreated()) { beanFactory = testContextManager.getBeanFactory(); for (Class<?> stepClass : stepClasses) { registerStepClassBeanDefinition(beanFactory, stepClass); } } GlueCodeContext.getInstance().start(); } }
Source:
private void handleWrite(WriteEvent event) { out.println(); try(BufferedReader lines = new BufferedReader(new StringReader(event.text))) { String line = lines.readLine(); while(line != null) { out.println(STEP_SCENARIO_INDENT + line); line = lines.readLine(); } } catch (IOException e) { throw new CucumberException(e); } out.println(); }

Target:
private void handleWrite(WriteEvent event) { out.println(); try(BufferedReader lines = new BufferedReader(new StringReader(event.text))) { String line; while ((line = lines.readLine()) != null) { out.println(STEP_SCENARIO_INDENT + line); } } catch (IOException e) { throw new CucumberException(e); } out.println(); }
Source:
public void addStepDefinition(StepDefinition stepDefinition) { StepDefinition previous = stepDefinitionsByPattern.get(stepDefinition.getPattern()); if (previous == null || haveSameLocation(previous, stepDefinition)) { stepDefinitionsByPattern.put(stepDefinition.getPattern(), stepDefinition); } else { throw new DuplicateStepDefinitionException(previous, stepDefinition); } }

Target:
public void addStepDefinition(StepDefinition stepDefinition) { StepDefinition previous = stepDefinitionsByPattern.get(stepDefinition.getPattern()); if (previous == null) { stepDefinitionsByPattern.put(stepDefinition.getPattern(), stepDefinition); } else if (!haveSameLocation(previous, stepDefinition)) { throw new DuplicateStepDefinitionException(previous, stepDefinition); } }
Source:
public void search_shouldReturnAllReportTemplatesByGivenPublisher() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter(MrrtReportTemplateSearchHandler.REQUEST_PARAM_PUBLISHER, PUBLISHER_QUERY); RequestContext requestContext = new RequestContext(); requestContext.setRequest(request); when(mrrtReportTemplateService.getMrrtReportTemplates(any(MrrtReportTemplateSearchCriteria.class))) .thenReturn(mrrtReportTemplates); PageableResult pageableResult = mrrtReportTemplateSearchHandler.search(requestContext); assertThat(pageableResult, is(instanceOf(NeedsPaging.class))); }

Target:
public void search_shouldReturnAllReportTemplatesByGivenPublisher() throws Exception { request.setParameter(MrrtReportTemplateSearchHandler.REQUEST_PARAM_PUBLISHER, PUBLISHER_QUERY); when(mrrtReportTemplateService.getMrrtReportTemplates(any(MrrtReportTemplateSearchCriteria.class))) .thenReturn(mrrtReportTemplates); PageableResult pageableResult = mrrtReportTemplateSearchHandler.search(requestContext); assertThat(pageableResult, is(instanceOf(NeedsPaging.class))); }
Source:
public void findEncounter_shouldThrowIllegalArgumentExceptionIfGivenVisitIsNull() throws Exception { // given EncounterParameters encounterParameters = EncounterParameters.instance() .setEncounterType(radiologyProperties.getRadiologyOrderEncounterType()) .setEncounterUuid(VOIDED_ENCOUNTER_UUID); Visit visit = null; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("visit is required"); radiologyEncounterMatcher.findEncounter(visit, encounterParameters); }

Target:
public void findEncounter_shouldThrowIllegalArgumentExceptionIfGivenVisitIsNull() throws Exception { // given EncounterParameters encounterParameters = EncounterParameters.instance() .setEncounterType(radiologyProperties.getRadiologyOrderEncounterType()) .setEncounterUuid(VOIDED_ENCOUNTER_UUID); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("visit is required"); radiologyEncounterMatcher.findEncounter(null, encounterParameters); }
Source:
public void findEncounter_shouldThrowIllegalArgumentExceptionIfGivenEncounterParametersIsNull() throws Exception { // given EncounterParameters encounterParameters = null; Visit visit = visitService.getVisit(VISIT_ID_WITH_VOIDED_ENCOUNTER); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("encounterParameters are required"); radiologyEncounterMatcher.findEncounter(visit, encounterParameters); }

Target:
public void findEncounter_shouldThrowIllegalArgumentExceptionIfGivenEncounterParametersIsNull() throws Exception { // given Visit visit = visitService.getVisit(VISIT_ID_WITH_VOIDED_ENCOUNTER); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("encounterParameters are required"); radiologyEncounterMatcher.findEncounter(visit, null); }
Source:
public String getDicomViewerUrl(Study study) { if (study == null) throw new IllegalArgumentException("study cannot be null"); else if (study.getStudyInstanceUid() == null) throw new IllegalArgumentException("studyInstanceUid cannot be null"); else { if (this.radiologyProperties == null) return "http://localhost:8081/weasis-pacs-connector/viewer?" + "studyUID=" + study.getStudyInstanceUid(); else return this.radiologyProperties.getDicomViewerUrl() + "studyUID=" + study.getStudyInstanceUid(); } }

Target:
public String getDicomViewerUrl(Study study) { if (study == null) throw new IllegalArgumentException("study cannot be null"); else if (study.getStudyInstanceUid() == null) throw new IllegalArgumentException("studyInstanceUid cannot be null"); return radiologyProperties.getDicomViewerUrl() + "studyUID=" + study.getStudyInstanceUid(); }
Source:
public void started() { try { startDicomOrderFiller(); } catch (Exception e) { // Just prints in console } typeAndRoles(); }

Target:
public void started() { startDicomOrderFiller(); typeAndRoles(); }
Source:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Boolean isDarkTheme = SalesforceSDKManager.getInstance().isDarkTheme(getActivity()); // Do not create a new Fragment when the Activity is re-created such as orientation changes. setRetainInstance(true); setStyle(DialogFragment.STYLE_NORMAL, (isDarkTheme ? R.style.SalesforceSDK_Dialog_Dark : R.style.SalesforceSDK_Dialog)); }

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean isDarkTheme = SalesforceSDKManager.getInstance().isDarkTheme(getActivity()); // Do not create a new Fragment when the Activity is re-created such as orientation changes. setRetainInstance(true); setStyle(DialogFragment.STYLE_NORMAL, (isDarkTheme ? R.style.SalesforceSDK_Dialog_Dark : R.style.SalesforceSDK_Dialog)); }
Source:
public boolean loadSqlCipher(Context context) { try { loadLibs(context); } catch (UnsatisfiedLinkError ule) { // We are assuming the library loaded by sql cipher failed return extractAndLoadAgain(context, DATABASE_SQLCIPHER, getSupportedAbis()); } catch (Exception ex) { Log.e(TAG, "Error loading native libraries for Sqlcipher", ex); return false; } return true; }

Target:
public static boolean loadSqlCipher(Context context) { try { loadLibs(context); } catch (UnsatisfiedLinkError ule) { // We are assuming the library loaded by sql cipher failed return extractAndLoadAgain(context, DATABASE_SQLCIPHER, getSupportedAbis()); } catch (Exception ex) { Log.e(TAG, "Error loading native libraries for Sqlcipher", ex); return false; } return true; }
Source:
protected TokenEndpointResponse performRequest(LoginOptions options) throws Exception { try { return OAuth2.swapJWTForTokens(HttpAccess.DEFAULT, new URI(options.loginUrl), options.jwt); } catch (Exception e) { onAuthFlowError("jwt_oauth_error", e.getLocalizedMessage()); callback.finish(); } return null; }

Target:
protected TokenEndpointResponse performRequest(LoginOptions options) { try { return OAuth2.swapJWTForTokens(HttpAccess.DEFAULT, new URI(options.loginUrl), options.jwt); } catch (Exception e) { onAuthFlowError("jwt_oauth_error", e.getLocalizedMessage()); callback.finish(); } return null; }
Source:
public Bundle asBundle() { bundle.putString(JWT, jwt); //jwt can be updated during flow return bundle; }

Target:
public Bundle asBundle() { return bundle; }
Source:
public static TokenEndpointResponse swapJWTForTokens(HttpAccess httpAccessor, URI loginServerUrl, String jwt) throws IOException, URISyntaxException, OAuthFailedException { // call the token endpoint, and swap jwt for an access tokens. FormBody.Builder formBodyBuilder = new FormBody.Builder() .add(GRANT_TYPE, JWT_BEARER) .add(ASSERTION, jwt); TokenEndpointResponse tr = makeTokenEndpointRequest(httpAccessor, loginServerUrl, formBodyBuilder); return tr; }

Target:
public static TokenEndpointResponse swapJWTForTokens(HttpAccess httpAccessor, URI loginServerUrl, String jwt) throws IOException, URISyntaxException, OAuthFailedException { // call the token endpoint, and swap jwt for an access tokens. FormBody.Builder formBodyBuilder = new FormBody.Builder() .add(GRANT_TYPE, JWT_BEARER) .add(ASSERTION, jwt); return makeTokenEndpointRequest(httpAccessor, loginServerUrl, formBodyBuilder); }
Source:
public void testResponseStreamConsumedByReadingStream() throws Exception { final RestResponse response = getStreamTestResponse(); try { InputStream in = response.asInputStream() inputStreamToString(in); } catch (IOException e) { fail("The InputStream should be readable and an IOException should not have been thrown"); } // We read the entire stream but forgot to call consume() or consumeQuietly() - can another REST call be made? final RestResponse anotherResponse = getStreamTestResponse(); assertNotNull(anotherResponse); }

Target:
public void testResponseStreamConsumedByReadingStream() throws Exception { final RestResponse response = getStreamTestResponse(); try { InputStream in = response.asInputStream(); inputStreamToString(in); } catch (IOException e) { fail("The InputStream should be readable and an IOException should not have been thrown"); } // We read the entire stream but forgot to call consume() or consumeQuietly() - can another REST call be made? final RestResponse anotherResponse = getStreamTestResponse(); assertNotNull(anotherResponse); }
Source:
public void loadRepository(boolean refresh) { Consumer subscriber = repository -> { mRepository = (Repository) repository; updateTitle(); invalidateTabs(); // Apply initial page selection first time the repo is loaded if (mInitialPage >= PAGE_REPO_OVERVIEW && mInitialPage <= PAGE_ACTIVITY) { getPager().setCurrentItem(mInitialPage); mInitialPage = -1; } setContentShown(true); supportInvalidateOptionsMenu(); }; RepositoryService.loadRepository(this, mRepoOwner, mRepoName, refresh) .subscribe(subscriber, e -> {}); }

Target:
private void loadRepository(boolean refresh) { Consumer<Repository> subscriber = repository -> { mRepository = repository; updateTitle(); invalidateTabs(); // Apply initial page selection first time the repo is loaded if (mInitialPage >= PAGE_REPO_OVERVIEW && mInitialPage <= PAGE_ACTIVITY) { getPager().setCurrentItem(mInitialPage); mInitialPage = -1; } setContentShown(true); supportInvalidateOptionsMenu(); }; RepositoryService.loadRepository(this, mRepoOwner, mRepoName, refresh) .subscribe(subscriber, error -> {}); }
Source:
public void reloadData() { setContentShown(false); Log.d("TEST", "reloadData callleeeed"); loadReadme(true); loadPullRequestsCount(true); }

Target:
private void reloadData() { setContentShown(false); loadReadme(true); loadPullRequestsCount(true); }
Source:
public Unit(String unitName, boolean enemy) { this(unitName, 1, enemy, GameController.getInstance().getUnitLife(unitName)); }

Target:
public Unit(String unitName, boolean enemy) { this(unitName, -1, enemy, GameController.getInstance().getUnitLife(unitName)); }