auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void assertUpdated( String expected, String namespace, String key, ConcurrentMap<String, Function<String, String>> lookup ) throws InterruptedException { final Function<String, String> extractionFn = lookup.get(namespace); int count = 0; if (expected == null) { <START> while (extractionFn.apply(key) != null) { <END> Thread.sleep(100); if (++count > 10) { throw new ISE("Update did not occur!"); } } } else { while (!expected.equals(extractionFn.apply(key))) { Thread.sleep(100); if (++count > 10) { throw new ISE("Update did not occur!"); } } } Assert.assertEquals("update check", expected, extractionFn.apply(key)); }</code><technical_language>Instead of a timeout here, this timeout instead applying a timeout test? @Test(timeout = blah). more robust big timeout a lot of timeouts more sensitive noise</technical_language>

Target:
private void assertUpdated( String expected, String namespace, String key, ConcurrentMap<String, Function<String, String>> lookup ) throws InterruptedException { final Function<String, String> extractionFn = lookup.get(namespace); if (expected == null) { while (extractionFn.apply(key) != null) { Thread.sleep(100); } } else { while (!expected.equals(extractionFn.apply(key))) { Thread.sleep(100); } } Assert.assertEquals("update check", expected, extractionFn.apply(key)); }
Source:
<code>protected void isThreadSuspended(IExecutionDMContext ctx, final DataRequestMonitor<Boolean> rm) { try { getSession().getExecutor().execute(new DsfRunnable() { @Override public void run() { IRunControl runControl = getServicesTracker().getService(IRunControl.class); rm.setData(runControl.isSuspended(ctx) || runControl.isStepping(ctx)); rm.done(); }}); } catch (RejectedExecutionException e) { <START> rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, "Session shut down", null)); END> rm.done(); } }</code><technical_language>Add exception Status message</technical_language>

Target:
protected void isThreadSuspended(IExecutionDMContext ctx, final DataRequestMonitor<Boolean> rm) { try { getSession().getExecutor().execute(new DsfRunnable() { @Override public void run() { IRunControl runControl = getServicesTracker().getService(IRunControl.class); rm.setData(runControl.isSuspended(ctx) || runControl.isStepping(ctx)); rm.done(); }}); } catch (RejectedExecutionException e) { rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, "Session shut down", e)); rm.done(); } }
Source:
<code>public static void tearDown() { <START> System.setProperty("org.uberfire.nio.git.daemon.port", String.valueOf(gitDaemonPort)); <END> if (tmpRoot != null) { TestUtil.rm(tmpRoot.toFile()); } }</code><technical_language>This "restore" previous of system property in cases line 53 returns null. recommend System.clearProperty("org.uberfire.nio.git.daemon.port") in @AfterClass. If other tests want property, set explicitly</technical_language>

