auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void completeResourceConfigurationUpdate(ConfigurationUpdateResponse response) { if (LOG.isDebugEnabled()) { LOG.debug("Received a configuration-update-completed message: " + response); } ResourceConfigurationUpdate update = entityManager.find(ResourceConfigurationUpdate.class, response.getConfigurationUpdateId()); if (update == null) { throw new IllegalStateException( "The completed request passed in does not match any request for any resource in inventory: " + response); } if (response.getStatus() == ConfigurationUpdateStatus.FAILURE) { if (response.getConfiguration() != null) { Configuration failedConfiguration = response.getConfiguration(); failedConfiguration = entityManager.merge(failedConfiguration); update.setConfiguration(failedConfiguration); } } else if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) { Resource resource = update.getResource(); Configuration oldResourceConfig = resource.getResourceConfiguration(); resource.setResourceConfiguration(update.getConfiguration().deepCopyWithoutProxies()); <START> entityManager.remove(oldResourceConfig); <END> notifyAlertConditionCacheManager("completeResourceConfigurationUpdate", update); } update.setStatus(response.getStatus()); update.setErrorMessage(response.getErrorMessage()); return; }</code><technical_language>question/concern before. updated resource configuration simply result in previous configuration history resource's configuration history page</technical_language>

Target:
public void completeResourceConfigurationUpdate(ConfigurationUpdateResponse response) { if (LOG.isDebugEnabled()) { LOG.debug("Received a configuration-update-completed message: " + response); } ResourceConfigurationUpdate update = entityManager.find(ResourceConfigurationUpdate.class, response.getConfigurationUpdateId()); if (update == null) { throw new IllegalStateException( "The completed request passed in does not match any request for any resource in inventory: " + response); } if (response.getStatus() == ConfigurationUpdateStatus.FAILURE) { if (response.getConfiguration() != null) { Configuration failedConfiguration = response.getConfiguration(); failedConfiguration = entityManager.merge(failedConfiguration); update.setConfiguration(failedConfiguration); } } else if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) { Resource resource = update.getResource(); entityManager.remove(resource.getResourceConfiguration()); resource.setResourceConfiguration(update.getConfiguration().deepCopyWithoutProxies()); notifyAlertConditionCacheManager("completeResourceConfigurationUpdate", update); } update.setStatus(response.getStatus()); update.setErrorMessage(response.getErrorMessage()); return; }
Source:
<code>public void init(ComputationContext context) { super.init(context); try { temp = Files.createTempDirectory(metadata().name()); <START> temp.toFile().deleteOnExit(); <END> } catch (IOException e) { throw new IllegalStateException("Cannot create temp directory for " + this); } }</code><technical_language>is Framework#trackFile</technical_language>

Target:
public void init(ComputationContext context) { super.init(context); try { temp = Files.createTempDirectory(metadata().name()); Framework.trackFile(temp.toFile(), temp); } catch (IOException e) { throw new IllegalStateException("Cannot create temp directory for " + this); } }
Source:
<code>public IdentityPoolCredentialSource(Map<String, Object> credentialSourceMap) { super(credentialSourceMap); if (credentialSourceMap.containsKey("file")) { credentialLocation = (String) credentialSourceMap.get("file"); credentialSourceType = IdentityPoolCredentialSourceType.FILE; } else if (credentialSourceMap.containsKey("url")) { credentialLocation = (String) credentialSourceMap.get("url"); credentialSourceType = IdentityPoolCredentialSourceType.URL; } else { throw new IllegalArgumentException( "Missing credential source file location or URL. At least one must be specified."); } Map<String, String> headersMap = (Map<String, String>) credentialSourceMap.get("headers"); if (headersMap != null && !headersMap.isEmpty()) { headers = new HashMap<>(); headers.putAll(headersMap); } credentialFormatType = CredentialFormatType.TEXT; Map<String, String> formatMap = (Map<String, String>) credentialSourceMap.get("format"); if (formatMap != null && formatMap.containsKey("type")) { <START> String type = formatMap.get("type"); if (!type.equals("text") && !type.equals("json")) { <END> throw new IllegalArgumentException( String.format("Invalid credential source format type: %s.", type)); } credentialFormatType = type.equals("text") ? CredentialFormatType.TEXT : CredentialFormatType.JSON; if (!formatMap.containsKey("subject_token_field_name")) { throw new IllegalArgumentException( "When specifying a JSON credential type, the subject_token_field_name must be set."); } subjectTokenFieldName = formatMap.get("subject_token_field_name"); } }</code><technical_language>Need a null check here</technical_language>

Target:
public IdentityPoolCredentialSource(Map<String, Object> credentialSourceMap) { super(credentialSourceMap); if (credentialSourceMap.containsKey("file")) { credentialLocation = (String) credentialSourceMap.get("file"); credentialSourceType = IdentityPoolCredentialSourceType.FILE; } else if (credentialSourceMap.containsKey("url")) { credentialLocation = (String) credentialSourceMap.get("url"); credentialSourceType = IdentityPoolCredentialSourceType.URL; } else { throw new IllegalArgumentException( "Missing credential source file location or URL. At least one must be specified."); } Map<String, String> headersMap = (Map<String, String>) credentialSourceMap.get("headers"); if (headersMap != null && !headersMap.isEmpty()) { headers = new HashMap<>(); headers.putAll(headersMap); } credentialFormatType = CredentialFormatType.TEXT; Map<String, String> formatMap = (Map<String, String>) credentialSourceMap.get("format"); if (formatMap != null && formatMap.containsKey("type")) { String type = formatMap.get("type"); if (type == null || (!type.equals("text") && !type.equals("json"))) { throw new IllegalArgumentException( String.format("Invalid credential source format type: %s.", type)); } credentialFormatType = type.equals("text") ? CredentialFormatType.TEXT : CredentialFormatType.JSON; if (!formatMap.containsKey("subject_token_field_name")) { throw new IllegalArgumentException( "When specifying a JSON credential type, the subject_token_field_name must be set."); } subjectTokenFieldName = formatMap.get("subject_token_field_name"); } }
Source:
<code>public static StringBuffer getIntialWebviewBuffer(Context context, Logger logger) { <START> StringBuffer buff = new StringBuffer(); <END> buff.append("<head>"); buff.append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); try { String cssFileContent = FileUtil.loadTextFileFromAssets(context , "css/render-html-in-webview.css"); buff.append("<style>"); buff.append(cssFileContent); buff.append("</style>"); } catch (IOException e) { logger.error(e); } buff.append("</head>"); return buff; }</code><technical_language>StringBuffer usages replaced StringBuilder, I guess</technical_language>

