auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private Map<String, Object> getDescription(String host, int port, String path) throws IOException { Map<String, Object> properties = new HashMap<>(2, 1); try { URL url = new URL("http", host, port, path); logger.debug("URL: {}", url.toString()); <START> BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream())); <END> String s; StringBuilder builder = new StringBuilder(); while ((s = bufferedReader.readLine()) != null) { builder.append(s); } Pattern ScalarWebAPImatch = Pattern.compile("<av:X_ScalarWebAPI_BaseURL>(.*)</av:X_ScalarWebAPI_BaseURL>"); Pattern baseURLmatch = Pattern.compile("http://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d+)([^<]*)"); Matcher tagmatch = ScalarWebAPImatch.matcher(builder.toString()); if (tagmatch.find()) { Matcher matcher = baseURLmatch.matcher(tagmatch.group()); matcher.find(); int scalar_port = Integer.parseInt(matcher.group(2)); String scalar_path = matcher.group(3); properties.put(SonyAudioBindingConstants.SCALAR_PORT_PARAMETER, scalar_port); properties.put(SonyAudioBindingConstants.SCALAR_PATH_PARAMETER, scalar_path); } return properties; } catch (IOException e) { throw e; } }</code><technical_language>This a resource leak closing reader anywhere. try-with-resources this is properly handled</technical_language>

Target:
private Map<String, Object> getDescription(String host, int port, String path) throws IOException { Map<String, Object> properties = new HashMap<>(2, 1); URL url = new URL("http", host, port, path); logger.debug("URL: {}", url.toString()); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()))) { String s; StringBuilder builder = new StringBuilder(); while ((s = bufferedReader.readLine()) != null) { builder.append(s); } Pattern ScalarWebAPImatch = Pattern.compile("<av:X_ScalarWebAPI_BaseURL>(.*)</av:X_ScalarWebAPI_BaseURL>"); Pattern baseURLmatch = Pattern.compile("http://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d+)([^<]*)"); Matcher tagmatch = ScalarWebAPImatch.matcher(builder.toString()); if (tagmatch.find()) { Matcher matcher = baseURLmatch.matcher(tagmatch.group()); matcher.find(); int scalar_port = Integer.parseInt(matcher.group(2)); String scalar_path = matcher.group(3); properties.put(SonyAudioBindingConstants.SCALAR_PORT_PARAMETER, scalar_port); properties.put(SonyAudioBindingConstants.SCALAR_PATH_PARAMETER, scalar_path); } return properties; } }
Source:
<code>public void setHealthD(double health) { <START> Living thisEntity = this; <END> setHealth((float) health); if (thisEntity instanceof EntityPlayer && health == 0) { ((EntityPlayer) thisEntity).onDeath(DamageSource.generic); } }</code><technical_language>Unnecessary</technical_language>

Target:
public void setHealthD(double health) { Living thisEntity = (Living) this; setHealth((float) health); if (thisEntity instanceof EntityPlayer && health == 0) { ((EntityPlayer) thisEntity).onDeath(DamageSource.generic); } }
Source:
<code>private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridData data = new GridData(GridData.FILL_HORIZONTAL); <START> data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; <END> String name = fTrace.getName(); Label newTraceLabel = new Label(folderGroup, SWT.NONE); newTraceLabel.setFont(font); newTraceLabel.setText(Messages.CopyTraceDialog_TraceNewName); fNewTraceName = new Text(folderGroup, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewTraceName.setLayoutData(data); fNewTraceName.setFont(font); fNewTraceName.setFocus(); fNewTraceName.setText(name); fNewTraceName.setSelection(0, name.length()); fNewTraceName.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { validateNewTraceName(); } }); }</code><technical_language>Unused instance</technical_language>

Target:
private void createNewTraceNameGroup(Composite parent) { Font font = parent.getFont(); Composite folderGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; folderGroup.setLayout(layout); folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String name = fTrace.getName(); Label newTraceLabel = new Label(folderGroup, SWT.NONE); newTraceLabel.setFont(font); newTraceLabel.setText(Messages.CopyTraceDialog_TraceNewName); fNewTraceName = new Text(folderGroup, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fNewTraceName.setLayoutData(data); fNewTraceName.setFont(font); fNewTraceName.setFocus(); fNewTraceName.setText(name); fNewTraceName.setSelection(0, name.length()); fNewTraceName.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { validateNewTraceName(); } }); }
Source:
<code>public ByteBuffer allocate(int size, final long timeToBlockInMs) throws TimeoutException, InterruptedException { if (size > capacity) { throw new IllegalArgumentException("Requested size cannot exceed pool capacity."); } final long startTimeInMs = System.currentTimeMillis(); long timeout = timeToBlockInMs; synchronized (lock) { while (size > availableMemory) { timeout = timeToBlockInMs - (System.currentTimeMillis() - startTimeInMs); if (timeout <= 0) { throw new TimeoutException("Memory not Enough. Request timeout."); } lock.wait(timeout); } availableMemory -= size; if (availableMemory > 0) { <START> lock.notifyAll(); <END> } } return ByteBuffer.allocate(size); }</code><technical_language>notify() enough. preferred avoid sudden contention</technical_language>

