auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private String getExceptionResponseHtml(Throwable throwable, int statusCode, String message, String report, StringManager smClient) { if (exceptionResponseHtml != null) { return exceptionResponseHtml; } String redirectHtmlPath = null; FileInputStream fis; try { redirectHtmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "resources" + File.separator + "identity" + File.separator + "pages" + <START> File.separator + "oauth2_server_error_response.html"; <END> fis = new FileInputStream(new File(redirectHtmlPath)); exceptionResponseHtml = new Scanner(fis, "UTF-8").useDelimiter("\\A").next(); } catch (FileNotFoundException e) { if (log.isDebugEnabled()) { log.debug("Showing default error page, " + "\'" + redirectHtmlPath + "\' not found"); } exceptionResponseHtml = buildDefaultErrorResponse(throwable, statusCode, message, report, smClient); } return exceptionResponseHtml; }</code><technical_language>This is a valve. a generic page</technical_language>

Target:
private String getExceptionResponseHtml(Throwable throwable, int statusCode, String message, String report, StringManager smClient) { if (exceptionResponseHtml != null) { return exceptionResponseHtml; } String redirectHtmlPath = null; FileInputStream fis; try { redirectHtmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "resources" + File.separator + "identity" + File.separator + "pages" + File.separator + "server_error_response.html"; fis = new FileInputStream(new File(redirectHtmlPath)); exceptionResponseHtml = new Scanner(fis, "UTF-8").useDelimiter("\\A").next(); } catch (FileNotFoundException e) { if (log.isDebugEnabled()) { log.debug("Showing default error page, " + "\'" + redirectHtmlPath + "\' not found"); } exceptionResponseHtml = buildDefaultErrorResponse(throwable, statusCode, message, report, smClient); } return exceptionResponseHtml; }
Source:
<code>private void initUnregisteredEntity(Guid entityId, Guid storageDomainId) { <START> if (!isUnregisteredEntityExists()) { <END> List<OvfEntityData> ovfEntityList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(entityId, storageDomainId); if (!ovfEntityList.isEmpty()) { ovfEntityData = ovfEntityList.get(0); try { setUnregisteredEntityAndImages(); } catch (OvfReaderException e) { log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData()); log.debug("Exception: ", e); } } } }</code><technical_language>convert early return log, a bit clearer</technical_language>

Target:
private void initUnregisteredEntity(Guid entityId, Guid storageDomainId) { List<OvfEntityData> ovfEntityList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(entityId, storageDomainId); if (!ovfEntityList.isEmpty()) { ovfEntityData = ovfEntityList.get(0); try { setUnregisteredEntityAndImages(); } catch (OvfReaderException e) { log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData()); log.debug("Exception: ", e); } } }
Source:
<code>public Task assign(AssignTaskPayload assignTaskPayload) { Task task; try { <START> task = task(assignTaskPayload.getTaskId()); <END> } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot assign task" + assignTaskPayload.getTaskId() + " due it is not a candidate for it"); } if (task.getAssignee() != null && !task.getAssignee().isEmpty()) { taskService.unclaim(assignTaskPayload.getTaskId()); } taskService.claim(assignTaskPayload.getTaskId(), assignTaskPayload.getAssignee()); return task(assignTaskPayload.getTaskId()); }</code><technical_language>@CTI777 need change this.. admin already.. do if task is assigned admin</technical_language>

Target:
public Task assign(AssignTaskPayload assignTaskPayload) { taskService.unclaim(assignTaskPayload.getTaskId()); taskService.claim(assignTaskPayload.getTaskId(), assignTaskPayload.getAssignee()); return task(assignTaskPayload.getTaskId()); }
Source:
<code>public synchronized Collection<MetaAnnotation> getAnnotations() { final Annotation[] array; <START> if (annotationsCache != null) { <END> array = annotationsCache; } else { array = annotationsCache = constructor.getAnnotations(); } return Arrays.stream(array).map(JavaReflectionAnnotation::new).collect(Collectors.toList()); }</code><technical_language>note for previous annotation cache</technical_language>

Target:
public Collection<MetaAnnotation> getAnnotations() { return Arrays.stream(constructor.getAnnotations()).map(JavaReflectionAnnotation::new).collect(toList()); }
Source:
<code>private String getName(PublicizeConnection connection) { String name = connection.getExternalDisplayName(); <START> if (name.isEmpty()) { <END> name = connection.getExternalName(); } return name; }</code><technical_language>TextUtils.isEmpty(name) null a possibility</technical_language>

Target:
private String getName(PublicizeConnection connection) { String name = connection.getExternalName(); if (name.isEmpty()) { name = connection.getExternalDisplayName(); } return name; }
Source:
<code><START> public boolean equalsTypeElementWithType(ATypeElementWithType o) { <END> return super.equals(o) && o.type.equals(type); }</code><technical_language>Hi, I thought changing name classes in AElement hierarchy double dispatching mechanism looked a convention, double dispatching mechanism is more clear Michael. This class is for equals method anywhere, familiar complete codebase I thought error prone change public api of class, I changed name change equals(Object) calls correct method. I do merged equals method in a branch. I a pull request it</technical_language>

Target:
public boolean equalsTypeElementWithType(ATypeElementWithType o) { return super.equals(o) && (o.type == null ? type == null : o.type.equals(type)); }
Source:
<code>public static void setUpValidator() { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); validator = factory.getValidator(); telephoneRequestBuilder .amount(1200) .description("Some description") .reference("Some reference") .createdDate("2018-02-21T16:04:25Z") .authorisedDate("2018-02-21T16:05:33Z") .authCode("666") .processorId("1PROC") .providerId("1PROV") .lastFourDigits("1234") .firstSixDigits("123456") .cardExpiry("01/13") .cardType("visa") .nameOnCard("Jane Doe") .emailAddress("jane_doe@example.com") <START> .telephoneNumber("+447700900796"); <END> }</code><technical_language>good practice for unit tests is minimal required data</technical_language>