Target:
public static void tearDown() { System.clearProperty("org.uberfire.nio.git.daemon.port"); if (tmpRoot != null) { TestUtil.rm(tmpRoot.toFile()); } }
Source:
<code>private int setWifiTethering(final boolean enable) { int rval = TETHER_ERROR_MASTER_ERROR; final long ident = Binder.clearCallingIdentity(); try { synchronized (mPublicSync) { mWifiTetherRequested = enable; final WifiManager mgr = getWifiManager(); if (mgr == null) { mLog.e("setWifiTethering: failed to get WifiManager!"); rval = TETHER_ERROR_SERVICE_UNAVAIL; } else if ((enable && mgr.startSoftAp(null )) || (!enable && mgr.stopSoftAp())) { rval = TETHER_ERROR_NO_ERROR; } } } finally { Binder.restoreCallingIdentity(ident); } if (rval != TETHER_ERROR_NO_ERROR) { <START> mWifiTetherRequested = <END> false; } return rval; }</code><technical_language>Is safe access this synchronized block? this instead? more readable well. Mark, correct? try { synchronized (mPublicSync) { final WifiManager mgr = getWifiManager(); if (mgr == null) { mLog.e("setWifiTethering: failed get WifiManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } if ((enable && mgr.startSoftAp(null /* existing wifi config */)) || (!enable && mgr.stopSoftAp())) { mWifiTetherRequested = enable; return TETHER_ERROR_NO_ERROR; } return TETHER_ERROR_MASTER_ERRROR; } } finally { Binder.restoreCallingIdentity(ident); }</technical_language>

Target:
private int setWifiTethering(final boolean enable) { int rval = TETHER_ERROR_MASTER_ERROR; final long ident = Binder.clearCallingIdentity(); try { synchronized (mPublicSync) { final WifiManager mgr = getWifiManager(); if (mgr == null) { mLog.e("setWifiTethering: failed to get WifiManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } if ((enable && mgr.startSoftAp(null )) || (!enable && mgr.stopSoftAp())) { mWifiTetherRequested = enable; return TETHER_ERROR_NO_ERROR; } return TETHER_ERROR_MASTER_ERRROR; } } finally { Binder.restoreCallingIdentity(ident); } if (rval != TETHER_ERROR_NO_ERROR) { mWifiTetherRequested = false; } return rval; }
Source:
<code>protected void lineAdded(String string) { String current = myTextArea1.getText(); if (current == null) { current = ""; } myTextArea1.setText(current + string); <START> if (string.contains("Nothing was installed") || <END> string.contains("Failed") || string.contains("The package filter removed all packages")) { myBackgroundSuccess = false; } else if (string.contains("Done") && !string.contains("othing")) { myBackgroundSuccess = true; } }</code><technical_language>(More hardcoded text here... especially, string.contains('othing') stomach ulcers engage a hack get inconsistent case of word "Nothing", guessign?)</technical_language>

Target:
protected void lineAdded(String string) { String current = mySdkManagerOutput.getText(); if (current == null) { current = ""; } mySdkManagerOutput.setText(current + string); if (string.contains("Nothing was installed") || string.contains("Failed") || string.contains("The package filter removed all packages")) { myBackgroundSuccess = false; } else if (string.contains("Done") && !string.contains("othing")) { myBackgroundSuccess = true; } }
Source:
<code>Mono<DigitalTwinsResponse<String>> getComponentWithResponse(String digitalTwinId, String componentPath, Context context) { return protocolLayer.getDigitalTwins().getComponentWithResponseAsync(digitalTwinId, componentPath, context) .flatMap(response -> { try { String jsonResponse = mapper.writeValueAsString(response.getValue()); DigitalTwinsResponseHeaders twinHeaders = mapper.convertValue(response.getDeserializedHeaders(), DigitalTwinsResponseHeaders.class); return Mono.just(new DigitalTwinsResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), jsonResponse, twinHeaders)); } catch (JsonProcessingException e) { <START> return Mono.error(e); <END> } }); }</code><technical_language>add a log statement here, returning error</technical_language>

Target:
Mono<DigitalTwinsResponse<String>> getComponentWithResponse(String digitalTwinId, String componentPath, Context context) { return protocolLayer.getDigitalTwins().getComponentWithResponseAsync(digitalTwinId, componentPath, context) .flatMap(response -> { try { String jsonResponse = mapper.writeValueAsString(response.getValue()); DigitalTwinsResponseHeaders twinHeaders = mapper.convertValue(response.getDeserializedHeaders(), DigitalTwinsResponseHeaders.class); return Mono.just(new DigitalTwinsResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), jsonResponse, twinHeaders)); } catch (JsonProcessingException e) { logger.error("Failed to deserialize the returned component object into a string", e); return Mono.error(e); } }); }
Source:
<code>public void processStartTimestampUpdateOnMultipleBatches() { <START> eventCache.processStartTransactionsUpdate(TIMESTAMPS, SNAPSHOT); <END> verifyStage(); Set<Long> secondTimestamps = ImmutableSet.of(5L, 123L); eventCache.processStartTransactionsUpdate(secondTimestamps, SUCCESS); verifyStage(); }</code><technical_language>tests start in way, refactor this somehow</technical_language>

Target:
public void processStartTimestampUpdateOnMultipleBatches() { setupInitialState(); verifyStage(); Set<Long> secondTimestamps = ImmutableSet.of(5L, 123L); eventCache.processStartTransactionsUpdate(secondTimestamps, SUCCESS); verifyStage(); Set<Long> thirdTimestamps = ImmutableSet.of(6677L, 8888L); eventCache.processStartTransactionsUpdate(thirdTimestamps, SUCCESS_2); verifyStage(); }
Source:
<code>public void addAttribute(String key, Object value) { fProperties.put(key, value); if (key.equals(NAME)) { fName = (String) value; } if (key.equals(FREQ)) { fIsScaled = !Objects.equals(getProperty(FREQ), ONE_BILLION_L); fClockScale = ONE_BILLION_D / ((Long) getProperty(FREQ)).doubleValue(); fClockAntiScale = 1.0 / fClockScale; } if (key.equals(OFFSET)) { fClockOffset = (Long) getProperty(OFFSET); } if (key.equals(OFFSET_S)) { BigDecimal offsetNs = BigDecimal.valueOf(((Long) getProperty(OFFSET_S))).multiply(BigDecimal.valueOf(ONE_BILLION_L)); <START> fClockOffsetNanoSeconds = offsetNs.compareTo(BigDecimal.valueOf(Long.MAX_VALUE)) > 0 ? 0 : offsetNs.longValue(); <END> } }</code><technical_language>I job of this class invalidate a valid offset_s. If user wants handle timestamps in nanoseconds long, user check overflows</technical_language>

Target:
public void addAttribute(String key, Object value) { fProperties.put(key, value); if (key.equals(NAME)) { fName = (String) value; } if (key.equals(FREQ)) { fIsScaled = !Objects.equals(getProperty(FREQ), ONE_BILLION_L); fClockScale = ONE_BILLION_D / ((Long) getProperty(FREQ)).doubleValue(); fClockAntiScale = 1.0 / fClockScale; } if (key.equals(OFFSET)) { fClockOffset = (Long) getProperty(OFFSET); } if (key.equals(OFFSET_S)) { fClockOffsetS = (Long) getProperty(OFFSET_S); } }
Source:
<code>public FilterHandler(String unparsedFilters) { String[] rawFilters = unparsedFilters.split(","); filters = new Filter[rawFilters.length]; for (int i = 0; i < rawFilters.length; i++) { String currentFilter = rawFilters[i]; int period = currentFilter.lastIndexOf('.'); if (period < 0) { <START> filters[i] = new Filter(currentFilter); <END> continue; } filters[i] = new Filter(currentFilter.substring(0, period), currentFilter.substring(period + 1)); } Arrays.sort(filters); }</code><technical_language>explicitly pass parameters two-parameter ctor</technical_language>

Target:
public FilterHandler(String unparsedFilters) { String[] rawFilters = unparsedFilters.split(","); filters = new Filter[rawFilters.length]; for (int i = 0; i < rawFilters.length; i++) { String currentFilter = rawFilters[i]; int period = currentFilter.lastIndexOf('.'); if (period < 0) { filters[i] = new Filter("", currentFilter); continue; } filters[i] = new Filter(currentFilter.substring(0, period), currentFilter.substring(period + 1)); } Arrays.sort(filters); }
Source:
<code>public void testTrace() { CTFTrace trace = null; CTFTraceReader reader = null; try { trace = new CTFTrace(fTracePath); reader = new CTFTraceReader(trace); reader.getCurrentEventDef(); while (reader.advance()) { <START> reader.getCurrentEventDef(); <END> reader.advance(); } if (!fExpectSuccess) { fail("Trace was expected to fail parsing: " + fTracePath); } } catch (CTFReaderException e) { if (fExpectSuccess) { fail("Trace was expected to succeed, but failed parsing: " + fTracePath); } } finally { if (reader != null) { reader.dispose(); } if (trace != null) { trace.dispose(); } } }</code><technical_language>assertnotnull this please</technical_language>

Target:
public void testTrace() { CTFTrace trace = null; CTFTraceReader reader = null; try { trace = new CTFTrace(fTracePath); reader = new CTFTraceReader(trace); reader.getCurrentEventDef(); while (reader.advance()) { assertNotNull(reader.getCurrentEventDef()); } if (!fExpectSuccess) { fail("Trace was expected to fail parsing: " + fTracePath); } } catch (CTFReaderException e) { if (fExpectSuccess) { fail("Trace was expected to succeed, but failed parsing: " + fTracePath); } } finally { if (reader != null) { reader.dispose(); } if (trace != null) { trace.dispose(); } } }
Source:
<code>public void confirmTransactionShouldReturnTheRequest() throws Exception { final AtomicReference<Request> bodyRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); final RestAdapter adapter = new RestAdapter.Builder().setEndpoint(MOCK_URL).setClient(new Client() { @Override public Response execute(Request request) throws IOException { bodyRef.set(request); latch.countDown(); <START> return null; <END> } }).build(); final UserCardService userCardService = adapter.create(UserCardService.class); userCardService.confirmTransaction("foo", "bar", new RetrofitPromise<Transaction>()); latch.await(); Assert.assertEquals(bodyRef.get().getUrl(), String.format("%s/v0/me/cards/%s/transactions/%s/commit", MOCK_URL, "foo", "bar")); Assert.assertEquals(bodyRef.get().getMethod(), "POST"); }</code><technical_language>Add newline return</technical_language>

Target:
public void confirmTransactionShouldReturnTheRequest() throws Exception { final AtomicReference<Request> bodyRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); final RestAdapter adapter = new RestAdapter.Builder().setEndpoint(MOCK_URL).setClient(new Client() { @Override public Response execute(Request request) throws IOException { bodyRef.set(request); latch.countDown(); return null; } }).build(); final UserCardService userCardService = adapter.create(UserCardService.class); userCardService.confirmTransaction("foo", "bar", new RetrofitPromise<Transaction>()); latch.await(); Assert.assertEquals(bodyRef.get().getMethod(), "POST"); Assert.assertEquals(bodyRef.get().getUrl(), String.format("%s/v0/me/cards/%s/transactions/%s/commit", MOCK_URL, "foo", "bar")); }
Source:
<code>public void testTooManyContexts() throws InterruptedException { final int lwcCount = 101; double increment = (end - begin) / lwcCount; final ArrayList<Long> vals = new ArrayList<>(); final ArrayList<Thread> threads = new ArrayList<>(); final ArrayList<CtfTmfContext> tooManyContexts = new ArrayList<>(); for (double i = begin; i < end; i += increment) { SeekerThread thread = new SeekerThread() { @Override public void run() { CtfTmfContext lwc = new CtfTmfContext(trace); lwc.seek(val); trace.getNext(lwc); synchronized(trace){ if (lwc.getCurrentEvent() != null) { vals.add(lwc.getCurrentEvent().getTimestamp().getValue()); } tooManyContexts.add(lwc); } <START> lwc.dispose(); <END> } }; thread.setVal((long)i); threads.add(thread); thread.start(); } for (Thread t: threads){ t.join(); } for (long val : vals){ assertTrue(val >= begin); assertTrue(val <= end); } }</code><technical_language>This fix failing test cases</technical_language>

Target:
public void testTooManyContexts() throws InterruptedException { final int lwcCount = 101; double increment = (end - begin) / lwcCount; final ArrayList<Long> vals = new ArrayList<>(); final ArrayList<Thread> threads = new ArrayList<>(); final ArrayList<CtfTmfContext> tooManyContexts = new ArrayList<>(); for (double i = begin; i < end; i += increment) { SeekerThread thread = new SeekerThread() { @Override public void run() { CtfTmfContext lwc = new CtfTmfContext(trace); lwc.seek(val); trace.getNext(lwc); synchronized (trace) { if (lwc.getCurrentEvent() != null) { vals.add(lwc.getCurrentEvent().getTimestamp().getValue()); } tooManyContexts.add(lwc); } } }; thread.setVal((long) i); threads.add(thread); thread.start(); } for (Thread t : threads) { t.join(); } assertEquals("seeks done ", lwcCount + 1, vals.size()); for (long val : vals) { assertTrue("val >= begin, " + val + " " + begin, val >= begin); assertTrue("val >= end, " + val + " " + end, val <= end); } }
Source:
<code>public String getInstallDir() { if (installDir != null) return installDir; Maybe<Object> minstallDir = getEntity().getConfigRaw(SoftwareProcess.INSTALL_DIR, true); if (!minstallDir.isPresent() || minstallDir.get()==null) { String installBasedir = ((EntityInternal)entity).getManagementContext().getConfig().getFirst("brooklyn.dirs.install"); if (installBasedir != null) { log.warn("Using legacy 'brooklyn.dirs.install' setting for "+entity+"; may be removed in future versions."); <START> installDir = installBasedir+"/"+getEntityVersionLabel()+"_"+entity.getId(); <END> installDir = ResourceUtils.tidyFilePath(installDir); getEntity().setAttribute(SoftwareProcess.INSTALL_DIR, installDir); return installDir; } } installDir = ResourceUtils.tidyFilePath(ConfigToAttributes.apply(getEntity(), SoftwareProcess.INSTALL_DIR)); entity.setAttribute(SoftwareProcess.INSTALL_DIR, installDir); return installDir; }</code><technical_language>Os.mergePathsUnix, in case installBaseDir ends in slash already? is handle. for runBaseDir below</technical_language>

Target:
public String getInstallDir() { if (installDir != null) return installDir; Maybe<Object> minstallDir = getEntity().getConfigRaw(SoftwareProcess.INSTALL_DIR, true); if (!minstallDir.isPresent() || minstallDir.get()==null) { String installBasedir = ((EntityInternal)entity).getManagementContext().getConfig().getFirst("brooklyn.dirs.install"); if (installBasedir != null) { log.warn("Using legacy 'brooklyn.dirs.install' setting for "+entity+"; may be removed in future versions."); installDir = Os.mergePathsUnix(installBasedir, getEntityVersionLabel()+"_"+entity.getId()); installDir = ResourceUtils.tidyFilePath(installDir); getEntity().setAttribute(SoftwareProcess.INSTALL_DIR, installDir); return installDir; } } installDir = ResourceUtils.tidyFilePath(ConfigToAttributes.apply(getEntity(), SoftwareProcess.INSTALL_DIR)); entity.setAttribute(SoftwareProcess.INSTALL_DIR, installDir); return installDir; }
Source:
<code><START> public void validate(JobParameters parameters) throws JobParametersInvalidException { <END> ParametersValidatorUtil.checkIsNotNullOrEmptyString( parameters.getString(JobParametersNames.INPUT_VCF_AGGREGATION), JobParametersNames.INPUT_VCF_AGGREGATION); }</code><technical_language>This test matches of considered acceptable</technical_language>

Target:
public void validate(JobParameters parameters) throws JobParametersInvalidException { ParametersValidatorUtil.checkIsNotNullOrEmptyString( parameters.getString(JobParametersNames.INPUT_VCF_AGGREGATION), JobParametersNames.INPUT_VCF_AGGREGATION); try { VariantSource.Aggregation.valueOf(parameters.getString(JobParametersNames.INPUT_VCF_AGGREGATION)); } catch (IllegalArgumentException e) { throw new JobParametersInvalidException(e.getMessage()); } }
Source:
<code>public LayoutBuilder assignResponsiveSequencerAsPrimary(@NonNull Set<String> excludedNodes) { List<String> modifiedSequencers = new LinkedList<>(layout.getSequencers()); String primarySequencer = null; Set<String> logTails = layout.getLastSegment().getStripes().stream() .map(LayoutStripe::getTailEndpoint) .collect(Collectors.toSet()); for (String sequencer : modifiedSequencers) { if (excludedNodes.contains(sequencer) || layout.getUnresponsiveServers().contains(sequencer)) { continue; } <START> if (primarySequencer == null) { primarySequencer = sequencer; } if (!logTails.contains(sequencer)) { primarySequencer = sequencer; break; } } <END> if (primarySequencer == null) { log.warn("Failover to a responsive sequencer server failed. Each of the layout " + "sequencers:{} is either a failed endpoint or an unresponsive server", modifiedSequencers.toString()); throw new LayoutModificationException("All sequencers failed."); } modifiedSequencers.remove(primarySequencer); modifiedSequencers.add(0, primarySequencer); layout.setSequencers(modifiedSequencers); return this; }</code><technical_language>A save if-clauses be: primarySequencer = sequencer; if (!logTails.contains(sequencer)) { break; } difference is if is non-tail servers, code picks sequencer in loop iteration picks one. this matter</technical_language>

Target:
public LayoutBuilder assignResponsiveSequencerAsPrimary(@NonNull Set<String> excludedNodes) { LinkedList<String> modifiedSequencers = new LinkedList<>(layout.getSequencers()); Optional<String> primarySequencer = Optional.empty(); Set<String> logTails = layout.getLastSegment().getStripes().stream() .map(LayoutStripe::getTailEndpoint) .collect(Collectors.toSet()); for (String sequencer : modifiedSequencers) { if (excludedNodes.contains(sequencer) || layout.getUnresponsiveServers().contains(sequencer)) { continue; } primarySequencer = Optional.of(sequencer); if (!logTails.contains(sequencer)) { break; } } if (primarySequencer.isPresent()) { modifiedSequencers.remove(primarySequencer.get()); modifiedSequencers.addFirst(primarySequencer.get()); layout.setSequencers(modifiedSequencers); return this; } log.warn("Failover to a responsive sequencer server failed. Each of the layout " + "sequencers:{} is either a failed endpoint or an unresponsive server", modifiedSequencers.toString()); throw new LayoutModificationException("All sequencers failed."); }
Source:
<code>public void tearDown() { <START> realm.close(); <END> }</code><technical_language>if (realm != null) - safe</technical_language>

Target:
public void tearDown() { if (realm != null) { realm.close(); } }
Source:
<code>protected void addHideLabelByDefaultPropertyDescriptor(Object object) { itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_HideLabelCapabilityStyleDescription_hideLabelByDefault_feature"), getString("_UI_PropertyDescriptor_description", "_UI_HideLabelCapabilityStyleDescription_hideLabelByDefault_feature", "_UI_HideLabelCapabilityStyleDescription_type"), StylePackage.Literals.HIDE_LABEL_CAPABILITY_STYLE_DESCRIPTION__HIDE_LABEL_BY_DEFAULT, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, <START> null, null)); <END> }</code><technical_language>Category</technical_language>

Target:
protected void addHideLabelByDefaultPropertyDescriptor(Object object) { itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), getResourceLocator(), getString("_UI_HideLabelCapabilityStyleDescription_hideLabelByDefault_feature"), getString("_UI_HideLabelCapabilityStyleDescription_hideLabelByDefault_description"), StylePackage.Literals.HIDE_LABEL_CAPABILITY_STYLE_DESCRIPTION__HIDE_LABEL_BY_DEFAULT, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, getString("_UI_LabelPropertyCategory"), null)); }
Source:
<code>public synchronized boolean launchModeAvailable(String mode) { if (fActiveModes == null) { ILaunchConfigurationType[] types = getLaunchConfigurationTypes(); ILaunchMode[] modes = getLaunchModes(); fActiveModes = new HashSet<>(3); for (ILaunchConfigurationType type : types) { for (ILaunchMode <START> mode2 : <END> modes) { if (type.supportsMode(mode2.getIdentifier())) { fActiveModes.add(mode2.getIdentifier()); } } } } return fActiveModes.contains(mode); }</code><technical_language>rename launchMode</technical_language>

Target:
public synchronized boolean launchModeAvailable(String mode) { if (fActiveModes == null) { fActiveModes = new HashSet<>(3); for (ILaunchConfigurationType type : getLaunchConfigurationTypes()) { for (ILaunchMode launchMode : getLaunchModes()) { if (type.supportsMode(launchMode.getIdentifier())) { fActiveModes.add(launchMode.getIdentifier()); } } } } return fActiveModes.contains(mode); }
Source:
<code>public void testProcessSingleComponentNoProducers() { Trace trace = new Trace(); trace.setId("traceId"); trace.setBusinessTransaction("traceName"); trace.setStartTime(100); Component c = new Component(); c.setUri("uri"); c.setBaseTime(1); c.setDuration(200000000); c.getProperties().add(new Property(Constants.PROP_FAULT, "myFault")); trace.getNodes().add(c); TraceCompletionInformationInitiator initiator = new TraceCompletionInformationInitiator(); TraceCompletionInformation ci = null; try { ci = initiator.processOneToOne(null, trace); } catch (Exception e) { fail("Failed: " + e); } assertNotNull(ci); assertEquals(1, ci.getCommunications().size()); assertTrue(ci.getCommunications().get(0).getIds().contains("traceId:0")); assertEquals(trace.getId(), ci.getCompletionTime().getId()); assertEquals(trace.getBusinessTransaction(), ci.getCompletionTime().getBusinessTransaction()); assertEquals(trace.getStartTime(), ci.getCompletionTime().getTimestamp()); assertEquals(EndpointUtil.encodeClientURI(c.getUri()), ci.getCompletionTime().getUri()); <START> assertEquals(200000000, ci.getCompletionTime().getDuration()); <END> assertEquals(c.getProperties(Constants.PROP_FAULT), ci.getCompletionTime().getProperties(Constants.PROP_FAULT)); assertEquals(1, ci.getCompletionTime().getProperties(Constants.PROP_FAULT).size()); }</code><technical_language>Wondering this 6 more zeros</technical_language>

Target:
public void testProcessSingleComponentNoProducers() { Trace trace = new Trace(); trace.setId("traceId"); trace.setBusinessTransaction("traceName"); trace.setStartTime(100000); Component c = new Component(); c.setUri("uri"); c.setBaseTime(1); c.setDuration(200000); c.getProperties().add(new Property(Constants.PROP_FAULT, "myFault")); trace.getNodes().add(c); TraceCompletionInformationInitiator initiator = new TraceCompletionInformationInitiator(); TraceCompletionInformation ci = null; try { ci = initiator.processOneToOne(null, trace); } catch (Exception e) { fail("Failed: " + e); } assertNotNull(ci); assertEquals(1, ci.getCommunications().size()); assertTrue(ci.getCommunications().get(0).getIds().contains("traceId:0")); assertEquals(trace.getId(), ci.getCompletionTime().getId()); assertEquals(trace.getBusinessTransaction(), ci.getCompletionTime().getBusinessTransaction()); assertEquals(trace.getStartTime(), ci.getCompletionTime().getTimestamp()); assertEquals(EndpointUtil.encodeClientURI(c.getUri()), ci.getCompletionTime().getUri()); assertEquals(200000, ci.getCompletionTime().getDuration()); assertEquals(c.getProperties(Constants.PROP_FAULT), ci.getCompletionTime().getProperties(Constants.PROP_FAULT)); assertEquals(1, ci.getCompletionTime().getProperties(Constants.PROP_FAULT).size()); }
Source:
<code>public void testEnumeratorReaderCommunication() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); MockBaseSource source = new MockBaseSource(2, 10, Boundedness.BOUNDED); DataStream<Integer> stream = env.continuousSource(source, "TestingSource"); stream.addSink(new RichSinkFunction<Integer>() { @Override public void open(Configuration parameters) throws Exception { getRuntimeContext().addAccumulator("result", new ListAccumulator<Integer>()); } @Override public void invoke(Integer value, Context context) throws Exception { getRuntimeContext().getAccumulator("result").add(value); } }); List<Integer> result = env.execute().getAccumulatorResult("result"); <START> SortedSet<Integer> resultSet = new TreeSet<>(result); <END> assertEquals(0, (int) resultSet.first()); assertEquals(19, (int) resultSet.last()); assertEquals(20, resultSet.size()); }</code><technical_language>I nice compare entire list. accidental losses / duplicates cancelling other out. And, test fails, immediately happens, assertEquals statement prints full list (you if duplicated)</technical_language>

