auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testNoTimeformat() throws IOException { <START> String str = "time:TIME, before:20170101, after:20120101, defaultExit:true, timeFormat:null, timeZone:EST"; <END> BundleFilterTimeRange filter = Configs.decodeObject(BundleFilterTimeRange.class, str); }</code><technical_language>timeFormat:null is unnecessary</technical_language>

Target:
public void testNoTimeformat() throws IOException { String str = "time:TIME, before:20170101, after:20120101, defaultExit:true, timeZone:EST"; BundleFilterTimeRange filter = Configs.decodeObject(BundleFilterTimeRange.class, str); }
Source:
<code>public void onCreated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException { for (CacheEntryEvent<? extends K, ? extends V> event : events) { switch (event.getEventType()){ case CREATED: created.incrementAndGet(); break; case UPDATED: updated.incrementAndGet(); break; case REMOVED: removed.incrementAndGet(); break; case EXPIRED: expired.incrementAndGet(); <START> break; <END> } System.out.println("Received " + event); } }</code><technical_language>add a default? loose events</technical_language>

Target:
public void onCreated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException { for (CacheEntryEvent<? extends K, ? extends V> event : events) { switch (event.getEventType()){ case CREATED: created.incrementAndGet(); break; case UPDATED: updated.incrementAndGet(); break; case REMOVED: removed.incrementAndGet(); break; case EXPIRED: expired.incrementAndGet(); break; default: unExpected.incrementAndGet(); break; } } }
Source:
<code>private static Collection<ITestResult> sort(Set<ITestResult> results) { List<ITestResult> sortedResults = new ArrayList<>(results); sortedResults.sort(Comparator.comparingInt(o -> o.getMethod().getPriority())); <START> return sortedResults; <END> }</code><technical_language>Unmodifiable if</technical_language>

Target:
private static Collection<ITestResult> sort(Set<ITestResult> results) { List<ITestResult> sortedResults = new ArrayList<>(results); sortedResults.sort(Comparator.comparingInt(o -> o.getMethod().getPriority())); return Collections.unmodifiableList(sortedResults); }
Source:
<code>public ChannelPinger() { String interval = System.getProperty(SYS_PROPERTY_NAME_INTERVAL_SECONDS); if (interval != null) { try { pingIntervalSeconds = Integer.parseInt(interval); } catch (NumberFormatException e) { LOGGER.warning("Ignoring invalid " + SYS_PROPERTY_NAME_INTERVAL_SECONDS + "=" + interval); } } if (interval == null) { interval = System.getProperty(SYS_PROPERTY_NAME_INTERVAL_MINUTES_DEPRECATED); if (interval != null) { LOGGER.warning(SYS_PROPERTY_NAME_INTERVAL_MINUTES_DEPRECATED + " property is deprecated, " + SYS_PROPERTY_NAME_INTERVAL_SECONDS + " should be used"); try { pingIntervalSeconds = Integer.parseInt(interval) * 60; } catch (NumberFormatException e) { LOGGER.warning("Ignoring invalid " + SYS_PROPERTY_NAME_INTERVAL_MINUTES_DEPRECATED + "=" + interval); } } } String timeout = System.getProperty(SYS_PROPERTY_NAME_TIMEOUT_SECONDS); if (timeout != null) { try { pingTimeoutSeconds = Integer.parseInt(timeout); } catch (NumberFormatException e) { LOGGER.warning("Ignoring invalid " + SYS_PROPERTY_NAME_TIMEOUT_SECONDS + "=" + timeout); } <START> } <END> }</code><technical_language>I this code SystemProperties#getInteger() it? if want log warnings, want create a overloaded method desired Level</technical_language>

Target:
public ChannelPinger() { Integer interval = SystemProperties.getInteger(INTERVAL_SECONDS_PROPERTY, null, Level.WARNING); if (interval == null) { interval = SystemProperties.getInteger(INTERVAL_MINUTES_PROPERTY_DEPRECATED,null, Level.WARNING); if (interval != null) { LOGGER.warning(INTERVAL_MINUTES_PROPERTY_DEPRECATED + " property is deprecated, " + INTERVAL_SECONDS_PROPERTY + " should be used"); interval *= 60; } } if (interval != null) { pingIntervalSeconds = interval; } }
Source:
<code>public double getDouble(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number) object).doubleValue() <START> : new BigDecimal((String) object).doubleValue(); <END> } catch (Exception e) { throw new JSONException("JSONObject[" + quote(key) + "] is not a number.", e); } }</code><technical_language>Introducing a BigDecimal parse a double add overhead for reason, if try represent a double a String stay is, if a double gained lost, adding more GC overhead. for other BigDecimal introduction working float double</technical_language>

Target:
public double getDouble(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble(object.toString()); } catch (Exception e) { throw new JSONException("JSONObject[" + quote(key) + "] is not a number.", e); } }
Source:
<code><START> private static double round(final double value, final int digits) { <END> final double x = Math.pow(10, digits); return ((int)(value * x)) / x; }</code><technical_language>this in some MathUtils class</technical_language>

Target:
private static double round(final double value, final int digits) { final double x = Math.pow(10, digits); return Math.round(value * x) / x; }
Source:
<code><START> public @Nullable MobSpawnerBaseLogic getSpawner() { return spawner; } <END></code><technical_language>@Nullable line before, in patches size is minimized</technical_language>

Target:
public MobSpawnerBaseLogic getSpawner() { return spawner; }
Source:
<code>public void testConvertToMimeType(String mimeType) throws IOException { String converterName = cs.getConverterName(mimeType, "text/html"); assertEquals("zip2html", converterName); checkConverterAvailability(converterName); BlobHolder htmlBH = getBlobFromPath("test-docs/hello.zip"); htmlBH.getBlob().setMimeType(mimeType); Map<String, Serializable> parameters = new HashMap<>(); BlobHolder result = cs.convert(converterName, htmlBH, parameters); assertNotNull(result); List<Blob> blobs = result.getBlobs(); assertNotNull(blobs); assertEquals(3, blobs.size()); String content = blobs.get(0).getString(); <START> assertTrue(content.contains("Hello") || content.contains("hello")); <END> }</code><technical_language>do a more precise check? Comparing string expect? check a specific blob well, (not a deterministic order)</technical_language>