Target:
public ByteBuffer allocate(int size, final long timeToBlockInMs) throws TimeoutException, InterruptedException { if (size > capacity) { throw new IllegalArgumentException("Requested size cannot exceed pool capacity."); } else if (timeToBlockInMs < 0) { throw new IllegalArgumentException("timeToBlockInMs cannot be negative."); } final long startTimeInMs = System.currentTimeMillis(); synchronized (lock) { while (size > availableMemory) { long timeout = timeToBlockInMs - (System.currentTimeMillis() - startTimeInMs); if (timeout <= 0) { throw new TimeoutException("Timed out waiting for allocation."); } lock.wait(timeout); } availableMemory -= size; if (availableMemory > 0) { lock.notify(); } } return ByteBuffer.allocate(size); }
Source:
<code>protected void initText(){ dayOfWeek = (TextView) findViewById(R.id.gregdayofweek); dayTxt = (EditText)findViewById(R.id.daytxtfield); yearTxt = (EditText)findViewById(R.id.yeartxtfield); MonthAdapter monthAdapter = new MonthAdapter(getContext(), monthList); monthTxt = (AutoCompleteTextView) findViewById(R.id.monthtxtfield); monthTxt.setAdapter(monthAdapter); dayTxt.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) @Override public void onTextChanged(CharSequence s, int start, int before, int count) @Override public void afterTextChanged(Editable s) { String contents = s.toString(); <START> if(contents.length() > 1) { <END> int num = Integer.parseInt(contents); int monthMax = selectedDate.getActualMaximum(Calendar.DAY_OF_MONTH); if (num <= monthMax && num >= 1) { selectedDate.set(Calendar.DAY_OF_MONTH, Integer.parseInt(s.toString())); } } } }); monthTxt.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) @Override public void onTextChanged(CharSequence s, int start, int before, int count) @Override public void afterTextChanged(Editable s) { String content = s.toString(); if(monthList.contains(content)){ monthArrayPointer = monthList.indexOf(content); selectedDate.set(Calendar.MONTH, monthArrayPointer); } } }); yearTxt.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) @Override public void onTextChanged(CharSequence s, int start, int before, int count) @Override public void afterTextChanged(Editable s) { String contents = s.toString(); if(contents.length() >= 4 ){ if(Integer.parseInt(contents) <= maxYear){ selectedDate.set(Calendar.YEAR, Integer.parseInt(contents)); } } } }); }</code><technical_language>check if input is 0, +, etc</technical_language>

Target:
protected void initText(){ dayOfWeek = (TextView) findViewById(R.id.greg_day_of_week); dayText = (EditText)findViewById(R.id.day_txt_field); yearText = (EditText)findViewById(R.id.year_txt_field); dayText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dayText.clearFocus(); dayText.requestFocus(); } }); yearText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { yearText.clearFocus(); yearText.requestFocus(); } }); setupMonthComponents(); }
Source:
<code>public Integer getStorageVersion() { <START> return GlobalSession.BOOKMARKS_ENGINE_VERSION; <END> }</code><technical_language>put this in some non-setup Constants file, move version into, say, BookmarkRecord all, record structure is main versioned</technical_language>

Target:
public Integer getStorageVersion() { return VersionConstants.BOOKMARKS_ENGINE_VERSION; }
Source:
<code>public void testMaybeCompleteValidationAfterPositionChange() { Node broker1 = new Node(1, "localhost", 9092); state.assignFromUser(Collections.singleton(tp0)); int currentEpoch = 10; long initialOffset = 10L; int initialOffsetEpoch = 5; long updateOffset = 20L; int updateOffsetEpoch = 8; SubscriptionState.FetchPosition initialPosition = new SubscriptionState.FetchPosition(initialOffset, Optional.of(initialOffsetEpoch), new Metadata.LeaderAndEpoch(Optional.of(broker1), Optional.of(currentEpoch))); state.seekUnvalidated(tp0, initialPosition); assertTrue(state.awaitingValidation(tp0)); SubscriptionState.FetchPosition updatePosition = new SubscriptionState.FetchPosition(updateOffset, Optional.of(updateOffsetEpoch), new Metadata.LeaderAndEpoch(Optional.of(broker1), Optional.of(currentEpoch))); state.seekUnvalidated(tp0, updatePosition); <START> Optional<LogTruncation> divergentOffsetMetadataOpt = state.maybeCompleteValidation(tp0, initialPosition, <END> new EpochEndOffset(initialOffsetEpoch, initialOffset + 5)); assertEquals(Optional.empty(), divergentOffsetMetadataOpt); assertTrue(state.awaitingValidation(tp0)); assertEquals(updatePosition, state.position(tp0)); }</code><technical_language>divergentOffsetMetadataOpt -> logTruncationOpt, for rest</technical_language>

Target:
public void testMaybeCompleteValidationAfterPositionChange() { Node broker1 = new Node(1, "localhost", 9092); state.assignFromUser(Collections.singleton(tp0)); int currentEpoch = 10; long initialOffset = 10L; int initialOffsetEpoch = 5; long updateOffset = 20L; int updateOffsetEpoch = 8; SubscriptionState.FetchPosition initialPosition = new SubscriptionState.FetchPosition(initialOffset, Optional.of(initialOffsetEpoch), new Metadata.LeaderAndEpoch(Optional.of(broker1), Optional.of(currentEpoch))); state.seekUnvalidated(tp0, initialPosition); assertTrue(state.awaitingValidation(tp0)); SubscriptionState.FetchPosition updatePosition = new SubscriptionState.FetchPosition(updateOffset, Optional.of(updateOffsetEpoch), new Metadata.LeaderAndEpoch(Optional.of(broker1), Optional.of(currentEpoch))); state.seekUnvalidated(tp0, updatePosition); Optional<LogTruncation> truncationOpt = state.maybeCompleteValidation(tp0, initialPosition, new EpochEndOffset(initialOffsetEpoch, initialOffset + 5)); assertEquals(Optional.empty(), truncationOpt); assertTrue(state.awaitingValidation(tp0)); assertEquals(updatePosition, state.position(tp0)); }
Source:
<code>void denyRoleInTree(String roleName, String resourceId, String action, boolean updateCache) throws UserStoreException { write.lock(); try { SearchResult sr = getNode(root, PermissionTreeUtil.toComponenets(resourceId)); if (sr.getUnprocessedPaths() != null) { List<String> paths = sr.getUnprocessedPaths(); TreeNode tn = sr.getLastNode().create(paths); tn.denyRole(roleName, PermissionTreeUtil.actionToPermission(action)); } else { sr.getLastNode().denyRole(roleName, PermissionTreeUtil.actionToPermission(action)); } if (updateCache) { invalidateCache(root); } } catch (Exception e) { <START> throw new UserStoreException(e.getMessage(),e); <END> } finally { write.unlock(); } }</code><technical_language>Add context specific message e.getMessage()</technical_language>