Target:
public static StringBuilder getIntialWebviewBuffer(Context context, Logger logger) { StringBuilder buff = new StringBuilder(); buff.append("<head>"); buff.append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); try { String cssFileContent = FileUtil.loadTextFileFromAssets(context, "css/render-html-in-webview.css"); buff.append("<style>"); buff.append(cssFileContent); buff.append("</style>"); } catch (IOException e) { logger.error(e); } buff.append("</head>"); return buff; }
Source:
<code>private Transaction getOngoingTransaction() { try { Transaction transaction = null; if (transactionManager != null) { transaction = transactionManager.getTransaction(); if (transaction == null && batchContainer != null) { transaction = batchContainer.getBatchTransaction(); } } return transaction; } catch (SystemException e) { throw new CacheException("Unable to get transaction", e); } <START> } <END></code><technical_language>This is implementing correct pattern of dealing transaction commit/rollback. [This code](<LINK_0> shows correct pattern</technical_language>

Target:
private Transaction getOngoingTransaction() { try { Transaction transaction = transactionManager.getTransaction(); if (transaction == null && batchContainer != null) { transaction = batchContainer.getBatchTransaction(); } return transaction; } catch (SystemException e) { throw new CacheException("Unable to get transaction", e); } }
Source:
<code><START> public static List<OVirtNodeInfo> get() { <END> final String delimiter = ":"; final String[] path = Config.resolveOVirtISOsRepositoryPath().split(delimiter); final String minimumVersion[] = Config.<String> GetValue(ConfigValues.OvirtInitialSupportedIsoVersion).split(delimiter); final String regex[] = Config.<String> GetValue(ConfigValues.OvirtIsoPrefix).split(delimiter); List<OVirtNodeInfo> info = new LinkedList<OVirtNodeInfo>(); log.debugFormat("NodeInfo: regex length {0} minimum length {1} path length {2}", regex.length, minimumVersion.length, path.length); if (regex.length != minimumVersion.length || regex.length != path.length) { throw new IllegalArgumentException("Illegal NodeInfo - length"); } for (int i=0; i < regex.length; i++) { log.debugFormat("NodeInfo: regex {0} path {1}, minimumVersion {2}", regex[i], path[i], minimumVersion[i]); info.add(new OVirtNodeInfo(Pattern.compile(regex[i]), new File(path[i]), minimumVersion[i])); } return info; }</code><technical_language>1. debated "get" logic reside in some other class. If possible, nicer (matter of taste) OvirtNodeInfoFactory.getInstance().create() for example</technical_language>

Target:
public List<Entry> get() { return info; }
Source:
<code>private final int[] decodeInts(final String string) { final int nValues = ParsingUtils.split(string, INT_DECODE_ARRAY, ','); if ( nValues > LARGE_SIZE ) <START> log.warn("Decoding " + nValues + " integers in " + name); <END> final int[] values = new int[nValues]; try { for ( int i = 0; i < nValues; i++ ) values[i] = Integer.valueOf(INT_DECODE_ARRAY[i]); } catch (final NumberFormatException e) { return null; } return values; }</code><technical_language>I this warning needs more clear, add "This warning is decoding genotype annotations a large number of values, typically due presence of a large number of alternate alleles." encounters in future some idea of happening</technical_language>

Target:
private final int[] decodeInts(final String string) { int numItems = StringUtils.countMatches(string, ",") + 1; String[] intDecodeArray = new String[numItems]; final int nValues = ParsingUtils.split(string, intDecodeArray, ','); final int[] values = new int[nValues]; try { for ( int i = 0; i < nValues; i++ ) values[i] = Integer.valueOf(intDecodeArray[i]); } catch (final NumberFormatException e) { return null; } return values; }
Source:
<code>public static void writeEntryHeader(CRC32 crc, ByteBuffer headerBuf, ByteBuffer destBuf, int size, int flag) { crc.update(size); crc.update(flag); crc.update(destBuf); headerBuf.clear(); headerBuf.order(ByteOrder.LITTLE_ENDIAN); <START> headerBuf.putLong(crc.getValue()); <END> headerBuf.putInt(size); headerBuf.putInt(flag); headerBuf.order(ByteOrder.BIG_ENDIAN); }</code><technical_language>if matters returned getValue is unsigned int store int save 4bytes if matters</technical_language>

Target:
public static void writeEntryHeader(CRC32 crc, ByteBuffer headerBuf, ByteBuffer destBuf, int size, int flag) { crc.update(size); crc.update(flag); crc.update(destBuf); headerBuf.putInt((int)crc.getValue()); headerBuf.putInt(size); headerBuf.putInt(flag); }
Source:
<code>public void test_Servlet16() throws Exception { Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { Part part = req.getPart("file"); Assert.assertNotNull(part); String submittedFileName = part.getSubmittedFileName(); String contentType = part.getContentType(); long size = part.getSize(); PrintWriter writer = resp.getWriter(); writer.write(submittedFileName); writer.write("|"); writer.write(contentType); writer.write("|" + size); } }; Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S16"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Servlet16/*"); <START> props.put("osgi.http.whiteboard.servlet.multipart.enabled", Boolean.TRUE); <END> registrations.add(getBundleContext().registerService(Servlet.class, servlet, props)); Map<String, List<Object>> map = new HashMap<String, List<Object>>(); map.put("file", Arrays.<Object>asList(getClass().getResource("resource1.txt"))); Map<String, List<String>> result = requestAdvisor.upload("Servlet16/do", map); Assert.assertEquals("200", result.get("responseCode").get(0)); Assert.assertEquals("resource1.txt|text/plain|1", result.get("responseBody").get(0)); }</code><technical_language>This means implementing R7 spec in master for Oxygen? part of it? Do R7 done for Oxygen? I hesitating R7 work in Oxygen</technical_language>