Target:
public void testEnumeratorReaderCommunication() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); MockBaseSource source = new MockBaseSource(2, 10, Boundedness.BOUNDED); DataStream<Integer> stream = env.continuousSource(source, "TestingSource"); executeAndVerify(env, stream, 20); }
Source:
<code>public AuthenticationHandler() { <START> log.info("Engaging API Security Handler"); <END> apiList = CoreUtils.readApiFilterList(); restInvoker = new RESTInvoker(); this.handlerDesc = EMPTY_HANDLER_METADATA; }</code><technical_language>seems, this info log printed constructed is called. Put this a debug log</technical_language>

Target:
public AuthenticationHandler() { log.info("Engaging API Security Handler"); apiList = CoreUtils.readApiFilterConfigs(); restInvoker = new RESTInvoker(); this.handlerDesc = EMPTY_HANDLER_METADATA; }
Source:
<code>private void updateActiveConfiguration() { final boolean[] fire = new boolean[] { false }; try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { synchronized (sync) { if (! live) { return; } ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescriptionManager().getProjectDescription(project); setActiveConfiguration(projectDescription != null ? projectDescription.getActiveConfiguration() : null); qmakeInfo = null; fire[0] = true; } } <START> }, null); <END> } catch (CoreException e) { QtPlugin.log(e); } if (fire[0]) { notifyListeners(); } }</code><technical_language>project is affected in this call, scheduling rule, i.e., change this to: .run( new IWorkspaceRunnable..., project, IWorkspace.AVOID_UPDATE, null);</technical_language>

