auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static Optional<String> getPayloadSerDe(Datastream datastream) { if (!datastream.hasDestination()) { return Optional.empty(); } <START> return Optional.ofNullable(datastream.getDestination().getPayloadSerDe(GetMode.NULL)); <END> }</code><technical_language>a suggestion: Optional::map, code shorter. return Optional.ofNullable(datastream.getDestination()).map(d -> d.getPayloadSerDe(GetMode.NULL));</technical_language>

Target:
public static Optional<String> getPayloadSerDe(Datastream datastream) { return Optional.ofNullable(datastream.getDestination()).map(d -> d.getPayloadSerDe(GetMode.NULL)); }
Source:
<code><START> public GetTaskListCommandParameters(Guid vdsId) { <END> spUUID = null; }</code><technical_language>super(vdsId)</technical_language>

Target:
public GetTaskListCommandParameters(Guid vdsId) { super(vdsId); StoragePoolId = null; }
Source:
<code>public Settings() { <START> if (this.configurations == null) { <END> this.configurations = new ArrayList<>(); } }</code><technical_language>this null here, in constructor</technical_language>

Target:
public Settings() { this.configurations = new ArrayList<>(); }
Source:
<code>public ServerAuthentication<String> serverAuthentication(Map<String, String> environment) { return new SimpleServerAuthentication<String>() { @Override public Authenticator<String> authenticator() { <START> return new Authenticator<String>() { <END> @Override public Optional<String> extractCredentials(final HttpRequestContext request) { return Optional.fromNullable(request.getHeaderValue(HttpHeaders.AUTHORIZATION)); } @Override public Optional<HeliosUser> authenticate(final String credentials) throws AuthenticationException { if ("secret123".equals(credentials)) { return Optional.of(new HeliosUser("the-user")); } ; return Optional.absent(); } }; } }; }</code><technical_language>Is semicolon <LINK_0> required</technical_language>

Target:
public ServerAuthentication<String> serverAuthentication(Map<String, String> environment) { return new SimpleServerAuthentication<String>() { @Override public Authenticator<String> authenticator() { return new Authenticator<String>() { @Override public Optional<String> extractCredentials(final HttpRequestContext request) { return Optional.fromNullable(request.getHeaderValue(HttpHeaders.AUTHORIZATION)); } @Override public Optional<HeliosUser> authenticate(final String credentials) throws AuthenticationException { if ("secret123".equals(credentials)) { return Optional.of(new HeliosUser("the-user")); } return Optional.absent(); } }; } }; }
Source:
<code>public static void <START> getLatency(){ <END> try { getLatency((long) minimum); } catch (Exception e) { log.error("failed to get latency error is: {}", e); } }</code><technical_language>is get.. if do return here</technical_language>

Target:
public static void getLatency(){ try { getLatency(minimum); } catch (Exception e) { log.error("failed to get latency error is: {}", e); } }
Source:
<code>public DebugStringVariableSubstitutor(String projectName) { <START> this(projectName == null ? null : projectName.isEmpty() ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)); <END> }</code><technical_language>slightly better: projectName == null || projectName.isEmpty() ? null ... is projectName empty instead of null for projectless debugging? this changed</technical_language>

Target:
public DebugStringVariableSubstitutor(String projectName) { this(projectName == null || projectName.isEmpty() ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)); }
Source:
<code>public ObjectBindingPatternTreeImpl objectBindingPattern2(InternalSyntaxToken lCurlyBrace, RestElementTree rest, InternalSyntaxToken rCurlyBrace) { return new ObjectBindingPatternTreeImpl( lCurlyBrace, <START> new SeparatedList<>(ImmutableList.<Tree>of(rest), Collections.<InternalSyntaxToken>emptyList()), <END> rCurlyBrace); }</code><technical_language>@vilchik-elena ImmutableList.of() Collections.emptyList()</technical_language>

Target:
public ObjectBindingPatternTreeImpl objectBindingPattern2(InternalSyntaxToken lCurlyBrace, RestElementTree rest, InternalSyntaxToken rCurlyBrace) { return new ObjectBindingPatternTreeImpl( lCurlyBrace, new SeparatedList<>(ImmutableList.<Tree>of(rest), ImmutableList.<InternalSyntaxToken>of()), rCurlyBrace); }
Source:
<code>public void bootstrapLayoutServer(@Nonnull String endpoint, @Nonnull Layout layout) { try { <START> CFUtils.getUninterruptibly(getRuntimeLayout(layout) <END> .getLayoutClient(endpoint) .bootstrapLayout(layout), AlreadyBootstrappedException.class); log.info("bootstrapLayoutServer: Layout Server bootstrap successful."); } catch (AlreadyBootstrappedException abe) { log.info("bootstrapLayoutServer: Layout Server already bootstrapped."); } }</code><technical_language>please async computation. return completable future. compose this future a future provided bootstrapManagementServer() method. If do need a boilerplate block of code try, catch, need handle exception in place</technical_language>

Target:
CompletableFuture<Boolean> bootstrapLayoutServer(@Nonnull String endpoint, @Nonnull Layout layout) { return getRuntimeLayout(layout).getLayoutClient(endpoint).bootstrapLayout(layout) .exceptionally(throwable -> { try { CFUtils.unwrap(throwable, AlreadyBootstrappedException.class); } catch (AlreadyBootstrappedException e) { log.info("bootstrapLayoutServer: Layout Server already bootstrapped.", endpoint); } return true; }) .thenApply(result -> { log.info("bootstrapLayoutServer: Layout Server bootstrap successful", endpoint); return true; }); }
Source:
<code>public List<CellWithTimestamp> getTimestamps(TableReference tableRef, byte[] startRowInclusive, int limit) { <START> try (CloseableTrace trace = startLocalTrace("cqlExecutor.getTimestamps(table {}, limit {})", <END> LoggingArgs.safeTableOrPlaceholder(tableRef), limit)) { return registerDuration(() -> delegate.getTimestamps(tableRef, startRowInclusive, limit), GET_TIMESTAMPS_TIMER); } }</code><technical_language>want add a TODO planning add safe-log configurability for row keys (or if want, add safeRowKeyOrPlaceholder method LoggingArgs return a placeholder)</technical_language>