Target:
public static void setUpValidator() { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); validator = factory.getValidator(); telephoneRequestBuilder .withAmount(1200) .withDescription("Some description") .withReference("Some reference") .withCreatedDate("2018-02-21T16:04:25Z") .withAuthorisedDate("2018-02-21T16:05:33Z") .withAuthCode("666") .withProcessorId("1PROC") .withProviderId("1PROV") .withLastFourDigits("1234") .withFirstSixDigits("123456") .withCardExpiry("01/13") .withCardType("visa") .withNameOnCard("Jane Doe") .withEmailAddress("jane_doe@example.com") .withTelephoneNumber("+447700900796"); }
Source:
<code><START> public Object call(ApiCaller ac, Deserializer parms) throws PerunException { <END> return ac.getDatabaseManager().getTimeOfQueryPerformance(ac.getSession()); }</code><technical_language>Please change return type of method Long: suggestion public Long call(ApiCaller ac, Deserializer parms) throws PerunException {</technical_language>

Target:
public Object call(ApiCaller ac, Deserializer parms) throws PerunException { return ac.getDatabaseManager().getCurrentDatabaseVersion(ac.getSession()); }
Source:
<code>public void testPrepRequestProcessorMetrics() throws Exception { PrepRequestProcessor prepRequestProcessor = new PrepRequestProcessor(zks, nextProcessor); PrepRequestProcessor.skipACL = true; prepRequestProcessor.processRequest(createRequest("/foo", ZooDefs.OpCode.setData)); prepRequestProcessor.processRequest(createRequest("/foo/bar", ZooDefs.OpCode.delete)); prepRequestProcessor.processRequest(createRequest(2, ZooDefs.OpCode.closeSession)); Map<String, Object> values = ServerMetrics.getAllValues(); Assert.assertEquals(3L, values.get("prep_processor_request_queued")); prepRequestProcessor.start(); <START> Thread.sleep(500); <END> values = ServerMetrics.getAllValues(); Assert.assertEquals(3L, values.get("max_prep_processor_queue_size")); Assert.assertThat((long)values.get("min_prep_processor_queue_time_ms"), greaterThan(0l)); Assert.assertEquals(3L, values.get("cnt_prep_processor_queue_time_ms")); Assert.assertEquals(3L, values.get("cnt_prep_process_time")); Assert.assertThat((long)values.get("max_prep_process_time"), greaterThan(0l)); Assert.assertEquals(1L, values.get("cnt_close_session_prep_time")); Assert.assertThat((long)values.get("max_close_session_prep_time"), greaterThanOrEqualTo(0L)); Assert.assertEquals(5L, values.get("outstanding_changes_queued")); }</code><technical_language>Mentioned lots of times sleeping in unit tests is a good practice. (not in production code either) Please try sync latches drop tests instead of introducing new flakies</technical_language>

Target:
public void testPrepRequestProcessorMetrics() throws Exception { CountDownLatch threeRequests = new CountDownLatch(3); doAnswer(invocationOnMock -> { threeRequests.countDown(); return null;}).when(nextProcessor).processRequest(any(Request.class)); PrepRequestProcessor prepRequestProcessor = new PrepRequestProcessor(zks, nextProcessor); PrepRequestProcessor.skipACL = true; prepRequestProcessor.processRequest(createRequest("/foo", ZooDefs.OpCode.setData)); prepRequestProcessor.processRequest(createRequest("/foo/bar", ZooDefs.OpCode.delete)); prepRequestProcessor.processRequest(createRequest(2, ZooDefs.OpCode.closeSession)); Map<String, Object> values = MetricsUtils.currentServerMetrics(); Assert.assertEquals(3L, values.get("prep_processor_request_queued")); prepRequestProcessor.start(); threeRequests.await(500, TimeUnit.MILLISECONDS); values = MetricsUtils.currentServerMetrics(); Assert.assertEquals(3L, values.get("max_prep_processor_queue_size")); Assert.assertThat((long)values.get("min_prep_processor_queue_time_ms"), greaterThan(0l)); Assert.assertEquals(3L, values.get("cnt_prep_processor_queue_time_ms")); Assert.assertEquals(3L, values.get("cnt_prep_process_time")); Assert.assertThat((long)values.get("max_prep_process_time"), greaterThan(0l)); Assert.assertEquals(1L, values.get("cnt_close_session_prep_time")); Assert.assertThat((long)values.get("max_close_session_prep_time"), greaterThanOrEqualTo(0L)); Assert.assertEquals(5L, values.get("outstanding_changes_queued")); }
Source:
<code>public DublinCoreSchemaImpl(DublinCoreSchema schema, Metadata metadata) { <START> this.schema = schema; <END> this.metadata = metadata; }</code><technical_language>check</technical_language>

Target:
public DublinCoreSchemaImpl(DublinCoreSchema schema, Metadata metadata) { if (schema == null) { throw new IllegalArgumentException("DublinCore schema representation can not be null"); } if (metadata == null) { throw new IllegalArgumentException("Metadata representation can not be null"); } this.schema = schema; this.metadata = metadata; }
Source:
<code>public void testSslHandshakeTimeoutHappenedWhenUpgradeSsl() { server.close(); client.close(); NetServerOptions serverOptions = new NetServerOptions() .setSsl(false); server = vertx.createNetServer(serverOptions); NetClientOptions clientOptions = new NetClientOptions() .setSsl(false) .setTrustAll(true) .setSslHandshakeTimeout(200) .setSslHandshakeTimeoutUnit(TimeUnit.MILLISECONDS); client = vertx.createNetClient(clientOptions); server.connectHandler(s -> { }).listen(testAddress, ar -> { assertTrue(ar.succeeded()); client.connect(testAddress, res -> { assertTrue(res.succeeded()); NetSocket socket = res.result(); assertFalse(socket.isSsl()); socket.upgradeToSsl(v -> { fail("this should never be called"); assertFalse(socket.isSsl()); }); <START> vertx.setTimer(2000, id -> { <END> testComplete(); }); }); }); await(); }</code><technical_language>this test a timer, instead set exception handler NetSocket get called upgrade fails, this is faster more reliable</technical_language>

Target:
public void testSslHandshakeTimeoutHappenedWhenUpgradeSsl() { server.close(); client.close(); NetServerOptions serverOptions = new NetServerOptions() .setSsl(false); server = vertx.createNetServer(serverOptions); NetClientOptions clientOptions = new NetClientOptions() .setSsl(false) .setTrustAll(true) .setSslHandshakeTimeout(200) .setSslHandshakeTimeoutUnit(TimeUnit.MILLISECONDS); client = vertx.createNetClient(clientOptions); server.connectHandler(s -> { }).listen(testAddress, ar -> { assertTrue(ar.succeeded()); client.connect(testAddress, res -> { assertTrue(res.succeeded()); NetSocket socket = res.result(); assertFalse(socket.isSsl()); socket.upgradeToSsl(v -> { fail("this should never be called because of failure of handshake"); }); socket.exceptionHandler(err -> { assertTrue(err instanceof SSLException); assertEquals("handshake timed out", err.getMessage()); testComplete(); }); }); }); await(); }
Source:
<code>public void registerKfsPvenApprovalForExistingPaymentWorksVendor(String kfsVendorDocumentNumber, VendorDetail vendorDetail) { PaymentWorksVendor pmwVendor = getPaymentWorksVendorByDocumentNumber(kfsVendorDocumentNumber); if (ObjectUtils.isNotNull(pmwVendor)) { LOG.info("registerKfsPvenApprovalForExistingPaymentWorksVendor: Approving PaymentWorks originating Vendor with table ID '" + pmwVendor.getId() + "' and kfsVendorDocumentNumber '" + kfsVendorDocumentNumber + "' and pmwVendorRequestId '" + pmwVendor.getPmwVendorRequestId() + "' and vendor number '"); getPaymentWorksVendorDao().updateExistingPaymentWorksVendorInStagingTable(pmwVendor.getId(), PaymentWorksConstants.KFSVendorProcessingStatus.VENDOR_APPROVED, vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), PaymentWorksConstants.SupplierUploadStatus.PENDING_PAAT, getDateTimeService().getCurrentTimestamp()); <START> } else { <END> LOG.error("registerKfsPvenApprovalForExistingPaymentWorksVendor: PaymentWorks staging table retrieval by KFS document number '" + kfsVendorDocumentNumber + "' failed to find vendor to set KFS Approve status values."); } }</code><technical_language>For consistency other status values set, I do SupplierUploadStatus set here. is appropriately set in service class PaymentWorksNewVendorPayeeAchServiceImpl in method setStatusValuesForPaymentWorksProcessedNewVendorKfsVendorCreatedAchPendingPven upload PMW happen for a vendor originating in PMW happen PAAT batch job runs</technical_language>