Target:
private void updateActiveConfiguration() { final boolean[] fire = new boolean[] { false }; IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { synchronized (sync) { if (! live) { return; } ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescriptionManager().getProjectDescription(project); setActiveConfiguration(projectDescription != null ? projectDescription.getActiveConfiguration() : null); qmakeInfo = null; fire[0] = true; } } }; try { if (ResourcesPlugin.getWorkspace().isTreeLocked()) { runnable.run(null); } else { ResourcesPlugin.getWorkspace().run(runnable, project, IWorkspace.AVOID_UPDATE, null); } } catch (CoreException e) { QtPlugin.log(e); } if (fire[0]) { notifyListeners(); } }
Source:
<code>public void handle(final Chat chat) throws Exception { ChatMessageType position = ChatMessageType.values()[chat.getPosition()]; Supplier<BaseComponent[]> msgSupplier = new Supplier<BaseComponent[]>() { @Override public BaseComponent[] get() { return ComponentSerializer.parse( chat.getMessage() ); } }; ServerChatEvent chatEvent = new ServerChatEvent( con.getServer(), con, msgSupplier, position ); if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() ) { <START> chat.setMessage( ComponentSerializer.toString( chatEvent.getMessage() ) ); <END> chat.setPosition( (byte) chatEvent.getPosition().ordinal() ); con.unsafe().sendPacket( chat ); } throw CancelSendSignal.INSTANCE; }</code><technical_language>This is a problem, if call getMessage supplier sense. This get called everytime. Please suggestion for a idea. Modifying paket necessary in cases above</technical_language>