Target:
void denyRoleInTree(String roleName, String resourceId, String action, boolean updateCache) throws UserStoreException { write.lock(); try { SearchResult sr = getNode(root, PermissionTreeUtil.toComponenets(resourceId)); if (sr.getUnprocessedPaths() != null) { List<String> paths = sr.getUnprocessedPaths(); TreeNode tn = sr.getLastNode().create(paths); tn.denyRole(roleName, PermissionTreeUtil.actionToPermission(action)); } else { sr.getLastNode().denyRole(roleName, PermissionTreeUtil.actionToPermission(action)); } if (updateCache) { invalidateCache(root); } } catch (IllegalArgumentException e) { throw new UserStoreException("Error while denying role: " + roleName + "in permission tree for resource id: " + resourceId + "for action: " + action, e); } finally { write.unlock(); } }
Source:
<code>private void printVersion() { final Properties props = new Properties(); final InputStream input = Arguments.class.getClassLoader().getResourceAsStream(PROPERTY_FILE); try { props.load(input); System.out.println("Version: " + props.get("version")); } catch (final IOException e) { <START> System.out.println("Failed to load property file due to: " + e.getMessage()); <END> } }</code><technical_language>other places in CLI error handling, System.err more System.out here</technical_language>

Target:
private void printVersion() { final Properties props = new Properties(); final InputStream input = Arguments.class.getClassLoader().getResourceAsStream(PROPERTY_FILE); try { props.load(input); System.out.println("Version: " + props.get("version")); } catch (final IOException e) { System.err.println("Failed to load property file due to: " + e.getMessage()); } }
Source:
<code>public SpatialKnownIndex selectAndCreate( Map<CoordinateReferenceSystem,SpatialKnownIndex> indexMap, long indexId, CoordinateReferenceSystem crs ) { return indexMap.computeIfAbsent( crs, <START> k -> new SpatialKnownIndex( directoryStructure(), crs, indexId, pageCache, fs, monitor, recoveryCleanupWorkCollector ) ); <END> }</code><technical_language>key provided mapping function instead of referencing method parameter. crsKey -> new SpatialKnownIndex( directoryStructure(), crsKey, indexId, pageCache, fs, monitor, recoveryCleanupWorkCollector ) );</technical_language>

Target:
public SpatialKnownIndex selectAndCreate( Map<CoordinateReferenceSystem,SpatialKnownIndex> indexMap, long indexId, CoordinateReferenceSystem crs ) { return indexMap.computeIfAbsent( crs, crsKey -> new SpatialKnownIndex( directoryStructure(), crsKey, indexId, pageCache, fs, monitor, recoveryCleanupWorkCollector ) ); }
Source:
<code><START> public void setHaltOnException(boolean haltOnException) <END> { this.haltOnException = haltOnException; }</code><technical_language>this builder pattern</technical_language>

Target:
public MetadataBuilder setHaltOnException(boolean haltOnException) { this.haltOnException = haltOnException; return this; }
Source:
<code>public long estimatedInMemorySize() { return INSTANCE_SIZE + SizeOf.SIZE_OF_INT + SizeOf.SIZE_OF_INT + <START> 2 * SizeOf.SIZE_OF_DOUBLE * Math.min(size, samples.length); END> }</code><technical_language>This INSTANCE_SIZE + sizeOf(samples) + sizeOf(weights)</technical_language>

Target:
public long estimatedInMemorySize() { return INSTANCE_SIZE + SizeOf.sizeOf(samples) + SizeOf.sizeOf(weights); }
Source:
<code>@Override public synchronized boolean cancel() throws IgniteCheckedException { <START> return onDone(null, null, true); <END> }</code><technical_language>return onCancelled()</technical_language>

Target:
@Override public synchronized boolean cancel() throws IgniteCheckedException { return onCancelled(); }
Source:
<code><START> public void saveTask () { <END> new ShellMenu("File", "Save").select(); new ShellMenu("File", "Properties").select(); new PushButton("OK").click(); }</code><technical_language>I able find case File -> Save menu is enabled. Im wondering if ? line 37 calling shell menu File -> Properties clicking OK. This needless operation ..</technical_language>

Target:
public void saveTask () { new ShellMenu("File", "Save").select(); }
Source:
<code>public void shouldThrowIntermediateMessageEvent() throws Exception{ securityUtil.logInAs("user"); ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start() .withBusinessKey("businessKey") .withProcessDefinitionKey(PROCESS_INTERMEDIATE_THROW_MESSAGE_EVENT) .build()); assertThat(MessageTestConfiguration.messageEvents) .isNotEmpty() .extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> ((BPMNMessage)(event.getEntity())).getMessagePayload().getName(), event -> ((BPMNMessage)(event.getEntity())).getMessagePayload().getCorrelationKey(), event -> ((BPMNMessage)(event.getEntity())).getMessagePayload().getBusinessKey(), event -> ((BPMNMessage)(event.getEntity())).getMessagePayload().getVariables() ) .contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_SENT, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), <START> "Test Message", <END> "value", "businessKey", Collections.singletonMap("message_payload_variable", "value"))); }</code><technical_language>lost activity type other attributes original engine event, i. e. process businessKey. useful info for downstream consumers I think</technical_language>