Target:
public void test_Servlet16() throws Exception { Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { Part part = req.getPart("file"); Assert.assertNotNull(part); String submittedFileName = part.getSubmittedFileName(); String contentType = part.getContentType(); long size = part.getSize(); PrintWriter writer = resp.getWriter(); writer.write(submittedFileName); writer.write("|"); writer.write(contentType); writer.write("|" + size); } }; Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S16"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Servlet16/*"); props.put("equinox.http.multipartSupported", Boolean.TRUE); registrations.add(getBundleContext().registerService(Servlet.class, servlet, props)); Map<String, List<Object>> map = new HashMap<String, List<Object>>(); map.put("file", Arrays.<Object>asList(getClass().getResource("resource1.txt"))); Map<String, List<String>> result = requestAdvisor.upload("Servlet16/do", map); Assert.assertEquals("200", result.get("responseCode").get(0)); Assert.assertEquals("resource1.txt|text/plain|1", result.get("responseBody").get(0)); }
Source:
<code>public final void update() { removeAllChildren(); add(new JSources(this, wrapper)); List<JResource> resList = getHierarchyResources(wrapper.getResources()); for (JResource jRes : resList) { jRes.update(); add(jRes); } ApkSignature signature = ApkSignature.getApkSignature(wrapper.getOpenFile()); <START> if (signature!=null) { <END> add(signature); } JCertificate certificate = getCertificate(wrapper.getResources()); if (certificate != null) { add(certificate); } }</code><technical_language>Please code formatting insert necessary spaces</technical_language>

Target:
public final void update() { removeAllChildren(); add(new JSources(this, wrapper)); List<JResource> resList = getHierarchyResources(wrapper.getResources()); for (JResource jRes : resList) { jRes.update(); add(jRes); } ApkSignature signature = ApkSignature.getApkSignature(wrapper); if (signature != null) { add(signature); } JCertificate certificate = getCertificate(wrapper.getResources()); if (certificate != null) { add(certificate); } }
Source:
<code>public void testLongDefaultValue() { <START> Schema.Field field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", 1); <END> assertTrue(field.hasDefaultValue()); assertEquals(1L, field.defaultVal()); assertEquals(1L, GenericData.get().getDefaultValue(field)); field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", Long.MIN_VALUE); assertTrue(field.hasDefaultValue()); assertEquals(Long.MIN_VALUE, field.defaultVal()); assertEquals(Long.MIN_VALUE, GenericData.get().getDefaultValue(field)); field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", Long.MAX_VALUE); assertTrue(field.hasDefaultValue()); assertEquals(Long.MAX_VALUE, field.defaultVal()); assertEquals(Long.MAX_VALUE, GenericData.get().getDefaultValue(field)); }</code><technical_language>suggestion Schema.Field field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", 1L); (If I understood intention for this test test below)</technical_language>

Target:
public void testLongDefaultValue() { Schema.Field field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", 1L); assertTrue(field.hasDefaultValue()); assertEquals(1L, field.defaultVal()); assertEquals(1L, GenericData.get().getDefaultValue(field)); field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", Long.MIN_VALUE); assertTrue(field.hasDefaultValue()); assertEquals(Long.MIN_VALUE, field.defaultVal()); assertEquals(Long.MIN_VALUE, GenericData.get().getDefaultValue(field)); field = new Schema.Field("myField", Schema.create(Schema.Type.LONG), "doc", Long.MAX_VALUE); assertTrue(field.hasDefaultValue()); assertEquals(Long.MAX_VALUE, field.defaultVal()); assertEquals(Long.MAX_VALUE, GenericData.get().getDefaultValue(field)); }
Source:
<code>public List<ResponseExceptionMapper<?>> createResponseExceptionMapper(Message m, Class<?> paramType) { if (responseExceptionMappers.isEmpty()) { return Collections.emptyList(); } <START> List<ResponseExceptionMapper<?>> candidates = <END> responseExceptionMappers.stream().map(ProviderInfo::getProvider).collect(Collectors.toList()); candidates.sort(new ResponseExceptionMapperComparator()); return Collections.unmodifiableList(candidates); }</code><technical_language>shorter: return Collections.unmodifiableList(responseExceptionMappers .stream() .map(ProviderInfo::getProvider) .sorted(new ResponseExceptionMapperComparator()) .collect(Collectors.toList()));</technical_language>

Target:
public List<ResponseExceptionMapper<?>> createResponseExceptionMapper(Message m, Class<?> paramType) { if (responseExceptionMappers.isEmpty()) { return Collections.emptyList(); } return Collections.unmodifiableList(responseExceptionMappers .stream() .map(ProviderInfo::getProvider) .sorted(new ResponseExceptionMapperComparator()) .collect(Collectors.toList())); }
Source:
<code>public void sendResultMsg(final boolean success, final String operationId, final TraceInfo parentTraceInfo) { try (final TraceScope sendResultMsgScope = Trace.startSpan(SEND_RESULT_MSG, parentTraceInfo)) { LOG.entering(ElasticMemoryMsgSenderImpl.class.getSimpleName(), "sendResultMsg", <START> new Object[]{}); <END> final ResultMsg resultMsg = ResultMsg.newBuilder() .setResult(success ? Result.SUCCESS : Result.FAILURE) .build(); send(driverId, AvroElasticMemoryMessage.newBuilder() .setType(Type.ResultMsg) .setSrcId(emNetworkSetup.getMyId().toString()) .setDestId(driverId) .setOperationId(operationId) .setTraceInfo(HTraceUtils.toAvro(parentTraceInfo)) .setResultMsg(resultMsg) .build()); LOG.exiting(ElasticMemoryMsgSenderImpl.class.getSimpleName(), "sendResultMsg", new Object[]{}); } }</code><technical_language>reason for passing empty Object array</technical_language>