Target:
public void registerKfsPvenApprovalForExistingPaymentWorksVendor(String kfsVendorDocumentNumber, VendorDetail vendorDetail) { PaymentWorksVendor pmwVendor = getPaymentWorksVendorByDocumentNumber(kfsVendorDocumentNumber); if (ObjectUtils.isNotNull(pmwVendor)) { LOG.info("registerKfsPvenApprovalForExistingPaymentWorksVendor: Approving PaymentWorks originating Vendor with table ID '" + pmwVendor.getId() + "' and kfsVendorDocumentNumber '" + kfsVendorDocumentNumber + "' and pmwVendorRequestId '" + pmwVendor.getPmwVendorRequestId() + "' and vendor number '"); getPaymentWorksVendorDao().updateExistingPaymentWorksVendorInStagingTable(pmwVendor.getId(), PaymentWorksConstants.KFSVendorProcessingStatus.VENDOR_APPROVED, vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), getDateTimeService().getCurrentTimestamp()); } else { LOG.error("registerKfsPvenApprovalForExistingPaymentWorksVendor: PaymentWorks staging table retrieval by KFS document number '" + kfsVendorDocumentNumber + "' failed to find vendor to set KFS Approve status values."); } }
Source:
<code>public void testFetchAllProjects() throws ProjectManagerException { System.out.println("projectManagerTest: testFetchAllProjects"); ProjectManager manager = createProjectManager(); String projectName1 = "myTestFetchAllProjects_1"; String projectDescription1 = "This is to test fetching all projects: project_1"; User user = new User("testUser"); Project project1 = createProjectUtil(manager, projectName1, projectDescription1, user); String projectName2 = "myTestFetchAllProjects_2"; String projectDescription2 = "This is to test fetching all projects: project_2"; Project project2 = createProjectUtil(manager, projectName2, projectDescription2, user); List<Project> fetchedProjects = manager.getProjects(); Assert.assertTrue("Fetched project_1", fetchedProjects.contains(project1)); Assert.assertTrue("Fetched project_2", fetchedProjects.contains(project2)); <START> System.out.println("Fetched all projects successfully"); <END> }</code><technical_language>Is this log necessary</technical_language>

Target:
public void testFetchAllProjects() throws Exception { System.out.println("TestFetchAllProjects"); List<Project> projects = new ArrayList<>(); Project new_project1 = manager.createProject(PROJECT_NAME, PROJECT_DESCRIPTION, user); Project project2 = new Project(PROJECT_ID_2, PROJECT_NAME_2); project2.setDescription(PROJECT_DESCRIPTION); project2.setActive(true); project2.setVersion(PROJECT_VERSION); when(loader.createNewProject(PROJECT_NAME_2, PROJECT_DESCRIPTION, user)).thenReturn(project2); Project new_project2 = manager.createProject(PROJECT_NAME_2, PROJECT_DESCRIPTION, user); projects.add(new_project1); projects.add(new_project2); when(loader.fetchAllActiveProjects()).thenReturn(projects); List<Project> fetchedProjects = manager.getProjects(); Assert.assertEquals("Fetched projects: ", projects, fetchedProjects); }
Source:
<code>public static void main(String[] args) { <START> LocalQueryRunner queryRunner = createLocalQueryRunner(ImmutableMap.of("reorder_joins", "false")); <END> new SqlConsecutiveJoinBenchmark(queryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); }</code><technical_language>Technically, queryRunner.close() (or t-w-r). This ensure proper cleanup of temp files (or whatevers) created</technical_language>