Target:
public List<CellWithTimestamp> getTimestamps(TableReference tableRef, byte[] startRowInclusive, int limit) { try (CloseableTrace trace = startLocalTrace("cqlExecutor.getTimestamps(table {}, limit {})", LoggingArgs.safeTableOrPlaceholder(tableRef), limit)) { return registerDuration(() -> delegate.getTimestamps(tableRef, startRowInclusive, limit), GET_TIMESTAMPS_TIMER, logger -> logger.warn("cqlExecutor.getTimestamps({}, {})", LoggingArgs.tableRef(tableRef), SafeArg.of("limit", limit))); } }
Source:
<code>void drainLoop() { int missed = 1; JoinInnerSubscriber<T>[] s = this.subscribers; int n = s.length; Subscriber<? super T> a = this.downstream; for (;;) { long r = requested.get(); long e = 0; middle: while (e != r) { if (cancelled) { cleanup(); return; } boolean d = done.get() == 0; boolean empty = true; <START> for (JoinInnerSubscriber<T> inner : s) { <END> SimplePlainQueue<T> q = inner.queue; if (q != null) { T v = q.poll(); if (v != null) { empty = false; a.onNext(v); inner.requestOne(); if (++e == r) { break middle; } } } } if (d && empty) { Throwable ex = errors.get(); if (ex != null) { a.onError(errors.terminate()); } else { a.onComplete(); } return; } if (empty) { break; } } if (e == r) { if (cancelled) { cleanup(); return; } boolean d = done.get() == 0; boolean empty = true; for (JoinInnerSubscriber<T> inner : s) { SimpleQueue<T> q = inner.queue; if (q != null && !q.isEmpty()) { empty = false; break; } } if (d && empty) { Throwable ex = errors.get(); if (ex != null) { a.onError(errors.terminate()); } else { a.onComplete(); } return; } } if (e != 0 && r != Long.MAX_VALUE) { requested.addAndGet(-e); } int w = get(); if (w == missed) { missed = addAndGet(-missed); if (missed == 0) { break; } } else { missed = w; } } }</code><technical_language>Please restore this well</technical_language>

