auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>SolrClient createSolrHttpClient(String coreName) throws IOException, SolrServerException { final HttpClientBuilder httpClientBuilder = createHttpBuilder(); final HttpSolrClient.Builder solrClientBuilder = new HttpSolrClient.Builder(getCoreUrl(coreName)); try (final Closer closer = new Closer()) { createSolrCore(coreName, httpClientBuilder.build()); <START> CloseableHttpClient noRetryHttpClient = httpClientBuilder.build(); <END> final HttpSolrClient noRetrySolrClient = closer.with(solrClientBuilder.withHttpClient(noRetryHttpClient).build()); CloseableHttpClient yesRetryHttpClient = httpClientBuilder.setRetryHandler(new SolrHttpRequestRetryHandler(coreName)).build(); final HttpSolrClient retrySolrClient = closer.with(solrClientBuilder.withHttpClient(yesRetryHttpClient).build()); return closer.returning(new PingAwareSolrClientProxy(retrySolrClient, noRetrySolrClient)); } }</code><technical_language>this client registered closer</technical_language>

Target:
SolrClient createSolrHttpClient(String coreName) throws IOException, SolrServerException { final HttpClientBuilder httpClientBuilder = createHttpBuilder(); final HttpSolrClient.Builder solrClientBuilder = new HttpSolrClient.Builder(solrSettings.getCoreUrl(coreName)); try (final Closer closer = new Closer()) { createSolrCore(coreName, closer.with(httpClientBuilder.build())); CloseableHttpClient noRetryHttpClient = httpClientBuilder.build(); closer.with(noRetryHttpClient); CloseableHttpClient yesRetryHttpClient = httpClientBuilder.setRetryHandler(new SolrHttpRequestRetryHandler(coreName)).build(); closer.with(yesRetryHttpClient); final HttpSolrClient noRetrySolrClient = solrClientBuilder.withHttpClient(noRetryHttpClient).build(); final HttpSolrClient retrySolrClient = solrClientBuilder.withHttpClient(yesRetryHttpClient).build(); return closer.returning(new PingAwareSolrClientProxy(retrySolrClient, noRetrySolrClient)); } }
Source:
<code>public void run() { Stopwatch stopwatch = Stopwatch.createStarted(); while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < timeouts.getWatchTimeoutMs()) { try (LogWatch logWatch = client .pods() .inNamespace(namespace) .withName(podName) .inContainer(containerName) .watchLog()) { <START> synchronized (this) { <END> if (closed.get()) { return; } currentLogWatch = logWatch; } if (!readAndHandle(currentLogWatch.getOutput(), logHandler)) { LOG.trace( "failed to get the logs for '{} : : {}'. Container probably still starting after [{}]ms.", namespace, podName, containerName, stopwatch.elapsed(TimeUnit.MILLISECONDS)); Thread.sleep(timeouts.getWaitBeforeNextTry()); } else { LOG.debug( "finished watching the logs of '{} : : {}'", namespace, podName, containerName); return; } } catch (InterruptedException e) { LOG.error( "Failed watch the logs '{} : : {}', nothing better to do here.", namespace, podName, containerName, e); return; } } }</code><technical_language>unexpected usage of synchronized + AtimicBoolean. bad happen if remove it</technical_language>

Target:
public void run() { Stopwatch stopwatch = Stopwatch.createStarted(); while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < timeouts.getWatchTimeoutMs()) { try (LogWatch logWatch = client .pods() .inNamespace(namespace) .withName(podName) .inContainer(containerName) .watchLog()) { synchronized (this) { if (closed) { return; } currentLogWatch = logWatch; } if (currentLogWatch.getOutput() == null || !readAndHandle( ByteStreams.limit(currentLogWatch.getOutput(), inputStreamLimit), logHandler)) { LOG.trace( "failed to get the logs for '{} : : {}'. Container probably still starting after [{}]ms.", namespace, podName, containerName, stopwatch.elapsed(TimeUnit.MILLISECONDS)); Thread.sleep(timeouts.getWaitBeforeNextTry()); } else { LOG.debug( "finished watching the logs of '{} : : {}'", namespace, podName, containerName); return; } } catch (InterruptedException e) { LOG.error( "Failed watch the logs '{} : : {}', nothing better to do here.", namespace, podName, containerName, e); return; } } }
Source:
<code>public Page<E> asPage() { Objects.requireNonNull(webContext); Watch w = Watch.start(); Page<E> result = new Page<E>().withStart(1).withPageSize(pageSize); result.bindToRequest(webContext); <START> if (Strings.isFilled(result.getQuery()) && !searchFields.isEmpty()) { <END> baseQuery.where(baseQuery.filters() .queryString(baseQuery.getDescriptor(), result.getQuery(), searchFields)); } applyFacets(result); try { setupPaging(result); List<E> items = executeQuery(); enforcePaging(result, items); fillPage(w, result, items); } catch (Exception e) { UserContext.handle(e); } return result; }</code><technical_language>getQuery</technical_language>

Target:
public Page<E> asPage() { Objects.requireNonNull(webContext); Watch w = Watch.start(); Page<E> result = new Page<E>().withStart(1).withPageSize(pageSize); result.bindToRequest(webContext); applyQuery(result.getQuery()); applyFacets(result); try { setupPaging(result); List<E> items = executeQuery(); enforcePaging(result, items); fillPage(w, result, items); } catch (Exception e) { UserContext.handle(e); } return result; }
Source:
<code>public static AuditMessageType.ActiveParticipant createActiveParticipantFromUser(final UserType userInfo, final Boolean userIsReq) { final AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant(); if (ipAddr == null) { try { ipAddr = InetAddress.getLocalHost().getHostAddress(); } catch (final UnknownHostException ex) { LOG.error("UnknownHostException thrown getting local host address: {}", ex.getLocalizedMessage(), ex); throw new RuntimeException(); } } String userId = null; if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().length() > 0) { userId = userInfo.getUserName(); } if (userId != null) { participant.setUserID(userId); } String userName = null; if (userInfo != null && userInfo.getPersonName() != null) { if (userInfo.getPersonName().getGivenName() != null <START> && userInfo.getPersonName().getGivenName().length() > 0) { <END> userName = userInfo.getPersonName().getGivenName(); } if (userInfo.getPersonName().getFamilyName() != null && userInfo.getPersonName().getFamilyName().length() > 0) { if (userName != null) { userName += " " + userInfo.getPersonName().getFamilyName(); } else { userName = userInfo.getPersonName().getFamilyName(); } } } if (userName != null) { participant.setUserName(userName); } participant.setUserIsRequestor(userIsReq); participant.setNetworkAccessPointID(ipAddr); participant.setNetworkAccessPointTypeCode(AuditDataTransformConstants.NETWORK_ACCESSOR_PT_TYPE_CODE_IP); return participant; }</code><technical_language>check for empty string do a length check here</technical_language>