Target:
public void sendResultMsg(final boolean success, final String operationId, final TraceInfo parentTraceInfo) { try (final TraceScope sendResultMsgScope = Trace.startSpan(SEND_RESULT_MSG, parentTraceInfo)) { LOG.entering(ElasticMemoryMsgSenderImpl.class.getSimpleName(), "sendResultMsg", new Object[]{success, operationId}); final ResultMsg resultMsg = ResultMsg.newBuilder() .setResult(success ? Result.SUCCESS : Result.FAILURE) .build(); send(driverId, AvroElasticMemoryMessage.newBuilder() .setType(Type.ResultMsg) .setSrcId(emNetworkSetup.getMyId().toString()) .setDestId(driverId) .setOperationId(operationId) .setTraceInfo(HTraceUtils.toAvro(parentTraceInfo)) .setResultMsg(resultMsg) .build()); LOG.exiting(ElasticMemoryMsgSenderImpl.class.getSimpleName(), "sendResultMsg", new Object[]{success, operationId}); } }
Source:
<code>public void testParseNoLocalWrite() { DistCpOptions options = OptionsParser.parse(new String[] { "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/"}); <START> Assert.assertEquals(options.shouldNoLocalWrite(), false); <END> options = OptionsParser.parse(new String[] { "-noLocalWrite", "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/"}); Assert.assertEquals(options.shouldNoLocalWrite(), true); }</code><technical_language>assertFalse</technical_language>

Target:
public void testParseNoLocalWrite() { DistCpOptions options = OptionsParser.parse(new String[] { "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/"}); Assert.assertFalse("Failed to parse option -noLocalWrite correctly.", options.shouldNoLocalWrite()); options = OptionsParser.parse(new String[] { "-noLocalWrite", "hdfs://localhost:8020/source/first", "hdfs://localhost:8020/target/"}); Assert.assertTrue("Failed to parse option -noLocalWrite correctly.", options.shouldNoLocalWrite()); }
Source:
<code>private List<String> validateMacraMeasuresAreUniqueForCertificationResult(List<PendingCertificationResultMacraMeasureDTO> macraMeasures, String certNumber, String messageCode) { List<String> messages = new ArrayList<String>(); Map<String, String> uniqueMacras = new HashMap<String, String>(); for (PendingCertificationResultMacraMeasureDTO macraMeasure : macraMeasures) { if (macraMeasure != null) { if (uniqueMacras.containsKey(macraMeasure.getEnteredValue())) { messages.add(msgUtil.getMessage(messageCode, certNumber, macraMeasure.getEnteredValue())); } else { <START> uniqueMacras.put(macraMeasure.getEnteredValue(), macraMeasure.getEnteredValue()); <END> } } } return messages; }</code><technical_language>This a odd a map of itself. a list (or set?) of macras check that</technical_language>

Target:
private List<String> validateMacraMeasuresAreUniqueForCertificationResult(List<PendingCertificationResultMacraMeasureDTO> macraMeasures, String certNumber, String messageCode) { List<String> messages = new ArrayList<String>(); Set<String> uniqueMacras = new HashSet<String>(); for (PendingCertificationResultMacraMeasureDTO macraMeasure : macraMeasures) { if (uniqueMacras.contains(macraMeasure.getEnteredValue())) { messages.add(msgUtil.getMessage(messageCode, certNumber, macraMeasure.getEnteredValue())); } else { uniqueMacras.add(macraMeasure.getEnteredValue()); } } return messages; }
Source:
<code>private void prepareAmend(boolean amend) { String jobname = NLS.bind(UIText.ResetAction_reset, HEADS_FIRST_PARENT); final ResetOperation operation; if (amend) { amendedCommit = Activator.getDefault().getRepositoryUtil() .parseHeadCommit(currentRepository); operation = new ResetOperation(currentRepository, HEADS_FIRST_PARENT, ResetType.SOFT); } else { if (amendedCommit == null) { throw new IllegalStateException( "amendedCommit should have been set on previous amend"); } operation = new ResetOperation(currentRepository, <START> amendedCommit.name(), ResetType.SOFT); <END> } JobUtil.scheduleUserJob(operation, jobname, JobFamilies.RESET); }</code><technical_language>I is Reflog for branch polluted. I amend a commit branch test1 Reflog extra entry: chris@vblub14:~/git/delve$ git reflog test cec2e97 test@{0}: commit (amend): test1 f37a26d test@{1}: HEAD~: updating HEAD 6aea04e test@{2}: commit: test1 f37a26d test@{3}: branch: Created branch refs/remotes/origin/master prohibit reflog entries</technical_language>

Target:
private void prepareAmend(boolean amend) { String jobname = NLS.bind(UIText.ResetAction_reset, HEADS_FIRST_PARENT); final ResetOperation operation; if (amend) { amendedCommit = Activator.getDefault().getRepositoryUtil() .parseHeadCommit(currentRepository); operation = new ResetOperation(currentRepository, HEADS_FIRST_PARENT, ResetType.SOFT); } else { if (amendedCommit == null) { throw new IllegalStateException( "amendedCommit should have been set on previous amend"); } operation = new ResetOperation(currentRepository, amendedCommit.name(), ResetType.SOFT); } operation.disableReflog(true); JobUtil.scheduleUserJob(operation, jobname, JobFamilies.RESET); }
Source:
<code>public static void main(String[] args) throws IOException { Connector connector = new Connector(); SessionManager sessionManager = connector.getSessionManager(); Session session = sessionManager.createOrFindSessionAndJoin("example2"); FileWriter writer = new FileWriter("demoBuildingText"); writer.write("Session link: " + "<LINK_0>" + session.getId() + "/?token=" + session.getServerToken() + "\n"); writer.close(); HttpConnection connection = connector.getConnection(); String allowInteraction = "event/SettingsLogicEventType/SETTINGS_ALLOW_GAME_INTERACTION/"; JSONArray param = new JSONArray(); param.put(true); connection.execute(allowInteraction, CallType.POST, new JsonObjectResultHandler(), session, param); Environment environment = session.getEnvironment(); environment.setStakeholder(2); StakeholderList stakeholderList = environment.loadStakeHolders(); Stakeholder selectedStakeholder = null; for (Stakeholder stakeholder : stakeholderList) { if (stakeholder.getType().equals("HOUSING_CORPORATION")) { selectedStakeholder = stakeholder; } } <START> System.out.println("Building done: " + environment.build(selectedStakeholder, 500)); <END> }</code><technical_language>Next time, please logger facility for consistency. matter this time a demofile :)</technical_language>