Target:
void drainLoop() { int missed = 1; JoinInnerSubscriber<T>[] s = this.subscribers; int n = s.length; Subscriber<? super T> a = this.downstream; for (;;) { long r = requested.get(); long e = 0; middle: while (e != r) { if (cancelled) { cleanup(); return; } boolean d = done.get() == 0; boolean empty = true; for (int i = 0; i < n; i++) { JoinInnerSubscriber<T> inner = s[i]; SimplePlainQueue<T> q = inner.queue; if (q != null) { T v = q.poll(); if (v != null) { empty = false; a.onNext(v); inner.requestOne(); if (++e == r) { break middle; } } } } if (d && empty) { Throwable ex = errors.get(); if (ex != null) { a.onError(errors.terminate()); } else { a.onComplete(); } return; } if (empty) { break; } } if (e == r) { if (cancelled) { cleanup(); return; } boolean d = done.get() == 0; boolean empty = true; for (int i = 0; i < n; i++) { JoinInnerSubscriber<T> inner = s[i]; SimpleQueue<T> q = inner.queue; if (q != null && !q.isEmpty()) { empty = false; break; } } if (d && empty) { Throwable ex = errors.get(); if (ex != null) { a.onError(errors.terminate()); } else { a.onComplete(); } return; } } if (e != 0 && r != Long.MAX_VALUE) { requested.addAndGet(-e); } int w = get(); if (w == missed) { missed = addAndGet(-missed); if (missed == 0) { break; } } else { missed = w; } } }
Source:
<code>private File createJar( @Nonnull List<String> classPath, @Nonnull String startClassName, @Nonnull File dumpLogDirectory ) throws IOException { File file = File.createTempFile( "surefirebooter", ".jar", getTempDirectory() ); if ( !isDebug() ) { file.deleteOnExit(); } String parent = file.getParent(); FileOutputStream fos = new FileOutputStream( file ); try ( JarOutputStream jos = new JarOutputStream( fos ) ) { jos.setLevel( JarOutputStream.STORED ); JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" ); jos.putNextEntry( je ); Manifest man = new Manifest(); StringBuilder cp = new StringBuilder(); for ( Iterator<String> it = classPath.iterator(); it.hasNext(); ) { String classPathElement = it.next(); String uri = toClasspathElementUri( parent, classPathElement, dumpLogDirectory ); cp.append( uri ); <START> if ( new File( classPathElement ).isDirectory() && !uri.endsWith( "/" ) ) <END> { cp.append( '/' ); } if ( it.hasNext() ) { cp.append( ' ' ); } } man.getMainAttributes().putValue( "Manifest-Version", "1.0" ); man.getMainAttributes().putValue( "Class-Path", cp.toString().trim() ); man.getMainAttributes().putValue( "Main-Class", startClassName ); man.write( jos ); jos.closeEntry(); jos.flush(); return file; } }</code><technical_language>Files.isDirectory more consistent new of Paths. do think</technical_language>

Target:
private File createJar( @Nonnull List<String> classPath, @Nonnull String startClassName, @Nonnull File dumpLogDirectory ) throws IOException { File file = File.createTempFile( "surefirebooter", ".jar", getTempDirectory() ); if ( !isDebug() ) { file.deleteOnExit(); } Path parent = file.getParentFile().toPath(); FileOutputStream fos = new FileOutputStream( file ); try ( JarOutputStream jos = new JarOutputStream( fos ) ) { jos.setLevel( JarOutputStream.STORED ); JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" ); jos.putNextEntry( je ); Manifest man = new Manifest(); StringBuilder cp = new StringBuilder(); for ( Iterator<String> it = classPath.iterator(); it.hasNext(); ) { Path classPathElement = Paths.get( it.next() ); String uri = toClasspathElementUri( parent, classPathElement, dumpLogDirectory ); cp.append( uri ); if ( isDirectory( classPathElement ) && !uri.endsWith( "/" ) ) { cp.append( '/' ); } if ( it.hasNext() ) { cp.append( ' ' ); } } man.getMainAttributes().putValue( "Manifest-Version", "1.0" ); man.getMainAttributes().putValue( "Class-Path", cp.toString().trim() ); man.getMainAttributes().putValue( "Main-Class", startClassName ); man.write( jos ); jos.closeEntry(); jos.flush(); return file; } }
Source:
<code>private SourceStatus findSourceStatusFor(Publisher source, List<SourceReadEntry> reads) { for (SourceReadEntry status : reads) { if (status.getPublisher().equals(source)) { return status.getSourceStatus(); } } <START> return null; <END> }</code><technical_language>Do expect get here? If so, NPE in calling code</technical_language>

Target:
private SourceStatus findSourceStatusFor(Publisher source, List<SourceReadEntry> reads) { for (SourceReadEntry status : reads) { if (status.getPublisher().equals(source)) { return status.getSourceStatus(); } } return source.getDefaultSourceStatus(); }
Source:
<code>public void revokeAccessTokens(String id, String token) { AccessToken accessToken = new AccessToken.Builder(token).build(); try { connector.revokeAllAccessTokens(id, accessToken); } catch (ConnectionInitializationException e) { String message = "Unable to revoke access token on auth-server " + authServerHome + ": " + e.getMessage(); <START> LOGGER.warn(message); <END> throw e; } }</code><technical_language>Please LOGGER.warn("Unable revoke access token auth-server {}: {}", authServerHome, e.getMessage());. Thanks @sputnik27 for hint ;)</technical_language>

Target:
public void revokeAccessTokens(String id, String token) { AccessToken accessToken = new AccessToken.Builder(token).build(); try { connector.revokeAllAccessTokens(id, accessToken); } catch (ConnectionInitializationException e) { LOGGER.warn(String.format("Unable to revoke access token on auth-server %s: %s", authServerHome, e.getMessage())); throw e; } }
Source:
<code>void persist() { try { recordManager.commit(); } catch (IOException e) { <START> e.printStackTrace(); <END> } }</code><technical_language>suggestion logger.error(e);</technical_language>

Target:
void persist() { try { recordManager.commit(); } catch (IOException e) { logger.error(e); } }
Source:
<code>public void onTestFailure(ITestResult result) { driver = NewDriverProvider.getWebDriver(); if (driver == null) { driver = NewDriverProvider.getWebDriver(); } imageCounter += 1; if (Global.LOG_ENABLED) { try { new Shooter().savePageScreenshot(screenPath + imageCounter, driver); CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", driver.getPageSource()); } catch (Exception e) { log("onException", "driver has no ability to catch screenshot or html source - driver may died", false); } String exception = escapeHtml(result.getThrowable().toString() + "\n" + ExceptionUtils.getStackTrace(result.getThrowable())); StringBuilder builder = new StringBuilder(); builder.append("<tr class=\"error\"><td>error</td><td>" + exception + "</td><td> <br/><a href='screenshots/screenshot" + imageCounter + ".png'>Screenshot</a><br/><a href='screenshots/screenshot" + imageCounter + ".html'>HTML Source</a></td></tr>"); CommonUtils.appendTextToFile(logPath, builder.toString()); testLogging.addSteps(new TestStepsLogging("error", "error", exception, false, screenPath + imageCounter +".png")); <START> imageCounter += 1; <END> logJSError(driver); onTestSuccess(result); } }</code><technical_language>increase imageCounter here</technical_language>

Target:
public void onTestFailure(ITestResult result) { driver = NewDriverProvider.getWebDriver(); if (driver == null) { driver = NewDriverProvider.getWebDriver(); } imageCounter += 1; if (Global.LOG_ENABLED) { try { new Shooter().savePageScreenshot(screenPath + imageCounter, driver); CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", driver.getPageSource()); } catch (Exception e) { log("onException", "driver has no ability to catch screenshot or html source - driver may died", false); } String exception = escapeHtml(result.getThrowable().toString() + "\n" + ExceptionUtils.getStackTrace(result.getThrowable())); StringBuilder builder = new StringBuilder(); builder.append("<tr class=\"error\"><td>error</td><td>" + exception + "</td><td> <br/><a href='screenshots/screenshot" + imageCounter + ".png'>Screenshot</a><br/><a href='screenshots/screenshot" + imageCounter + ".html'>HTML Source</a></td></tr>"); CommonUtils.appendTextToFile(logPath, builder.toString()); String screenshotPath = screenPath + imageCounter + ".png"; String htmlPath = screenPath + imageCounter + ".html"; testLogging.addSteps( new TestStepsLogging("error", "error", exception, false, screenshotPath, htmlPath)); logJSError(driver); onTestSuccess(result); } }
Source:
<code>public static String toASCII(String input, int flag) { try { return IDNA.convertIDNToASCII(input, flag).toString(); } catch (android.icu.text.StringPrepParseException e) { <START> if (input.equals(".")) { <END> return input; } throw new IllegalArgumentException("Invalid input to toASCII: " + input, e); } END Android-changed: Use ICU4J implementation }</code><technical_language>nit: obvious input null not. ".".equals(input)</technical_language>

Target:
public static String toASCII(String input, int flag) { try { return IDNA.convertIDNToASCII(input, flag).toString(); } catch (android.icu.text.StringPrepParseException e) { if (".".equals(input)) { return input; } throw new IllegalArgumentException("Invalid input to toASCII: " + input, e); } END Android-changed: Use ICU4J implementation }
Source:
<code>public Product() { this.attributes = new HashMap<>(); this.productContent = new LinkedList<>(); this.dependentProductIds = new HashSet<>(); this.branding = new HashSet<>(); this.providedProducts = new HashSet<>(); this.derivedProvidedProducts = new HashSet<>(); this.providedProductDtos = null; <START> this.derivedProvidedProductDtos = null; <END> }</code><technical_language>DTOs is legacy code loooong ago. try avoid carrying updated model</technical_language>

Target:
public Product() { this.attributes = new HashMap<>(); this.productContent = new LinkedList<>(); this.dependentProductIds = new HashSet<>(); this.branding = new HashSet<>(); this.providedProducts = new HashSet<>(); }
Source:
<code>public static Slice castFromInteger(@SqlType(INTEGER) long value) throws IOException { <START> return internalCastFromLong(value, 20); <END> }</code><technical_language>A more accurate estimate for tinyint/smallint/int 4/6/11. Do this is correct</technical_language>

Target:
public static Slice castFromInteger(@SqlType(INTEGER) long value) throws IOException { return internalCastFromLong(value, 12); }
Source:
<code>public Iterable<Repo> iterate( @NotNull(message = "identifier can't be NULL") final String identifier) { <START> throw new NotImplementedException("MkRepos#iterate"); <END> }</code><technical_language>UnsupportedOperationException</technical_language>

Target:
public Iterable<Repo> iterate( @NotNull(message = "identifier can't be NULL") final String identifier) { throw new UnsupportedOperationException("MkRepos#iterate"); }
Source:
<code>public boolean mediate(MessageContext synCtx) { if (synCtx.getEnvironment().isDebuggerEnabled()) { if (super.divertMediationRoute(synCtx)) { return true; } } SynapseLog synLog = getLog(synCtx); if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("Start : Respond Mediator"); if (synLog.isTraceTraceEnabled()) { synLog.traceTrace("Message : " + synCtx.getEnvelope()); } } synCtx.setTo(null); synCtx.setResponse(true); String proxyName = (String) synCtx.getProperty(SynapseConstants.PROXY_SERVICE); <START> if (proxyName == null || "".equals(proxyName)) { <END> RESTUtils.handleCORSHeadersForResponse(synCtx); } Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx; org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext(); axis2MessageCtx.getOperationContext() .setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "SKIP"); Axis2Sender.sendBack(synCtx); if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("End : Respond Mediator"); } return false; }</code><technical_language>isEmpty() method check empty string</technical_language>