Target:
public static void main(String[] args) { LocalQueryRunner queryRunner = createLocalQueryRunner(ImmutableMap.of("reorder_joins", "false")); new SqlConsecutiveJoinBenchmark(queryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); queryRunner.close(); }
Source:
<code>public String getSuggestedLabel() { final Date highestValue = getHighestValue(); final Date lowestValue = getLowestValue(); if (highestValue == null || lowestValue == null) { return null; } <START> final InputColumn column = getColumn(); <END> if (column == null) { return null; } return getDateLabel(lowestValue) + " =< " + column.getName() + " =< " + getDateLabel(highestValue); }</code><technical_language>InputColumn is a raw type. References generic type InputColumn<E> parameterized</technical_language>

Target:
public String getSuggestedLabel() { final Date highestValue = getHighestValue(); final Date lowestValue = getLowestValue(); if (highestValue == null || lowestValue == null) { return null; } final InputColumn<Date> column = getColumn(); if (column == null) { return null; } return getDateLabel(lowestValue) + " =< " + column.getName() + " =< " + getDateLabel(highestValue); }
Source:
<code>private boolean readMessageHeader(ByteBuffer peerDataBuffer) throws IOException { int headerStartPos = peerDataBuffer.position(); messageLength = peerDataBuffer.getInt(); calcHdrVersion(messageLength); messageLength = calcMsgByteSize(messageLength); messageType = peerDataBuffer.get(); messageId = peerDataBuffer.getShort(); directAck = (messageType & DIRECT_ACK_BIT) != 0; if (directAck) { messageType &= ~DIRECT_ACK_BIT; } if (!validMsgType(messageType)) { Integer nioMessageTypeInteger = (int) messageType; logger.fatal("Unknown P2P message type: {}", nioMessageTypeInteger); <START> readerShuttingDown = true; <END> requestClose(String.format("Unknown P2P message type: %s", nioMessageTypeInteger)); return false; } lengthSet = true; peerDataBuffer.position(headerStartPos); return true; }</code><technical_language>obvious this bool is flipped..</technical_language>

Target:
private boolean readMessageHeader(ByteBuffer peerDataBuffer) throws IOException { int headerStartPos = peerDataBuffer.position(); messageLength = peerDataBuffer.getInt(); throwExceptionIfWrongMessageVersion(messageLength); messageLength = calcMsgByteSize(messageLength); messageType = peerDataBuffer.get(); messageId = peerDataBuffer.getShort(); directAck = (messageType & DIRECT_ACK_BIT) != 0; if (directAck) { messageType &= ~DIRECT_ACK_BIT; } if (!validMsgType(messageType)) { Integer nioMessageTypeInteger = (int) messageType; logger.fatal("Unknown P2P message type: {}", nioMessageTypeInteger); readerShuttingDown = true; requestClose(String.format("Unknown P2P message type: %s", nioMessageTypeInteger)); return false; } lengthSet = true; peerDataBuffer.position(headerStartPos); return true; }
Source:
<code>private static List<String> formatList(JSONArray array) { List<String> result = new ArrayList<String>(); if (array != null) { for (int i = 0; i < array.size(); i++) { <START> result.add(array.getJSONObject(i).getString(SuggestConstants.LABEL)); <END> } } return result; }</code><technical_language>Select2Common -> SuggestConstants do rest of changes</technical_language>

Target:
private static List<String> formatList(JSONArray array) { List<String> result = new ArrayList<String>(); if (array != null) { for (int i = 0; i < array.size(); i++) { result.add(array.getJSONObject(i).getString(Select2Common.LABEL)); } } return result; }
Source:
<code>public static void setUp() throws Exception { if (!SystemUtils.IS_OS_WINDOWS) { ExecutionPermission.setExecutePermission(script); } FileLoader.createConfigProjectsFileForCalendarHierarchyTests(); MockDatabase.startNode(); MockDatabase.insertProcessesFull(); MockDatabase.insertProcessForCalendarHierarchyTests(); MockDatabase.setUpAwaitility(); fileService.createDirectory(URI.create(""), "1"); SecurityTestUtils.addUserDataToSecurityContext(ServiceManager.getUserService().getById(1), 1); <START> while (Objects.isNull(processService.findByTitle(firstProcess))) { <END> Thread.sleep(256); } }</code><technical_language>please await() in other serviceTests e.g.: <LINK_0></technical_language>

Target:
public static void setUp() throws Exception { if (!SystemUtils.IS_OS_WINDOWS) { ExecutionPermission.setExecutePermission(script); } FileLoader.createConfigProjectsFileForCalendarHierarchyTests(); MockDatabase.startNode(); MockDatabase.insertProcessesFull(); MockDatabase.insertProcessForCalendarHierarchyTests(); MockDatabase.setUpAwaitility(); fileService.createDirectory(URI.create(""), "1"); SecurityTestUtils.addUserDataToSecurityContext(ServiceManager.getUserService().getById(1), 1); Awaitility.await().untilTrue(new AtomicBoolean(Objects.nonNull(processService.findByTitle(firstProcess)))); }
Source:
<code>public void setOnClosedByKeyboardCallback(final Consumer callback) { <START> if (Objects.isNull(callback)) { <END> closedByKeyboardCallback = Optional.empty(); } else { closedByKeyboardCallback = Optional.of(callback); } }</code><technical_language>Optional.ofNullable(..) replace need for this if statement</technical_language>

Target:
public void setOnClosedByKeyboardCallback(final Consumer callback) { closedByKeyboardCallback = Optional.ofNullable(callback); }
Source:
<code>public void resolve_hasAnnotations_hasNoCookieParams() { HasAnnotations hasAnnotations = mock(HasAnnotations.class); String value = resolver.resolve(hasAnnotations); <START> assertThat(value).isEqualTo(SOME_VALUE); <END> }</code><technical_language>I assert is null. assert is throwing NPE</technical_language>