Target:
public void shouldThrowIntermediateMessageEvent() { securityUtil.logInAs("user"); ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start() .withBusinessKey("businessKey") .withProcessDefinitionKey(PROCESS_INTERMEDIATE_THROW_MESSAGE_EVENT) .build()); assertThat(MessageTestConfiguration.messageEvents) .isNotEmpty() .extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables() ) .contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_SENT, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "Test Message", "value", "businessKey", Collections.singletonMap("message_payload_variable", "value"))); }
Source:
<code>private void deleteExtendedDataForElement(Element element) { try { FilterBuilder filters[] = new FilterBuilder[1]; filters[0] = FilterBuilders.termFilter(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_ELEMENT_ID_FIELD_NAME, element.getId()); <START> FilterBuilder filter = FilterBuilders.andFilter(filters); <END> SearchRequestBuilder s = getClient().prepareSearch(getIndicesToQuery()) .setTypes(ElasticsearchSingleDocumentSearchIndex.ELEMENT_TYPE) .setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), filter)) .addField(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_ELEMENT_ID_FIELD_NAME) .addField(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_TABLE_NAME_FIELD_NAME) .addField(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_TABLE_ROW_ID_FIELD_NAME); for (SearchHit hit : s.execute().get().getHits()) { if (MUTATION_LOGGER.isTraceEnabled()) { LOGGER.trace("deleting extended data document %s", hit.getId()); } getClient().prepareDelete(hit.getIndex(), ELEMENT_TYPE, hit.getId()).execute().actionGet(); } } catch (Exception ex) { throw new VertexiumException("Could not delete extended data for element: " + element.getId()); } }</code><technical_language>add a andFilter method takes a single filter calls addFilter(filters[])</technical_language>

Target:
private void deleteExtendedDataForElement(Element element) { try { FilterBuilder filter = FilterBuilders.termFilter(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_ELEMENT_ID_FIELD_NAME, element.getId()); SearchRequestBuilder s = getClient().prepareSearch(getIndicesToQuery()) .setTypes(ElasticsearchSingleDocumentSearchIndex.ELEMENT_TYPE) .setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), filter)) .addField(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_ELEMENT_ID_FIELD_NAME) .addField(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_TABLE_NAME_FIELD_NAME) .addField(ElasticsearchSingleDocumentSearchIndex.EXTENDED_DATA_TABLE_ROW_ID_FIELD_NAME); for (SearchHit hit : s.execute().get().getHits()) { if (MUTATION_LOGGER.isTraceEnabled()) { LOGGER.trace("deleting extended data document %s", hit.getId()); } getClient().prepareDelete(hit.getIndex(), ELEMENT_TYPE, hit.getId()).execute().actionGet(); } } catch (Exception ex) { throw new VertexiumException("Could not delete extended data for element: " + element.getId()); } }
Source:
<code>public static <T extends Resource> Flux<IDocumentQueryExecutionComponent<T>> createAsync( Function<String, Flux<IDocumentQueryExecutionComponent<T>>> createSourceComponentFunction, String continuationToken, Map<String, AggregateOperator> groupByAliasToAggregateType, List<String> orderedAliases, boolean hasSelectValue) { if (continuationToken != null) { CosmosException dce = new BadRequestException(CONTINUATION_TOKEN_NOT_SUPPORTED_WITH_GROUP_BY); return Flux.error(dce); } <START> GroupingTable table = new GroupingTable(groupByAliasToAggregateType, orderedAliases, hasSelectValue); <END> return createSourceComponentFunction.apply(null) .map(component -> new GroupByDocumentQueryExecutionContext<>(component, table)); }</code><technical_language>null check other argumetns</technical_language>

Target:
public static <T extends Resource> Flux<IDocumentQueryExecutionComponent<T>> createAsync( Function<String, Flux<IDocumentQueryExecutionComponent<T>>> createSourceComponentFunction, String continuationToken, Map<String, AggregateOperator> groupByAliasToAggregateType, List<String> orderedAliases, boolean hasSelectValue) { if (continuationToken != null) { CosmosException dce = new BadRequestException(CONTINUATION_TOKEN_NOT_SUPPORTED_WITH_GROUP_BY); return Flux.error(dce); } if (groupByAliasToAggregateType == null) { throw new IllegalArgumentException("groupByAliasToAggregateType should not be null"); } if (orderedAliases == null) { throw new IllegalArgumentException("orderedAliases should not be null"); } GroupingTable table = new GroupingTable(groupByAliasToAggregateType, orderedAliases, hasSelectValue); return createSourceComponentFunction.apply(null) .map(component -> new GroupByDocumentQueryExecutionContext<>(component, table)); }
Source:
<code>public void containsFileWithContent(String path, byte[] content) { <START> assertThat(extractContentAsByte(path)).isEqualTo(content); <END> }</code><technical_language>want named(path) named(new File(path).getName()). This is useful for tests throw multiple asserts revert searching for a matching line number understand test fail. BTW, in this case, content show in error message, a manual comparison manually building erorr message (using failWithBadResult)</technical_language>

Target:
public void containsFileWithContent(String path, byte[] content) { assertThat(extractContentAsByte(path)).named(path).isEqualTo(content); }
Source:
<code>private void prepareChangesInfo(Change[] changes, List<ChangeInfo> changesInfo) { for (Change ch : changes) { if (ch instanceof DynamicValidationStateChange) { prepareChangesInfo(((DynamicValidationStateChange)ch).getChildren(), changesInfo); } else { ChangeInfo changeInfo = DtoFactory.newDto(ChangeInfo.class); String refactoringName = ch.getName(); if (ch instanceof UndoTextFileChange) { changeInfo.setName(ChangeInfo.ChangeName.UPDATE); changeInfo.setPath(((CompilationUnit)ch.getModifiedElement()).getPath().toString()); } if (refactoringName.startsWith("Rename")) { <START> if (ch instanceof RenameCompilationUnitChange) { <END> prepareRenameCompilationUnitChange(changeInfo, ch); } if (ch instanceof RenamePackageChange) { prepareRenamePackageChange(changesInfo, changeInfo, ch); } } if (refactoringName.startsWith("Move")) { prepareMoveChange(changeInfo, ch); } changesInfo.add(changeInfo); } } }</code><technical_language>ch instance of RenameCompilationUnitChange RenamePackageChange time? If no, is if else</technical_language>