Target:
public boolean mediate(MessageContext synCtx) { if (synCtx.getEnvironment().isDebuggerEnabled()) { if (super.divertMediationRoute(synCtx)) { return true; } } SynapseLog synLog = getLog(synCtx); if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("Start : Respond Mediator"); if (synLog.isTraceTraceEnabled()) { synLog.traceTrace("Message : " + synCtx.getEnvelope()); } } synCtx.setTo(null); synCtx.setResponse(true); String proxyName = (String) synCtx.getProperty(SynapseConstants.PROXY_SERVICE); if (proxyName == null || proxyName.isEmpty()) { RESTUtils.handleCORSHeadersForResponse(synCtx); } Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx; org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext(); axis2MessageCtx.getOperationContext() .setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "SKIP"); Axis2Sender.sendBack(synCtx); if (synLog.isTraceOrDebugEnabled()) { synLog.traceOrDebug("End : Respond Mediator"); } return false; }
Source:
<code>public void testAuths() throws Exception { LocalFileSystem localFs = FileSystem.getLocal(new Configuration()); String testFile = createTmpTestFile(); RFileWriter writer = RFile.newWriter().to(testFile).withFileSystem(localFs).build(); Key k1 = new Key("r1", "f1", "q1", "A&B"); Key k2 = new Key("r1", "f1", "q2", "A"); Key k3 = new Key("r1", "f1", "q3"); Value v1 = new Value("p".getBytes()); Value v2 = new Value("c".getBytes()); Value v3 = new Value("t".getBytes()); writer.append(k1, v1); writer.append(k2, v2); writer.append(k3, v3); writer.close(); Scanner scanner = RFile.newScanner().from(testFile).withFileSystem(localFs) .withAuthorizations(new Authorizations("A")).build(); assertEquals(Map.of(k2, v2, k3, v3), toMap(scanner)); assertEquals(new Authorizations("A"), scanner.getAuthorizations()); scanner.close(); scanner = RFile.newScanner().from(testFile).withFileSystem(localFs) .withAuthorizations(new Authorizations("A", "B")).build(); assertEquals(Map.of(k1, v1, k2, v2, k3, v3), toMap(scanner)); assertEquals(new Authorizations("A", "B"), scanner.getAuthorizations()); scanner.close(); scanner = RFile.newScanner().from(testFile).withFileSystem(localFs) .withAuthorizations(new Authorizations("B")).build(); <START> assertEquals(Map.of(k3, v3), toMap(scanner)); <END> assertEquals(new Authorizations("B"), scanner.getAuthorizations()); scanner.close(); }</code><technical_language>test changes nice</technical_language>

Target:
public void testAuths() throws Exception { LocalFileSystem localFs = FileSystem.getLocal(new Configuration()); String testFile = createTmpTestFile(); RFileWriter writer = RFile.newWriter().to(testFile).withFileSystem(localFs).build(); Key k1 = new Key("r1", "f1", "q1", "A&B"); Key k2 = new Key("r1", "f1", "q2", "A"); Key k3 = new Key("r1", "f1", "q3"); Value v1 = new Value("p".getBytes()); Value v2 = new Value("c".getBytes()); Value v3 = new Value("t".getBytes()); writer.append(k1, v1); writer.append(k2, v2); writer.append(k3, v3); writer.close(); Scanner scanner = RFile.newScanner().from(testFile).withFileSystem(localFs) .withAuthorizations(new Authorizations("A")).build(); assertEquals(ImmutableMap.of(k2, v2, k3, v3), toMap(scanner)); assertEquals(new Authorizations("A"), scanner.getAuthorizations()); scanner.close(); scanner = RFile.newScanner().from(testFile).withFileSystem(localFs) .withAuthorizations(new Authorizations("A", "B")).build(); assertEquals(ImmutableMap.of(k1, v1, k2, v2, k3, v3), toMap(scanner)); assertEquals(new Authorizations("A", "B"), scanner.getAuthorizations()); scanner.close(); scanner = RFile.newScanner().from(testFile).withFileSystem(localFs) .withAuthorizations(new Authorizations("B")).build(); assertEquals(ImmutableMap.of(k3, v3), toMap(scanner)); assertEquals(new Authorizations("B"), scanner.getAuthorizations()); scanner.close(); }
Source:
<code>public void remove(CraftingRecipe recipe) { <START> recipes.remove(recipe); <END> }</code><technical_language>this</technical_language>