Target:
public void handle(final Chat chat) throws Exception { ChatMessageType position = ChatMessageType.values()[chat.getPosition()]; ServerChatEvent chatEvent = new ServerChatEvent( con.getServer(), con, chat.getMessage(), position ); if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() ) { chat.setMessage( chatEvent.getMessageJson() ); chat.setPosition( (byte) chatEvent.getPosition().ordinal() ); con.unsafe().sendPacket( chat ); } throw CancelSendSignal.INSTANCE; }
Source:
<code><START> public String getDisplayString(String[] children) { <END> StringBuilder sb = new StringBuilder(); sb.append("assert_true("); for (int i = 0; i < children.length; ++i) { sb.append(children[i]); if (i != children.length - 1) { sb.append(", "); } } sb.append(")"); return sb.toString(); }</code><technical_language>remove this function</technical_language>

Target:
public String getDisplayString(String[] children) { assert (children.length == 1); return "user_agent_parser(" + children[0] + ")"; }
Source:
<code><START> private static EntityManager ensureEntityManager(EntityManagerFactory entityManagerFactory) { <END> EntityManager entityManager = EntityManagerHolder.getInstance().getThreadLocal().get(); if (entityManager == null) { entityManager = entityManagerFactory.createEntityManager(); EntityManagerHolder.getInstance().getThreadLocal().set(entityManager); } entityManager.joinTransaction(); return entityManager; }</code><technical_language>this is exact context of AbstractJpaDao.em() - responsibility of interceptor set entity manager dao</technical_language>