Target:
public void prepareChangesInfo(Change[] changes, List<ChangeInfo> changesInfo) { for (Change ch : changes) { if (ch instanceof DynamicValidationStateChange) { prepareChangesInfo(((DynamicValidationStateChange)ch).getChildren(), changesInfo); } else { ChangeInfo changeInfo = DtoFactory.newDto(ChangeInfo.class); String refactoringName = ch.getName(); if (ch instanceof UndoTextFileChange) { changeInfo.setName(ChangeInfo.ChangeName.UPDATE); changeInfo.setPath(((CompilationUnit)ch.getModifiedElement()).getPath().toString()); } if (refactoringName.startsWith("Rename")) { if (ch instanceof RenameCompilationUnitChange) { prepareRenameCompilationUnitChange(changeInfo, ch); } else if (ch instanceof RenamePackageChange) { prepareRenamePackageChange(changesInfo, changeInfo, ch); } } if (refactoringName.startsWith("Move")) { prepareMoveChange(changeInfo, ch); } changesInfo.add(changeInfo); } } }
Source:
<code>protected void setUpTasksComboColumn(TableColumn column, final JTable table) { final JComboBox comboBox = new JComboBox(); Task[] tasks = myTaskManager.getTasks(); <START> for (int i = 0; i < tasks.length; i++) { <END> Task next = tasks[i]; comboBox.addItem(next); } comboBox.setEditable(false); column.setCellEditor(new DefaultCellEditor(comboBox)); }</code><technical_language>foreach: for (Task t : myTaskManager.getTasks())</technical_language>

Target:
private void setUpTasksComboColumn(TableColumn column, final JTable table) { final JComboBox comboBox = new JComboBox(); Task[] tasks = myTaskManager.getTasks(); for (Task next : tasks) { comboBox.addItem(next); } comboBox.setEditable(false); column.setCellEditor(new DefaultCellEditor(comboBox)); }
Source:
<code>private void processTaskEvent(ITmfStateSystemBuilder ssb, TaskContainerEvent t) { if (!rootContainerInfoAdded) { throw new IllegalStateException("Error, cannot process task while root container info is not valid!"); } int rootContainerQuark = ContainerHelper.getRootContainerQuark(ssb); ContainerInfo rootContainerInfo = ContainerHelper.getContainerInfo(ssb, rootContainerQuark); if (rootContainerInfo == null) { throw new IllegalStateException("Error, root container seems added but container info is unavailable!"); } TaskContainerEvent parent = hmTasks.get(t.getPpid()); if (parent != null && t.getNsInode() != rootContainerInfo.getContainerInode()) { try{ int taskContainerINode = ContainerHelper.findContainerQuarkWithInode(ssb, t.getNsInode()); if (taskContainerINode != rootContainerQuark) { int containerQuark = ContainerHelper.findContainerQuarkWithInode(ssb, t.getNsInode()); ContainerHelper.addTaskToContainer(ssb, containerQuark, t.getTs(), t.getVtid(), t.getTid()); } <START> } catch (AttributeNotFoundException e) <END> { if (t.getNsInode() != parent.getNsInode()) { if (!isParentContainerAdded(ssb, t)) { throw new IllegalStateException("the parent container of the task does not exist!"); } ContainerInfo cInfo = new ContainerInfo(t.getNsInode(), parent.getTid(), "TODO_ADD_HOSTNAME"); ContainerHelper.addContainerAndTask(ssb, t.getTs(), parent.getNsInode(), t.getTid(), t.getVtid(), cInfo); } } } }</code><technical_language>Exceptions for "unusual" things. is expected attributes exist first, this normal, expected code path exceptions. For instance, writing a state system, -AndAdd() variants of getQuark* methods, do throw a AttributeNotFoundException create attribute exist. if this pattern reused here, is a solution in vein</technical_language>

Target:
private void processTaskEvent(ITmfStateSystemBuilder ssb, TaskContainerEvent t) { int rootContainerQuark = ContainerHelper.getRootContainerQuark(ssb); ContainerInfo rootContainerInfo = ContainerHelper.getContainerInfo(ssb, rootContainerQuark); if (rootContainerInfo == null) { throw new IllegalStateException("Error, root container seems added but container info is unavailable!"); } TaskContainerEvent parent = fTasks.get(t.getPpid()); if (parent != null && t.getNsInode() != rootContainerInfo.getContainerInode()) { int taskContainerQuark = ContainerHelper.findContainerQuarkWithInode(ssb, t.getNsInode()); if (taskContainerQuark != ContainerHelper.fCONTAINER_QUARK_NOT_FOUND) { ContainerHelper.addTaskToContainer(ssb, taskContainerQuark, t.getTs(), t.getVtid(), t.getTid()); } else { if (t.getNsInode() != parent.getNsInode()) { if (!isParentContainerAdded(ssb, t)) { throw new IllegalStateException("the parent container of the task does not exist!"); } ContainerInfo cInfo = new ContainerInfo(t.getNsInode(), parent.getTid(), "TODO_ADD_HOSTNAME"); ContainerHelper.addContainerAndTask(ssb, t.getTs(), parent.getNsInode(), t.getTid(), t.getVtid(), cInfo); } } } }
Source:
<code><START> private static Optional<URI> buildUri(String reportUri) { <END> try { return Optional.of(URI.create(reportUri)); } catch (IllegalArgumentException ignored) { } return Optional.empty(); }</code><technical_language>static</technical_language>