Target:
public void resolve_hasAnnotations_hasNoCookieParams() { HasAnnotations hasAnnotations = mock(HasAnnotations.class); resolver.resolve(hasAnnotations); }
Source:
<code>public void setUp() throws Exception { super.setUp(); <START> localPhone = new ClippingDto().setContent("+919876543210") <END> .setType(ClippingDto.ClippingType.PHONE_NUMBER) .setClippingProvider(ClippingDto.ClippingProvider.LOCAL).setCreateAt(new Date()) .setDeviceId("uniqueId"); remoteAddress = new ClippingDto(localPhone).setContent("H.No. 22/7, India") .setType(ClippingDto.ClippingType.ADDRESS) .setClippingProvider(ClippingDto.ClippingProvider.CLOUD); context = DroidOmniApplication_.getAppContext(); }</code><technical_language>name is poorly chose, object created is a Phone is a clipping name localClipping, content of clipping is relevant for test</technical_language>

Target:
public void setUp() throws Exception { super.setUp(); context = DroidOmniApplication_.getAppContext(); }
Source:
<code>public static BuddyDisconnectMessageDTO createInstance(UserDTO actingUser, BuddyDisconnectMessage messageEntity) { User userEntity = messageEntity.getUser(); <START> return new BuddyDisconnectMessageDTO(messageEntity.getID(), messageEntity.getCreationTime(), <END> UserDTO.createInstance(userEntity), messageEntity.getRelatedUserAnonymizedID(), messageEntity.getNickname(), messageEntity.getMessage(), messageEntity.getReason(), messageEntity.isProcessed()); }</code><technical_language>If retain line, API contract for createInstance regular: UserDTO user = userEntity == null ? null : UserDTO.createInstance(userEntity);</technical_language>

Target:
public static BuddyDisconnectMessageDTO createInstance(UserDTO actingUser, BuddyDisconnectMessage messageEntity) { return new BuddyDisconnectMessageDTO(messageEntity.getID(), messageEntity.getCreationTime(), UserDTO.createInstanceIfNotNull(messageEntity.getUser()), messageEntity.getRelatedUserAnonymizedID(), messageEntity.getNickname(), messageEntity.getMessage(), messageEntity.getReason(), messageEntity.isProcessed()); }
Source:
<code>private static synchronized Properties getProperties() { if (properties != null) { return properties; } properties = new Properties(); try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(MESSAGES_PROPERTIES_PATH)) { properties.load(inputStream); } catch (IOException exception) { <START> LOGGER.error("Error loading message properties {}", Messages.class, exception); END> } return properties; }</code><technical_language>if unable load inputStream.. Do messages show? rethrowing this IOException? @JonathanGiles</technical_language>

Target:
private static synchronized Properties getProperties() { if (properties != null) { return properties; } properties = new Properties(); try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(MESSAGES_PROPERTIES_PATH)) { if (inputStream != null) { properties.load(inputStream); } else { LOGGER.error("Message properties not found", MESSAGES_PROPERTIES_PATH); } } catch (IOException exception) { LOGGER.error("Error loading message properties [{}]", MESSAGES_PROPERTIES_PATH, exception); } return properties; }
Source:
<code>public Settings getState() { <START> System.out.println(pathToProjectContainer); <END> return this; }</code><technical_language>remove this</technical_language>

Target:
public Settings getState() { return this; }
Source:
<code><START> private List<String> verifyFileInDestinations(MountTable entry) <END> throws IOException { GetDestinationRequest request = GetDestinationRequest.newInstance(entry.getSourcePath()); List<RemoteLocation> locations = entry.getDestinations(); List<String> nsId = getDestinationNameServices(request, locations); Set<String> destNs = new HashSet<>(nsId); List<String> nsWithoutFile = new ArrayList<>(); for (RemoteLocation location : locations) { String ns = location.getNameserviceId(); if (!destNs.contains(ns)) { nsWithoutFile.add(ns); } } return nsWithoutFile; }</code><technical_language>I unit tests for this function if possible</technical_language>

Target:
public List<String> verifyFileInDestinations(MountTable entry) throws IOException { GetDestinationRequest request = GetDestinationRequest.newInstance(entry.getSourcePath()); List<RemoteLocation> locations = entry.getDestinations(); List<String> nsId = getDestinationNameServices(request, locations); Set<String> destNs = new HashSet<>(nsId); List<String> nsWithoutFile = new ArrayList<>(); for (RemoteLocation location : locations) { String ns = location.getNameserviceId(); if (!destNs.contains(ns)) { nsWithoutFile.add(ns); } } return nsWithoutFile; }
Source:
<code>public void setJobToStatus(String theJobUUID, BulkJobStatusEnum theStatus) { Optional<BulkExportJobEntity> oJob = myBulkExportJobDao.findByJobId(theJobUUID); if (!oJob.isPresent()) { <START> ourLog.error("Job doesn't exist!"); <END> } else { ourLog.info("Setting job with UUID to {}", theJobUUID, theStatus); BulkExportJobEntity bulkExportJobEntity = oJob.get(); bulkExportJobEntity.setStatus(theStatus); myBulkExportJobDao.save(bulkExportJobEntity); } }</code><technical_language>warn name it</technical_language>

Target:
public void setJobToStatus(String theJobUUID, BulkJobStatusEnum theStatus) { Optional<BulkExportJobEntity> oJob = myBulkExportJobDao.findByJobId(theJobUUID); if (!oJob.isPresent()) { ourLog.error("Job with UUID doesn't exist!", theJobUUID); return; } ourLog.info("Setting job with UUID to {}", theJobUUID, theStatus); BulkExportJobEntity bulkExportJobEntity = oJob.get(); bulkExportJobEntity.setStatus(theStatus); myBulkExportJobDao.save(bulkExportJobEntity); }
Source:
<code>public Map<String, Serializable> getAllVariablesWithTaskResult(TaskContext taskContext, TaskResult taskResult) { Map<String, Serializable> variables = new HashMap<>(); try { variables = extractAllVariables(taskContext, taskResult, ""); } catch (IOException | ClassNotFoundException e) { <START> logger.error("Error reading variables from task context!"); <END> } return resolveVariables(variables, variables); }</code><technical_language>log exception</technical_language>