Target:
public static void main(String[] args) throws IOException { Connector connector = new Connector(); SessionManager sessionManager = connector.getSessionManager(); Session session = sessionManager.createOrFindSessionAndJoin("example2"); FileWriter writer = new FileWriter("demoBuildingText"); writer.write("Session link: " + "<LINK_0>" + session.getId() + "/?token=" + session.getServerToken() + "\n"); writer.close(); HttpConnection connection = connector.getConnection(); String allowInteraction = "event/SettingsLogicEventType/SETTINGS_ALLOW_GAME_INTERACTION/"; JSONArray param = new JSONArray(); param.put(true); connection.execute(allowInteraction, CallType.POST, new JsonObjectResultHandler(), session, param); Environment environment = session.getEnvironment(); environment.setStakeholder(2); StakeholderList stakeholderList = environment.loadStakeHolders(); Stakeholder selectedStakeholder = null; for (Stakeholder stakeholder : stakeholderList) { if (stakeholder.getType().equals("HOUSING_CORPORATION")) { selectedStakeholder = stakeholder; } } logger.info("Building done: " + environment.build(selectedStakeholder, 50)); }
Source:
<code>protected String createADocument() throws Exception { DocumentModel doc = session.createDocumentModel("/", "myFolder", "Folder"); doc = session.createDocument(doc); ACP acp = new ACPImpl(); ACL acl = new ACLImpl(); acl.add(new ACE("Administrator", "Everything", true)); <START> acl.add(new ACE(USERNAME, "Read", true)); <END> acp.addACL(acl); doc.setACP(acp, false); session.save(); txFeature.nextTransaction(); return doc.getId(); }</code><technical_language>replaced by: acp.getOrCreateACL().add(new ACE("Administrator", "Everything", true)); acp.getOrCreateACL().add(new ACE(USERNAME, "Read", true)); code section ACP acp = new ACPImpl(); acp.getOrCreateACL().add(new ACE("Administrator", "Everything", true)); acp.getOrCreateACL().add(new ACE(USERNAME, "Read", true)); doc.setACP(acp, false);</technical_language>

Target:
protected String createADocument() throws Exception { DocumentModel doc = session.createDocumentModel("/", "myFolder", "Folder"); doc = session.createDocument(doc); ACP acp = new ACPImpl(); acp.getOrCreateACL().add(new ACE("Administrator", "Everything", true)); acp.getOrCreateACL().add(new ACE(USERNAME, "Read", true)); doc.setACP(acp, false); session.save(); txFeature.nextTransaction(); return doc.getId(); }
Source:
<code>private BufferedImage createErrorImage(final Rectangle area) { final BufferedImage bufferedImage = new BufferedImage(area.width, area.height, TYPE_INT_ARGB_PRE); final Graphics2D graphics = bufferedImage.createGraphics(); try { <START> graphics.setBackground(new Color(255, 78, 78, 125)); <END> graphics.clearRect(0, 0, area.width, area.height); return bufferedImage; } finally { graphics.dispose(); } }</code><technical_language>configurable</technical_language>

Target:
private BufferedImage createErrorImage(final Rectangle area) { final BufferedImage bufferedImage = new BufferedImage(area.width, area.height, TYPE_INT_ARGB_PRE); final Graphics2D graphics = bufferedImage.createGraphics(); try { graphics.setBackground(this.configuration.getTransparentTileErrorColor()); graphics.clearRect(0, 0, area.width, area.height); return bufferedImage; } finally { graphics.dispose(); } }
Source:
<code>static KeyStore createTrustStoreFromCertificates(Path path) { KeyStore keyStore; keyStore = createKeyStore(); for (File currFile : getFilesForPath(path)) { try (InputStream in = Files.newInputStream(currFile.toPath())) { List<Certificate> certificates = readX509Certificates(in); int certIndex = 0; for (Certificate cert : certificates) { <START> keyStore.setCertificateEntry(currFile.getName() + certIndex, cert); <END> certIndex++; } } catch (IOException e) { throw new RuntimeException(String.format( "IOException encountered when opening '%s'", currFile.toPath()), e); } catch (CertificateException | KeyStoreException e) { throw new RuntimeException(String.format( "Could not read file at \"%s\" as an X.509 certificate", currFile.toPath()), e); } } return keyStore; }</code><technical_language>add a dash certIndex, pull this out a function</technical_language>

Target:
static KeyStore createTrustStoreFromCertificates(Path path) { KeyStore keyStore; keyStore = createKeyStore(); for (File currFile : getFilesForPath(path)) { try (InputStream in = Files.newInputStream(currFile.toPath())) { addCertificatesToKeystore(keyStore, currFile.getName(), readX509Certificates(in)); } catch (IOException e) { throw new RuntimeException(String.format( "IOException encountered when opening '%s'", currFile.toPath()), e); } catch (CertificateException | KeyStoreException e) { throw new RuntimeException(String.format( "Could not read file at \"%s\" as an X.509 certificate", currFile.toPath()), e); } } return keyStore; }
Source:
<code>public void dispose() { app.getChildren().remove(windowModel); coolBarManager.dispose(); menuManager.dispose(); statusLineManager.dispose(); <START> windowModel.setToBeRendered(false); <END> windowModel.getContext().deactivate(); windowModel.getContext().dispose(); ((Shell) windowModel.getWidget()).dispose(); }</code><technical_language>I this hurts line 96 sets this window.tbr false I this property changed</technical_language>