Target:
private Optional<URI> buildUri(String reportUri) { try { return Optional.of(URI.create(reportUri)); } catch (IllegalArgumentException ignored) { } return Optional.empty(); }
Source:
<code>protected void processManyValuedFeatureByCopying(EStructuralFeature manyValuedFeature, SIRIUS processedDescription, SIRIUS currentDescription, TransformationCache cache) { Object processedValue = processedDescription.eGet(manyValuedFeature); Object currentValue = currentDescription.eGet(manyValuedFeature); if (currentValue instanceof Iterable<?> && processedValue instanceof Iterable<?>) { List<Object> newValue = new ArrayList<>(); Iterable<?> currentIterable = (Iterable<?>) currentValue; Iterable<?> processedIterable = (Iterable<?>) processedValue; <START> for (Object object : currentIterable) { if (object instanceof EObject) { EObject newEObject = EcoreUtil.copy((EObject) object); cache.put(object, newEObject); newValue.add(newEObject); } } for (Object object : processedIterable) { newValue.add(object); } <END> processedDescription.eSet(manyValuedFeature, newValue); } }</code><technical_language>java8-isation [forEach][filter]</technical_language>

Target:
protected void processManyValuedFeatureByCopying(EStructuralFeature manyValuedFeature, SIRIUS processedDescription, SIRIUS currentDescription, TransformationCache cache) { Object processedValue = processedDescription.eGet(manyValuedFeature); Object currentValue = currentDescription.eGet(manyValuedFeature); if (currentValue instanceof Iterable<?> && processedValue instanceof Iterable<?>) { List<Object> newValue = new ArrayList<>(); Iterable<?> currentIterable = (Iterable<?>) currentValue; Iterable<?> processedIterable = (Iterable<?>) processedValue; StreamSupport.stream(currentIterable.spliterator(), false).filter(EObject.class::isInstance).map(EObject.class::cast).forEach(object -> { EObject newEObject = EcoreUtil.copy(object); cache.put(object, newEObject); newValue.add(newEObject); }); processedIterable.forEach(newValue::add); processedDescription.eSet(manyValuedFeature, newValue); } }
Source:
<code>public void testFirstAndLastBothShape() { editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), getRepresentationDescriptionName(), "Distribute Action Package Diagram 2", DDiagram.class); <START> Collection<SWTBotGefEditPart> editPartsToDistribute = getEditParts("CanvasPackageToDrop1", "RootPackage1", "RootPackage2", "CanvasPackageToDrop2", "AAPackage"); <END> horizontallyOrderEditParts(editPartsToDistribute); PointList previousPoints = new PointList(); for (SWTBotGefEditPart editPart : editPartsToDistribute) { previousPoints.addPoint(editor.getLocation(editPart)); } editor.select(editPartsToDistribute); SWTBotUtils.waitAllUiEvents(); editor.clickContextMenu(HORIZONTALLY_GAPS_LABEL); SWTBotUtils.waitAllUiEvents(); PointList expectedPoints = new PointList(); for (int i = 0; i < editPartsToDistribute.size(); i++) { expectedPoints.addPoint(editor.getLocation((SWTBotGefEditPart) editPartsToDistribute.toArray()[i])); } assertEquals("Distribute Action should not move nodes when the first shape is the last one", previousPoints.getBounds(), expectedPoints.getBounds()); }</code><technical_language>Collection<SWTBotGefEditPart> --> List<SWTBotGefEditPart></technical_language>

Target:
public void testFirstAndLastBothShape() { editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), getRepresentationDescriptionName(), "Distribute Action Package Diagram 2", DDiagram.class); List<SWTBotGefEditPart> editPartsToDistribute = getEditParts("CanvasPackageToDrop1", "RootPackage1", "RootPackage2", "CanvasPackageToDrop2", "AAPackage"); List<SWTBotGefEditPart> orderedEditPartsToDistribute = horizontallyOrderEditParts(editPartsToDistribute); PointList previousPoints = new PointList(); for (SWTBotGefEditPart editPart : orderedEditPartsToDistribute) { previousPoints.addPoint(editor.getLocation(editPart)); } editor.select(editPartsToDistribute); editor.clickContextMenu(HORIZONTALLY_GAPS_LABEL); PointList expectedPoints = new PointList(); for (int i = 0; i < orderedEditPartsToDistribute.size(); i++) { expectedPoints.addPoint(editor.getLocation((SWTBotGefEditPart) orderedEditPartsToDistribute.get(i))); } assertEquals("Distribute Action should not move nodes when the first shape is the last one", previousPoints.getBounds(), expectedPoints.getBounds()); }
Source:
<code>@Override protected VisorEither<VisorQueryPingTaskResult> run(VisorQueryNextPageTaskArg arg) { String qryId = arg.getQueryId(); long start = U.currentTimeMillis(); if (debug) start = log(ignite.log(), "Ping of query started: " + qryId, getClass(), start); VisorQueryHolder holder = getQueryHolder(ignite, qryId); if (holder.getErr() != null) return new VisorEither<>(new VisorExceptionWrapper(holder.getErr())); holder.setAccessed(true); if (debug) log(ignite.log(), "Ping of query finished: " + qryId, getClass(), start); <START> return new VisorEither<>(new VisorQueryPingTaskResult(true)); <END> }</code><technical_language>inProgress flag is true, I removed</technical_language>

Target:
@Override protected VisorEither<VisorQueryPingTaskResult> run(VisorQueryNextPageTaskArg arg) { String qryId = arg.getQueryId(); long start = U.currentTimeMillis(); if (debug) start = log(ignite.log(), "Ping of query started: " + qryId, getClass(), start); VisorQueryHolder holder = getQueryHolder(ignite, qryId); if (holder.getErr() != null) return new VisorEither<>(new VisorExceptionWrapper(holder.getErr())); holder.setAccessed(true); if (debug) log(ignite.log(), "Ping of query finished: " + qryId, getClass(), start); return new VisorEither<>(new VisorQueryPingTaskResult()); }
Source:
<code>public String toString() { <START> return String.format("double@0x%x=%s", Pointer.nativeValue(getPointer()), Double.toString(getValue())); <END> }</code><technical_language>explicit call Double#toString is necessary, String#format invoked a primitive boolean</technical_language>