Target:
public Map<String, Serializable> getAllVariablesWithTaskResult(TaskContext taskContext, TaskResult taskResult) { Map<String, Serializable> variables = new HashMap<>(); try { variables = extractAllVariables(taskContext, taskResult, ""); } catch (IOException | ClassNotFoundException e) { logger.error(ERROR_READING_VARIABLES, e); } return resolveVariables(variables, variables); }
Source:
<code>private void renderHtmlArtifact(StringBuilder output, Artifact artifact) throws Exception { String htmlContent = ""; String blankLine = "<br /><br />"; String underline = "<span style=\"text-decoration: underline;\">"; String underlineEnd = "</span>"; Collection<IAttributeType> types = artifact.getAttributeTypes(); for (IAttributeType type : types) { if (type.equals(CoreAttributeTypes.HTMLContent)) { htmlContent = artifact.getAttributesToString(type); } else if (type.equals(CoreAttributeTypes.ImageContent)) { } else { try { String attributeValue = artifact.getAttributesToString(type); if (Strings.isValid(attributeValue)) { <START> output.append(blankLine + underline + type.getName() + underlineEnd + ": " + attributeValue); <END> } } catch (Exception ex) { } } } output.append(blankLine + htmlContent); }</code><technical_language>concatenate strings + a stringbuilder, call append multiple times. Example: output.append(blankLine).append(underline)....etc. output.append(blankLine); output.append(underline); etc..</technical_language>

Target:
private void renderHtmlArtifact(StringBuilder output, Artifact artifact) throws Exception { String htmlContent = ""; String blankLine = "<br /><br />"; String underline = "<span style=\"text-decoration: underline;\">"; String underlineEnd = "</span>"; Collection<AttributeType> types = artifact.getAttributeTypesUsed(); for (AttributeType type : types) { if (type.equals(CoreAttributeTypes.HTMLContent)) { htmlContent = artifact.getAttributesToString(type); } else if (type.equals(CoreAttributeTypes.ImageContent)) { } else { List<Attribute<Object>> attrs = artifact.getAttributes((IAttributeType) type); for (Object o : attrs) { if ((o instanceof StringAttribute) || (o instanceof OutlineNumberAttribute)) { String attributeValue = artifact.getAttributesToString(type); if (Strings.isValid(attributeValue)) { output.append(blankLine); output.append(underline); output.append(type.getName()); output.append(underlineEnd); output.append(": "); output.append(attributeValue); } } } } } output.append(blankLine); output.append(htmlContent); }
Source:
<code>public Map<String, Object> getPermissions(AgentPrincipals agent, PID pid) { Map<String, Object> result = getObjectPermissions(agent, pid); RepositoryObject parent = repoObjLoader.getRepositoryObject(pid); if (parent instanceof ContentContainerObject) { List<ContentObject> members = ((ContentContainerObject) parent).getMembers(); <START> ArrayList<Map<String, Object>> memberPermissions = new ArrayList<Map<String,Object>>(); <END> for (ContentObject member : members) { Map<String, Object> permissions = getObjectPermissions(agent, member.getPid()); memberPermissions.add(permissions); } result.put("memberPermissions", memberPermissions); } return result; }</code><technical_language>Change List<Map<String, Object>> memberPermissions = new ArrayList<>(); for length</technical_language>

Target:
public Map<String, Object> getPermissions(AgentPrincipals agent, PID pid) { Map<String, Object> result = getObjectPermissions(agent, pid); RepositoryObject parent = repoObjLoader.getRepositoryObject(pid); if (parent instanceof ContentContainerObject) { List<ContentObject> members = ((ContentContainerObject) parent).getMembers(); if (!members.isEmpty()) { List<Map<String, Object>> memberPermissions = new ArrayList<>(); for (ContentObject member : members) { Map<String, Object> permissions = getObjectPermissions(agent, member.getPid()); memberPermissions.add(permissions); } result.put("memberPermissions", memberPermissions); } } return result; }
Source:
<code>public void close() throws IOException { <START> synchronized (this) { <END> if (!mIsOpen) { LOG.warn("close() called on an KijiTable that was already closed."); return; } mIsOpen = false; } LOG.debug(String.format("Closing KijiTable '%s'.", mTableURI)); if (null != mHTable) { mHTable.close(); } mKiji.release(); }</code><technical_language>this synchronized avoided AtomicBoolean</technical_language>

Target:
public void close() throws IOException { if (!mIsOpen.getAndSet(false)) { LOG.warn("close() called on resource that was already closed."); return; } LOG.debug("Closing resource '{}'.", mTableURI); if (null != mHTable) { mHTable.close(); } ResourceUtils.releaseOrLog(mKiji); LOG.debug("Resource '{}' closed.", mTableURI); }
Source:
<code>private static int convertRawAvroType(Schema.Type type) { int sqlType = Types.NULL; switch (type) { case ENUM: case RECORD: case ARRAY: case MAP: case FIXED: case NULL: throw new UnsupportedOperationException(type + "Avro type not supported"); <START> case STRING: <END> sqlType = Types.VARCHAR; break; case BYTES: sqlType = Types.BINARY; break; case INT: sqlType = Types.NUMERIC; break; case LONG: sqlType = Types.NUMERIC; break; case FLOAT: sqlType = Types.FLOAT; break; case DOUBLE: sqlType = Types.DOUBLE; break; case BOOLEAN: sqlType = Types.BOOLEAN; break; } return sqlType; }</code><technical_language>support VARIANT type? I handling variant String in schema</technical_language>