Target:
public void remove(CraftingRecipe recipe) { this.recipes.remove(recipe); }
Source:
<code>public ResponseEntity<?> createEventType(@Valid @RequestBody final EventType eventType, final Errors errors, final NativeWebRequest nativeWebRequest) { <START> if (featureToggleService.isFeatureEnabled("disable_event_type_creation")) { <END> return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } if (errors.hasErrors()) { return create(new ValidationProblem(errors), nativeWebRequest); } try { validateSchema(eventType); enrichment.validate(eventType); partitionResolver.validate(eventType); eventTypeRepository.saveEventType(eventType); topicRepository.createTopic(eventType.getName(), eventType.getDefaultStatistics()); return status(HttpStatus.CREATED).build(); } catch (final InvalidEventTypeException | NoSuchPartitionStrategyException | DuplicatedEventTypeNameException e) { LOG.debug("Failed to create EventType.", e); return create(e.asProblem(), nativeWebRequest); } catch (final TopicCreationException e) { LOG.error("Problem creating kafka topic. Rolling back event type database registration.", e); try { eventTypeRepository.removeEventType(eventType.getName()); } catch (final NakadiException e1) { return create(e.asProblem(), nativeWebRequest); } return create(e.asProblem(), nativeWebRequest); } catch (final NakadiException e) { LOG.error("Error creating event type " + eventType, e); return create(e.asProblem(), nativeWebRequest); } }</code><technical_language>Usually, I put in constant</technical_language>

Target:
public ResponseEntity<?> createEventType(@Valid @RequestBody final EventType eventType, final Errors errors, final NativeWebRequest nativeWebRequest) { if (featureToggleService.isFeatureEnabled(DISABLE_EVENT_TYPE_CREATION)) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } if (errors.hasErrors()) { return create(new ValidationProblem(errors), nativeWebRequest); } try { assignTopic(eventType); validateSchema(eventType); enrichment.validate(eventType); partitionResolver.validate(eventType); eventTypeRepository.saveEventType(eventType); topicRepository.createTopic(eventType.getTopic(), eventType.getDefaultStatistics()); return status(HttpStatus.CREATED).build(); } catch (final InvalidEventTypeException | NoSuchPartitionStrategyException | DuplicatedEventTypeNameException e) { LOG.debug("Failed to create EventType.", e); return create(e.asProblem(), nativeWebRequest); } catch (final TopicCreationException e) { LOG.error("Problem creating kafka topic. Rolling back event type database registration.", e); try { eventTypeRepository.removeEventType(eventType.getTopic()); } catch (final NakadiException e1) { return create(e.asProblem(), nativeWebRequest); } return create(e.asProblem(), nativeWebRequest); } catch (final NakadiException e) { LOG.error("Error creating event type " + eventType, e); return create(e.asProblem(), nativeWebRequest); } }
Source:
<code>Type getTypeForBlock(PinotColumnHandle pinotColumnHandle) { if (pinotColumnHandle.getColumnType().equals(INTEGER)) { return BIGINT; } <START> else { <END> return pinotColumnHandle.getColumnType(); } }</code><technical_language>else is redundant</technical_language>

Target:
private static Type getTypeForBlock(PinotColumnHandle pinotColumnHandle) { if (pinotColumnHandle.getColumnType().equals(INTEGER)) { return BIGINT; } return pinotColumnHandle.getColumnType(); }
Source:
<code>public List<Failure> getFailures() { <START> return Collections.unmodifiableList(new ArrayList<>(failures)); <END> }</code><technical_language>return Collections.unmodifiableList(failures); suffice, iirc</technical_language>

Target:
public List<Failure> getFailures() { return Collections.unmodifiableList(failures); }
Source:
<code>public void testDataSet1() throws Exception { JavaRDD<Page> pages = sc.parallelize(getPagesSet1()); IndexStats stats = new IndexStats(sc); <START> JavaPairRDD<RowColumn, Bytes> accumuloIndex = IndexUtil.createAccumuloIndex(stats, pages); <END> verifyRDD(new File("src/test/resources/data/set1/accumulo-data.txt"), accumuloIndex); JavaPairRDD<RowColumn, Bytes> fluoIndex = IndexUtil.createFluoIndex(accumuloIndex); verifyRDD(new File("src/test/resources/data/set1/fluo-data.txt"), fluoIndex); JavaPairRDD<RowColumn, Bytes> reindex = IndexUtil.reindexFluo(fluoIndex); verifyRDD(new File("src/test/resources/data/set1/accumulo-data.txt"), reindex); }</code><technical_language>pairs of lines</technical_language>

Target:
public void testDataSet1() throws Exception { JavaRDD<Page> pages = sc.parallelize(getPagesSet1()); IndexStats stats = new IndexStats(sc); JavaPairRDD<RowColumn, Bytes> accumuloIndex = IndexUtil.createAccumuloIndex(stats, pages); verifyRDD(new File("src/test/resources/data/set1/accumulo-data.txt"), accumuloIndex); JavaPairRDD<RowColumn, Bytes> fluoIndex = IndexUtil.createFluoIndex(accumuloIndex); verifyRDD(new File("src/test/resources/data/set1/fluo-data.txt"), fluoIndex); JavaPairRDD<RowColumn, Bytes> accumuloIndexRecreated = IndexUtil.createAccumuloIndex(fluoIndex); verifyRDD(new File("src/test/resources/data/set1/accumulo-data.txt"), accumuloIndexRecreated); }
Source:
<code>private void handleContent(HttpContent httpContent) throws RestServiceException { if (request != null) { logger.trace("Received content for request - {}", request.getUri()); try { request.addContent(httpContent); } catch (IllegalStateException e) { throw new RestServiceException(e, RestServiceErrorCode.InvalidRequestState); } catch (ClosedChannelException e) { throw new RestServiceException("The request has been closed and is not accepting content", RestServiceErrorCode.RequestChannelClosed); } if (!RestMethod.POST.equals(request.getRestMethod())) { <START> requestHandler.handleRequest(request, responseChannel); <END> } } else { logger.warn("Received content without a request on channel {}", ctx.channel()); nettyMetrics.noRequestError.inc(); throw new RestServiceException("Received content without a request", RestServiceErrorCode.InvalidRequestState); } }</code><technical_language>incase of http content, supposed invoke handle request right</technical_language>