Target:
public String toString() { return String.format("double@0x%x=%s", Pointer.nativeValue(getPointer()), getValue()); }
Source:
<code>public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); FailureCollector collector = context.getFailureCollector(); config.validate(collector); collector.getOrThrowException(); <START> Schema inputSchema = context.getInputSchema(); <END> if (inputSchema == null || inputSchema.getFields() == null || inputSchema.getFields().isEmpty()) { return; } Set<String> input = inputSchema.getFields().stream().map(Schema.Field::getName).collect(Collectors.toSet()); List<FieldOperation> operationList = new ArrayList<>(); for (String inputField : input) { List<String> outputs = new ArrayList<>(); for (int i = 0; i < config.copies; i++) { outputs.add(inputField); } FieldTransformOperation operation = new FieldTransformOperation("clone" + inputField, "Clone field " + inputField, Collections.singletonList(inputField), outputs); operationList.add(operation); } context.record(operationList); }</code><technical_language>This is incorrect, this transform copies record n times based config. input output schema change, field operations a list of one-to-one field mapping input field output field</technical_language>

Target:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); FailureCollector collector = context.getFailureCollector(); config.validate(collector); collector.getOrThrowException(); context.record( TransformLineageRecorderUtils.generateOneToOnes(TransformLineageRecorderUtils.getFields(context.getInputSchema()), "clone", "Copied the input record.")); }
Source:
<code>private String getPartitionLeasePrefix() { <START> return this.settings.getContainerNamePrefix() + ".."; <END> }</code><technical_language>consider making defined constants</technical_language>

Target:
private String getPartitionLeasePrefix() { return this.settings.getContainerNamePrefix() + LEASE_STORE_MANAGER_LEASE_SUFFIX; }
Source:
<code><START> public Object getCredential() { <END> return credential; }</code><technical_language>return type Credential</technical_language>

Target:
public Credential getCredential() { return credential; }
Source:
<code>static AlgorithmParameterSpec resolveSymmetricAlgorithmParameters(String symmetricAlgorithm) throws CryptoException { String errorMessage = String.format("'%s' symmetric algorithm is not supported.", symmetricAlgorithm); if (symmetricAlgorithm.contains("AES")) { <START> byte[] iv = new byte[16]; <END> random.nextBytes(iv); if (symmetricAlgorithm.contains("GCM")) { return new GCMParameterSpec(128, iv); } else if (symmetricAlgorithm.contains("OFB") || symmetricAlgorithm.contains("CBC") || symmetricAlgorithm.contains("CFB")) { return new IvParameterSpec(iv); } else { throw new CryptoException(errorMessage); } } else if (symmetricAlgorithm.contains("DES")) { byte[] iv = new byte[8]; random.nextBytes(iv); return new IvParameterSpec(iv); } else { throw new CryptoException(errorMessage); } }</code><technical_language>Is this a standard variable name? If not, a meaningful variable name</technical_language>

Target:
static AlgorithmParameterSpec resolveSymmetricAlgorithmParameters(String symmetricAlgorithm) throws CryptoException { String errorMessage = String.format("'%s' symmetric algorithm is not supported.", symmetricAlgorithm); if (symmetricAlgorithm.contains(AlgorithmConstants.ENC_METHOD_AES)) { byte[] iv = new byte[AlgorithmConstants.AES.DEFAULT_IV_LENGTH]; random.nextBytes(iv); if (symmetricAlgorithm.contains(AlgorithmConstants.AES.GCM_MODE)) { return new GCMParameterSpec(AlgorithmConstants.AES.DEFAULT_GCM_TAG_LENGTH, iv); } else if (symmetricAlgorithm.contains(AlgorithmConstants.AES.CFB_MODE) || symmetricAlgorithm.contains( AlgorithmConstants.AES.CBC_MODE) || symmetricAlgorithm.contains(AlgorithmConstants.AES.OFB_MODE)) { return new IvParameterSpec(iv); } else { throw new CryptoException(errorMessage); } } else if (symmetricAlgorithm.contains(AlgorithmConstants.ENC_METHOD_DES)) { byte[] iv = new byte[AlgorithmConstants.DES.DEFAULT_IV_LENGTH]; random.nextBytes(iv); return new IvParameterSpec(iv); } else { throw new CryptoException(errorMessage); } }
Source:
<code>protected final MultiConnectionState getStateFromId(final String key) { if (this.getParentServer() == null) { <START> LOG.info("null parent"); <END> return null; } return this.getParentServer().getIdToState().get(key); }</code><technical_language>change "parent server exist is null"</technical_language>

Target:
protected final MultiConnectionState getStateFromId(final String key) { if (this.getParentServer() == null) { LOG.info("parent server does not exist and is null"); return null; } return this.getParentServer().getIdToState().get(key); }
Source:
<code><START> public String getRealElementName() { <END> if (elementName.startsWith("get") && Character.isUpperCase(elementName.charAt(3))) { return elementName.substring(3).toLowerCase(); } else if (elementName.startsWith("is") && Character.isUpperCase(elementName.charAt(2))) { return elementName.substring(2).toLowerCase(); } else { return elementName; } }</code><technical_language>nullability missed)</technical_language>

Target:
public String getRealElementName() { if (elementName.startsWith("get") && Character.isUpperCase(elementName.charAt(3))) { return decapitalize(elementName.substring(3)); } else if (elementName.startsWith("is") && Character.isUpperCase(elementName.charAt(2))) { return decapitalize(elementName.substring(2)); } else { return elementName; } }
Source:
<code>public void removeAllBucketNotification(String bucketName) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException { <START> setBucketNotification( SetBucketNotificationArgs.builder() .bucket(bucketName) .config(new NotificationConfiguration()) .build()); <END> }</code><technical_language>call deleteBucketNotification</technical_language>