Target:
public void testConvertToMimeType(String mimeType) throws IOException { String converterName = cs.getConverterName(mimeType, "text/html"); assertEquals("zip2html", converterName); checkConverterAvailability(converterName); BlobHolder htmlBH = getBlobFromPath("test-docs/hello.zip"); htmlBH.getBlob().setMimeType(mimeType); Map<String, Serializable> parameters = Collections.emptyMap(); BlobHolder result = cs.convert(converterName, htmlBH, parameters); assertNotNull(result); List<Blob> blobs = result.getBlobs(); assertNotNull(blobs); assertEquals(3, blobs.size()); String content = blobs.get(0).getString(); String zipList = "<html>" + "<body>" + "<h1>hello.zip</h1>" + "<ul>" + "<li><a href=\"hello.xml\">hello.xml</a></li>" + "<li><a href=\"hello.txt\">hello.txt</a></li>" + "</ul>" + "</body>" + "</html>"; String zipListAlternative = "<html>" + "<body>" + "<h1>hello.zip</h1>" + "<ul>" + "<li><a href=\"hello.xml\">hello.xml</a></li>" + "<li><a href=\"hello.txt\">hello.txt</a></li>" + "</ul>" + "</body>" + "</html>"; assertTrue(zipList.equals(content) || zipListAlternative.equals(content)); content = DocumentUTUtils.readContent(blobs.get(1).getFile()); assertTrue(content.contains("Hello from a xml <b>document</b>")); content = DocumentUTUtils.readContent(blobs.get(2).getFile()); assertTrue(content.contains("Hello from a text document")); }
Source:
<code>public void failedCacheActionAsCacheMiss() throws Exception { ActionResult actionResult = ActionResult.newBuilder().setExitCode(1).build(); when(remoteCache.getCachedActionResult(any(ActionKey.class))) .thenAnswer( (Answer<ActionResult>) invocation -> { RequestMetadata meta = TracingMetadataUtils.fromCurrentContext(); assertThat(meta.getCorrelatedInvocationsId()).isEqualTo("build-req-id"); <START> assertThat(meta.getToolInvocationId()).isEqualTo("command-id"); <END> return actionResult; }); CacheHandle entry = cache.lookup(simpleSpawn, simplePolicy); assertThat(entry.hasResult()).isFalse(); verify(remoteCache, never()) .download( any(ActionResult.class), any(Path.class), eq(outErr) ); assertThat(progressUpdates) .containsExactly(Pair.of(ProgressStatus.CHECKING_CACHE, "remote-cache")); }</code><technical_language>do need test for metadata</technical_language>

Target:
public void failedCacheActionAsCacheMiss() throws Exception { ActionResult actionResult = ActionResult.newBuilder().setExitCode(1).build(); when(remoteCache.getCachedActionResult(any(ActionKey.class))).thenReturn(actionResult); CacheHandle entry = cache.lookup(simpleSpawn, simplePolicy); assertThat(entry.hasResult()).isFalse(); }
Source:
<code>private static boolean hasLangAttribute(TagNode node) { <START> return node.getAttribute("lang") != null || node.getAttribute("xml:lang") != null; <END> }</code><technical_language>For clarity, hasProperty(...) instead</technical_language>

Target:
private static boolean hasLangAttribute(TagNode node) { return node.hasProperty("lang") || node.hasProperty("xml:lang"); }
Source:
<code><START> void ensureCameraEntityCreated() { <END> if (!localPlayer.getCameraEntity().exists()) { ClientComponent clientComponent = localPlayer.getClientEntity().getComponent(ClientComponent.class); EntityBuilder builder = entityManager.newBuilder("engine:camera"); builder.setPersistent(false); clientComponent.camera = builder.build(); localPlayer.getClientEntity().saveComponent(clientComponent); mountCamera(); } }</code><technical_language>Is this method intentionally package-private</technical_language>

Target:
private void ensureCameraEntityCreated() { if (!localPlayer.getCameraEntity().exists()) { ClientComponent clientComponent = localPlayer.getClientEntity().getComponent(ClientComponent.class); EntityBuilder builder = entityManager.newBuilder("engine:camera"); builder.setPersistent(false); clientComponent.camera = builder.build(); localPlayer.getClientEntity().saveComponent(clientComponent); } }
Source:
<code><START> public void setPostId() { } <END></code><technical_language>parameter in setter method</technical_language>

Target:
private void setPostId() { }
Source:
<code>public int hashCode() { <START> return Objects.hash(threadRecord); <END> }</code><technical_language>arg, do: return threadRecord.hashCode();</technical_language>

Target:
public int hashCode() { return threadRecord.hashCode(); }
Source:
<code>static public FqInfo parse(String fqName) { ArrayList<String> packageParts = new ArrayList<String>(); ArrayList<String> classParts = new ArrayList<String>(); String[] parts = StringUtils.split(fqName, '.'); boolean inClassPart = false; for (String part : parts) { if (HaxeNameUtils.isValidClassName(part)) { classParts.add(part); inClassPart = true; } else if (HaxeNameUtils.isValidPackageName(part)) { if (inClassPart) { return null; } packageParts.add(part); } else { return null; } } <START> if (classParts.size() > 2) { <END> return null; } String className = ""; String fileName = ""; if (classParts.size() >= 1) { className = classParts.get(classParts.size() - 1); fileName = classParts.get(classParts.size() - ((classParts.size() >= 2) ? 2 : 1)); } return new FqInfo(Joiner.on('.').join(packageParts), fileName, className); }</code><technical_language>error if classParts.size() == 0</technical_language>