Target:
public void dispose() { app.getChildren().remove(windowModel); coolBarManager.dispose(); menuManager.dispose(); statusLineManager.dispose(); windowModel.getContext().deactivate(); windowModel.getContext().dispose(); ((Shell) windowModel.getWidget()).dispose(); }
Source:
<code><START> public Long getCurrSequenceValue(final String SequenceName) { <END> session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Query query = session.createSQLQuery(String.format("select currval('public.%s')", SequenceName)); return ((BigInteger) query.uniqueResult()).longValue(); }</code><technical_language>Duplicated code</technical_language>

Target:
public Long getCurrSequenceValue(final String SequenceName) { return getSequenceValue(SequenceName, COL_CURRVAl); }
Source:
<code>private Library createLibrary(DetailedSample sample, int libraryNum) { Library lib = new LibraryImpl(); lib.setDescription("library"); lib.setSample(sample); LibraryType lt = new LibraryType(); lt.setId(libraryTypeId); lib.setLibraryType(lt); lib.setPlatformName("Illumina"); lib.setPaired(true); lib.setQcPassed(true); LibrarySelectionType sel = new LibrarySelectionType(); sel.setId(librarySelectionTypeId); lib.setLibrarySelectionType(sel); LibraryStrategyType strat = new LibraryStrategyType(); strat.setId(libraryStrategyTypeId); lib.setLibraryStrategyType(strat); <START> ((DetailedLibrary) lib).setArchived(false); <END> lib.setAlias(getRootSample(sample).getAlias() + "_Ad_R_PE_" + (libraryNum > 9 ? libraryNum : "0" + libraryNum) + "_WG"); return lib; }</code><technical_language>Need declare lib DetailedLibraryImpl</technical_language>

Target:
private DetailedLibrary createLibrary(DetailedSample sample, int libraryNum) { DetailedLibrary lib = new DetailedLibraryImpl(); lib.setDescription("library"); lib.setSample(sample); LibraryType lt = new LibraryType(); lt.setId(libraryTypeId); lib.setLibraryType(lt); lib.setPlatformName("Illumina"); lib.setPaired(true); lib.setQcPassed(true); LibrarySelectionType sel = new LibrarySelectionType(); sel.setId(librarySelectionTypeId); lib.setLibrarySelectionType(sel); LibraryStrategyType strat = new LibraryStrategyType(); strat.setId(libraryStrategyTypeId); lib.setLibraryStrategyType(strat); lib.setAlias(getRootSample(sample).getAlias() + "_Ad_R_PE_" + (libraryNum > 9 ? libraryNum : "0" + libraryNum) + "_WG"); return lib; }
Source:
<code>public Well(final Composite parent, final String text, final FormToolkit toolkit, final int severity) { super(parent, SWT.NONE); setLayout(GridLayoutFactory.fillDefaults().extendedMargins(10, 10, 5, 8).create()); addPaintListener(new PaintListener() { @Override <START> public void paintControl(final PaintEvent e) { <END> e.gc.setForeground(separatorColor(toolkit, severity)); e.gc.setLineWidth(2); e.gc.drawLine(5, -5, 5, e.height + 10); e.gc.setBackground(backgroundrColor(toolkit, severity)); e.gc.fillRectangle(6, -5, e.width, e.height + 10); } }); toolkit.adapt(this); label = toolkit.createLabel(this, text, SWT.WRAP); label.setBackground(backgroundrColor(toolkit, severity)); label.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT) .create()); }</code><technical_language>playing paint, need test Linux mac</technical_language>

Target:
public Well(final Composite parent, final String text, final FormToolkit toolkit, final int severity) { super(parent, SWT.NONE); setLayout(GridLayoutFactory.fillDefaults().extendedMargins(10, 10, 5, 8).create()); addPaintListener(new PaintListener() { @Override public void paintControl(final PaintEvent e) { e.gc.setForeground(separatorColor(toolkit, severity)); e.gc.setLineWidth(2); e.gc.drawLine(5, -5, 5, e.height + 10); e.gc.setBackground(backgroundColor(toolkit, severity)); e.gc.fillRectangle(6, -5, e.width, e.height + 10); } }); toolkit.adapt(this); label = toolkit.createLabel(this, text, SWT.WRAP); label.setBackground(backgroundColor(toolkit, severity)); label.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT) .create()); }
Source:
<code>public <K, V> Store<K, V> createStore(Store.Configuration<K, V> storeConfig, ServiceConfiguration<?>... serviceConfigs) { <START> ResourcePools resourcePools = storeConfig.getResourcePools(); <END> ResourcePool heapPool = null; ResourcePool diskPool = null; if (resourcePools != null) { heapPool = resourcePools.getPoolForResource("heap"); diskPool = resourcePools.getPoolForResource("disk"); } List<ServiceConfiguration<?>> enhancedServiceConfigs = new ArrayList<ServiceConfiguration<?>>(Arrays.asList(serviceConfigs)); Store.Provider provider; if (diskPool != null) { if (heapPool == null) { throw new IllegalArgumentException("Cannot store to disk without heap resource"); } provider = serviceProvider.findService(CacheStore.Provider.class); enhancedServiceConfigs.add(new CacheStoreServiceConfig().cachingTierProvider(OnHeapStore.Provider.class).authoritativeTierProvider(DiskStore.Provider.class)); } else { provider = serviceProvider.findService(OnHeapStore.Provider.class); } return provider.createStore(storeConfig, enhancedServiceConfigs.toArray(new ServiceConfiguration<?>[0])); }</code><technical_language>a null resource pool mean</technical_language>