Target:
private EntityManager ensureEntityManager(EntityManagerFactory entityManagerFactory) { EntityManager entityManager = EntityManagerHolder.getInstance().getThreadLocal().get(); if (entityManager == null) { entityManager = entityManagerFactory.createEntityManager(); EntityManagerHolder.getInstance().getThreadLocal().set(entityManager); } entityManager.joinTransaction(); return entityManager; }
Source:
<code><START> public void updateNode(Node n) throws IOException { <END> nodes.updateNode(n); }</code><technical_language>return a boolean esp. semantics of update operation if is existing node of name is provided node instance</technical_language>

Target:
public boolean updateNode(Node n) throws IOException { return nodes.updateNode(n); }
Source:
<code>public ResourceGroupStateInfo getStateInfo() { synchronized (root) { return new ResourceGroupStateInfo( id, getState(), <START> new DataSize(softMemoryLimitBytes, BYTE), <END> new DataSize(cachedMemoryUsageBytes, BYTE), maxRunningQueries, maxQueuedQueries, runningTimeLimit, queuedTimeLimit, getAggregatedRunningQueriesInfo(), queuedQueries.size() + descendantQueuedQueries); } }</code><technical_language>succinctBytes for</technical_language>

Target:
public ResourceGroupStateInfo getStateInfo() { synchronized (root) { return new ResourceGroupStateInfo( id, getState(), DataSize.succinctBytes(softMemoryLimitBytes), DataSize.succinctBytes(cachedMemoryUsageBytes), maxRunningQueries, maxQueuedQueries, runningTimeLimit, queuedTimeLimit, getAggregatedRunningQueriesInfo(), queuedQueries.size() + descendantQueuedQueries); } }
Source:
<code>public static Map<Integer, ? extends Collection<Tile>> readLaneTiles(final File illuminaRunDirectory, final ReadStructure readStructure, final ValidationStringency validationStringency, final boolean isNovaSeq) { final Collection<Tile> tiles; try { if (isNovaSeq) { tiles = TileMetricsUtil.parseTileMetrics( <START> TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory(illuminaRunDirectory, true), <END> TileMetricsUtil.renderPhasingMetricsFilesFromBasecallingDirectory(illuminaRunDirectory), readStructure, validationStringency); } else { tiles = TileMetricsUtil.parseTileMetrics(TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory(illuminaRunDirectory, false), readStructure, validationStringency ); } } catch (final FileNotFoundException e) { throw new PicardException("Unable to open laneMetrics file.", e); } return tiles.stream().filter(tile -> tile.getLaneNumber() > 0).collect(Collectors.groupingBy(Tile::getLaneNumber)); }</code><technical_language>this boolean argument is isNovaSeq</technical_language>