Target:
static public FqInfo parse(String fqName) { ArrayList<String> packageParts = new ArrayList<String>(); ArrayList<String> classParts = new ArrayList<String>(); String[] parts = StringUtils.split(fqName, '.'); boolean inClassPart = false; for (String part : parts) { if (HaxeNameUtils.isValidClassName(part)) { classParts.add(part); inClassPart = true; } else if (HaxeNameUtils.isValidPackageName(part)) { if (inClassPart) { return null; } packageParts.add(part); } else { return null; } } if (classParts.isEmpty() || classParts.size() > 2) { return null; } String className = ""; String fileName = ""; if (classParts.size() >= 1) { className = classParts.get(classParts.size() - 1); fileName = classParts.get(classParts.size() - ((classParts.size() >= 2) ? 2 : 1)); } return new FqInfo(Joiner.on('.').join(packageParts), fileName, className); }
Source:
<code><START> public List<ITmfEventField> getValue() { <END> return new ArrayList<ITmfEventField>(Arrays.asList((ITmfEventField[])super.getValue())); }</code><technical_language>too, return type <CtfTmfEventField> (cast safe if CtfTmfEventField's constructor). Also, reason return array directly? (ie, CtfTmfEventField[] for return type)</technical_language>

Target:
public List<CtfTmfEventField> getValue() { return new ArrayList<CtfTmfEventField>(Arrays.asList((CtfTmfEventField[])super.getValue())); }
Source:
<code>IndexValue(long size, Offset offset, long expiresAtMs) { <START> this(size, offset, (byte) 0, expiresAtMs, offset.getOffset(), (int) Utils.Infinite_Time, (short) 0, (short) 0); <END> }</code><technical_language>call constructor 4 args</technical_language>

Target:
IndexValue(long size, Offset offset, long expiresAtMs) { this(size, offset, FLAGS_DEFAULT_VALUE, expiresAtMs, offset.getOffset(), (int) Utils.Infinite_Time, SERVICE_CONTAINER_ID_DEFAULT_VALUE, SERVICE_CONTAINER_ID_DEFAULT_VALUE); }
Source:
<code><START> static private void validateFilters(final VariantContext variantContext) { <END> final Set<String> filters = variantContext.getFilters(); if (filters == null) { return; } for (String filter : filters) { if (!VALID_FILTER.matcher(filter).matches()) { throw new IllegalStateException("Filter '" + filter + "' contains an illegal character. It must conform to the regex ;'" + VALID_FILTER); } } }</code><technical_language>suggestion private static void validateFilters(final VariantContext variantContext) {</technical_language>

Target:
private static void validateFilters(final VariantContext variantContext) { final Set<String> filters = variantContext.getFilters(); if (filters == null) { return; } for (String filter : filters) { if (!VALID_FILTER.matcher(filter).matches()) { throw new IllegalStateException("Filter '" + filter + "' contains an illegal character. It must conform to the regex ;'" + VALID_FILTER); } } }
Source:
<code>public String[] registerOAuthConsumer() throws IdentityOAuthAdminException { String loggedInUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); if (log.isDebugEnabled()) { log.debug("Adding a consumer secret for the logged in user " + loggedInUser); } String tenantUser = MultitenantUtils.getTenantAwareUsername(loggedInUser); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); <START> String userDomain = UserCoreUtil.extractDomainFromName(loggedInUser); <END> OAuthAppDAO dao = new OAuthAppDAO(); return dao.addOAuthConsumer(UserCoreUtil.removeDomainFromName(tenantUser), tenantId, userDomain); }</code><technical_language>User IdentityUtil.extractDomainFromName this method return domain if primary user store is explicit domain name</technical_language>

Target:
public String[] registerOAuthConsumer() throws IdentityOAuthAdminException { String loggedInUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); if (log.isDebugEnabled()) { log.debug("Adding a consumer secret for the logged in user " + loggedInUser); } String tenantUser = MultitenantUtils.getTenantAwareUsername(loggedInUser); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); String userDomain = IdentityUtil.extractDomainFromName(loggedInUser); OAuthAppDAO dao = new OAuthAppDAO(); return dao.addOAuthConsumer(UserCoreUtil.removeDomainFromName(tenantUser), tenantId, userDomain); }
Source:
<code>private DDiagramElement findByTargetName(final List<DDiagramElement> list, final String targetName) { DDiagramElement found = list.stream().filter(input->input.getTarget() instanceof ENamedElement && targetName.equals(((ENamedElement) <START> input.getTarget()).getName())).findFirst().get(); <END> assertNotNull("'" + targetName + "' element not found", found); return found; }</code><technical_language>remark in previous file</technical_language>

Target:
private DDiagramElement findByTargetName(final List<DDiagramElement> list, final String targetName) { DDiagramElement found = list.stream().filter(input->input.getTarget() instanceof ENamedElement && targetName.equals(((ENamedElement) input.getTarget()).getName())).findFirst().orElse(null); assertNotNull("'" + targetName + "' element not found", found); return found; }
Source:
<code>private void doInitialize(RequestMonitor requestMonitor) { fCommandControl = getServicesTracker().getService(ICommandControlService.class); fProcesses = getServicesTracker().getService(IGDBProcesses.class); <START> stackService = getServicesTracker().getService(IStack.class); <END> fGdbcontrol = getServicesTracker().getService(IGDBControl.class); fCommandFactory = fGdbcontrol.getCommandFactory(); register(new String[] { IGDBSynchronizer.class.getName()}, new Hashtable<String, String>()); fCommandControl.addEventListener(this); getSession().addServiceEventListener(this, null); fCurrentThreadCtx = createExecContextFromThreadId(THREAD_ID_DEFAULT); fCurrentStackFrameCtx = createFrameContext(fCurrentThreadCtx, STACKFRAME_ID_DEFAULT); requestMonitor.done(); }</code><technical_language>This is get MIStack</technical_language>