Target:
private int convertRawAvroType(Schema.Type type) { Integer sqlType = this.config.CONVERT_AVROTYPE_TO_SQLTYPE.get(type); if(sqlType != null){ return sqlType; } switch (type) { case STRING: sqlType = Types.VARCHAR; break; case BYTES: sqlType = Types.BINARY; break; case INT: sqlType = Types.NUMERIC; break; case LONG: sqlType = Types.NUMERIC; break; case FLOAT: sqlType = Types.FLOAT; break; case DOUBLE: sqlType = Types.DOUBLE; break; case BOOLEAN: sqlType = Types.BOOLEAN; break; default: throw new UnsupportedOperationException(type + "Avro type not supported"); } return sqlType; }
Source:
<code>private void updateFullyQualifiedReference(String newName) { HaxeReferenceExpression referenceExpression = HaxeElementGenerator.createReferenceExpressionFromText(getProject(), newName); <START> assert referenceExpression != null; <END> replace(referenceExpression); }</code><technical_language>_not_ assert directly. LOG.traceAssert() instead. [Edit: Added missing 'not'. :/ ]</technical_language>

Target:
private void updateFullyQualifiedReference(String newName) { HaxeReferenceExpression referenceExpression = HaxeElementGenerator.createReferenceExpressionFromText(getProject(), newName); if (referenceExpression == null) { LOG.error("ReferenceExpression generated by HaxeElementGenerator is null!"); } else { replace(referenceExpression); } }
Source:
<code>public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { ctx.channel().close(); <START> HttpServerImpl.this.connectionExceptionHandler.handle(cause); <END> }</code><technical_language>I Context#executeFromIO test handler is null</technical_language>

Target:
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel channel = ctx.channel(); channel.close(); HandlerHolder<HttpHandler> reqHandler = reqHandlerManager.chooseHandler(channel.eventLoop()); reqHandler.context.executeFromIO(() -> HttpServerImpl.this.connectionExceptionHandler.handle(cause)); }
Source:
<code>public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { if (orderParams instanceof CancelOrderByPairAndIdParams) { final CancelOrderByPairAndIdParams params = (CancelOrderByPairAndIdParams) orderParams; return cancelBithumbOrder(Long.valueOf(params.getOrderId()), params.getCurrencyPair()); } else { throw new NotYetImplementedForExchangeException( "Only CancelOrderByPairAndIdParams supported"); <START> } <END> }</code><technical_language>try / catch BithumbException needed</technical_language>

Target:
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { if (orderParams instanceof CancelOrderByPairAndIdParams) { try { final CancelOrderByPairAndIdParams params = (CancelOrderByPairAndIdParams) orderParams; return cancelBithumbOrder(Long.valueOf(params.getOrderId()), params.getCurrencyPair()); } catch (BithumbException e) { throw BithumbErrorAdapter.adapt(e); } } else { throw new NotYetImplementedForExchangeException( "Only CancelOrderByPairAndIdParams supported"); } }
Source:
<code>public CompletableFuture<Void> visitEntrySetCommand(InvocationContext ctx, EntrySetCommand command) throws Throwable { ctx.onReturn((ctx1, command1, rv, throwable) -> { if (throwable != null) throw throwable; CacheSet<CacheEntry<K, V>> entrySet = (CacheSet<CacheEntry<K, V>>) rv; if (!enabled || hasSkipLoadFlag(command)) { return CompletableFuture.completedFuture(entrySet); } CacheSet<CacheEntry<K, V>> wrappedEntrySet = new WrappedEntrySet(command, entrySet); return CompletableFuture.completedFuture(wrappedEntrySet); }); <START> return ctx.continueInvocation(); <END> }</code><technical_language>needed onReturn() returns CONTINUE_INVOCATION</technical_language>

Target:
public CompletableFuture<Void> visitEntrySetCommand(InvocationContext ctx, EntrySetCommand command) throws Throwable { return ctx.onReturn((rCtx, rCommand, rv, throwable) -> { if (throwable != null || !enabled || hasSkipLoadFlag(command)) { return null; } CacheSet<CacheEntry<K, V>> entrySet = (CacheSet<CacheEntry<K, V>>) rv; CacheSet<CacheEntry<K, V>> wrappedEntrySet = new WrappedEntrySet(command, entrySet); return CompletableFuture.completedFuture(wrappedEntrySet); }); }
Source:
<code>public boolean isCertChainValid() { <START> return false; <END> }</code><technical_language>throw a runtimeex. some message "not implemented yet"</technical_language>

Target:
public boolean isCertChainValid() throws ScriptSignatureException { return isCertChainValid(null, null); }
Source:
<code>private static void setScores(DynamicEndpointSnitch dsnitch, int rounds, List<InetAddressAndPort> hosts, Integer... scores) throws InterruptedException { for (int round = 0; round < rounds; round++) { for (int i = 0; i < hosts.size(); i++) dsnitch.receiveTiming(hosts.get(i), scores[i], LatencyMeasurementType.READ); } <START> Thread.sleep(UPDATE_INTERVAL_MS + 10); <END> }</code><technical_language>This end a source of flakiness. A test method force recalculate in other thread wait resulting future</technical_language>

Target:
private static void setScores(DynamicEndpointSnitch dsnitch, int rounds, List<InetAddressAndPort> hosts, Integer... scores) throws InterruptedException { for (int round = 0; round < rounds; round++) { for (int i = 0; i < hosts.size(); i++) dsnitch.receiveTiming(hosts.get(i), scores[i], LatencyMeasurementType.READ); } dsnitch.updateScores(); }
Source:
<code>static Map<String, String> getDefaultDevDependencies() { Map<String, String> defaults = new HashMap<>(); defaults.put("html-webpack-plugin", "3.2.0"); defaults.put("script-ext-html-webpack-plugin", "2.1.4"); defaults.put("typescript", "4.0.3"); defaults.put("awesome-typescript-loader", "5.2.1"); defaults.put("webpack", "4.42.0"); defaults.put("webpack-cli", "3.3.11"); defaults.put("webpack-dev-server", "3.11.0"); defaults.put("copy-webpack-plugin", "5.1.2"); defaults.put("compression-webpack-plugin", "4.0.1"); defaults.put("webpack-merge", "4.2.2"); defaults.put("css-loader", "4.2.1"); <START> defaults.put("file-loader", "6.1.0"); <END> defaults.put("extract-loader", "5.1.0"); defaults.put("lit-css-loader", "0.0.4"); defaults.put("file-loader", "6.1.0"); defaults.put("loader-utils", "1.4.0"); defaults.put("lit-element", "2.3.1"); defaults.put("lit-html", "1.2.1"); defaults.put("@types/validator", "13.1.0"); defaults.put("validator", "13.1.17"); defaults.put("construct-style-sheets-polyfill", "2.4.2"); defaults.put("chokidar", "^3.4.0"); return defaults; }</code><technical_language>Remove extra file-loader added merge in master. 3 lines</technical_language>