Target:
private void handleContent(HttpContent httpContent) throws RestServiceException { if (request != null) { logger.trace("Received content for request - {}", request.getUri()); try { request.addContent(httpContent); } catch (IllegalStateException e) { throw new RestServiceException(e, RestServiceErrorCode.InvalidRequestState); } catch (ClosedChannelException e) { throw new RestServiceException("The request has been closed and is not accepting content", RestServiceErrorCode.RequestChannelClosed); } if (!request.getRestMethod().equals(RestMethod.POST)) { requestHandler.handleRequest(request, responseChannel); } } else { logger.warn("Received content without a request on channel {}", ctx.channel()); nettyMetrics.noRequestError.inc(); throw new RestServiceException("Received content without a request", RestServiceErrorCode.InvalidRequestState); } }
Source:
<code>public static ClientRegistration.Builder fromOidcIssuerLocation(String issuer) { Assert.hasText(issuer, "issuer cannot be empty"); <START> return oidc(URI.create(issuer)).get(); <END> }</code><technical_language>I want route this getBuilder exception handling before</technical_language>

Target:
public static ClientRegistration.Builder fromOidcIssuerLocation(String issuer) { Assert.hasText(issuer, "issuer cannot be empty"); return getBuilder(issuer, oidc(URI.create(issuer))); }
Source:
<code>public InstrumentedThreadFactory(ThreadFactory delegate, MetricRegistry registry, String name) { this.delegate = delegate; this.created = registry.counter(MetricRegistry.name(name, "created")); this.running = registry.counter(MetricRegistry.name(name, "running")); <START> this.finished = registry.counter(MetricRegistry.name(name, "finished")); <END> }</code><technical_language>I terminated more finished. Also, meters</technical_language>

Target:
public InstrumentedThreadFactory(ThreadFactory delegate, MetricRegistry registry, String name) { this.delegate = delegate; this.created = registry.meter(MetricRegistry.name(name, "created")); this.running = registry.counter(MetricRegistry.name(name, "running")); this.terminated = registry.meter(MetricRegistry.name(name, "terminated")); }
Source:
<code>private void add(Document doc, FieldDef<ChangeData, ?> f, Iterable<?> values) throws OrmException { if (f.getType() == FieldType.INTEGER) { for (Object value : values) { doc.add(new IntField(f.getName(), (Integer) value, store(f))); } } else if (f.getType() == FieldType.EXACT) { for (Object value : values) { doc.add(new StringField(f.getName(), (String) value, store(f))); } } else if (f.getType() == FieldType.FULL_TEXT) { for (Object value : values) { <START> doc.add(new TextField(f.getName(), (String) value, store(f))); <END> } } else { throw badFieldType(f.getType()); } }</code><technical_language>rebase this current master, f.getName() store(f) local variables top of method</technical_language>

Target:
private void add(Document doc, FieldDef<ChangeData, ?> f, Iterable<?> values) throws OrmException { String name = f.getName(); Store store = store(f); if (f.getType() == FieldType.INTEGER) { for (Object value : values) { doc.add(new IntField(name, (Integer) value, store)); } } else if (f.getType() == FieldType.LONG) { for (Object value : values) { doc.add(new LongField(name, (Long) value, store)); } } else if (f.getType() == FieldType.TIMESTAMP) { for (Object v : values) { doc.add(new IntField(name, toIndexTime((Timestamp) v), store)); } } else if (f.getType() == FieldType.EXACT || f.getType() == FieldType.PREFIX) { for (Object value : values) { doc.add(new StringField(name, (String) value, store)); } } else if (f.getType() == FieldType.FULL_TEXT) { for (Object value : values) { doc.add(new TextField(name, (String) value, store)); } } else { throw badFieldType(f.getType()); } }
Source:
<code>public static String getFromUrl( String url, String encoding ) throws IOException { String protocol = StringUtils.substringBefore( url, ":" ).toLowerCase(); Charset charset = Charset.forName( encoding ); String result = null; if ( CLASSPATH_PROTOCOL.equals( protocol ) ) { ClassLoader classLoader = UrlRequester.class.getClassLoader(); String resource = url.substring( CLASSPATH_PROTOCOL.length() + 1 ); URL resourceUrl = classLoader.getResource( resource ); if ( resourceUrl == null ) { resourceUrl = ClassLoader.getSystemResource( resource ); } if ( resourceUrl != null ) { result = IOUtils.toString( resourceUrl, charset ); } else { throw new IOException( "The resource " + resource + " was not found in the maven plugin classpath" ); } } else if ( "http".equals( protocol ) || "https".equals( protocol ) ) { <START> CloseableHttpClient httpClient = HttpClientBuilder.create().build(); <END> HttpGet get = new HttpGet( url ); CloseableHttpResponse response = null; try { response = httpClient.execute( get ); result = IOUtils.toString( response.getEntity().getContent(), charset ); } catch ( ClientProtocolException e ) { throw new IOException( e.getMessage(), e ); } finally { if ( response != null ) { try { response.close(); } catch ( IOException e ) { } } } } else { result = IOUtils.toString( new URL( url ).openStream(), charset ); } return result; }</code><technical_language>CloseableHttpClient implements Closeable. Please try (CloseableHttpClient httpClient = HttpClientBuilder.create().build())</technical_language>