Target:
private void doInitialize(RequestMonitor requestMonitor) { fCommandControl = getServicesTracker().getService(ICommandControlService.class); fProcesses = getServicesTracker().getService(IGDBProcesses.class); fStackService = getServicesTracker().getService(MIStack.class); fGdbcontrol = getServicesTracker().getService(IGDBControl.class); fCommandFactory = fGdbcontrol.getCommandFactory(); register(new String[] { IGDBSynchronizer.class.getName()}, new Hashtable<String, String>()); fCommandControl.addEventListener(this); getSession().addServiceEventListener(this, null); fCurrentThreadCtx = createExecContextFromThreadId(THREAD_ID_DEFAULT); fCurrentStackFrameCtx = createFrameContext(fCurrentThreadCtx, STACKFRAME_ID_DEFAULT); requestMonitor.done(); }
Source:
<code>private ThreadPoolBulkheadRegistry createBulkheadRegistry( ThreadPoolBulkheadConfigurationProperties threadPoolBulkheadConfigurationProperties, RegistryEventConsumer<ThreadPoolBulkhead> threadPoolBulkheadRegistryEventConsumer, CompositeCustomizer<ThreadPoolBulkheadConfigCustomizer> compositeThreadPoolBulkheadCustomizer) { Map<String, ThreadPoolBulkheadConfig> configs = threadPoolBulkheadConfigurationProperties .getConfigs() .entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> threadPoolBulkheadConfigurationProperties .createThreadPoolBulkheadConfig(entry.getValue(), compositeThreadPoolBulkheadCustomizer, entry.getKey()))); <START> return ThreadPoolBulkheadRegistry.of(configs, threadPoolBulkheadRegistryEventConsumer, threadPoolBulkheadConfigurationProperties.getTags()); <END> }</code><technical_language>I create a defensive copy of Map</technical_language>

Target:
private ThreadPoolBulkheadRegistry createBulkheadRegistry( ThreadPoolBulkheadConfigurationProperties threadPoolBulkheadConfigurationProperties, RegistryEventConsumer<ThreadPoolBulkhead> threadPoolBulkheadRegistryEventConsumer, CompositeCustomizer<ThreadPoolBulkheadConfigCustomizer> compositeThreadPoolBulkheadCustomizer) { Map<String, ThreadPoolBulkheadConfig> configs = threadPoolBulkheadConfigurationProperties .getConfigs() .entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> threadPoolBulkheadConfigurationProperties .createThreadPoolBulkheadConfig(entry.getValue(), compositeThreadPoolBulkheadCustomizer, entry.getKey()))); return ThreadPoolBulkheadRegistry.of(configs, threadPoolBulkheadRegistryEventConsumer, Map.copyOf(threadPoolBulkheadConfigurationProperties.getTags())); }
Source:
<code>public String toString() { <START> return "DroolsConstraint(" + constraintPackage + " " + constraintName + ") in " + fromStreamList.size() + <END> " from() stream(s)"; }</code><technical_language>Constraint.getConstraintId(...)</technical_language>

Target:
public String toString() { return "DroolsConstraint(" + getConstraintId() + ") in " + fromStreamList.size() + " from() stream(s)"; }
Source:
<code>public Subject getSubject() { <START> return subject; <END> }</code><technical_language>this</technical_language>

Target:
public Subject getSubject() { return this.subject; }
Source:
<code>public void onLoad(Screen screen) { String projectName = URL.decode(screen.getToken(1)); String <START> fileName = <END> URL.decode(screen.getToken(2)); screen.show(new XDocScreen(projectName, "HEAD", fileName)); screen.setWindowTitle(getFileName(fileName)); }</code><technical_language>Rename this path consistent parameter name getFileName</technical_language>

Target:
public void onLoad(Screen screen) { String projectName = URL.decode(screen.getToken(1)); String path = URL.decode(screen.getToken(2)); screen.show(new XDocScreen(projectName, "HEAD", path)); screen.setWindowTitle(getFileName(path)); }
Source:
<code>private Collection<LoadBalancer> getAllLoadBalancers(Collection<BaragonGroup> baragonGroups) { Set<String> trafficSources = new HashSet<>(); for (BaragonGroup baragonGroup : baragonGroups) { for (TrafficSource trafficSource : baragonGroup.getSources()) { if (trafficSource.getType() == TrafficSourceType.APPLICATION) { trafficSources.add(trafficSource.getName()); } } } Collection<LoadBalancer> loadBalancers = new HashSet<>(); DescribeLoadBalancersRequest loadBalancersRequest = new DescribeLoadBalancersRequest() .withNames(trafficSources); DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(loadBalancersRequest); String nextPage = result.getNextMarker(); loadBalancers.addAll(result.getLoadBalancers()); <START> while (! nextPage.isEmpty()) { <END> loadBalancersRequest = new DescribeLoadBalancersRequest() .withMarker(nextPage); result = elbClient.describeLoadBalancers(loadBalancersRequest); nextPage = result.getNextMarker(); loadBalancers.addAll(result.getLoadBalancers()); } return loadBalancers; }</code><technical_language>checking, aws API return a null for this, is empty string more pages? If a null, opt for !Strings.isNullOrEmpty()</technical_language>

Target:
private Collection<LoadBalancer> getAllLoadBalancers(Collection<BaragonGroup> baragonGroups) { Set<String> trafficSources = new HashSet<>(); for (BaragonGroup baragonGroup : baragonGroups) { for (TrafficSource trafficSource : baragonGroup.getSources()) { if (trafficSource.getType() == TrafficSourceType.APPLICATION) { trafficSources.add(trafficSource.getName()); } } } Collection<LoadBalancer> loadBalancers = new HashSet<>(); DescribeLoadBalancersRequest loadBalancersRequest = new DescribeLoadBalancersRequest() .withNames(trafficSources); DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(loadBalancersRequest); String nextPage = result.getNextMarker(); loadBalancers.addAll(result.getLoadBalancers()); while (!Strings.isNullOrEmpty(nextPage)) { loadBalancersRequest = new DescribeLoadBalancersRequest() .withMarker(nextPage); result = elbClient.describeLoadBalancers(loadBalancersRequest); nextPage = result.getNextMarker(); loadBalancers.addAll(result.getLoadBalancers()); } return loadBalancers; }
Source:
<code><START> protected Statement withInterruptIsolation(final Statement statement) { <END> return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); } finally { Thread.interrupted(); } } }; }</code><technical_language>I personally prefer this is final</technical_language>