Target:
public <K, V> Store<K, V> createStore(Store.Configuration<K, V> storeConfig, ServiceConfiguration<?>... serviceConfigs) { ResourcePool heapPool = storeConfig.getResourcePools().getPoolForResource(ResourceType.Core.HEAP); ResourcePool diskPool = storeConfig.getResourcePools().getPoolForResource(ResourceType.Core.DISK); List<ServiceConfiguration<?>> enhancedServiceConfigs = new ArrayList<ServiceConfiguration<?>>(Arrays.asList(serviceConfigs)); Store.Provider provider; if (diskPool != null) { if (heapPool == null) { throw new IllegalArgumentException("Cannot store to disk without heap resource"); } provider = serviceProvider.findService(CacheStore.Provider.class); enhancedServiceConfigs.add(new CacheStoreServiceConfig().cachingTierProvider(OnHeapStore.Provider.class).authoritativeTierProvider(DiskStore.Provider.class)); } else { provider = serviceProvider.findService(OnHeapStore.Provider.class); } return provider.createStore(storeConfig, enhancedServiceConfigs.toArray(new ServiceConfiguration<?>[0])); }
Source:
<code>public static boolean match (final String mimeType1, final String mimeType2) { if (ACCEPT_ALL.equals(mimeType1)) { return true; } final MimeType mimeTypeObj1 = Sneaky.sneak(() -> new MimeType(mimeType1)); final MimeType mimeTypeObj2 = Sneaky.sneak(() -> new MimeType(mimeType2)); return mimeTypeObj1.match(mimeTypeObj2); <START> } <END></code><technical_language>If this is MimeTypeUtils, please add a convenience method calls FileAssetAPI.getMimeType() move call FileAssetAPIImpl</technical_language>

Target:
public static boolean match (final String mimeType1, final String mimeType2) { if (ACCEPT_ALL.equals(mimeType1)) { return true; } if (FileAsset.UNKNOWN_MIME_TYPE.equals(mimeType1) || FileAsset.UNKNOWN_MIME_TYPE.equals(mimeType2)) { return false; } final MimeType mimeTypeObj1 = Sneaky.sneak(() -> new MimeType(mimeType1)); final MimeType mimeTypeObj2 = Sneaky.sneak(() -> new MimeType(mimeType2)); return mimeTypeObj1.match(mimeTypeObj2); }
Source:
<code>public void verifyConnectionTimeoutSettingWorks() throws IOException { String testPathPrefix = IntegrationTestConfigContext.generateBasePath( config, this.getClass().getSimpleName()); Instant start = null; Instant stop; try (MantaClient client = new MantaClient(config)) { start = Instant.now(); client.head(testPathPrefix); <START> } catch (ConnectTimeoutException e) { <END> } catch(InterruptedIOException e){ Assert.assertEquals(e.getClass().getSimpleName(), "ConnectTimeoutException"); Assert.assertTrue(e.getMessage().endsWith("connect timed out"), "ConnectTimeoutException didn't end with expected " + "connection timeout message. Actual exception:\n" + ExceptionUtils.getStackTrace(e)); } finally { stop = Instant.now(); } Duration totalTime = Duration.between(start, stop); if (totalTime.getSeconds() != 1) { String msg = String.format("Expected total connection time duration " + "to be 1 second. Actually [%d] ms", totalTime.toMillis()); Assert.fail(msg); } }</code><technical_language>swallow this exception do nothing</technical_language>

Target:
public void verifyConnectionTimeoutSettingWorks() throws IOException { String testPathPrefix = IntegrationTestConfigContext.generateBasePath( config, this.getClass().getSimpleName()); Instant start = null; Instant stop; try (MantaClient client = new MantaClient(config)) { start = Instant.now(); client.head(testPathPrefix); } catch(InterruptedIOException e){ Assert.assertEquals(e.getClass().getSimpleName(), "ConnectTimeoutException"); Assert.assertTrue(e.getMessage().endsWith("connect timed out"), "ConnectTimeoutException didn't end with expected " + "connection timeout message. Actual exception:\n" + ExceptionUtils.getStackTrace(e)); } finally { stop = Instant.now(); } Duration totalTime = Duration.between(start, stop); if (totalTime.getSeconds() != 1) { String msg = String.format("Expected total connection time duration " + "to be 1 second. Actually [%d] ms", totalTime.toMillis()); Assert.fail(msg); } }
Source:
<code>public void install(TextEditor editor) { this.editor = editor; this.dirtyRegionQueue = new DirtyRegionQueue(); reconcilerDocumentChanged(); <START> editor.addPropertyListener(new PropertyListener() { <END> @Override public void propertyChanged(PartPresenter source, int propId) { } }); }</code><technical_language>Listener nothing, weird for me. Is okay</technical_language>

Target:
public void install(TextEditor editor) { this.editor = editor; this.dirtyRegionQueue = new DirtyRegionQueue(); reconcilerDocumentChanged(); }
Source:
<code>private HttpsServerFake startHttpsServerFake(String statusLine) throws Exception { int port = new Random().nextInt(9 * 1024) + 1024; <START> HttpsServerFake serverFake; <END> if (statusLine == null) { serverFake = new HttpsServerFake(port); } else { serverFake = new HttpsServerFake(port, null, statusLine); } serverFake.start(); return serverFake; }</code><technical_language>please dont remove explicit initialization</technical_language>