Target:
public static Map<Integer, ? extends Collection<Tile>> readLaneTiles(final File illuminaRunDirectory, final ReadStructure readStructure, final ValidationStringency validationStringency, final boolean isNovaSeq) { final Collection<Tile> tiles; try { File tileMetricsOutFile = TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory(illuminaRunDirectory, isNovaSeq); if (isNovaSeq) { tiles = TileMetricsUtil.parseTileMetrics( tileMetricsOutFile, TileMetricsUtil.renderPhasingMetricsFilesFromBasecallingDirectory(illuminaRunDirectory), readStructure, validationStringency); } else { tiles = TileMetricsUtil.parseTileMetrics(tileMetricsOutFile, readStructure, validationStringency ); } } catch (final FileNotFoundException e) { throw new PicardException("Unable to open laneMetrics file.", e); } return tiles.stream().filter(tile -> tile.getLaneNumber() > 0).collect(Collectors.groupingBy(Tile::getLaneNumber)); }
Source:
<code>public void onEventMainThread(ServiceEvent event) { Log.d(TAG, "onEvent(" + event + ")"); <START> switch(event.action) { <END> case SERVICE_STARTED: if (controller != null) { controller.init(); } break; } }</code><technical_language>Alt + Enter -> "replace switch if"</technical_language>

Target:
public void onEventMainThread(ServiceEvent event) { Log.d(TAG, "onEvent(" + event + ")"); if (event.action == ServiceEvent.Action.SERVICE_STARTED) { if (controller != null) { controller.init(); } } }
Source:
<code>public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { _collector = collector; Config conf = new Config(); conf.putAll(stormConf); checkConfiguration(conf); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); long start = System.currentTimeMillis(); LOG.info("[Fetcher #{}] : starting at {}", taskIndex, sdf.format(start)); this.eventCounter = context.registerMetric("fetcher_counter", new MultiCountMetric(), 10); this.metricGauge = context.registerMetric("fetcher", new MultiCountMetric(), 10); <START> this.averagedMetrics = context.registerMetric("fetcher_reduced", <END> new MultiReducedMetric(new MeanReducer()), 10); protocolFactory = new ProtocolFactory(conf); this.fetchQueues = new FetchItemQueues(conf); this.taskIndex = context.getThisTaskIndex(); int threadCount = ConfUtils.getInt(conf, "fetcher.threads.number", 10); for (int i = 0; i < threadCount; i++) { new FetcherThread(conf).start(); } String urlconfigfile = ConfUtils.getString(conf, "urlfilters.config.file", "urlfilters.json"); if (urlconfigfile != null) try { urlFilters = new URLFilters(conf, urlconfigfile); } catch (IOException e) { LOG.error("Exception caught while loading the URLFilters"); throw new RuntimeException( "Exception caught while loading the URLFilters", e); } allowRedirs = ConfUtils.getBoolean(stormConf, com.digitalpebble.storm.crawler.Constants.AllowRedirParamName, true); metadataTransfer = MetadataTransfer.getInstance(stormConf); }</code><technical_language>'fetcher_average' instead of 'fetcher_reduced'</technical_language>

Target:
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { _collector = collector; Config conf = new Config(); conf.putAll(stormConf); checkConfiguration(conf); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); long start = System.currentTimeMillis(); LOG.info("[Fetcher #{}] : starting at {}", taskIndex, sdf.format(start)); this.eventCounter = context.registerMetric("fetcher_counter", new MultiCountMetric(), 10); this.metricGauge = context.registerMetric("fetcher", new MultiCountMetric(), 10); this.averagedMetrics = context.registerMetric("fetcher_average", new MultiReducedMetric(new MeanReducer()), 10); protocolFactory = new ProtocolFactory(conf); this.fetchQueues = new FetchItemQueues(conf); this.taskIndex = context.getThisTaskIndex(); int threadCount = ConfUtils.getInt(conf, "fetcher.threads.number", 10); for (int i = 0; i < threadCount; i++) { new FetcherThread(conf).start(); } String urlconfigfile = ConfUtils.getString(conf, "urlfilters.config.file", "urlfilters.json"); if (urlconfigfile != null) try { urlFilters = new URLFilters(conf, urlconfigfile); } catch (IOException e) { LOG.error("Exception caught while loading the URLFilters"); throw new RuntimeException( "Exception caught while loading the URLFilters", e); } allowRedirs = ConfUtils.getBoolean(stormConf, com.digitalpebble.storm.crawler.Constants.AllowRedirParamName, true); metadataTransfer = MetadataTransfer.getInstance(stormConf); }
Source:
<code>private ComponentName getConnectedUi() { InCallServiceInfo connectedUi = mInCallServices.keySet().stream().filter( i -> i.getType() == IN_CALL_SERVICE_TYPE_DIALER_UI <START> || i.getType() == IN_CALL_SERVICE_TYPE_DIALER_UI) <END> .findAny() .orElse(null); if (connectedUi != null) { return connectedUi.mComponentName; } return null; }</code><technical_language>Is this a typo? "x==a || x==a"</technical_language>

Target:
private ComponentName getConnectedUi() { InCallServiceInfo connectedUi = mInCallServices.keySet().stream().filter( i -> i.getType() == IN_CALL_SERVICE_TYPE_DIALER_UI || i.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI) .findAny() .orElse(null); if (connectedUi != null) { return connectedUi.mComponentName; } return null; }
Source:
<code>public void parse(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException { if (args.hasNext()) { Object start = args.getState(); try { this.element.parse(source, args, context); } catch (ArgumentParseException ex) { if (!this.considerInvalidFormatEmpty && !args.hasNext()) { throw ex; } args.setState(start); } } <START> if (this.element.getKey() != null && this.value != null) { <END> context.putArg(this.element.getUntranslatedKey(), this.value); } }</code><technical_language>is return parsing, _always_ adding fallback context, of parsed successfully not</technical_language>

Target:
public void parse(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException { if (!args.hasNext()) { Text key = this.element.getKey(); if (key != null && this.value != null) { context.putArg(key.toPlain(), this.value); } return; } Object startState = args.getState(); try { this.element.parse(source, args, context); } catch (ArgumentParseException ex) { if (this.considerInvalidFormatEmpty || args.hasNext()) { args.setState(startState); if (this.element.getKey() != null && this.value != null) { context.putArg(this.element.getUntranslatedKey(), this.value); } } else { throw ex; } } }
Source:
<code>private void copyInputStreamToFile(InputStream in, File file) throws IOException { OutputStream out = new FileOutputStream(file); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); <START> } <END> out.close(); in.close(); }</code><technical_language>remove this code replace org.eclim.util.IOUtils.copy(in, out)</technical_language>