Target:
protected final Statement withInterruptIsolation(final Statement statement) { return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); } finally { Thread.interrupted(); } } }; }
Source:
<code>private boolean shouldReconnect(int code) { <START> return !(code >= 4000 && code <= 4099); <END> }</code><technical_language>personally find this easier read negative, i.e. code < 4000 || code >= 4100, a big deal</technical_language>

Target:
private boolean shouldReconnect(int code) { return code < 4000 || code >= 4100; }
Source:
<code>public void testCleanupSequence() throws SQLException { Connection connection = dbsvc.getConnection(); connection.prepareStatement("TRUNCATE TABLE " + tableName).execute(); String emitterPid = "emitter"; List<WireRecord> wireRecords = new ArrayList<WireRecord>(); Map<String, TypedValue<?>> recordProps = new HashMap<String, TypedValue<?>>(); TypedValue<?> val = new StringValue("val"); recordProps.put("key", val); WireRecord record = new WireRecord(recordProps); wireRecords.add(record); WireEnvelope wireEvelope = new WireEnvelope(emitterPid, wireRecords); for (int i = 0; i < maxSize; i++) { dbstore.onWireReceive(wireEvelope); try { <START> Thread.sleep(1); <END> } catch (InterruptedException e) { } } try { Thread.sleep(500); } catch (InterruptedException e) { } ResultSet resultSet = connection.prepareStatement("SELECT count(*) FROM " + tableName).executeQuery(); resultSet.next(); int count = resultSet.getInt(1); assertEquals("Unexpected number of records", maxSize, count); for (int i = 0; i < 5; i++) { dbstore.onWireReceive(wireEvelope); try { Thread.sleep(1); } catch (InterruptedException e) { } } try { Thread.sleep(500); } catch (InterruptedException e) { } resultSet = connection.prepareStatement("SELECT count(*) FROM " + tableName).executeQuery(); resultSet.next(); count = resultSet.getInt(1); assertEquals("Unexpected number of records", cleanupSize + 5, count); }</code><technical_language>This sleep needed anymore</technical_language>

Target:
public void testCleanupSequence() throws SQLException { Connection connection = dbsvc.getConnection(); connection.prepareStatement("TRUNCATE TABLE " + tableName).execute(); String emitterPid = "emitter"; List<WireRecord> wireRecords = new ArrayList<WireRecord>(); Map<String, TypedValue<?>> recordProps = new HashMap<String, TypedValue<?>>(); TypedValue<?> val = new StringValue("val"); recordProps.put("key", val); WireRecord record = new WireRecord(recordProps); wireRecords.add(record); WireEnvelope wireEvelope = new WireEnvelope(emitterPid, wireRecords); for (int i = 0; i < maxSize; i++) { dbstore.onWireReceive(wireEvelope); } try { Thread.sleep(500); } catch (InterruptedException e) { } ResultSet resultSet = connection.prepareStatement("SELECT count(*) FROM " + tableName).executeQuery(); resultSet.next(); int count = resultSet.getInt(1); assertEquals("Unexpected number of records", maxSize, count); for (int i = 0; i < 5; i++) { dbstore.onWireReceive(wireEvelope); } try { Thread.sleep(500); } catch (InterruptedException e) { } resultSet = connection.prepareStatement("SELECT count(*) FROM " + tableName).executeQuery(); resultSet.next(); count = resultSet.getInt(1); assertEquals("Unexpected number of records", cleanupSize + 5, count); }
Source:
<code>protected CatalogStorage(String uriTemplate, Configuration conf) throws URISyntaxException { this(uriTemplate); setConf(conf); <START> verifyAndUpdateConfiguration(conf); <END> }</code><technical_language>need here. verifyAndUpdateConfiguration is called in CatalogStorage(String uriTemplate)</technical_language>

Target:
protected CatalogStorage(String uriTemplate, Configuration conf) throws URISyntaxException { if (uriTemplate == null || uriTemplate.length() == 0) { throw new IllegalArgumentException("URI template cannot be null or empty"); } final String processed = uriTemplate.replaceAll(DOLLAR_EXPR_START_REGEX, DOLLAR_EXPR_START_NORMALIZED) .replaceAll("}", EXPR_CLOSE_NORMALIZED); URI uri = new URI(processed); this.catalogUrl = uri.getScheme() + "://" + uri.getAuthority(); verifyAndUpdateConfiguration(conf); parseUriTemplate(uri); }
Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { RevCommit commit = (RevCommit) getSelection(getPage()).getFirstElement(); RevCommit newHead; Repository repo = getRepository(event); <START> RevertCommand cherryPick; <END> Git git = new Git(repo); try { cherryPick = git.revert().include(commit.getId()); newHead = cherryPick.call(); } catch (Exception e) { throw new ExecutionException(CoreText.RevertOperation_InternalError, e); } if (newHead == null) throw new ExecutionException(CoreText.RevertOperation_Failed); return null; }</code><technical_language>this is a misleading variable name, "revert"</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { RevCommit commit = (RevCommit) getSelection(getPage()).getFirstElement(); RevCommit newHead; Repository repo = getRepository(event); RevertCommand revert; Git git = new Git(repo); try { revert = git.revert().include(commit.getId()); newHead = revert.call(); } catch (Exception e) { throw new ExecutionException(CoreText.RevertOperation_InternalError, e); } if (newHead == null) throw new ExecutionException(CoreText.RevertOperation_Failed); return null; }
Source:
<code>protected static ImmutableList<SpecializedCommand> toSpecializedCommands(final ImmutableList<Ds3Request> ds3Requests) { if (isEmpty(ds3Requests)) { return ImmutableList.of(); } <START> final ImmutableList.Builder<SpecializedCommand> builder = ImmutableList.builder(); <END> for (final Ds3Request ds3Request : ds3Requests) { if (isGetObjectAmazonS3Request(ds3Request)) { builder.add(toGetObjectCommand(ds3Request)); } } return builder.build(); }</code><technical_language>This simplified to: java return ds3Requests.stream() .filter(this::isGetObjectAmazonS3Request) .map(this::toGetObjectCommand) .collect(GuavaCollectors.immutableList());</technical_language>