Target:
private HttpsServerFake startHttpsServerFake(String statusLine) throws Exception { int port = new Random().nextInt(9 * 1024) + 1024; HttpsServerFake serverFake = null; if (statusLine == null) { serverFake = new HttpsServerFake(port); } else { serverFake = new HttpsServerFake(port, null, statusLine); } serverFake.start(); return serverFake; }
Source:
<code>void verifyClosureExpressionBraceStyle(ClosureExpressionContext ctx) { ParseTree left = ParseTreeUtil.getLeftNode(ctx); if (left == null) { return; } Location leftLocation = ListenerUtil.getTokenLocation(ParseTreeUtil.getStopTokenForNode(left)); verifyCodeBlockOpenBraceIsInline(ctx, leftLocation, Messages.CLOSURE); <START> verifyBodyCloseBraceStyle(ctx, Messages.CLOSURE); <END> ParseTree leftSibling = ParseTreeUtil.getLeftSibling(ctx); if (leftSibling != null && (leftSibling instanceof ParenthesizedExpressionContext || leftSibling instanceof PostfixExpressionContext)) { Token leftToken = ((ParserRuleContext) leftSibling).getStop(); verifySingleSpaceBeforeOpenBrace(ctx, leftToken); } }</code><technical_language>Based examples in tests [The Swift Programming Language: Closures](<LINK_0> I reconsider enforcing closing brace styles for closures. remove this check for now</technical_language>

Target:
void verifyClosureExpressionBraceStyle(ClosureExpressionContext ctx) { ParseTree left = ParseTreeUtil.getLeftNode(ctx); if (left == null) { return; } Location leftLocation = ListenerUtil.getTokenLocation(ParseTreeUtil.getStopTokenForNode(left)); verifyCodeBlockOpenBraceIsInline(ctx, leftLocation, Messages.CLOSURE); verifyClosureCloseBraceStyle(ctx); ParseTree leftSibling = ParseTreeUtil.getLeftSibling(ctx); if (leftSibling != null && (leftSibling instanceof ParenthesizedExpressionContext || leftSibling instanceof PostfixExpressionContext)) { Token leftToken = ((ParserRuleContext) leftSibling).getStop(); verifySingleSpaceBeforeOpenBrace(ctx, leftToken); } }
Source:
<code>public GetDeviceListQueryParameters() { privateStorageType = StorageType.UNKNOWN; <START> checkStatus = false; <END> }</code><technical_language>This call this(...) somehow, clunky</technical_language>

Target:
public GetDeviceListQueryParameters() { this(null, StorageType.UNKNOWN, false, null); }
Source:
<code>public void repeatedlyReassignsUnmarkedResidues() { givenGeneratorHasModulus(3); <START> whenModuliAreRequested(9); <END> whenResidueIsUnmarked(2); whenResidueIsUnmarked(2); whenResidueIsUnmarked(2); whenModuliAreRequested(6); thenOperationSucceeds(); thenResponsesSatisfy(responses -> { assertThat(responses).hasSize(15); assertThat(responses.get(9)).isEqualTo(2); assertThat(responses.get(10)).isEqualTo(2); assertThat(responses.get(11)).isEqualTo(2); assertThat(responses.subList(12, 15)).containsExactlyInAnyOrder(0, 1, 2); }); }</code><technical_language>forth, I find easier read answers responses method calls i.e. List<Int> answer = whenModuliAreRequested(9); assertions that. I thenOperationFail is misleading fail in chain test read if failed sequence of commands. I thought I caught something, I reread it</technical_language>

Target:
public void repeatedlyReassignsUnmarkedResidues() { setupGeneratorWithModulus(3); requestResiduesAndAssertEachUsedOnce(3); requestResiduesAndAssertEachUsedOnce(3); requestResiduesAndAssertEachUsedOnce(3); unmarkResidue(2); unmarkResidue(2); unmarkResidue(2); List<Integer> additionalResponses = requestResidues(3); assertThat(additionalResponses).containsExactly(2, 2, 2); requestResiduesAndAssertEachUsedOnce(3); }
Source:
<code>private double[] getPercentages(List<Double> tBreaks, List<Bucket> buckets, int nvalues, int numClasses) { Map<Double, Integer> values = new HashMap<>(); for (Bucket b : buckets) { values.put(b.getMin(), b.getCount()); } ClassPercentagesManager percentagesManager = new ClassPercentagesManager(); <START> return percentagesManager.getPercentages(values, tBreaks, nvalues, numClasses); <END> }</code><technical_language>histogram based natural breaks quantiles percentage calculation require counting portions of buckets in a set of ranges, do necessarily match buckets limits. methods compute results</technical_language>

Target:
private double[] getPercentages(List<Double> tBreaks, List<Bucket> buckets, int nvalues, int numClasses) { ClassPercentagesManager percentagesManager = new ClassPercentagesManager(); return percentagesManager.getPercentages(buckets, tBreaks, numClasses); }
Source:
<code>private void revokeManyKeys(Address backup, CountDownCompletableFuture future, Collection<?> keys, int topologyId) { Map<Address, GroupRevocation> revokedKeys = new HashMap<>(); for (Object key : keys) { BiasManager.Revocation revocation = biasManager.startRevokingRemoteBias(key, backup); if (revocation != null) { if (revocation.shouldRevoke()) { for (Address member : revocation.biased()) { revokedKeys.computeIfAbsent(member, m -> new GroupRevocation()).add(key, revocation); } } else { future.increment(); revocation.handleCompose(() -> { CompletableFuture<?> revokeFuture = revokeBiasSync(key, backup, topologyId); <START> if (revokeFuture == null) { <END> future.countDown(); } else { revokeFuture.thenRun(future::countDown); } return CompletableFutures.completedNull(); }); } } } for (Map.Entry<Address, GroupRevocation> mapping : revokedKeys.entrySet()) { future.increment(); sendRevokeBias(Collections.singleton(mapping.getKey()), mapping.getValue().keys, topologyId, null).whenComplete((nil, throwable) -> { if (throwable != null) { mapping.getValue().revocations.forEach(BiasManager.Revocation::fail); future.completeExceptionally(throwable); } else { mapping.getValue().revocations.forEach(BiasManager.Revocation::complete); future.countDown(); } }); } }</code><technical_language>revokeFuture is null</technical_language>

Target:
private void revokeManyKeys(Address backup, CountDownCompletableFuture future, Collection<?> keys, int topologyId) { Map<Address, GroupRevocation> revokedKeys = new HashMap<>(); for (Object key : keys) { BiasManager.Revocation revocation = biasManager.startRevokingRemoteBias(key, backup); if (revocation != null) { if (revocation.shouldRevoke()) { for (Address member : revocation.biased()) { revokedKeys.computeIfAbsent(member, m -> new GroupRevocation()).add(key, revocation); } } else { future.increment(); revocation.handleCompose(() -> { CompletableFuture<?> revokeFuture = revokeBiasSync(key, backup, topologyId); revokeFuture.thenRun(future::countDown); return CompletableFutures.completedNull(); }); } } } for (Map.Entry<Address, GroupRevocation> mapping : revokedKeys.entrySet()) { future.increment(); sendRevokeBias(Collections.singleton(mapping.getKey()), mapping.getValue().keys, topologyId, null).whenComplete((nil, throwable) -> { if (throwable != null) { mapping.getValue().revocations.forEach(BiasManager.Revocation::fail); future.completeExceptionally(throwable); } else { mapping.getValue().revocations.forEach(BiasManager.Revocation::complete); future.countDown(); } }); } }