Target:
public static AuditMessageType.ActiveParticipant createActiveParticipantFromUser(final UserType userInfo, final Boolean userIsReq) { final AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant(); if (ipAddr == null) { try { ipAddr = InetAddress.getLocalHost().getHostAddress(); } catch (final UnknownHostException ex) { LOG.error("UnknownHostException thrown getting local host address: {}", ex.getLocalizedMessage(), ex); throw new RuntimeException(); } } String userId = null; if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().length() > 0) { userId = userInfo.getUserName(); } if (userId != null) { participant.setUserID(userId); } String userName = null; if (userInfo != null && userInfo.getPersonName() != null) { if (StringUtils.isNotEmpty(userInfo.getPersonName().getGivenName())) { userName = userInfo.getPersonName().getGivenName(); } if (StringUtils.isNotEmpty(userInfo.getPersonName().getFamilyName())) { if (userName != null) { userName += " " + userInfo.getPersonName().getFamilyName(); } else { userName = userInfo.getPersonName().getFamilyName(); } } } if (userName != null) { participant.setUserName(userName); } participant.setUserIsRequestor(userIsReq); participant.setNetworkAccessPointID(ipAddr); participant.setNetworkAccessPointTypeCode(AuditDataTransformConstants.NETWORK_ACCESSOR_PT_TYPE_CODE_IP); return participant; }
Source:
<code>public String parseMessage(HttpResponse response) { if (response.getPayload() == null) return null; try { return Strings2.toString(response.getPayload()); } catch (IOException e) { throw Throwables.propagate(e); } finally { try { <START> response.getPayload().getInput().close(); <END> } catch (IOException e) { throw Throwables.propagate(e); } } }</code><technical_language>payload is closeable. Close payload avoid deprecation warning</technical_language>