Target:
protected static ImmutableList<SpecializedCommand> toSpecializedCommands(final ImmutableList<Ds3Request> ds3Requests) { if (isEmpty(ds3Requests)) { return ImmutableList.of(); } return ds3Requests.stream() .filter(Ds3RequestClassificationUtil::isGetObjectAmazonS3Request) .map(BaseClientGenerator::toGetObjectCommand) .collect(GuavaCollectors.immutableList()); }
Source:
<code>protected void closeConnection() { for (IpNode receiverNode : receiverNodes.keySet()) { Socket socket = receiverNodes.get(receiverNode); if ((socket != null) && (!socket.isClosed())) { try { <START> socket.close(); <END> } catch (IOException e) { logger.warn("Could not close socket in {}: {}", receiverNode, this.thing.getUID(), e); } } receiverNodes.put(receiverNode, null); } isConnected = false; }</code><technical_language>This method in OlaBridgeHandler. class DmxBridgeHandler methods anyway, implementing core of this method a parameter if need specific</technical_language>

Target:
protected void closeConnection() { for (IpNode receiverNode : receiverNodes.keySet()) { Socket socket = receiverNodes.get(receiverNode); if ((socket != null) && (!socket.isClosed())) { try { socket.close(); } catch (IOException e) { logger.warn("Could not close socket in {}: {}", receiverNode, this.thing.getUID(), e); } } receiverNodes.put(receiverNode, null); } }
Source:
<code>public BlobHolder convert(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) throws ConversionException { ConverterDescriptor desc = converterDescriptors.get(converterName); if (desc == null) { throw new ConversionException("Converter " + converterName + " can not be found", blobHolder); } String mimeType = blobHolder.getBlob().getMimeType(); <START> if (desc.isBypassIfSameMimeTypet() && desc.getDestinationMimeType().equals(mimeType)) { <END> return blobHolder; } if (parameters == null) { parameters = new HashMap<>(); } ConverterCheckResult check = isConverterAvailable(converterName); if (!check.isAvailable()) { throw new ConverterNotAvailable(converterName, blobHolder); } if (!hasSourceMimeType(desc, mimeType)) { throw new ConversionException( String.format("%s mime type not supported by %s converter", mimeType, desc.getConverterName()), blobHolder); } String cacheKey = CacheKeyGenerator.computeKey(converterName, blobHolder, parameters); BlobHolder result = ConversionCacheHolder.getFromCache(cacheKey); if (result == null) { Converter converter = desc.getConverterInstance(); result = converter.convert(blobHolder, parameters); if (config.isCacheEnabled()) { ConversionCacheHolder.addToCache(cacheKey, result); } } else if (result.getBlobs() != null && result.getBlobs().size() == 1) { result.getBlob().setFilename(null); } if (result != null) { updateResultBlobMimeType(result, desc); updateResultBlobFileName(blobHolder, result); } return result; }</code><technical_language>@NourNuxeo please mark conversations resolved pushed actual resolution</technical_language>

Target:
public BlobHolder convert(String converterName, BlobHolder blobHolder, Map<String, Serializable> parameters) throws ConversionException { if (parameters == null) { parameters = new HashMap<>(); } ConverterCheckResult check = isConverterAvailable(converterName); if (!check.isAvailable()) { throw new ConverterNotAvailable(converterName, blobHolder); } ConverterDescriptor desc = converterDescriptors.get(converterName); if (desc == null) { throw new ConversionException("Converter " + converterName + " can not be found", blobHolder); } String mimeType = blobHolder.getBlob().getMimeType(); if (!hasSourceMimeType(desc, mimeType)) { throw new ConversionException( String.format("%s mime type not supported by %s converter", mimeType, desc.getConverterName()), blobHolder); } if (desc.isBypassIfSameMimeType() && desc.getDestinationMimeType().equals(mimeType)) { return blobHolder; } String cacheKey = CacheKeyGenerator.computeKey(converterName, blobHolder, parameters); BlobHolder result = ConversionCacheHolder.getFromCache(cacheKey); if (result == null) { Converter converter = desc.getConverterInstance(); result = converter.convert(blobHolder, parameters); if (config.isCacheEnabled()) { ConversionCacheHolder.addToCache(cacheKey, result); } } else if (result.getBlobs() != null && result.getBlobs().size() == 1) { result.getBlob().setFilename(null); } if (result != null) { updateResultBlobMimeType(result, desc); updateResultBlobFileName(blobHolder, result); } return result; }
Source:
<code>protected void testExecute_asStudentGetHasRespondedForSession_shouldPass() { StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1"); loginAsStudent(student1InCourse1.googleId); FeedbackSessionAttributes feedbackSession = typicalBundle.feedbackSessions.get("session1InCourse1"); <START> String[] params = new String[] { <END> Const.ParamsNames.COURSE_ID, student1InCourse1.course, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSession.getFeedbackSessionName(), Const.ParamsNames.ENTITY_TYPE, "student", }; GetHasResponsesAction getHasResponsesAction = getAction(params); JsonResult jsonResult = getJsonResult(getHasResponsesAction); HasResponsesData hasResponsesData = (HasResponsesData) jsonResult.getOutput(); assertEquals(HttpStatus.SC_OK, jsonResult.getStatusCode()); assertTrue(hasResponsesData.hasResponses()); }</code><technical_language>verify student answered session first</technical_language>

Target:
protected void testExecute_asStudentGetHasRespondedForSession_shouldPass() { StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1"); loginAsStudent(student1InCourse1.googleId); FeedbackSessionAttributes feedbackSession = typicalBundle.feedbackSessions.get("session1InCourse1"); FeedbackResponseAttributes feedbackResponse = typicalBundle.feedbackResponses.get("response1ForQ1S1C1"); assertEquals(feedbackResponse.getFeedbackSessionName(), feedbackSession.getFeedbackSessionName()); assertEquals(feedbackResponse.getGiver(), student1InCourse1.getEmail()); String[] params = new String[] { Const.ParamsNames.COURSE_ID, student1InCourse1.course, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSession.getFeedbackSessionName(), Const.ParamsNames.ENTITY_TYPE, Const.EntityType.STUDENT, }; GetHasResponsesAction getHasResponsesAction = getAction(params); JsonResult jsonResult = getJsonResult(getHasResponsesAction); HasResponsesData hasResponsesData = (HasResponsesData) jsonResult.getOutput(); assertEquals(HttpStatus.SC_OK, jsonResult.getStatusCode()); assertTrue(hasResponsesData.hasResponses()); }
Source:
<code>public void showInterstitial() { Context context = mInterstitialContext != null ? mInterstitialContext.get() : null; if (mInterstitialSpot.getSelectedUnitController() instanceof InneractiveFullscreenUnitController && context != null) { if (mInterstitialSpot.isReady()) { ((InneractiveFullscreenUnitController) mInterstitialSpot .getSelectedUnitController()).show(context); } else { Log.w(TAG, "showInterstitial called, but Ad has expired."); <START> mMediationInterstitialListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INTERNAL_ERROR); <END> mMediationInterstitialListener.onAdOpened(this); mMediationInterstitialListener.onAdClosed(this); } } else { Log.w(TAG, "showInterstitial called, but context reference was lost, or wrong spot has been used (should not happen)"); mMediationInterstitialListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INTERNAL_ERROR); } }</code><technical_language>Remove. onAdFailedToLoad() called show time</technical_language>