Target:
public static String getFromUrl( String url, String encoding ) throws IOException { String protocol = StringUtils.substringBefore( url, ":" ).toLowerCase(); Charset charset = Charset.forName( encoding ); String result = null; if ( CLASSPATH_PROTOCOL.equals( protocol ) ) { ClassLoader classLoader = UrlRequester.class.getClassLoader(); String resource = url.substring( CLASSPATH_PROTOCOL.length() + 1 ); URL resourceUrl = classLoader.getResource( resource ); if ( resourceUrl != null ) { result = IOUtils.toString( resourceUrl, charset ); } else { throw new IOException( "The resource " + resource + " was not found in the maven plugin classpath" ); } } else if ( "http".equals( protocol ) || "https".equals( protocol ) ) { try ( CloseableHttpClient httpClient = HttpClientBuilder.create().build() ) { HttpGet get = new HttpGet( url ); try ( CloseableHttpResponse response = httpClient.execute( get ) ) { int responseCode = response.getStatusLine().getStatusCode(); if ( responseCode >= 200 && responseCode < 300 ) { HttpEntity entity = response.getEntity(); ContentType contentType = ContentType.get( entity ); if ( contentType != null ) { charset = contentType.getCharset(); } result = IOUtils.toString( entity.getContent(), charset ); } else { throw new IOException( "For the URL (" + url + ") the server responded with " + response.getStatusLine() ); } } } } else { result = IOUtils.toString( new URL( url ).openStream(), charset ); } return result; }
Source:
<code>public void run() { store.setValue(prefName, isChecked()); <START> if (store.needsSaving()) { <END> try { store.save(); } catch (IOException e) { Activator.handleError(e.getMessage(), e, false); } } }</code><technical_language>curlies un-needed</technical_language>

Target:
public void run() { store.setValue(prefName, isChecked()); if (store.needsSaving()) try { store.save(); } catch (IOException e) { Activator.handleError(e.getMessage(), e, false); } }
Source:
<code>private Event getEvent(final DataObject eventDataObject) throws ProtocolAdapterException { final List<DataObject> eventData = eventDataObject.value(); if (eventData == null) { throw new ProtocolAdapterException("eventData DataObject should not be null"); } if (eventData.size() != 2) { throw new ProtocolAdapterException("eventData size should be 2"); } final DateTime dateTime = this.dlmsHelperService.convertDataObjectToDateTime(eventData.get(0)); <START> final Short code = eventData.get(1).value(); <END> LOGGER.info("Event time is and event code is {}", dateTime, code); final Event event = new Event(dateTime, code.intValue()); return event; }</code><technical_language>This works, I consider perform a bit more defensive programming results external library (checking DataObject type instead of assuming it). Some examples of extra checks exist in DlmsHelperService</technical_language>

Target:
private Event getEvent(final DataObject eventDataObject) throws ProtocolAdapterException { final List<DataObject> eventData = eventDataObject.value(); if (eventData == null) { throw new ProtocolAdapterException("eventData DataObject should not be null"); } if (eventData.size() != 2) { throw new ProtocolAdapterException("eventData size should be 2"); } final DateTime dateTime = this.dlmsHelperService.convertDataObjectToDateTime(eventData.get(0)); if (!eventData.get(1).isNumber()) { throw new ProtocolAdapterException("eventData value is not a number"); } final Short code = eventData.get(1).value(); LOGGER.info("Event time is and event code is {}", dateTime, code); return new Event(dateTime, code.intValue()); }
Source:
<code>public boolean createSubBlock(ItemStack itemStack, Direction direction, EntityPlayer player) { <START> SixNodeDescriptor descriptor = Eln.sixNodeItem.getDescriptor(itemStack); <END> if (sideElementList[direction.getInt()] != null) return false; try { sideElementIdList[direction.getInt()] = itemStack.getItemDamage(); sideElementList[direction.getInt()] = (SixNodeElement) descriptor.ElementClass.getConstructor(SixNode.class, Direction.class, SixNodeDescriptor.class).newInstance(this, direction, descriptor); sideElementIdList[direction.getInt()] = 0; disconnect(); sideElementList[direction.getInt()].front = descriptor.getFrontFromPlace(direction, player); sideElementList[direction.getInt()].initialize(); sideElementIdList[direction.getInt()] = itemStack.getItemDamage(); connect(); Utils.println("createSubBlock " + sideElementIdList[direction.getInt()] + " " + direction); setNeedPublish(true); return true; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } return false; }</code><technical_language>This is a todo</technical_language>

Target:
public boolean createSubBlock(ItemStack itemStack, Direction direction, EntityPlayer player) { SixNodeDescriptor descriptor = null; if (sideElementList[direction.getInt()] != null) return false; try { sideElementIdList[direction.getInt()] = itemStack.getItemDamage(); sideElementList[direction.getInt()] = (SixNodeElement) descriptor.ElementClass.getConstructor(SixNode.class, Direction.class, SixNodeDescriptor.class).newInstance(this, direction, descriptor); sideElementIdList[direction.getInt()] = 0; disconnect(); sideElementList[direction.getInt()].front = descriptor.getFrontFromPlace(direction, player); sideElementList[direction.getInt()].initialize(); sideElementIdList[direction.getInt()] = itemStack.getItemDamage(); connect(); Utils.println("createSubBlock " + sideElementIdList[direction.getInt()] + " " + direction); setNeedPublish(true); return true; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } return false; }
Source:
<code><START> public void testUpdateProperties() throws OperationException { <END> DocumentModel doc = session.createDocumentModel("/", "docComplex", "File"); doc.setPropertyValue("dc:description", "description"); doc.setPropertyValue("dc:source", "source"); doc = session.createDocument(doc); try (OperationContext ctx = new OperationContext(session)) { ctx.setInput(doc); DocumentModel res = (DocumentModel) automationService.run(ctx, "Scripting.TestUpdateProperties"); assertEquals("foo", res.getPropertyValue("dc:description")); assertEquals("bar", res.getPropertyValue("dc:source")); } }</code><technical_language>Why</technical_language>