Target:
static Map<String, String> getDefaultDevDependencies() { Map<String, String> defaults = new HashMap<>(); defaults.put("html-webpack-plugin", "3.2.0"); defaults.put("script-ext-html-webpack-plugin", "2.1.4"); defaults.put("typescript", "4.0.3"); defaults.put("awesome-typescript-loader", "5.2.1"); defaults.put("webpack", "4.42.0"); defaults.put("webpack-cli", "3.3.11"); defaults.put("webpack-dev-server", "3.11.0"); defaults.put("copy-webpack-plugin", "5.1.2"); defaults.put("compression-webpack-plugin", "4.0.1"); defaults.put("webpack-merge", "4.2.2"); defaults.put("css-loader", "4.2.1"); defaults.put("extract-loader", "5.1.0"); defaults.put("lit-css-loader", "0.0.4"); defaults.put("file-loader", "6.1.0"); defaults.put("loader-utils", "1.4.0"); defaults.put("lit-element", "2.3.1"); defaults.put("lit-html", "1.2.1"); defaults.put("@types/validator", "13.1.0"); defaults.put("validator", "13.1.17"); defaults.put("construct-style-sheets-polyfill", "2.4.2"); defaults.put("chokidar", "^3.4.0"); return defaults; }
Source:
<code>public String translate(final StringAgg stringAgg) { inject(stringAgg.column); if (stringAgg.isDistinct()) { return String.format( <START> "string_agg(DISTINCT CAST (%s AS TEXT), CAST ('%c' AS TEXT))", <END> stringAgg.getColumn().translate(), stringAgg.getDelimiter() ); } else { return String.format( "string_agg(CAST (%s AS TEXT), CAST ('%c' AS TEXT))", stringAgg.getColumn().translate(), stringAgg.getDelimiter() ); } }</code><technical_language>I difference, please uppercase STRING_AGG compliant rest of class</technical_language>

Target:
public String translate(final StringAgg stringAgg) { inject(stringAgg.column); return String.format( "STRING_AGG(%s %s, '%c')", stringAgg.isDistinct() ? "DISTINCT" : "", stringAgg.getColumn().translate(), stringAgg.getDelimiter() ); }
Source:
<code>private static OutputWrapper connectMySql(String param) throws IOException { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql:" + param); return new OutputWrapper(conn); } catch (Exception e) { <START> throw (IOException)new IOException(e.getMessage()).initCause(e); <END> } }</code><technical_language>throw new IOException(e)</technical_language>

Target:
private static OutputWrapper connectMySql(String param) throws IOException { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql:" + param); return new OutputWrapper(conn); } catch (Exception e) { throw new IOException(e); } }
Source:
<code>public void testMultipleAttributes() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); List<IASTAttribute> attributes = getAttributes(tu); <START> assertEquals(1, attributes.size()); <END> }</code><technical_language>Is getAttributes(tu) returns attribute specifiers, attributes themselves</technical_language>

Target:
public void testMultipleAttributes() throws Exception { ICPPASTAttribute[] attributes = getAttributes(); assertEquals(2, attributes.length); ICPPASTAttribute attr1 = attributes[0]; assertEquals("attr1", String.valueOf(attr1.getName())); ICPPASTAttribute attr2 = attributes[1]; assertEquals("attr2", String.valueOf(attr2.getName())); }
Source:
<code>public void testNumberLargerThanMaxLongInEvents() { final String events = "[{\"number\": 9223372036854775808 }]"; try { BatchFactory.from(events); fail(); <START> } catch (JSONException e) <END> }</code><technical_language>@ferbncode do in @Test annotation @Test(expected = JSONException.class) instead of catching exception calling fail(). Another improve - currently if BatchFactory.from(events); throws some other exception - test green (but red in case)</technical_language>

Target:
public void testNumberLargerThanMaxLongInEvents() { final String events = "[{\"number\": 9223372036854775808 }]"; BatchFactory.from(events); }
Source:
<code>public boolean removeUserFromTenant(String tenantId, String userId) { PreConditions.notNullOrEmpty(tenantId, "tenantId"); PreConditions.notNullOrEmpty(userId, "userId"); Tenant tenant = tenantRepo.findByTenantId(tenantId); PreConditions.notNull(tenant, "Tenant with given tenantId doesnt exists"); Optional<TenantUser> maybeUser = tenant.getUser(userId); boolean userIsPresent = false; if (maybeUser.isPresent()) { <START> userIsPresent = tenant.hasUser(maybeUser.get().getUser().getUsername()); <END> if (userIsPresent) { tenant.removeUser(maybeUser.get()); } } tenantRepo.save(tenant); return userIsPresent; }</code><technical_language>this true</technical_language>

Target:
public boolean removeUserFromTenant(String tenantId, String userId) { PreConditions.notNullOrEmpty(tenantId, "tenantId"); PreConditions.notNullOrEmpty(userId, "userId"); Tenant tenant = tenantRepo.findByTenantId(tenantId); PreConditions.notNull(tenant, "Tenant with given tenantId doesnt exists"); Optional<TenantUser> maybeUser = tenant.getUser(userId); boolean userIsPresent = false; if (maybeUser.isPresent()) { userIsPresent = true; tenant.removeUser(maybeUser.get()); } tenantRepo.save(tenant); return userIsPresent; }