Target:
public void showInterstitial() { Context context = mInterstitialContext != null ? mInterstitialContext.get() : null; if (mInterstitialSpot.getSelectedUnitController() instanceof InneractiveFullscreenUnitController && context != null) { if (mInterstitialSpot.isReady()) { ((InneractiveFullscreenUnitController) mInterstitialSpot .getSelectedUnitController()).show(context); } else { Log.w(TAG, "showInterstitial called, but Ad has expired."); mMediationInterstitialListener.onAdOpened(this); mMediationInterstitialListener.onAdClosed(this); } } else { Log.w(TAG, "showInterstitial called, but context reference was lost, or wrong spot has been used (should not happen)"); mMediationInterstitialListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INTERNAL_ERROR); } }
Source:
<code>public static Map<String, SQLStmt> getSQLStmtMap(VoltCompiler compiler, Class<?> procClass) throws VoltCompilerException { VoltProcedure procInstance; try { procInstance = (VoltProcedure) procClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { <START> throw new RuntimeException("Error instantiating procedure \"%s\"" + procClass.getName(), e); <END> } Map<String, SQLStmt> stmtMap = getValidSQLStmts(compiler, procClass.getSimpleName(), procClass, procInstance, true); return stmtMap; }</code><technical_language>intended String.format(...)</technical_language>

Target:
public static Map<String, SQLStmt> getSQLStmtMap(VoltCompiler compiler, Class<?> procClass) throws VoltCompilerException { VoltProcedure procInstance; try { procInstance = (VoltProcedure) procClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Error instantiating procedure " + procClass.getName(), e); } Map<String, SQLStmt> stmtMap = getValidSQLStmts(compiler, procClass.getSimpleName(), procClass, procInstance, true); return stmtMap; }
Source:
<code>public static Field getInheritableThreadLocalsField() { String javaVersion = System.getProperty("java.specification.version"); <START> if (Integer.valueOf(javaVersion.split(".")[0]) >= 9) { <END> return null; } try { Field inheritableThreadLocals = Thread.class.getDeclaredField("inheritableThreadLocals"); inheritableThreadLocals.setAccessible(true); return inheritableThreadLocals; } catch (Throwable t) { return null; } }</code><technical_language>a shame sniffing strings is do for a Java version check. This break for new version scheme 18.3 it</technical_language>

Target:
public static Field getInheritableThreadLocalsField() { try { Field inheritableThreadLocals = Thread.class.getDeclaredField("inheritableThreadLocals"); inheritableThreadLocals.setAccessible(true); return inheritableThreadLocals; } catch (Throwable t) { return null; } }
Source:
<code>protected Session doReadSession(final Serializable sessionId) { if (sessionId == null) { return null; } <START> final String recordId = sessionId.toString(); <END> final SessionModelDao sessionModelDao = jdbcSessionSqlDao.read(recordId); if (sessionModelDao == null) { return null; } try { return sessionModelDao.toSimpleSession(); } catch (final IOException e) { log.warn("Corrupted cookie", e); return null; } }</code><technical_language>avoid confusion, rename variable sessionId</technical_language>

Target:
protected Session doReadSession(final Serializable sessionId) { if (sessionId == null) { return null; } final String sessionIdString = sessionId.toString(); final SessionModelDao sessionModelDao = jdbcSessionSqlDao.read(sessionIdString); if (sessionModelDao == null) { return null; } try { return sessionModelDao.toSimpleSession(); } catch (final IOException e) { log.warn("Corrupted cookie", e); return null; } }
Source:
<code>protected void executeVmCommand() { VM vm = getVm(); vm.setConsoleCurrentUserName(getParameters().getConsoleUserName()); <START> final VmDynamicDAO dao = DbFacade.getInstance().getVmDynamicDao(); <END> dao.update(vm.getDynamicData()); setSucceeded(true); }</code><technical_language>please use: runVdsCommand(VDSCommandType.UpdateVmDynamicData,..) sync'd monitoring updates</technical_language>

Target:
protected void executeVmCommand() { VM vm = getVm(); vm.setConsoleCurrentUserName(getParameters().getConsoleUserName()); VDSParametersBase updateVmDynamicParams = new UpdateVmDynamicDataVDSCommandParameters(getVdsId(), vm.getDynamicData()); runVdsCommand(VDSCommandType.UpdateVmDynamicData, updateVmDynamicParams); setSucceeded(true); }
Source:
<code>public CompleteTransactionMessage(long initiatorHSId, long coordinatorHSId, long txnId, boolean isReadOnly, int hash, boolean isRollback, boolean requiresAck, boolean isRestart, boolean isForReplay) { super(initiatorHSId, coordinatorHSId, txnId, 0, isReadOnly, isForReplay); m_hash = hash; setBit(ISROLLBACK, isRollback); setBit(REQUIRESACK, requiresAck); setBit(ISRESTART, isRestart); <START> m_toLeader = false; <END> m_ackRequestedFromSender = true; }</code><technical_language>inherited "m_isLeaderToReplica" instead of adding a new "m_toLeader"? message is leader replica MPI leader</technical_language>

Target:
public CompleteTransactionMessage(long initiatorHSId, long coordinatorHSId, long txnId, boolean isReadOnly, int hash, boolean isRollback, boolean requiresAck, boolean isRestart, boolean isForReplay) { super(initiatorHSId, coordinatorHSId, txnId, 0, isReadOnly, isForReplay); m_hash = hash; setBit(ISROLLBACK, isRollback); setBit(REQUIRESACK, requiresAck); setBit(ISRESTART, isRestart); }
Source:
<code>public static <T> AttributeSensor<T> newSensor(ConfigBag params) { String name = Preconditions.checkNotNull(params.get(SENSOR_NAME), "name must be supplied when defining a sensor"); String className = Preconditions.checkNotNull(params.get(SENSOR_TYPE), "target class must be supplied when defining a sensor"); Class<T> type = null; try { type = (Class<T>) Class.forName(className); } catch (ClassNotFoundException e) { <START> throw new IllegalArgumentException("Invalid target type"); <END> } return Sensors.newSensor(type, name); }</code><technical_language>In exception, include more information diagnosing problems log files. e.g. "Invalid target type for sensor "+name+": "+className</technical_language>

Target:
public static <T> AttributeSensor<T> newSensor(ConfigBag params) { String name = Preconditions.checkNotNull(params.get(SENSOR_NAME), "name must be supplied when defining a sensor"); String className = getFullClassName(params.get(SENSOR_TYPE)); Class<T> type = null; try { type = (Class<T>) Class.forName(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Invalid target type for sensor "+name+": " + className); } return Sensors.newSensor(type, name); }
Source:
<code><START> public void testConcurrentWriteAndRestart() { <END> final int THREADS = 4; final AtomicBoolean run = new AtomicBoolean(true); final CountDownLatch started = new CountDownLatch(THREADS); ExecutorService executor = Executors.newFixedThreadPool(THREADS); for (int i = 0; i < THREADS; ++i) { executor.execute(new Runnable() { @Override public void run() { started.countDown(); int i = 0; while (run.get()) { InternalCacheEntry entry = TestInternalCacheEntryFactory.create("k" + i, "v" + i); MarshalledEntry me = TestingUtil.marshalledEntry(entry, getMarshaller()); cl.write(me); ++i; } } }); } try { started.await(); Thread.sleep(1000); cl.stop(); Thread.sleep(1000); cl.start(); Thread.sleep(1000); } catch (InterruptedException e) { throw new IllegalStateException(e); } finally { run.set(false); executor.shutdown(); } }</code><technical_language>This test in "stress" group</technical_language>

Target:
public void testConcurrentWriteAndRestart() { concurrentWriteAndRestart(true); }
Source:
<code>public void purgeDefinition_shouldPurgeDesignsAndRequestsAndDefinition() throws Exception { executeDataSet("org/openmrs/module/reporting/include/ReportDefinitionServiceImplTest.xml"); assertNotNull(reportService.getReportDesign(3)); assertNotNull(reportService.getReportDesign(4)); assertNotNull(reportService.getReportRequest(1)); assertNotNull(reportService.getReportRequest(3)); reportDefinitionService.purgeDefinition("c11f5354-9567-4cc5-b3ef-163e28873926"); assertNull(reportService.getReportDesign(3)); assertNull(reportService.getReportDesign(4)); assertNull(reportService.getReportRequest(1)); assertNull(reportService.getReportRequest(3)); <START> assertNull(reportDefinitionService.getDefinition(80)); <END> }</code><technical_language>is of assertion line 69</technical_language>

Target:
public void purgeDefinition_shouldPurgeDesignsAndRequestsAndDefinition() throws Exception { executeDataSet("org/openmrs/module/reporting/include/ReportDefinitionServiceImplTest.xml"); assertNotNull(reportService.getReportDesignByUuid("d7a82b63-1066-4c1d-9b43-b405851fc467")); assertNotNull(reportService.getReportDesignByUuid("e7a82b63-1066-4c1d-9b43-b405851fc467")); assertNotNull(reportService.getReportRequestByUuid("h8a82b63-1066-4c1d-9b43-b405851fc467")); assertNotNull(reportService.getReportRequestByUuid("b0a82b63-1066-4c1d-9b43-b405851fc467")); Context.clearSession(); reportDefinitionService.purgeDefinition("c11f5354-9567-4cc5-b3ef-163e28873926"); assertNull(reportService.getReportDesignByUuid("d7a82b63-1066-4c1d-9b43-b405851fc467")); assertNull(reportService.getReportDesignByUuid("e7a82b63-1066-4c1d-9b43-b405851fc467")); assertNull(reportService.getReportRequestByUuid("h8a82b63-1066-4c1d-9b43-b405851fc467")); assertNull(reportService.getReportRequestByUuid("b0a82b63-1066-4c1d-9b43-b405851fc467")); assertNull(reportDefinitionService.getDefinitionByUuid("c11f5354-9567-4cc5-b3ef-163e28873926")); }
Source:
<code>public static void tearDown() throws Exception { testSupport.stop(); <START> PathUtil.deleteSilentlyRecursively(runtimeConfigurationStateChangeFile); <END> PathUtil.deleteSilentlyRecursively(runningStateChangeFile); }</code><technical_language>delete data directory instead</technical_language>

Target:
public static void tearDown() throws Exception { testSupport.stop(); PathUtil.deleteSilentlyRecursively(data); }