Target:
public void removeAllBucketNotification(String bucketName) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, XmlParserException { deleteBucketNotification(DeleteBucketNotificationArgs.builder().bucket(bucketName).build()); }
Source:
<code>private ApiFuture<?> issueAsyncRequest(Row row) { try { if (row instanceof Get) { return bulkRead.add( <START> ByteString.copyFrom(row.getRow()), Adapters.GET_ADAPTER.buildFilter((Get) row)); <END> } else if (row instanceof Mutation) { return bufferedMutatorHelper.mutate((Mutation) row); } else if (row instanceof RowMutations) { return bufferedMutatorHelper.mutate((RowMutations) row); } } catch (Throwable e) { return ApiFutures.immediateFailedFuture(new IOException("Could not process the batch", e)); } LOG.error("Encountered unknown action type %s", row.getClass()); return ApiFutures.immediateFailedFuture( new IllegalArgumentException("Encountered unknown action type: " + row.getClass())); }</code><technical_language>zero copy util here</technical_language>

Target:
private ApiFuture<?> issueAsyncRequest(Row row) { try { if (row instanceof Get) { return bulkRead.add( ByteStringer.wrap(row.getRow()), Adapters.GET_ADAPTER.buildFilter((Get) row)); } else if (row instanceof Mutation) { return bufferedMutatorHelper.mutate((Mutation) row); } else if (row instanceof RowMutations) { return bufferedMutatorHelper.mutate((RowMutations) row); } } catch (Throwable e) { return ApiFutures.immediateFailedFuture(new IOException("Could not process the batch", e)); } LOG.error("Encountered unknown action type %s", row.getClass()); return ApiFutures.immediateFailedFuture( new IllegalArgumentException("Encountered unknown action type: " + row.getClass())); }
Source:
<code>public void run(ToolingApiOperation runnable, CancellationTokenSource tokenSource, IProgressMonitor monitor) throws CoreException { IProgressMonitor efficientMonitor = new RateLimitingProgressMonitor(monitor, 500, TimeUnit.MILLISECONDS); <START> ResourcesPlugin.getWorkspace().run(new WorkspaceRunnableAdapter(runnable, tokenSource), runnable.getRule(), IWorkspace.AVOID_UPDATE, efficientMonitor); <END> }</code><technical_language>elaborate explain AVOID_WORKSPACE is necessary here</technical_language>

Target:
public void run(ToolingApiOperation runnable, CancellationTokenSource tokenSource, IProgressMonitor monitor) throws CoreException { IProgressMonitor efficientMonitor = new RateLimitingProgressMonitor(monitor, 500, TimeUnit.MILLISECONDS); ResourcesPlugin.getWorkspace().run(new WorkspaceRunnableAdapter(runnable, tokenSource), runnable.getRule(), 0, efficientMonitor); }
Source:
<code>public int compare(final TimeZoneTransition x, final TimeZoneTransition y) { if (x == y) { return 0; } else if (x != null && y != null) { <START> if (x instanceof AbsoluteDateTransition && y instanceof AbsoluteDateTransition) { <END> final AbsoluteDateTransition firstTransition = (AbsoluteDateTransition) x; final AbsoluteDateTransition secondTransition = (AbsoluteDateTransition) y; final Date firstDateTime = firstTransition.getDateTime(); final Date secondDateTime = secondTransition.getDateTime(); return firstDateTime.compareTo(secondDateTime); } else if (x instanceof RelativeDayOfMonthTransition && y instanceof RelativeDayOfMonthTransition) { final RelativeDayOfMonthTransition firstTransition = (RelativeDayOfMonthTransition) x; final RelativeDayOfMonthTransition secondTransition = (RelativeDayOfMonthTransition) y; final DayOfTheWeek first = firstTransition.getDayOfTheWeek(); final DayOfTheWeek second = secondTransition.getDayOfTheWeek(); return first.compareTo(second); } else if (x instanceof AbsoluteDayOfMonthTransition && y instanceof AbsoluteDayOfMonthTransition) { final AbsoluteDayOfMonthTransition firstTransition = (AbsoluteDayOfMonthTransition) x; final AbsoluteDayOfMonthTransition secondTransition = (AbsoluteDayOfMonthTransition) y; final int first = firstTransition.getDayOfMonth(); final int second = secondTransition.getDayOfMonth(); return Integer.valueOf(first).compareTo(Integer.valueOf(second)); } } else if (y == null) { return 1; } return -1; }</code><technical_language>I did't project's unit tests yet, write it, if necessary</technical_language>

Target:
public int compare(final TimeZoneTransition x, final TimeZoneTransition y) { if (x == y) { return 0; } else if (x != null && y != null) { if (x instanceof AbsoluteDateTransition && y instanceof AbsoluteDateTransition) { final AbsoluteDateTransition firstTransition = (AbsoluteDateTransition) x; final AbsoluteDateTransition secondTransition = (AbsoluteDateTransition) y; final Date firstDateTime = firstTransition.getDateTime(); final Date secondDateTime = secondTransition.getDateTime(); return firstDateTime.compareTo(secondDateTime); } else if (y instanceof TimeZoneTransition) { return 1; } } else if (y == null) { return 1; } return -1; }
Source:
<code>public String toString() { return "LooseObjects[" + <START> getDirectory() + <END> "]"; }</code><technical_language>directory</technical_language>

Target:
public String toString() { return "LooseObjects[" + directory + "]"; }
Source:
<code>public JSONObject toApiFormatJson() { try { JSONObject json = new JSONObject(); json.put("ld", this.direction.toString()); json.put("lc", this.code); json.put("ln", this.name); json.put("lr", this.region); return json; } catch (Exception e) { <START> return null; <END> } }</code><technical_language>safe completely ignore exception. e.printStackTrace() other developers opportunity find exception in console if needed</technical_language>

Target:
public JSONObject toApiFormatJson() { try { JSONObject json = new JSONObject(); json.put("ld", this.direction.toString()); json.put("lc", this.code); json.put("ln", this.name); json.put("lr", this.region); return json; } catch (Exception e) { e.printStackTrace(); } return null; }