Target:
public String parseMessage(HttpResponse response) { if (response.getPayload() == null) return null; try { return Strings2.toString(response.getPayload()); } catch (IOException e) { throw Throwables.propagate(e); } finally { try { response.getPayload().close(); } catch (IOException e) { throw Throwables.propagate(e); } } }
Source:
<code><START> public ActionResult execute() { <END> String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); if (courseId != null) { if (logic.getCourse(courseId) == null) { return new JsonResult("No course with id: " + courseId, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.hasResponsesForCourse(courseId); return new JsonResult(new HasResponsesData(hasResponses)); } String feedbackQuestionID = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID); if (feedbackQuestionID != null) { if (logic.getFeedbackQuestion(feedbackQuestionID) == null) { return new JsonResult("No feedback question with id: " + feedbackQuestionID, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.areThereResponsesForQuestion(feedbackQuestionID); return new JsonResult(new HasResponsesData(hasResponses)); } throw new InvalidHttpParameterException("At least courseid or questionid must be supplied"); }</code><technical_language>this point, do getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID) do logic extra null check. throwing exception null, this result</technical_language>

Target:
public ActionResult execute() { String feedbackQuestionID = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID); if (feedbackQuestionID != null) { if (logic.getFeedbackQuestion(feedbackQuestionID) == null) { return new JsonResult("No feedback question with id: " + feedbackQuestionID, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.areThereResponsesForQuestion(feedbackQuestionID); return new JsonResult(new HasResponsesData(hasResponses)); } String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); if (logic.getCourse(courseId) == null) { return new JsonResult("No course with id: " + courseId, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.hasResponsesForCourse(courseId); return new JsonResult(new HasResponsesData(hasResponses)); }
Source:
<code>private int getSeparator(String qualified) { int result = -1; if (userNameFormat == UserNameFormat.UPN && qualified.indexOf("\\") == -1) { <START> result = qualified.lastIndexOf("@"); <END> } else if (userNameFormat == UserNameFormat.DOWN_LEVEL_LOGON_NAME && qualified.indexOf("@") == -1) { result = qualified.lastIndexOf("\\"); } return result; }</code><technical_language>I if this is new notation accept as-is, fall if is \ atIndex = qualified.lastIndexOf("@") if (atIndex != -1) { } else if (userNameFormat == UserNameFormat.DOWN_LEVEL_LOGON_NAME) { backslashIndex = ... }</technical_language>

Target:
private int getSeparator(String qualified) { int result = -1; if (userNameFormat == UserNameFormat.UPN && qualified.indexOf("\\") == -1) { result = qualified.lastIndexOf("@"); } else if (userNameFormat == UserNameFormat.RESTAPI_SPECIFIC && qualified.indexOf("@") == -1) { result = qualified.indexOf("\\"); } return result; }
Source:
<code>private Context getMockContext(final Signature signature, final String brokerPackageName, final String contextPackageName, boolean permissionStatus) throws NameNotFoundException { Context mockContext = mock(Context.class); PackageManager mockPackageManager = getPackageManager(signature, brokerPackageName, permissionStatus); when(mockContext.getPackageManager()).thenReturn(mockPackageManager); when(mockContext.getPackageName()).thenReturn(contextPackageName); List<ResolveInfo> mockList = new ArrayList<>(); mockList.add(new ResolveInfo()); <START> int size = mockList.size(); <END> when(mockPackageManager.queryIntentActivities(Matchers.any(Intent.class), anyInt())).thenReturn(mockList); return mockContext; }</code><technical_language>sorry, I meant size</technical_language>

Target:
private Context getMockContext(final Signature signature, final String brokerPackageName, final String contextPackageName, boolean permissionStatus) throws NameNotFoundException { Context mockContext = mock(Context.class); PackageManager mockPackageManager = getPackageManager(signature, brokerPackageName, permissionStatus); when(mockContext.getPackageManager()).thenReturn(mockPackageManager); when(mockContext.getPackageName()).thenReturn(contextPackageName); List<ResolveInfo> mockList = new ArrayList<>(); mockList.add(new ResolveInfo()); when(mockPackageManager.queryIntentActivities(Matchers.any(Intent.class), anyInt())).thenReturn(mockList); return mockContext; }
Source:
<code>public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { for (Object cookie : cookiesToClear) { Cookie realCookie = null; <START> if (cookie instanceof String) { <END> realCookie = new Cookie((String) cookie, null); String cookiePath = request.getContextPath() + "/"; realCookie.setPath(cookiePath); realCookie.setMaxAge(0); }else if (cookie instanceof Cookie){ realCookie = (Cookie) cookie; } response.addCookie(realCookie); } }</code><technical_language>This logic need updated change this.cookiesToClear</technical_language>

Target:
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { cookiesToClear.forEach( f -> response.addCookie(f.apply(request)) ); }
Source:
<code>private void runSe(String filename) { JavaScriptVisitorContext context; <START> try { <END> context = createContext(new TestInputFile("src/test/resources/se/", filename)); verifier.scanExpectedIssues(context); SeChecksDispatcher seChecksDispatcher = new SeChecksDispatcher(ImmutableList.of((SeCheck) verifier)); seChecksDispatcher.scanTree(context); } catch (IOException e) { Throwables.propagate(e); } }</code><technical_language>@janos-ss I catch IOException createContext</technical_language>

Target:
private void runSe(String filename) { JavaScriptVisitorContext context = createContext(new TestInputFile("src/test/resources/se/", filename)); verifier.scanExpectedIssues(context); SeChecksDispatcher seChecksDispatcher = new SeChecksDispatcher(ImmutableList.of((SeCheck) verifier)); seChecksDispatcher.scanTree(context); }
Source:
<code>public static void saveCustomSettings(PostgresConnectionSettings settings) { Map<String, String> map = new HashMap<String, String>(); map.put(HOST_KEY, settings.getHost()); map.put(PORT_KEY, Integer.toString(settings.getPort())); map.put(DBNAME_KEY, settings.getDbName()); map.put(BULK_THRESHOLD_KEY, Integer.toString(settings.getBulkThreshold())); map.put(USER_KEY, settings.getUserName()); try { map.put(PASSWORD_KEY, TextConverter.convertTextToHexText(settings.getPassword())); } catch (TextConverterException ex) { <START> LOGGER.log(Level.SEVERE, "Failed to convert password from text to hex text.", ex); <END> } ModuleSettings.setConfigSettings(MODULE_KEY, map); }</code><technical_language>In previous section this is a warning default password is used. is here? if error is "SEVERE" log continue on</technical_language>

Target:
public void saveCustomSettings(PostgresConnectionSettings settings) { Map<String, String> map = new HashMap<String, String>(); map.put(HOST_KEY, settings.getHost()); map.put(PORT_KEY, Integer.toString(settings.getPort())); map.put(DBNAME_KEY, settings.getDbName()); map.put(BULK_THRESHOLD_KEY, Integer.toString(settings.getBulkThreshold())); map.put(USER_KEY, settings.getUserName()); try { map.put(PASSWORD_KEY, TextConverter.convertTextToHexText(settings.getPassword())); } catch (TextConverterException ex) { LOGGER.log(Level.SEVERE, "Failed to convert password from text to hex text.", ex); } ModuleSettings.setConfigSettings(MODULE_KEY, map); }
Source:
<code>public DocumentModel run(DocumentModel doc) throws ConcurrentUpdateException, IOException { if (changeToken != null) { <START> save = true; <END> doc.putContextData(CoreSession.CHANGE_TOKEN, changeToken); } DocumentHelper.setProperties(session, doc, properties); if (save) { doc = session.saveDocument(doc); } return doc; }</code><technical_language>stated in changeToken parameter description forces session saved, if save parameter set false</technical_language>

Target:
public DocumentModel run(DocumentModel doc) throws ConcurrentUpdateException, IOException { if (changeToken != null) { doc.putContextData(CoreSession.CHANGE_TOKEN, changeToken); } DocumentHelper.setProperties(session, doc, properties); if (save) { doc = session.saveDocument(doc); } return doc; }
Source:
<code>private void handleEOF() { MySubscriber<Void> fnfsub = new MySubscriber<>(0L, AGENT); <START> RSocket fnfclient = createClient; <END> Publisher<Void> fnfpub = fnfclient.fireAndForget(new PayloadImpl("shutdown", "shutdown")); fnfpub.subscribe(fnfsub); fnfsub.request(1); }</code><technical_language>nit: inline</technical_language>

Target:
private void handleEOF() { MySubscriber<Void> fnfsub = new MySubscriber<>(0L, AGENT); RSocket fnfclient = createClient.get(); Publisher<Void> fnfpub = fnfclient.fireAndForget(new PayloadImpl("shutdown", "shutdown")); fnfpub.subscribe(fnfsub); fnfsub.request(1); }
Source:
<code>public void commit() throws TransactionException { final DatabaseTransaction transaction = getCurrentTransaction(); logger.trace("Committing transaction: " + transaction.transactionId()); try { transaction.applyActions(databaseTemplate); currentTransaction.remove(); <START> logger.trace("Transaction successfully commit: " + transaction.transactionId()); <END> } catch (final Throwable e) { throw new TransactionalResourceException("Failed to commit DynamoDb transaction: " + transaction.transactionId(), e); } }</code><technical_language>Replace 'commit' 'committed'</technical_language>

Target:
public void commit() throws TransactionException { final DatabaseTransaction transaction = getCurrentTransaction(); logger.trace("Committing transaction: " + transaction.transactionId()); try { transaction.applyActions(databaseTemplate); currentTransaction.remove(); logger.trace("Transaction successfully committed: " + transaction.transactionId()); } catch (final Throwable e) { throw new TransactionalResourceException("Failed to commit DatabaseTemplate transaction: " + transaction.transactionId(), e); } }
Source:
<code>public static void readInDocFromString(String fName, ByteBufferInputStream bbis, DataInputStream di, ArrayBackedValueStorage abvs, IParser parser) throws IOException { Reader input; if (!fName.contains("hdfs:/")) { File file = new File(fName); if (file.exists()) { input = new InputStreamReader(new FileInputStream(file)); parser.parse(input, abvs); } else{ <START> throw new IOException(); <END> } } else { HDFSFunctions hdfs = new HDFSFunctions(null, null); FileSystem fs = hdfs.getFileSystem(); if (fs != null) { String fHdfsName = fName.replaceAll("hdfs:/", ""); Path xmlDocument = new Path(fHdfsName); if (fs.exists(xmlDocument)) { InputStream in = fs.open(xmlDocument).getWrappedStream(); input = new InputStreamReader(in); parser.parse(input, abvs); in.close(); } fs.close(); } } }</code><technical_language>throw new FileNotFoundException(file.getAbsolutePath());</technical_language>

Target:
public static void readInDocFromString(String fName, ByteBufferInputStream bbis, DataInputStream di, ArrayBackedValueStorage abvs, IParser parser) throws IOException { Reader input; if (!fName.contains("hdfs:/")) { File file = new File(fName); if (file.exists()) { input = new InputStreamReader(new FileInputStream(file)); parser.parse(input, abvs); } else { throw new FileNotFoundException(file.getAbsolutePath()); } } else { HDFSFunctions hdfs = new HDFSFunctions(null, null); FileSystem fs = hdfs.getFileSystem(); if (fs != null) { String fHdfsName = fName.replaceAll("hdfs:/", ""); Path xmlDocument = new Path(fHdfsName); if (fs.exists(xmlDocument)) { InputStream in = fs.open(xmlDocument).getWrappedStream(); input = new InputStreamReader(in); parser.parse(input, abvs); in.close(); } else { throw new FileNotFoundException(xmlDocument.getName()); } fs.close(); } else { throw new IOException(); } } }
Source:
<code><START> void increment_operator() { <END> int i = 0; i++; int b = 12; ++b; int j = -1; while ((j = foo(++j)) != -1) { System.out.println(""); } }</code><technical_language>@benzonico include realistic example of mistake: return i++;</technical_language>

Target:
int increment_operator() { int i = 0; int b = 12; ++b; int c = 0; foo(++c); int j = -1; while ((j = foo(++j)) != -1) { System.out.println(""); } if(i != 0) { return i++; } else { return ++i; } }
Source:
<code>public List<T> get() { <START> return new ArrayList<>(registerableList); <END> }</code><technical_language>defensive copy</technical_language>

Target:
public List<T> get() { return unmodifiableList(registerableList); }
Source:
<code>public Optional<ItemType> getById(String id) { checkNotNull(id); if (!id.contains(":")) { <START> id = "minecraft:" + id.toLowerCase(); END> } return Optional.ofNullable(this.itemTypeMappings.get(id)); }</code><technical_language>need pass Locale.ENGLISH you</technical_language>

Target:
public Optional<ItemType> getById(String id) { checkNotNull(id); if (!id.contains(":")) { id = "minecraft:" + id.toLowerCase(Locale.ENGLISH); } return Optional.ofNullable(this.itemTypeMappings.get(id)); }
Source:
<code>private Pair<Integer, Integer> findLeafCombineDegreeAndNumBuffers( ByteBuffer combineBuffer, int requiredMinimumBufferCapacity, int numAvailableThreads, int numLeafNodes ) { for (int leafCombineDegree = MINIMUM_LEAF_COMBINE_DEGREE; leafCombineDegree <= numLeafNodes; leafCombineDegree++) { final int requiredBufferNum = computeRequiredBufferNum(numLeafNodes, leafCombineDegree); if (requiredBufferNum <= numAvailableThreads) { final int expectedSliceSize = combineBuffer.capacity() / requiredBufferNum; if (expectedSliceSize >= requiredMinimumBufferCapacity) { return Pair.of(leafCombineDegree, requiredBufferNum); } } } <START> throw new ISE("Cannot find a proper leaf combine degree. Try increasing druid.processing.buffer.sizeBytes."); <END> }</code><technical_language>I needs addressed in this specific PR, nice more information in exception message guides users change need druid.processing.buffer.sizeBytes. if calculated bounds of sizeBytes needed support MINIMUM_LEAF_COMBINE_DEGREE highest leafCombineDegree requiredBufferNum is numAvailableThreads, of nature</technical_language>

Target:
private Pair<Integer, Integer> findLeafCombineDegreeAndNumBuffers( ByteBuffer combineBuffer, int requiredMinimumBufferCapacity, int numAvailableThreads, int numLeafNodes ) { for (int leafCombineDegree = MINIMUM_LEAF_COMBINE_DEGREE; leafCombineDegree <= numLeafNodes; leafCombineDegree++) { final int requiredBufferNum = computeRequiredBufferNum(numLeafNodes, leafCombineDegree); if (requiredBufferNum <= numAvailableThreads) { final int expectedSliceSize = combineBuffer.capacity() / requiredBufferNum; if (expectedSliceSize >= requiredMinimumBufferCapacity) { return Pair.of(leafCombineDegree, requiredBufferNum); } } } throw new ISE( "Cannot find a proper leaf combine degree for the combining tree. " + "Each node of the combining tree requires a buffer of [%d] bytes. " + "Try increasing druid.processing.buffer.sizeBytes for larger buffer or " + "druid.query.groupBy.intermediateCombineDegree for a smaller tree", requiredMinimumBufferCapacity ); }
Source:
<code>protected void addCleaner(final Exchange exchange, final Message message) { message.addMessageObserver(new MessageObserverAdapter() { @Override public void onCancel() { complete("canceled"); } @Override public void failed() { complete("failed"); } private void complete(final String action) { if (exchange.executeComplete()) { if (exchange.isOfLocalOrigin()) { <START> LOG.debug("{}, request [MID={}, {}]", exchange, exchange.getRequest().getMID(), <END> exchange.getRequest().getToken()); } else { LOG.debug("{}, response [MID={}, {}]", exchange, exchange.getResponse().getMID(), exchange.getResponse().getToken()); } message.removeMessageObserver(this); } } }); }</code><technical_language>Uups, I forgot add action parameter log message in commit 28e20c025f2328be491b25c2d777192106c97533</technical_language>

Target:
protected void addCleaner(final Exchange exchange, final Message message) { message.addMessageObserver(new MessageObserverAdapter() { @Override public void onCancel() { complete("canceled"); } @Override public void failed() { complete("failed"); } private void complete(final String action) { if (exchange.executeComplete()) { if (exchange.isOfLocalOrigin()) { LOG.debug("{}, request [MID={}, Token={}]", exchange, action, exchange.getRequest().getMID(), exchange.getRequest().getToken()); } else { LOG.debug("{}, request [MID={}, Token={}]", exchange, action, exchange.getResponse().getMID(), exchange.getResponse().getToken()); } message.removeMessageObserver(this); } } }); }
Source:
<code>public static String buildJobGroupId(InterpreterContext context) { <START> return context.getAuthenticationInfo().getUser() + "-" + context.getNoteId() + "-" + context.getParagraphId(); <END> }</code><technical_language>Is context.getAuthenticationInfo() is null context.getAuthenticationInfo().getUser() is null</technical_language>

Target:
public static String buildJobGroupId(InterpreterContext context) { String uName = "anonymous"; if (context.getAuthenticationInfo() != null) { uName = getUserName(context.getAuthenticationInfo()); } return "zeppelin-" + uName + "-" + context.getNoteId() + "-" + context.getParagraphId(); }
Source:
<code>private AttributeType getEnrichedType(AttributeType guess, Object value) { if (guess == null || value == null) { return guess; } if (guess.equals(STRING)) { String stringValue = value.toString(); if (stringValue.length() > MAX_STRING_LENGTH) { return TEXT; } <START> if (Boolean.TRUE.equals(canValueBeUsedAsDate(value))) { <END> return DATE; } } else if (guess.equals(DECIMAL)) { if (value instanceof Integer) { return INT; } else if (value instanceof Long) { Long longValue = (Long) value; return longValue > Integer.MIN_VALUE && longValue < Integer.MAX_VALUE ? INT : LONG; } else if (value instanceof Double) { Double doubleValue = (Double) value; if (doubleValue != Math.rint(doubleValue)) { return DECIMAL; } if (doubleValue > Integer.MIN_VALUE && doubleValue < Integer.MAX_VALUE) { return INT; } if (doubleValue > Long.MIN_VALUE && doubleValue < Long.MAX_VALUE) { return LONG; } } } return guess; }</code><technical_language>Better: change private Boolean canValueBeUsedAsDate(Object value) private boolean canValueBeUsedAsDate(Object value)</technical_language>

Target:
private AttributeType getEnrichedType(AttributeType guess, Object value) { if (guess == null || value == null) { return guess; } if (guess.equals(STRING)) { String stringValue = value.toString(); if (stringValue.length() > MAX_STRING_LENGTH) { return TEXT; } if (canValueBeUsedAsDate(value)) { return DATE; } } else if (guess.equals(DECIMAL)) { if (value instanceof Integer) { return INT; } else if (value instanceof Long) { Long longValue = (Long) value; return longValue > Integer.MIN_VALUE && longValue < Integer.MAX_VALUE ? INT : LONG; } else if (value instanceof Double) { Double doubleValue = (Double) value; if (doubleValue != Math.rint(doubleValue)) { return DECIMAL; } if (doubleValue > Integer.MIN_VALUE && doubleValue < Integer.MAX_VALUE) { return INT; } if (doubleValue > Long.MIN_VALUE && doubleValue < Long.MAX_VALUE) { return LONG; } } } return guess; }
Source:
<code>public String[] getFilePaths(RepoObject repoObject) throws RepoException { String[] paths = null; try { paths = mfs.getPaths(getObjectLocationString(repoObject.getBucketName(), repoObject.getChecksum()), true); } catch (Exception e){ throw new RepoException(e); <START> } <END> return paths; }</code><technical_language>i if leave logging information</technical_language>

Target:
public String[] getFilePaths(RepoObject repoObject) throws RepoException { String[] paths = null; try{ paths = mfs.getPaths(getObjectLocationString(repoObject.getBucketName(), repoObject.getChecksum()), true); if (paths == null) { throw new RepoException(RepoException.Type.ObjectFilePathMissing); } } catch(Exception e){ throw new RepoException(e); } return paths; }
Source:
<code>void completePlayerSetup(boolean asked) { if (asked) { skinLayout = (OoyalaSkinLayout) findViewById(R.id.ooyalaSkin); PlayerDomain playerDomain = new PlayerDomain(domain); Options options = null; if(selectedFormat.equalsIgnoreCase("default")) options = new Options.Builder().setShowNativeLearnMoreButton(false).setShowPromoImage(false).setUseExoPlayer(true).build(); else options = new Options.Builder().setShowNativeLearnMoreButton(false).setShowPromoImage(false).setUseExoPlayer(true).setPlayerInfo(new CustomPlayerInfo(selectedFormat)).build(); if(getCallingActivity().getClassName().contains("AddAssetActivity")) { ACCOUNT_ID = accountId; APIKEY = apiKey; SECRET = secret; } if(isStaging) { Log.i(TAG, "Environment Set to Staging:"); OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING, Environment.PROTOCOL_HTTPS); } else { <START> OoyalaPlayer.setEnvironment(Environment.EnvironmentType.PRODUCTION, Environment.PROTOCOL_HTTPS); <END> } player = new OoyalaPlayer(pcode, playerDomain,this, options); JSONObject overrides = createSkinOverrides(); SkinOptions skinOptions = new SkinOptions.Builder().setSkinOverrides(overrides).build(); playerLayoutController = new OoyalaSkinLayoutController(getApplication(), skinLayout, player, skinOptions); playerLayoutController.addObserver(this); player.addObserver(this); if (player.setEmbedCode(embedCode)) { if(autoPlay) { player.play(); } } else { Log.e(TAG, "Asset Failure"); } } }</code><technical_language>need log too</technical_language>

Target:
void completePlayerSetup(boolean asked) { if (asked) { skinLayout = (OoyalaSkinLayout) findViewById(R.id.ooyalaSkin); PlayerDomain playerDomain = new PlayerDomain(domain); Options.Builder optionsBuilder = new Options.Builder().setShowNativeLearnMoreButton(false).setShowPromoImage(false).setUseExoPlayer(true); if(!selectedFormat.equalsIgnoreCase("default")) { optionsBuilder.setPlayerInfo(new CustomPlayerInfo(selectedFormat)).build(); } Options options = optionsBuilder.build(); if(getIntent().getExtras().getString("className").contains("AddAssetActivity")) { ACCOUNT_ID = accountId; APIKEY = apiKey; SECRET = secret; } if(isStaging) { Log.i(TAG, "Environment Set to Staging:"); OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING, Environment.PROTOCOL_HTTPS); } else { Log.i(TAG, "Environment Set to Production:"); OoyalaPlayer.setEnvironment(Environment.EnvironmentType.PRODUCTION, Environment.PROTOCOL_HTTPS); } player = new OoyalaPlayer(pcode, playerDomain,this, options); JSONObject overrides = createSkinOverrides(); SkinOptions skinOptions = new SkinOptions.Builder().setSkinOverrides(overrides).build(); playerLayoutController = new OoyalaSkinLayoutController(getApplication(), skinLayout, player, skinOptions); playerLayoutController.addObserver(this); player.addObserver(this); if (player.setEmbedCode(embedCode)) { if(autoPlay) { player.play(); } } else { Log.e(TAG, "Asset Failure"); } } }
Source:
<code>private List<ObservationUnitRow> createObservationUnitRowsGroup(final int column, final int range, final int noOfItems) { final List<ObservationUnitRow> observationUnitRows = new LinkedList<>(); for (int i = 1; i <= noOfItems; i++) { final ObservationUnitData fieldMapRangeObservationData = new ObservationUnitData(); fieldMapRangeObservationData.setValue(String.valueOf(range)); final ObservationUnitData fieldMapColumnObservationData = new ObservationUnitData(); fieldMapColumnObservationData.setValue(String.valueOf(column)); final ObservationUnitRow observationUnitRow = new ObservationUnitRow(); final Map<String, ObservationUnitData> variables = new HashMap<>(); <START> variables.put(ExperimentDao.FIELD_MAP_RANGE, fieldMapRangeObservationData); <END> variables.put(ExperimentDao.FIELD_MAP_COLUMN, fieldMapColumnObservationData); observationUnitRow.setVariables(variables); observationUnitRows.add(observationUnitRow); } return observationUnitRows; }</code><technical_language>accessing Dao classes BMSAPI</technical_language>

Target:
private List<ObservationUnitRow> createObservationUnitRowsGroup(final int column, final int range, final int noOfItems) { final List<ObservationUnitRow> observationUnitRows = new LinkedList<>(); for (int i = 1; i <= noOfItems; i++) { final ObservationUnitData fieldMapRangeObservationData = new ObservationUnitData(); fieldMapRangeObservationData.setValue(String.valueOf(range)); final ObservationUnitData fieldMapColumnObservationData = new ObservationUnitData(); fieldMapColumnObservationData.setValue(String.valueOf(column)); final ObservationUnitRow observationUnitRow = new ObservationUnitRow(); final Map<String, ObservationUnitData> variables = new HashMap<>(); variables.put(DataCollectionSorter.FIELDMAP_RANGE, fieldMapRangeObservationData); variables.put(DataCollectionSorter.FIELDMAP_COLUMN, fieldMapColumnObservationData); observationUnitRow.setVariables(variables); observationUnitRows.add(observationUnitRow); } return observationUnitRows; }
Source:
<code>public CRUDHealth checkHealth() { boolean isHealthy = true; Collection<MongoConfiguration> configs = dbResolver.getConfigurations(); Map<String, Object> details = new LinkedHashMap<>(); DBObject ping = new BasicDBObject("ping", 1); DB db = null; for (MongoConfiguration config : configs) { try { db = dbResolver.get(new MongoDataStore(config.getDatabase(), null, null)); CommandResult result = db.command(ping); if (!result.get("ok").equals(1.0)) { isHealthy = false; } else { isHealthy = true; } } catch (Exception e) { isHealthy = false; <START> details.put("stackTrace", e); <END> } details.putAll(getMongoConfigDetails(config)); } return new CRUDHealth(isHealthy, details); }</code><technical_language>Do if jackson serialize Exception instance nicely</technical_language>

Target:
public CRUDHealth checkHealth() { boolean isHealthy = true; Collection<MongoConfiguration> configs = dbResolver.getConfigurations(); Map<String, Object> details = new LinkedHashMap<>(); DBObject ping = new BasicDBObject("ping", 1); DB db = null; for (MongoConfiguration config : configs) { try { db = dbResolver.get(new MongoDataStore(config.getDatabase(), null, null)); CommandResult result = db.command(ping); if (!result.get("ok").equals(1.0)) { isHealthy = false; } else { isHealthy = true; } } catch (Exception e) { isHealthy = false; details.put("exception", e); } details.putAll(getMongoConfigDetails(config)); } return new CRUDHealth(isHealthy, details); }
Source:
<code>public DarkSuspicionsEffect() { super(Outcome.LoseLife); staticText = "that player loses X life, where X is the number of cards in that player's hand minus the number of cards in your hand."; <START> } <END></code><technical_language>need for dots end of effect text, added automatically</technical_language>

Target:
public DarkSuspicionsEffect() { super(Outcome.LoseLife); staticText = "that player loses X life, where X is the number of cards in that player's hand minus the number of cards in your hand"; }
Source:
<code>public MetadataImpl(XMPMetadata metadata, COSStream stream) { <START> this.metadata = metadata; <END> this.stream = stream; }</code><technical_language>check for null</technical_language>

Target:
public MetadataImpl(XMPMetadata metadata, COSStream stream) { if (metadata == null) { throw new IllegalArgumentException("Metadata package can not be null"); } if (stream == null) { throw new IllegalArgumentException("Metadata stream can not be null"); } this.metadata = metadata; this.stream = stream; }
Source:
<code>@Override public void checkJta() throws IgniteCheckedException { if (jtaTm == null) { try { CacheTmLookup tmLookup = tmLookupRef.get(); if (tmLookup == null) return; jtaTm = tmLookup.getTm(); } catch (Exception e) { throw new IgniteCheckedException("Failed to get transaction manager: " + e, e); } } if (jtaTm != null) { try { Transaction jtaTx = jtaTm.getTransaction(); if (jtaTx != null) { GridNearTxLocal tx = cctx.tm().userTx(); if (tx == null) { TransactionConfiguration tCfg = cctx.kernalContext().config() .getTransactionConfiguration(); tx = cctx.tm().newTx( false, false, null, tCfg.getDefaultTxConcurrency(), tCfg.getDefaultTxIsolation(), tCfg.getDefaultTxTimeout(), true, 0 ); CacheJtaResource rsrc = new CacheJtaResource(tx, cctx.kernalContext()); if (useJtaSync) jtaTx.registerSynchronization(rsrc); else if (!jtaTx.enlistResource(rsrc)) throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction."); } <START> <END> } } catch (SystemException e) { throw new IgniteCheckedException("Failed to obtain JTA transaction.", e); } catch (RollbackException e) { throw new IgniteCheckedException("Failed to enlist XAResource to JTA transaction.", e); } } }</code><technical_language>new line required</technical_language>

Target:
@Override public void checkJta() throws IgniteCheckedException { if (jtaTm == null) { try { CacheTmLookup tmLookup = tmLookupRef.get(); if (tmLookup == null) return; jtaTm = tmLookup.getTm(); } catch (Exception e) { throw new IgniteCheckedException("Failed to get transaction manager: " + e, e); } } if (jtaTm != null) { try { Transaction jtaTx = jtaTm.getTransaction(); if (jtaTx != null) { GridNearTxLocal tx = cctx.tm().userTx(); if (tx == null) { TransactionConfiguration txCfg = cctx.kernalContext().config().getTransactionConfiguration(); tx = cctx.tm().newTx( false, false, null, txCfg.getDefaultTxConcurrency(), txCfg.getDefaultTxIsolation(), txCfg.getDefaultTxTimeout(), true, 0 ); CacheJtaResource rsrc = new CacheJtaResource(tx, cctx.kernalContext()); if (useJtaSync) jtaTx.registerSynchronization(rsrc); else if (!jtaTx.enlistResource(rsrc)) throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction."); } } } catch (SystemException e) { throw new IgniteCheckedException("Failed to obtain JTA transaction.", e); } catch (RollbackException e) { throw new IgniteCheckedException("Failed to enlist XAResource to JTA transaction.", e); } } }
Source:
<code>public JumpingSumoAnimationsBrick(Animation animation) { this.animationenum = animation; <START> this.animation = animationenum.name(); <END> }</code><technical_language>call rename animationenum animation animation animationName</technical_language>

Target:
public JumpingSumoAnimationsBrick(Animation animation) { this.animation = animation; this.animationName = animation.name(); }
Source:
<code>public String toStatsDString() { StringBuilder sb = new StringBuilder(); sb.append(String.format("_sc|%s|%d", name, status)); if (timestamp > 0) { sb.append(String.format("|d:%d", timestamp)); } if (hostname != null) { sb.append(String.format("|h:%s", hostname)); } if (tags != null && tags.length > 0) { sb.append(String.format("|#%s", tags[0])); for(int i=1;i<tags.length;i++) { sb.append(',').append(tags[i]); } <START> sb.append(String.format("", hostname)); <END> } if (message != null) { sb.append(String.format("|m:%s", this.getEscapedMessage())); } return sb.toString(); }</code><technical_language>this is empty string time</technical_language>

Target:
public String toStatsDString() { StringBuilder sb = new StringBuilder(); sb.append(String.format("_sc|%s|%d", name, status)); if (timestamp > 0) { sb.append(String.format("|d:%d", timestamp)); } if (hostname != null) { sb.append(String.format("|h:%s", hostname)); } if (tags != null && tags.length > 0) { sb.append(String.format("|#%s", tags[0])); for(int i=1;i<tags.length;i++) { sb.append(',').append(tags[i]); } } if (message != null) { sb.append(String.format("|m:%s", this.getEscapedMessage())); } return sb.toString(); }
Source:
<code>public void processAst(IASTTranslationUnit ast) { list = (Object[]) getPreference(getProblemById(ERR_ID, getFile()), PARAM_BLACKLIST); if (list == null || list.length == 0) return; Arrays.sort(list); ast.accept(new ASTVisitor() { { shouldVisitNames = true; } @Override public int visit(IASTName name) { IBinding binding = name.resolveBinding(); <START> if (binding instanceof ICPPFunction) { <END> ICPPFunction method = (ICPPFunction) binding; try { if (isInBlackList(String.join("::", method.getQualifiedName()))) reportProblem(ERR_ID, name); } catch (DOMException e) { CodanCheckersActivator.log(e); } } else if (binding instanceof IFunction) { if (isInBlackList(binding.getName())) reportProblem(ERR_ID, name); } return PROCESS_CONTINUE; } }); }</code><technical_language>extract a helper function "String getBindingQualifiedName(IBinding)" simplify code a bit</technical_language>

Target:
public void processAst(IASTTranslationUnit ast) { Object[] list = (Object[]) getPreference(getProblemById(ERR_ID, getFile()), PARAM_BLACKLIST); if (list == null || list.length == 0) return; Arrays.sort(list); ast.accept(new ASTVisitor() { { shouldVisitNames = true; } @Override public int visit(IASTName name) { IBinding binding = name.resolveBinding(); String completeName = getBindingQualifiedName(binding); if (completeName != null && Arrays.binarySearch(list, completeName) >= 0) reportProblem(ERR_ID, name, completeName); return PROCESS_CONTINUE; } }); }
Source:
<code>public void Soap(){ String actionSet = "Consume SOAP Web Service"; String project_SOAP_name = "SOAP_Web"; String model_SOAP_name = "soapSourceModel"; String view_SOAP_name = "soapViewModel"; String vdb_SOAP_name = "SOAP_VDB"; String test_SQL = "exec FullCountryInfo('US')"; String test_SQL2 = "exec FullCountryInfoAllCountries()"; String soapProfile = "SOAP_WS"; guides.createProjectViaGuides(actionSet, project_SOAP_name); guides.chooseAction(actionSet, "Create Web "); DefaultShell cp = new DefaultShell("New Connection Profile"); new LabeledText("Name:").setText(soapProfile); new PushButton(cp, "Next >").click(); WsdlConnectionProfileWizard.getInstance() <START> .setWsdl("<LINK_0>") <END> .testConnection() .nextPage() .setEndPoint("Countries") .finish(); guides.chooseAction(actionSet, "Generate "); new DefaultShell("Create Relational Model from Web Service"); wsdlImportWizard(soapProfile, model_SOAP_name, view_SOAP_name); guides.previewDataViaActionSet(actionSet, project_SOAP_name, view_SOAP_name+".xmi","FullCountryInfoAllCountries"); assertTrue(testLastPreview()); guides.defineVDB(actionSet, project_SOAP_name, vdb_SOAP_name, view_SOAP_name); assertTrue(guides.editVDB(actionSet, project_SOAP_name, vdb_SOAP_name)); List<Integer> results = guides.executeVDB(actionSet, teiidServer, vdb_SOAP_name,test_SQL,test_SQL2); assertEquals(Integer.valueOf(1),results.get(0)); assertEquals(Integer.valueOf(3),results.get(1)); }</code><technical_language>Do internal url in public tests</technical_language>

Target:
public void Soap(){ String actionSet = "Consume SOAP Web Service"; String project_SOAP_name = "SOAP_Web"; String model_SOAP_name = "soapSourceModel"; String view_SOAP_name = "soapViewModel"; String vdb_SOAP_name = "SOAP_VDB"; String test_SQL = "exec FullCountryInfo('US')"; String test_SQL2 = "exec FullCountryInfoAllCountries()"; guides.createProjectViaGuides(actionSet, project_SOAP_name); guides.chooseAction(actionSet, "Create Web "); DefaultShell cp = new DefaultShell("New Connection Profile"); new CancelButton(cp).click(); guides.chooseAction(actionSet, "Generate "); new DefaultShell("Create Relational Model from Web Service"); wsdlImportWizard(ConnectionProfileConstants.SOAP, model_SOAP_name, view_SOAP_name); guides.previewDataViaActionSet(actionSet, project_SOAP_name, view_SOAP_name+".xmi","FullCountryInfoAllCountries"); assertTrue(testLastPreview()); guides.defineVDB(actionSet, project_SOAP_name, vdb_SOAP_name, view_SOAP_name); assertTrue(guides.editVDB(actionSet, project_SOAP_name, vdb_SOAP_name)); List<Integer> results = guides.executeVDB(actionSet, teiidServer, vdb_SOAP_name,test_SQL,test_SQL2); assertEquals(Integer.valueOf(1),results.get(0)); assertEquals(Integer.valueOf(3),results.get(1)); }
Source:
<code>protected void performCall() { Object service; try { service = getService(call.getService()); } catch (OsgiServiceNotAvailableException e1) { handleExceptionWithFeedback(e1); return; } <START> Method m; <END> try { m = getMethodOfService(service,call.getMethod()); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException(ex); } if(m == null){ return; } try { Object result = m.invoke(service, call.getArgumentsAsArray()); info("Methodcall called successfully"); Class<?> returnType = m.getReturnType(); if (returnType.equals(void.class)) { return; } String resultString; if (returnType.isArray()) { try { Constructor<String> constructor = String.class.getConstructor(returnType); resultString = constructor.newInstance(result); } catch (Exception e) { resultString = ArrayUtils.toString(result); } } else { resultString = result.toString(); } info("Result " + returnType.getName() + ": " + resultString); LOGGER.info("result: {}", resultString); } catch (IllegalAccessException e) { handleExceptionWithFeedback(e); } catch (InvocationTargetException e) { handleExceptionWithFeedback(e.getCause()); } }</code><technical_language>method name; m is hard read in src</technical_language>

Target:
protected void performCall() { Object service; try { service = getService(call.getService()); } catch (OsgiServiceNotAvailableException e1) { handleExceptionWithFeedback(e1); return; } Method method; try { method = getMethodOfService(service,call.getMethod()); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException(ex); } if(method == null){ return; } try { Object result = method.invoke(service, call.getArgumentsAsArray()); info("Methodcall called successfully"); Class<?> returnType = method.getReturnType(); if (returnType.equals(void.class)) { return; } String resultString; if (returnType.isArray()) { try { Constructor<String> constructor = String.class.getConstructor(returnType); resultString = constructor.newInstance(result); } catch (Exception e) { resultString = ArrayUtils.toString(result); } } else { resultString = result.toString(); } info("Result " + returnType.getName() + ": " + resultString); LOGGER.info("result: {}", resultString); } catch (IllegalAccessException e) { handleExceptionWithFeedback(e); } catch (InvocationTargetException e) { handleExceptionWithFeedback(e.getCause()); } }