Target:
private void copyInputStreamToFile(InputStream in, File file) throws IOException { OutputStream out = new FileOutputStream(file); IOUtils.copy(in, out); }
Source:
<code>private void handleCommandAsNonCoordinator(final CommandContext ctx) { log.info("Received SYNC request from coordinator"); boolean update = false; if(ctx.getMessage().getProtocolParameters().containsKey("branch") || ctx.getMessage().getProtocolParameters().containsKey("sha")) { update = true; } if(update) { log.info("Taking site down to run sync update!"); maintFilter.start(); final CoordinatedWorkerListener oldListener = worker.getListener(); worker.setListener(new CoordinatedWorkerListener() { @Override public void workDone(Map<String, String> properties) { log.info("Sync done"); fileServlet.switchContent(ctx.getMessage().getRequestTime()); if(processor != null) { processor.makeLive(); } if(manager != null) { try { <START> manager.logEvent(properties.get("BranchName"), properties.get("CurrentRevision"), "SYNC".equals(properties.get("comment")) ? "AUTO" : properties.get("openId"), configProperties.getProperty("com.meltmedia.cadmium.lastUpdated"), properties.get("uuid"), properties.get("comment"), !new Boolean(properties.get("nonRevertible")), true); <END> } catch(Exception e){ log.warn("Failed to update log", e); } } maintFilter.stop(); worker.setListener(oldListener); } @Override public void workFailed(String branch, String sha, String openId, String uuid) { log.info("Sync failed"); worker.setListener(oldListener); } }); ctx.getMessage().getProtocolParameters().put("comment", "SYNC"); this.worker.beginPullUpdates(ctx.getMessage().getProtocolParameters()); } }</code><technical_language>This line is a long side</technical_language>

Target:
private void handleCommandAsNonCoordinator(final CommandContext ctx) { log.info("Received SYNC request from coordinator"); boolean update = false; if(ctx.getMessage().getProtocolParameters().containsKey("branch") || ctx.getMessage().getProtocolParameters().containsKey("sha")) { update = true; } if(update) { log.info("Taking site down to run sync update!"); maintFilter.start(); final CoordinatedWorkerListener oldListener = worker.getListener(); worker.setListener(new CoordinatedWorkerListener() { @Override public void workDone(Map<String, String> properties) { log.info("Sync done"); fileServlet.switchContent(ctx.getMessage().getRequestTime()); if(processor != null) { processor.makeLive(); } if(manager != null) { try { String branch = properties.get("BranchName"); String rev = properties.get("CurrentRevision"); String lastUpdated = configProperties.getProperty("com.meltmedia.cadmium.lastUpdated"); String uuid = properties.get("uuid"); String comment = properties.get("comment"); boolean revertible = !new Boolean(properties.get("nonRevertible")); manager.logEvent(branch, rev, "AUTO", lastUpdated, uuid, comment, revertible, true); } catch(Exception e){ log.warn("Failed to update log", e); } } maintFilter.stop(); worker.setListener(oldListener); } @Override public void workFailed(String branch, String sha, String openId, String uuid) { log.info("Sync failed"); worker.setListener(oldListener); } }); ctx.getMessage().getProtocolParameters().put("comment", "SYNC"); this.worker.beginPullUpdates(ctx.getMessage().getProtocolParameters()); } }
Source:
<code>void writeData(String messageToBeSent) { try { OutputStream outputStream = clientSocket.getOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); objectOutputStream.writeObject(messageToBeSent); outputStream.flush(); getLog().info("Artifact data and test cases data send to the synapse agent successfully"); <START> } catch (Exception e) { <END> getLog().error("Error while sending deployable data to the synapse agent ", e); } }</code><technical_language>catch exact exceptions instead of general exception</technical_language>

Target:
void writeData(String messageToBeSent) { try { outputStream = clientSocket.getOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); objectOutputStream.writeObject(messageToBeSent); outputStream.flush(); getLog().info("Artifact data and test cases data send to the synapse agent successfully"); } catch (IOException e) { getLog().error("Error while sending deployable data to the synapse agent ", e); } }
Source:
<code>public void testCoinbaseHeightTestnet() throws Exception { <START> byte[] blockAsBytes = CoinbaseBlockTest.getBytes(getClass().getResourceAsStream("block_testnet21066.dat")); <END> Block block = params.getDefaultSerializer().makeBlock(blockAsBytes); assertNotNull(block); block.verify(21066, EnumSet.of(Block.VerifyFlag.HEIGHT_IN_COINBASE)); }</code><technical_language>Guava here? Block block = params.getDefaultSerializer().makeBlock( ByteStreams.toByteArray(getClass().getResourceAsStream("block.dat")));</technical_language>

Target:
public void testCoinbaseHeightTestnet() throws Exception { Block block = TestNet3Params.get().getDefaultSerializer().makeBlock( ByteStreams.toByteArray(getClass().getResourceAsStream("block_testnet21066.dat"))); assertEquals("0000000004053156021d8e42459d284220a7f6e087bf78f30179c3703ca4eefa", block.getHashAsString()); block.verify(21066, EnumSet.of(Block.VerifyFlag.HEIGHT_IN_COINBASE)); block = TestNet3Params.get().getDefaultSerializer().makeBlock( ByteStreams.toByteArray(getClass().getResourceAsStream("block_testnet32768.dat"))); assertEquals("000000007590ba495b58338a5806c2b6f10af921a70dbd814e0da3c6957c0c03", block.getHashAsString()); block.verify(32768, EnumSet.of(Block.VerifyFlag.HEIGHT_IN_COINBASE)); }