Target:
public void testUpdateProperties() throws OperationException { DocumentModel doc = session.createDocumentModel("/", "file", "File"); doc.setPropertyValue("dc:description", "description"); doc.setPropertyValue("dc:source", "source"); doc = session.createDocument(doc); try (OperationContext ctx = new OperationContext(session)) { ctx.setInput(doc); DocumentModel res = (DocumentModel) automationService.run(ctx, "Scripting.TestUpdateProperties"); assertEquals("foo", res.getPropertyValue("dc:description")); assertEquals("bar", res.getPropertyValue("dc:source")); } }
Source:
<code>public synchronized void listenOn(Cache<CounterKey, CounterValue> cache) throws InterruptedException { if (!topologyListener.registered) { this.cache = cache; topologyListener.register(cache); } if (!listenersRegistered) { <START> this.cache.addFilteredListener(valueListener, null, null, <END> Util.asSet(CacheEntryCreated.class, CacheEntryModified.class, CacheEntryRemoved.class)); listenersRegistered = true; } }</code><technical_language>This wrong, filter anymore</technical_language>

Target:
public synchronized void listenOn(Cache<CounterKey, CounterValue> cache) throws InterruptedException { if (!topologyListener.registered) { this.cache = cache; topologyListener.register(cache); } if (!listenersRegistered) { this.cache.addListener(valueListener); listenersRegistered = true; } }
Source:
<code>public int hashCode() { <START> return 31* testNGMethod.hashCode(); <END> }</code><technical_language>space missing *</technical_language>

Target:
public int hashCode() { return multiplicationFactor * testNGMethod.hashCode(); }
Source:
<code>public void writeRevision(Revision rev) throws IOException { XmlWriter writer = this.writer; writer.openElement("revision"); <START> writer.textElement("id", Integer.toString(rev.Id)); <END> if (rev.Parentid != 0) { writer.textElement("parentid", Integer.toString(rev.Parentid)); } writer.textElement("timestamp", formatTimestamp(rev.Timestamp)); writeContributor(rev.Contributor); if (rev.Minor) { writer.emptyElement("minor"); } if (rev.Comment == null) { writer.emptyElement("comment", deletedAttrib); } else if (rev.Comment.length() != 0) { writer.textElement("comment", rev.Comment); } writer.textElement("model", rev.Model); writer.textElement("format", rev.Format); ArrayList<String[]> textAttribs = new ArrayList<String[]>(); textAttribs.add(new String[] {"xml:space", "preserve"}); if (rev.Text == null) { textAttribs.add(new String[] {"deleted", "deleted"}); } else if (rev.Bytes != null) { textAttribs.add(new String[] {"bytes", rev.Bytes.toString()}); } writer.textElement("text", rev.Text, textAttribs.toArray(new String[][] {})); writer.textElement("sha1", rev.Sha1); writer.closeElement(); }</code><technical_language>needs fixing</technical_language>

Target:
public void writeRevision(Revision rev) throws IOException { XmlWriter writer = this.writer; writer.openElement("revision"); if (rev.Id != 0) { writer.textElement("id", Integer.toString(rev.Id)); } if (rev.Parentid != 0) { writer.textElement("parentid", Integer.toString(rev.Parentid)); } writer.textElement("timestamp", formatTimestamp(rev.Timestamp)); writeContributor(rev.Contributor); if (rev.Minor) { writer.emptyElement("minor"); } if (rev.Comment == null) { writer.emptyElement("comment", deletedAttrib); } else if (rev.Comment.length() != 0) { writer.textElement("comment", rev.Comment); } if (rev.Model != null) { writer.textElement("model", rev.Model); } if (rev.Format != null) { writer.textElement("format", rev.Format); } ArrayList<String[]> textAttribs = new ArrayList<String[]>(); textAttribs.add(new String[] {"xml:space", "preserve"}); if (rev.Text == null) { textAttribs.add(new String[] {"deleted", "deleted"}); } else if (rev.Bytes != null) { textAttribs.add(new String[] {"bytes", rev.Bytes.toString()}); } writer.textElement("text", rev.Text, textAttribs.toArray(new String[][] {})); if (rev.Sha1 != null) { writer.textElement("sha1", rev.Sha1); } writer.closeElement(); }
Source:
<code><START> protected byte[] encryptWrite(byte[] b, int off, int len, long fp) <END> { if (writeBuffer == null || writeBuffer.length < b.length) writeBuffer = new byte[b.length]; System.arraycopy(b, off, writeBuffer, off, len); encrypt(writeBuffer, off, len, fp); return writeBuffer; }</code><technical_language>this method synchronized of writeBuffer access</technical_language>

Target:
protected synchronized byte[] encryptWrite(byte[] b, int off, int len, long fp) { if (writeBuffer == null || writeBuffer.length < b.length) writeBuffer = new byte[b.length]; System.arraycopy(b, off, writeBuffer, off, len); encrypt(writeBuffer, off, len, fp); return writeBuffer; }
Source:
<code>private static <T> List<T> extractList(Map<String, Object> xmlRpcStruct, String propertyName, boolean returnNullOnEmpty) { <START> if (!xmlRpcStruct.containsKey(propertyName)){ return returnNullOnEmpty ? null : Collections.emptyList(); } <END> Object[] items = (Object[]) xmlRpcStruct.get(propertyName); if (items.length == 0) { return returnNullOnEmpty ? null : Collections.emptyList(); } return Arrays.stream(items).map(item -> (T) item).collect(Collectors.toList()); }</code><technical_language>This block redundant. get key. Then, if null empty, return default</technical_language>

Target:
private static <T> List<T> extractList(Map<String, Object> xmlRpcStruct, String propertyName, boolean returnNullOnEmpty) { if (xmlRpcStruct.containsKey(propertyName)){ Object[] items = (Object[]) xmlRpcStruct.get(propertyName); if (items.length > 0) { return Arrays.stream(items).map(item -> (T) item).collect(Collectors.toList()); } } return returnNullOnEmpty ? null : Collections.emptyList(); }