auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>static Response parseResponse(HttpResponse response) throws IOException { StatusLine statusLine = response.getStatusLine(); int status = statusLine.getStatusCode(); String reason = statusLine.getReasonPhrase(); List<Header> headers = new ArrayList<Header>(); String contentType = "application/octet-stream"; for (org.apache.http.Header header : response.getAllHeaders()) { String name = header.getName(); String value = header.getValue(); if ("Content-Type".equalsIgnoreCase(name)) { contentType = value; } headers.add(new Header(name, value)); } TypedByteArray body = null; HttpEntity entity = response.getEntity(); <START> boolean isGzipped = false; <END> if (entity != null) { if (entity.getContentEncoding() != null) { HeaderElement[] codecs = entity.getContentEncoding().getElements(); for (HeaderElement codec : codecs) { if ("gzip".equalsIgnoreCase(codec.getName())) { isGzipped = true; break; } } } byte[] bytes; if (isGzipped) { final GZIPInputStream gin = new GZIPInputStream(entity.getContent()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int bytesRead = 0; while ((bytesRead = gin.read(buffer)) != -1) { baos.write(buffer, 0, bytesRead); } bytes = baos.toByteArray(); } else { bytes = EntityUtils.toByteArray(entity); } body = new TypedByteArray(contentType, bytes); } return new Response(status, reason, headers, body); }</code><technical_language>Move this if block</technical_language>

Target:
static Response parseResponse(HttpResponse response) throws IOException { StatusLine statusLine = response.getStatusLine(); int status = statusLine.getStatusCode(); String reason = statusLine.getReasonPhrase(); List<Header> headers = new ArrayList<Header>(); String contentType = "application/octet-stream"; for (org.apache.http.Header header : response.getAllHeaders()) { String name = header.getName(); String value = header.getValue(); if ("Content-Type".equalsIgnoreCase(name)) { contentType = value; } headers.add(new Header(name, value)); } TypedByteArray body = null; final HttpEntity entity = response.getEntity(); if (entity != null) { boolean isGzipped = false; if (entity.getContentEncoding() != null) { HeaderElement[] codecs = entity.getContentEncoding().getElements(); for (HeaderElement codec : codecs) { if ("gzip".equalsIgnoreCase(codec.getName())) { isGzipped = true; break; } } } byte[] bytes; if (isGzipped) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { final GZIPInputStream gin = new GZIPInputStream(entity.getContent()); byte[] buffer = new byte[4096]; int bytesRead = 0; while ((bytesRead = gin.read(buffer)) != -1) { baos.write(buffer, 0, bytesRead); } bytes = baos.toByteArray(); } finally { baos.close(); } } else { bytes = EntityUtils.toByteArray(entity); } body = new TypedByteArray(contentType, bytes); } return new Response(status, reason, headers, body); }
Source:
<code>public void should_extract_null_from_unknown_key() { Map<String, List<String>> map = createTestData(); assertThat(map) .flatExtracting("name", "id") <START> .contains("Jeff", (Object) null); <END> }</code><technical_language>containsNull()</technical_language>

Target:
public void should_extract_null_from_unknown_key() { Map<String, List<String>> map = createTestData(); assertThat(map).flatExtracting("name", "id") .containsNull(); }
Source:
<code>protected double convertDegreesToValue(double degrees) { <START> return ((degrees - ServoSubsystem.kMinServoAngle)) / getServoAngleRange(); <END> }</code><technical_language>passed in values</technical_language>

Target:
protected static double convertDegreesToValue(double degrees) { return ((degrees - ServoSubsystem.MIN_SERVO_ANGLE)) / ServoSubsystem.getServoAngleRange(); }
Source:
<code>private AccountGroup findGroup(final String name) throws OrmException, Failure { final AccountGroup g = groupCache.get(new AccountGroup.NameKey(name)); if (g == null) { <START> throw new Failure(new NoSuchEntityException()); <END> } return g; }</code><technical_language>NoSuchGroupException</technical_language>

Target:
private AccountGroup findGroup(final String name) throws OrmException, Failure { final AccountGroup g = groupCache.get(new AccountGroup.NameKey(name)); if (g == null) { throw new Failure(new NoSuchGroupException(name)); } return g; }
Source:
<code>RegionStateNode createRegionStateNode(RegionInfo regionInfo) { synchronized (regionsMapLock) { RegionStateNode node = regionsMap.computeIfAbsent(regionInfo.getRegionName(), key -> new RegionStateNode(regionInfo, regionInTransition)); <START> return encodedRegionsMap.putIfAbsent(regionInfo.getEncodedName(), node); <END> } }</code><technical_language>This is correct, if is putIfAbsent returns null... I add assert, putIfAbsent return null, return node above</technical_language>

Target:
RegionStateNode createRegionStateNode(RegionInfo regionInfo) { synchronized (regionsMapLock) { RegionStateNode node = regionsMap.computeIfAbsent(regionInfo.getRegionName(), key -> new RegionStateNode(regionInfo, regionInTransition)); if (encodedRegionsMap.get(regionInfo.getEncodedName()) != node) { encodedRegionsMap.put(regionInfo.getEncodedName(), node); } return node; } }
Source:
<code>public void assertOpen() { Status reason = this.terminationReason; if ( reason != null ) { throw new TransactionTerminatedException( reason ); } if ( closed ) { <START> throw new NotInTransactionException( "The statement has been closed." ); <END> } }</code><technical_language>transaction closed</technical_language>

Target:
public void assertOpen() { Status reason = this.terminationReason; if ( reason != null ) { throw new TransactionTerminatedException( reason ); } if ( closed ) { throw new NotInTransactionException( "The transaction has been closed." ); } }
Source:
<code>public FeedLoadResult copyTables() { FeedLoadResult result = new FeedLoadResult(); try { connection = dataSource.getConnection(); this.tablePrefix = randomIdString(); result.uniqueIdentifier = tablePrefix; registerSnapshot(); <START> this.tablePrefix += "."; <END> long startTime = System.currentTimeMillis(); result.agency = copy(Table.AGENCY, true, true); result.calendar = copy(Table.CALENDAR, true, true); result.calendarDates = copy(Table.CALENDAR_DATES, true, false); result.fareAttributes = copy(Table.FARE_ATTRIBUTES, true, true); result.fareRules = copy(Table.FARE_RULES, true, true); result.feedInfo = copy(Table.FEED_INFO, true, false); result.frequencies = copy(Table.FREQUENCIES, true, true); result.routes = copy(Table.ROUTES, true, true); copy(Table.PATTERNS, true, true); copy(Table.PATTERN_STOP, true, true); result.shapes = copy(Table.SHAPES, true, false); result.stops = copy(Table.STOPS, true, true); result.stopTimes = copy(Table.STOP_TIMES, true, false); result.transfers = copy(Table.TRANSFERS, true, true); result.trips = copy(Table.TRIPS, true, true); LOG.info("Copying tables took sec", (System.currentTimeMillis() - startTime) / 1000); } catch (Exception ex) { LOG.error("Exception while creating snapshot: {}", ex.toString()); ex.printStackTrace(); result.fatalException = ex.getMessage(); } return result; }</code><technical_language>do measure start time methods called</technical_language>

Target:
public FeedLoadResult copyTables() { FeedLoadResult result = new FeedLoadResult(); try { long startTime = System.currentTimeMillis(); connection = dataSource.getConnection(); this.tablePrefix = randomIdString(); result.uniqueIdentifier = tablePrefix; registerSnapshot(); this.tablePrefix += "."; result.agency = copy(Table.AGENCY, true); result.calendar = copy(Table.CALENDAR, true); result.calendarDates = copy(Table.CALENDAR_DATES, true); result.fareAttributes = copy(Table.FARE_ATTRIBUTES, true); result.fareRules = copy(Table.FARE_RULES, true); result.feedInfo = copy(Table.FEED_INFO, true); result.frequencies = copy(Table.FREQUENCIES, true); result.routes = copy(Table.ROUTES, true); copy(Table.PATTERNS, true); copy(Table.PATTERN_STOP, true); result.shapes = copy(Table.SHAPES, true); result.stops = copy(Table.STOPS, true); result.stopTimes = copy(Table.STOP_TIMES, true); result.transfers = copy(Table.TRANSFERS, true); result.trips = copy(Table.TRIPS, true); result.completionTime = System.currentTimeMillis(); result.loadTimeMillis = result.completionTime - startTime; LOG.info("Copying tables took sec", (result.loadTimeMillis) / 1000); } catch (Exception ex) { LOG.error("Exception while creating snapshot: {}", ex.toString()); ex.printStackTrace(); result.fatalException = ex.getMessage(); } return result; }
Source:
<code>public Utf8PrintStream(final OutputStream output, final boolean flush) throws UnsupportedEncodingException { <START> super(output, flush, Utf8PrintStream.ENCODING); <END> }</code><technical_language>@dalifreire StandardCharsets.UTF_8.toString() ? do think</technical_language>

Target:
public Utf8PrintStream(final OutputStream output, final boolean flush) throws UnsupportedEncodingException { super(output, flush, StandardCharsets.UTF_8.toString()); }
Source:
<code><START> public void notifyHasMessage(final Mailbox mailbox, final MessageKind kind) { <END> final Receiver receiver = mailbox.getReceiver(); final CommunicationGroup group = getGroup(receiver); if (kind == null) { group.defaultMailboxes.add(mailbox); } else if (kind == MessageKind.MONOTONE) { group.monotoneMailboxes.add(mailbox); } else if (kind == MessageKind.ANTI_MONOTONE) { group.nonMonotoneMailboxes.add(mailbox); } else { throw new IllegalArgumentException(); } activate(group); }</code><technical_language>move this group object, singleton groups avoid (and maintaining) mailboxes sets</technical_language>

Target:
public void notifyHasMessage(final Mailbox mailbox, final MessageKind kind) { final Receiver receiver = mailbox.getReceiver(); final CommunicationGroup group = this.groupMap.get(receiver); group.notifyHasMessage(mailbox, kind); activate(group); }
Source:
<code>public String getText(Object arg0) { if (arg0 instanceof IAtsInsertionActivity) { IAtsWorkPackage workPacakage = (IAtsWorkPackage) arg0; IAtsInsertionActivity insertionActivity = AtsClientService.get().getProgramService().getInsertionActivity(workPacakage); IAtsInsertion insertion = AtsClientService.get().getProgramService().getInsertion(insertionActivity); IAtsProgram program = AtsClientService.get().getProgramService().getProgram(insertion); return String.format("%s - %s - %s - <START> %", program, <END> insertion, insertionActivity, workPacakage); } return super.getText(arg0); }</code><technical_language>Missing 's'</technical_language>

Target:
public String getText(Object arg0) { if (arg0 instanceof IAtsInsertionActivity) { IAtsWorkPackage workPacakage = (IAtsWorkPackage) arg0; IAtsInsertionActivity insertionActivity = AtsClientService.get().getProgramService().getInsertionActivity(workPacakage); IAtsInsertion insertion = AtsClientService.get().getProgramService().getInsertion(insertionActivity); IAtsProgram program = AtsClientService.get().getProgramService().getProgram(insertion); return String.format("%s - %s - %s - %s", program, insertion, insertionActivity, workPacakage); } return super.getText(arg0); }
Source:
<code>PaxosQuorumCheckingCoalescingFunction<REQ, RESP, F> wrapWithRemotes( List<SERVICE> services, Map<SERVICE, CheckedRejectionExecutorService> executors, int quorumSize, Function<SERVICE, F> functionFactory) { <START> List<FunctionAndExecutor<F>> functionsAndExecutors = KeyedStream.of(services) <END> .map(executors::get) .mapKeys(functionFactory) .entries() .<FunctionAndExecutor<F>>map(entry -> ImmutableFunctionAndExecutor.of(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); List<F> functions = new ArrayList<>(services.size()); Map<F, CheckedRejectionExecutorService> executorMap = new HashMap<>(services.size()); for (SERVICE service: services) { F function = functionFactory.apply(service); functions.add(function); executorMap.put(function, executors.get(service)); } return new PaxosQuorumCheckingCoalescingFunction<>(functions, executorMap, quorumSize); }</code><technical_language>is this used</technical_language>

Target:
PaxosQuorumCheckingCoalescingFunction<REQ, RESP, F> wrapWithRemotes( List<SERVICE> services, Map<SERVICE, CheckedRejectionExecutorService> executors, int quorumSize, Function<SERVICE, F> functionFactory) { List<F> functions = new ArrayList<>(services.size()); Map<F, CheckedRejectionExecutorService> executorMap = new HashMap<>(services.size()); for (SERVICE service: services) { F function = functionFactory.apply(service); functions.add(function); executorMap.put(function, executors.get(service)); } return new PaxosQuorumCheckingCoalescingFunction<>(functions, executorMap, quorumSize); }
Source:
<code>public void run() throws XMLStreamException { int index = 0; final var iterator = source.iterator(); <START> while (true) { <END> try { if (!iterator.hasNext()) { break; } final var o = iterator.next(); final String pid = o.getObjectInfo().getPid(); if (pid != null) { if ((limit < 0 || index++ < limit) && acceptPid(pid)) { LOGGER.info("Processing \"" + pid + "\"..."); try { o.processObject(handler); } catch (Exception ex) { LOGGER.error("MIGRATION_FAILURE: pid=\"{}\", message=\"{}\"", pid, ex.getMessage(), ex); if (this.continueOnError) { continue; } else { throw new RuntimeException(ex); } } } } } catch (Exception ex) { if (this.continueOnError) { LOGGER.error("MIGRATION_FAILURE: UNREADABLE_OBJECT: message=\"{}\"", ex.getMessage(), ex); continue; } else { throw new RuntimeException(ex); } } } }</code><technical_language>Is a reason a loop instead of: java for (final var iterator = source.iterator(); iterator.hasNext();) { final var o = iterator.next(); }</technical_language>

Target:
public void run() throws XMLStreamException { int index = 0; for (final var iterator = source.iterator(); iterator.hasNext();) { try { final var o = iterator.next(); final String pid = o.getObjectInfo().getPid(); if (pid != null) { if ((limit < 0 || index++ < limit) && acceptPid(pid)) { LOGGER.info("Processing \"" + pid + "\"..."); try { o.processObject(handler); } catch (Exception ex) { LOGGER.error("MIGRATION_FAILURE: pid=\"{}\", message=\"{}\"", pid, ex.getMessage(), ex); if (this.continueOnError) { continue; } else { throw new RuntimeException(ex); } } } } } catch (Exception ex) { if (this.continueOnError) { LOGGER.error("MIGRATION_FAILURE: UNREADABLE_OBJECT: message=\"{}\"", ex.getMessage(), ex); continue; } else { throw new RuntimeException(ex); } } } }
Source:
<code><START> protected void appendGroupByClause(StringBuilder sbSelectFrom) { <END> Set<String> clauses = new LinkedHashSet<String>(); groupByManager.buildGroupByClauses(clauses); for (ExpressionTransformerGroup<?> transformerGroup : transformerGroups) { clauses.addAll(transformerGroup.getRequiredGroupByClauses()); } if (hasGroupBy) { if (mainQuery.getQueryConfiguration().isImplicitGroupByFromSelectEnabled()) { selectManager.buildGroupByClauses(cbf.getMetamodel(), clauses); } if (mainQuery.getQueryConfiguration().isImplicitGroupByFromHavingEnabled()) { havingManager.buildGroupByClauses(clauses); } if (mainQuery.getQueryConfiguration().isImplicitGroupByFromOrderByEnabled()) { orderByManager.buildGroupByClauses(clauses); } } if (!clauses.isEmpty()) { for (ExpressionTransformerGroup<?> transformerGroup : transformerGroups) { clauses.addAll(transformerGroup.getOptionalGroupByClauses()); } } groupByManager.buildGroupBy(sbSelectFrom, clauses); havingManager.buildClause(sbSelectFrom); }</code><technical_language>Leave loops please. Loops iterators generally slower in interpreter C1 compiler of JVM enhanced for loop syntax here</technical_language>

Target:
protected void appendGroupByClause(StringBuilder sbSelectFrom) { Set<String> clauses = new LinkedHashSet<String>(); groupByManager.buildGroupByClauses(clauses); int size = transformerGroups.size(); for (int i = 0; i < transformerGroups.size(); i++) { ExpressionTransformerGroup<?> transformerGroup = transformerGroups.get(i); clauses.addAll(transformerGroup.getRequiredGroupByClauses()); } if (hasGroupBy) { if (mainQuery.getQueryConfiguration().isImplicitGroupByFromSelectEnabled()) { selectManager.buildGroupByClauses(cbf.getMetamodel(), clauses); } if (mainQuery.getQueryConfiguration().isImplicitGroupByFromHavingEnabled()) { havingManager.buildGroupByClauses(clauses); } if (mainQuery.getQueryConfiguration().isImplicitGroupByFromOrderByEnabled()) { orderByManager.buildGroupByClauses(clauses); } } if (!clauses.isEmpty()) { for (int i = 0; i < size; i++) { ExpressionTransformerGroup<?> transformerGroup = transformerGroups.get(i); clauses.addAll(transformerGroup.getOptionalGroupByClauses()); } } groupByManager.buildGroupBy(sbSelectFrom, clauses); havingManager.buildClause(sbSelectFrom); }
Source:
<code>public void setCountriesOfOrigin(Iterable<Country> countries) { <START> this.countriesOfOrigin = Sets.newHashSet(countries); <END> }</code><technical_language>ImmutableSet.copyOf(countries)</technical_language>

Target:
public void setCountriesOfOrigin(Iterable<Country> countries) { this.countriesOfOrigin = ImmutableSet.copyOf(countries); }
Source:
<code>public Image getImage(Object element) { <START> return TasksUiPlugin.getDefault().getBrandingIcon(MYLYN_GERRIT); <END> }</code><technical_language>hard code Gerrit store a "connectorKind" attribute in element for instance work generically for kind of task</technical_language>

Target:
public Image getImage(Object element) { return TasksUiPlugin.getDefault().getBrandingIcon(((ActivityEvent) element).getKind()); }
Source:
<code>public void with_decorators() throws Exception { assertThat(Kind.CLASS_DECLARATION) .matches("@decorator class A {}") .matches("@decorator1 @decorator2 class A {}") .matches("class C { @decorator method(){} }") .matches("class C { @decorator static method(){} }") .matches("class C { @decorator1 @decorator2 method(){} }") <START> .matches("class C {method(){} property; }") <END> .matches("class C { property; property=42; }") ; }</code><technical_language>@vilchik-elena lines removed cut-and-paste of method with_properties. irrelevant decorators</technical_language>

Target:
public void with_decorators() throws Exception { assertThat(Kind.CLASS_DECLARATION) .matches("@decorator class A {}") .matches("@decorator1 @decorator2 class A {}") .matches("class C { @decorator method(){} }") .matches("class C { @decorator static method(){} }") .matches("class C { @decorator1 @decorator2 method(){} }") ; }
Source:
<code>public SQLQueryEngine(EntityManagerFactory emf, MetaDataStore metaDataStore) { this.emf = emf; <START> this.dictionary = metaDataStore.getDictionary(); <END> Set<Table> tables = metaDataStore.getMetaData(Table.class); tables.addAll(metaDataStore.getMetaData(AnalyticView.class)); this.tables = tables.stream() .map(table -> table instanceof AnalyticView ? new SQLAnalyticView(table.getCls(), dictionary) : new SQLTable(table.getCls(), dictionary)) .collect(Collectors.toMap(Table::getCls, Function.identity())); }</code><technical_language>change dictionary metaDataDictionary this dictionary is exposed Elide core dictionary</technical_language>

Target:
public SQLQueryEngine(EntityManagerFactory emf, MetaDataStore metaDataStore) { this.emf = emf; this.metadataDictionary = metaDataStore.getDictionary(); Set<Table> tables = metaDataStore.getMetaData(Table.class); tables.addAll(metaDataStore.getMetaData(AnalyticView.class)); this.tables = tables.stream() .map(table -> table instanceof AnalyticView ? new SQLAnalyticView(table.getCls(), metadataDictionary) : new SQLTable(table.getCls(), metadataDictionary)) .collect(Collectors.toMap(Table::getCls, Function.identity())); }
Source:
<code>public void loadDetails() { if(null==currentServer) return; ModelNode operation = new ModelNode(); operation.get(OP).set(READ_RESOURCE_OPERATION); <START> operation.get(ADDRESS).set(new ResourceAddress().add("host", serverStore.getSelectedServer().getHostName()).add("server", serverStore.getSelectedServer().getServerName())); <END> operation.get(ADDRESS).add("subsystem", "undertow"); operation.get(ADDRESS).add("server", currentServer); operation.get(INCLUDE_RUNTIME).set(true); operation.get(RECURSIVE).set(true); dispatcher.execute(new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if(response.isFailure()) { Log.error("Failed to load http server details", response.getFailureDescription()); } else { ModelNode data = response.get(RESULT); List<Property> connectors = new ArrayList<Property>(); connectors.addAll(failSafeGetCollection(data.get("http-listener"))); connectors.addAll(failSafeGetCollection(data.get("ajp-listener"))); connectors.addAll(failSafeGetCollection(data.get("https-listener"))); getView().setConnectors(connectors); } } }); }</code><technical_language>This work in standalone mode. Instead RuntimeBaseAddress.get() used, returns right address based operation mode selected host / server</technical_language>

Target:
public void loadDetails() { if(null==currentServer) return; ModelNode operation = new ModelNode(); operation.get(OP).set(READ_RESOURCE_OPERATION); operation.get(ADDRESS).set(RuntimeBaseAddress.get()); operation.get(ADDRESS).add("subsystem", "undertow"); operation.get(ADDRESS).add("server", currentServer); operation.get(INCLUDE_RUNTIME).set(true); operation.get(RECURSIVE).set(true); dispatcher.execute(new DMRAction(operation), new SimpleCallback<DMRResponse>() { @Override public void onSuccess(DMRResponse result) { ModelNode response = result.get(); if(response.isFailure()) { Log.error("Failed to load http server details", response.getFailureDescription()); } else { ModelNode data = response.get(RESULT); List<Property> connectors = new ArrayList<Property>(); connectors.addAll(failSafeGetCollection(data.get("http-listener"))); connectors.addAll(failSafeGetCollection(data.get("ajp-listener"))); connectors.addAll(failSafeGetCollection(data.get("https-listener"))); getView().setConnectors(connectors); } } }); }
Source:
<code>public void testHasExpired() { CompositeRegistry r = new CompositeRegistry(clock); Counter c1 = r.counter("id1"); Assert.assertTrue(c1.hasExpired()); Registry r1 = new DefaultRegistry(clock); r.add(r1); <START> Assert.assertTrue(c1.hasExpired()); <END> }</code><technical_language>long add more assertion c1.hasExpired returns false add a counter r1</technical_language>

Target:
public void testHasExpired() { CompositeRegistry r = new CompositeRegistry(clock); Counter c1 = r.counter("id1"); Assert.assertTrue(c1.hasExpired()); Registry r1 = new DefaultRegistry(clock); r.add(r1); Assert.assertTrue(c1.hasExpired()); c1.increment(); Assert.assertFalse(c1.hasExpired()); }
Source:
<code><START> public void testAResourceIsDisplayedAsAColumnWhenItsIconIsSelectedInTheTopOfRoomGrid() { <END> HomeAdminPage homeAdminPage = new HomeAdminPage(); RoomsPage roomsPage = homeAdminPage.clickConferenceRoomsLink(); RoomInfoPage roomInfoPage = roomsPage.doubleClickOverRoomName(roomName); RoomResourceAssociationsPage roomResourceAssociationsPage = roomInfoPage .clickResourceAssociationsLink(); roomResourceAssociationsPage.clickAddResourceToARoom(resourceDisplayName); roomResourceAssociationsPage.changeValueForResourceFromAssociatedList(resourceDisplayName, quantity); roomsPage = roomResourceAssociationsPage.clickSaveBtn(); roomsPage.clickResourceIcon(resourceDisplayName); Assert.assertEquals(roomsPage.getResourceQuantity(roomName),"x " + quantity); Assert.assertTrue(roomsPage.isResourcePresentInTableHeader(resourceDisplayName)); }</code><technical_language>name of method name of class preceding test</technical_language>

Target:
public void testAResourceIsDisplayedAsAColumnWhenItsIconIsSelectedInTheTopOfRoomGrid() { HomeAdminPage homeAdminPage = new HomeAdminPage(); RoomsPage roomsPage = homeAdminPage.clickConferenceRoomsLink(); RoomInfoPage roomInfoPage = roomsPage.doubleClickOverRoomName(roomName); RoomResourceAssociationsPage roomResourceAssociationsPage = roomInfoPage .clickResourceAssociationsLink(); roomResourceAssociationsPage.clickAddResourceToARoom(resourceDisplayName) .changeValueForResourceFromAssociatedList(resourceDisplayName,quantity); roomsPage = roomResourceAssociationsPage.clickSaveBtn(); roomsPage.clickResourceIcon(resourceDisplayName); Assert.assertEquals(roomsPage.getResourceQuantity(roomName),"x " + quantity); Assert.assertTrue(roomsPage.isResourcePresentInTableHeader(resourceDisplayName)); Assert.assertTrue(roomsPage.searchResource(resourceDisplayName)); }
Source:
<code>protected IDialogSettings getPersistentPropertyStore() { IDialogSettings settings = Activator.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(fViewId); if (section == null) { section = settings.addNewSection(fViewId); if (section == null) { <START> throw new IllegalStateException(); <END> } } return section; }</code><technical_language>please add a string wrong</technical_language>

Target:
protected IDialogSettings getPersistentPropertyStore() { IDialogSettings settings = Activator.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(fViewId); if (section == null) { section = settings.addNewSection(fViewId); if (section == null) { throw new IllegalStateException("The persistent property section could not be added"); } } return section; }
Source:
<code>public NewExecutableDialog( Shell parentShell, NewExecutableInfo info ) { super( parentShell ); setShellStyle( getShellStyle() | SWT.RESIZE ); <START> fInfo = info != null ? info : new NewExecutableInfo(SessionType.LOCAL); <END> }</code><technical_language>new call this line is unreachable</technical_language>

Target:
public NewExecutableDialog( Shell parentShell, NewExecutableInfo info ) { super( parentShell ); assert info != null; setShellStyle( getShellStyle() | SWT.RESIZE ); fInfo = info; }
Source:
<code>public Set<String> getErrorCodes() { <START> return errorCodes; <END> }</code><technical_language>initialize error codes here, instead of in constructor</technical_language>

Target:
public Set<String> getErrorCodes() { if (errorCodes == null) { errorCodes = new HashSet<>(); } else { return errorCodes; } if (lightblueResponse.getErrors()!=null) { for(Error e:lightblueResponse.getErrors()) { errorCodes.add(e.getErrorCode()); } } if (lightblueResponse.getDataErrors()!=null) { for(DataError de:lightblueResponse.getDataErrors()) { if (de.getErrors()!=null) { for(Error e:de.getErrors()) { errorCodes.add(e.getErrorCode()); } } } } return errorCodes; }
Source:
<code>public static void changeValueCommand(final List<Command> response, final ServerAttribute attribute, final Object value) { if (response == null) { return; } if (attribute == null) { <START> LOG.info("Cannot change value on a null attribute to '{}'", value); <END> return; } forceChangeValue(value, response, attribute); }</code><technical_language>This error</technical_language>

Target:
public static void changeValueCommand(final List<Command> response, final ServerAttribute attribute, final Object value) { if (response == null) { return; } if (attribute == null) { LOG.error("Cannot change value on a null attribute to '{}'", value); return; } forceChangeValue(value, response, attribute); }
Source:
<code>public void notifyLeaderChanged(RaftGroupMemberId groupMemberId, RaftPeerId raftPeerId) { <START> if (mRaftGroupId == groupMemberId.getGroupId()) { <END> mIsLeader = groupMemberId.getPeerId() == raftPeerId; mJournalSystem.notifyLeadershipStateChanged(mIsLeader); } }</code><technical_language>if this is true? happen, do want log some sort of warning happens</technical_language>

Target:
public void notifyLeaderChanged(RaftGroupMemberId groupMemberId, RaftPeerId raftPeerId) { if (mRaftGroupId == groupMemberId.getGroupId()) { mIsLeader = groupMemberId.getPeerId() == raftPeerId; mJournalSystem.notifyLeadershipStateChanged(mIsLeader); } else { LOG.warn("Received notification for unrecognized group {}, current group is {}", groupMemberId.getGroupId(), mRaftGroupId); } }
Source:
<code>protected void onPageWillGetDeactivated(Direction progress, PageChangingEvent event, DataBindingContext dbc) { class ImageValidator implements IRunnableWithProgress { private boolean imageExistsLocally = false; private boolean imageExistsRemotely = false; @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { this.imageExistsLocally = model.imageExistsLocally(model.getImage()); if(!imageExistsLocally) { this.imageExistsRemotely = model.imageExistsRemotely(model.getImage()); } } } final ImageValidator imageValidator = new ImageValidator(); try { getContainer().run(true, false, imageValidator); } catch (InvocationTargetException | InterruptedException e) { final String message = "Failed to verify if an image with the name '" + model.getImage() + "' exists."; MessageDialog.openError(getShell(), "Error", message); OpenShiftUIActivator.getDefault().getLogger().logError(message, e); } if (imageValidator.imageExistsLocally) { return; } else if (!imageValidator.imageExistsLocally && imageValidator.imageExistsRemotely) { if(!MessageDialog.openConfirm(getShell(), "Missing Docker Image", "This Docker image will need to be pulled before opening the next page.")) { event.doit = false; } } else { <START> MessageDialog.openError(getShell(), "Error", "No Docker image with the given repository and tag could be found."); <END> event.doit = false; } }</code><technical_language>repeat name tag of image for in error dialog</technical_language>

Target:
protected void onPageWillGetDeactivated(Direction progress, PageChangingEvent event, DataBindingContext dbc) { class ImageValidatorJob extends Job { public ImageValidatorJob(String name) { super(name); } private boolean imageExistsLocally = false; private boolean imageExistsRemotely = false; @Override protected IStatus run(IProgressMonitor monitor) { this.imageExistsLocally = model.imageExistsLocally(model.getImage()); if(!imageExistsLocally) { this.imageExistsRemotely = model.imageExistsRemotely(model.getImage()); } return Status.OK_STATUS; } } final ImageValidatorJob imageValidator = new ImageValidatorJob("Looking-up the selected Docker image..."); try { final IStatus validatorJobStatus = WizardUtils.runInWizard(imageValidator, getContainer()); if (imageValidator.imageExistsLocally) { return; } else if (imageValidator.imageExistsRemotely) { if (!MessageDialog.openConfirm(getShell(), "Missing Docker Image", "The metadata for the Docker image named '" + model.getImage() + "' will need to be pulled before opening the next page.")) { event.doit = false; } } else if(validatorJobStatus.isOK()){ MessageDialog.openError(getShell(), "Error", "No Docker image named '" + model.getImage() + "' could be found."); event.doit = false; } else { event.doit = false; } } catch (InvocationTargetException | InterruptedException e) { final String message = "Failed to verify if an image named '" + model.getImage() + "' exists."; MessageDialog.openError(getShell(), "Error", message); OpenShiftUIActivator.getDefault().getLogger().logError(message, e); } }
Source:
<code>private void serverRemoved(final MongoDBServer member) { if (LOG.isDebugEnabled()) LOG.debug("Scheduling removal of member from {}: {}", getName(), member); if (member.equals(getAttribute(PRIMARY_ENTITY))) setAttribute(PRIMARY_ENTITY, null); executor.submit(new Runnable() { @Override public void run() { Boolean isAvailable = member.getAttribute(MongoDBServer.SERVICE_UP); MongoDBServer primary = getPrimary(); if (primary != null && !isAvailable) { primary.getClient().removeMemberFromReplicaSet(member); if (LOG.isInfoEnabled()) { LOG.info("Removed from replica set {}", member, getName()); } } else { if (LOG.isTraceEnabled()) { LOG.trace("Rescheduling removal of member from replica set {}: service_up={}, primary={}", new Object[]{member, getName(), isAvailable, primary}); } <START> executor.schedule(this, 3, TimeUnit.SECONDS); <END> } } }); }</code><technical_language>a worried looping potentially forever, retrying 3 seconds, log.trace hung (if primary null etc). I guess obvious sensor values, stop() stop executor (though discarding entity unmanage - prevent graceful termination of brooklyn process?)</technical_language>

Target:
private void serverRemoved(final MongoDBServer member) { if (LOG.isDebugEnabled()) LOG.debug("Scheduling removal of member from {}: {}", getName(), member); if (member.equals(getAttribute(PRIMARY_ENTITY))) setAttribute(PRIMARY_ENTITY, null); executor.submit(new Runnable() { @Override public void run() { Boolean isAvailable = member.getAttribute(MongoDBServer.SERVICE_UP); MongoDBServer primary = getPrimary(); if (primary != null && !isAvailable) { primary.removeMemberFromReplicaSet(member); if (LOG.isInfoEnabled()) { LOG.info("Removed from replica set {}", member, getName()); } } else { if (LOG.isTraceEnabled()) { LOG.trace("Rescheduling removal of member from replica set {}: service_up={}, primary={}", new Object[]{member, getName(), isAvailable, primary}); } executor.schedule(this, 3, TimeUnit.SECONDS); } } }); }
Source:
<code>public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case ACTION_START: SyncthingHelper.startSynchthingService(context); break; case ACTION_STOP: SyncthingHelper.stopSynchtingService(context); break; case ACTION_STOP2: SyncthingHelper.stopSynchtingService2(context); <START> break; <END> } }</code><technical_language>I reason a static helper class here. sense put stopSynctingService() a method pretty long, in class. startSyncthingService() need extra method, line. some typos (Sync**h**thing)</technical_language>

Target:
public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case ACTION_START: context.startService(new Intent(context, SyncthingService.class)); break; case ACTION_STOP: if (SyncthingService.alwaysRunInBackground(context)) { final String msg = context.getString(R.string.appconfig_receiver_background_enabled); Context appContext = context.getApplicationContext(); NotificationCompat.Builder nb = new NotificationCompat.Builder(context) .setContentText(msg) .setTicker(msg) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) .setContentTitle(context.getText(context.getApplicationInfo().labelRes)) .setSmallIcon(R.drawable.ic_stat_notify) .setAutoCancel(true) .setContentIntent(PendingIntent.getActivity(appContext, 0, new Intent(appContext, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { nb.setCategory(Notification.CATEGORY_ERROR); } NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(ID_NOTIFICATION_BACKGROUND_ACTIVE, nb.build()); } else { context.stopService(new Intent(context, SyncthingService.class)); } break; } }
Source:
<code>public void setUp() throws Exception { <START> IOUtils.copy(getClass().getClassLoader().getResourceAsStream(PDF_NAME), new FileOutputStream(pdfFile)); <END> blob = Blobs.createBlob(pdfFile); }</code><technical_language>IOUtils.copy close streams, write: try (InputStream in = getClass().getClassLoader().getResourceAsStream(PDF_NAME); OutputStream out = new FileOutputStream(pdfFile)) { IOUtils.copy(in, out); }</technical_language>

Target:
public void setUp() throws Exception { targetDirectory = Framework.createTempDirectory("target").toFile(); tempDirectory = Framework.createTempDirectory("tmp").toFile(); pdfFile = new File(tempDirectory.getAbsolutePath(), PDF_NAME); blob = Blobs.createBlob(pdfFile); try (InputStream in = getClass().getClassLoader().getResourceAsStream(PDF_NAME); OutputStream out = new FileOutputStream(pdfFile)) { IOUtils.copy(in, out); } }
Source:
<code>public void setup() throws Exception { customDeployer = new CustomDeployer(); artifactsList = new ArrayList<>(); artifact = new Artifact(new File(getTestResourceFile(DEPLOYER_REPO).getAbsolutePath() + File.separator + "sample1.txt")); artifact.setType(new ArtifactType<>("txt")); artifactsList.add(artifact); System.setProperty(org.wso2.carbon.kernel.Constants.CARBON_HOME, getTestResourceFile("yaml").getAbsolutePath()); <START> ConfigProvider configProvider = new ConfigProviderImpl(new YAMLBasedConfigFileReader("deployment.yaml")); <END> CarbonRuntime carbonRuntime = CarbonRuntimeFactory .createCarbonRuntime(configProvider); DataHolder.getInstance().setCarbonRuntime(carbonRuntime); DataHolder.getInstance().setConfigProvider(configProvider); brokerService = new BrokerService(); brokerService.setUseJmx(false); brokerService.setBrokerName("carbon"); brokerService.setDataDirectory("target/activemq-data"); brokerService.start(); Topic topic = new ActiveMQTopic("topic0"); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://carbon?create=false"); Connection connection = connectionFactory.createConnection(); connection.setClientID("carbon"); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); topicSubscriber = session.createDurableSubscriber(topic, "durable"); connection.start(); }</code><technical_language>hard-code config file name</technical_language>

Target:
public void setup() throws Exception { customDeployer = new CustomDeployer(); artifactsList = new ArrayList<>(); artifact = new Artifact(new File(getTestResourceFile(DEPLOYER_REPO).getAbsolutePath() + File.separator + "sample1.txt")); artifact.setType(new ArtifactType<>("txt")); artifactsList.add(artifact); System.setProperty(org.wso2.carbon.kernel.Constants.CARBON_HOME, getTestResourceFile("yaml").getAbsolutePath()); ConfigProvider configProvider = new ConfigProviderImpl(new YAMLBasedConfigFileReader(DEPLOYMENT_YAML)); CarbonRuntime carbonRuntime = CarbonRuntimeFactory .createCarbonRuntime(configProvider); DataHolder.getInstance().setCarbonRuntime(carbonRuntime); DataHolder.getInstance().setConfigProvider(configProvider); brokerService = new BrokerService(); brokerService.setUseJmx(false); brokerService.setBrokerName("carbon"); brokerService.setDataDirectory("target/activemq-data"); brokerService.start(); Topic topic = new ActiveMQTopic("topic0"); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://carbon?create=false"); Connection connection = connectionFactory.createConnection(); connection.setClientID("carbon"); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); topicSubscriber = session.createDurableSubscriber(topic, "durable"); connection.start(); }
Source:
<code>protected void createAdditionalControls(Composite parent) { Composite apiKeyContainer = new Composite(parent, SWT.NONE); <START> GridLayout gridLayout = new GridLayout(3, false); <END> gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; apiKeyContainer.setLayout(gridLayout); Label shortLoginLabel = new Label(apiKeyContainer, SWT.NONE); shortLoginLabel.setText("use API Key"); useApiKey = new Button(apiKeyContainer, SWT.CHECK | SWT.LEFT); apiKey = new Text(apiKeyContainer, SWT.BORDER); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .hint(300, SWT.DEFAULT) .applyTo(apiKey); if (repository != null) { useApiKey.setSelection( Boolean.parseBoolean(repository.getProperty(IBugzillaRestConstants.REPOSITORY_USE_API_KEY))); String apiKeyValue = repository.getProperty(IBugzillaRestConstants.REPOSITORY_API_KEY); apiKey.setText(apiKeyValue == null ? "" : apiKeyValue); } }</code><technical_language>GridLayoutFactory</technical_language>

Target:
protected void createAdditionalControls(Composite parent) { Composite apiKeyContainer = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(3).applyTo(apiKeyContainer); Label apiKeyLabel = new Label(apiKeyContainer, SWT.NONE); apiKeyLabel.setText(Messages.BugzillaRestRepositorySettingsPage_use_api_key); useApiKey = new Button(apiKeyContainer, SWT.CHECK | SWT.LEFT); apiKey = new Text(apiKeyContainer, SWT.BORDER); GridDataFactory.fillDefaults() .grab(true, false) .align(SWT.FILL, SWT.CENTER) .hint(300, SWT.DEFAULT) .applyTo(apiKey); if (repository != null) { useApiKey.setSelection( Boolean.parseBoolean(repository.getProperty(IBugzillaRestConstants.REPOSITORY_USE_API_KEY))); String apiKeyValue = repository.getProperty(IBugzillaRestConstants.REPOSITORY_API_KEY); apiKey.setText(apiKeyValue == null ? "" : apiKeyValue); } }
Source:
<code>public void noDormantCheckOnModifies() throws Exception { AgendaEventListener ael = mock(AgendaEventListener.class); session.addEventListener(ael); List<Command<?>> commands = new ArrayList<Command<?>>(); commands.add(KieServices.Factory.get().getCommands().newInsert(new Person("Bob", 19))); commands.add(KieServices.Factory.get().getCommands().newInsert(new Cheese("brie", 10))); <START> commands.add(KieServices.Factory.get().getCommands().newFireAllRules()); <END> session.execute(KieServices.Factory.get().getCommands().newBatchExecution(commands, null)); verify(ael, times(2)).afterMatchFired(any(AfterMatchFiredEvent.class)); verify(ael, never()).matchCancelled(any(MatchCancelledEvent.class)); }</code><technical_language>copy&paste, reuse</technical_language>

Target:
public void noDormantCheckOnModifies() throws Exception { AgendaEventListener ael = mock(AgendaEventListener.class); session.addEventListener(ael); session.setGlobal("LOGGER", LOGGER); List<Command<?>> commands = new ArrayList<Command<?>>(); commands.add(getCommands().newInsert(new Person("Bob", 19))); commands.add(getCommands().newInsert(new Cheese("brie", 10))); commands.add(getCommands().newFireAllRules()); session.execute(getCommands().newBatchExecution(commands, null)); verify(ael, times(2)).afterMatchFired(any(AfterMatchFiredEvent.class)); verify(ael, never()).matchCancelled(any(MatchCancelledEvent.class)); }
Source:
<code>public void storeBlock(BlockState blockState, int amount) throws BlockBagException { if (blockState.getBlockType() == BlockTypes.AIR) { throw new IllegalArgumentException("Can't store air block"); } if (!blockState.getBlockType().hasItemType()) { throw new IllegalArgumentException("This block cannot be stored"); } loadInventory(); int freeSlot = -1; for (int slot = 0; slot < items.length; ++slot) { ItemStack bukkitItem = items[slot]; if (bukkitItem == null) { if (freeSlot == -1) { freeSlot = slot; } continue; } <START> if (!bukkitItem.getType().getKey().toString().equals(blockState.getBlockType().getId())) { <END> continue; } int currentAmount = bukkitItem.getAmount(); if (currentAmount < 0) { return; } if (currentAmount >= 64) { continue; } int spaceLeft = 64 - currentAmount; if (spaceLeft >= amount) { bukkitItem.setAmount(currentAmount + amount); return; } bukkitItem.setAmount(64); amount -= spaceLeft; } if (freeSlot > -1) { items[freeSlot] = new ItemStack(BukkitUtil.toItemStack(new BaseItemStack(blockState.getBlockType().getItemType(), amount))); return; } throw new OutOfSpaceException(blockState.getBlockType()); }</code><technical_language>Utility method, maybe? BukkitUtil: java public static boolean equals(final BlockType type, final Material material) { return material.getKey().equals(type.getId()); } BukkitPlayerBlockBag (and other places): java if (!BukkitUtil.equals(blockState.getBlockType(), bukkitItem.getType())) {</technical_language>

Target:
public void storeBlock(BlockState blockState, int amount) throws BlockBagException { if (blockState.getBlockType() == BlockTypes.AIR) { throw new IllegalArgumentException("Can't store air block"); } if (!blockState.getBlockType().hasItemType()) { throw new IllegalArgumentException("This block cannot be stored"); } loadInventory(); int freeSlot = -1; for (int slot = 0; slot < items.length; ++slot) { ItemStack bukkitItem = items[slot]; if (bukkitItem == null) { if (freeSlot == -1) { freeSlot = slot; } continue; } if (!BukkitAdapter.equals(blockState.getBlockType(), bukkitItem.getType())) { continue; } int currentAmount = bukkitItem.getAmount(); if (currentAmount < 0) { return; } if (currentAmount >= 64) { continue; } int spaceLeft = 64 - currentAmount; if (spaceLeft >= amount) { bukkitItem.setAmount(currentAmount + amount); return; } bukkitItem.setAmount(64); amount -= spaceLeft; } if (freeSlot > -1) { items[freeSlot] = BukkitAdapter.adapt(new BaseItemStack(blockState.getBlockType().getItemType(), amount)); return; } throw new OutOfSpaceException(blockState.getBlockType()); }
Source:
<code>public static void call() { try { URL url = new URL(URL_STRING); CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = getHtppPost(url); if (user != null) { httpPost.addHeader("Authorization", "Bearer " + Helios.getAccessToken(user)); } if (nvps != null) { httpPost.setEntity(new UrlEncodedFormEntity(nvps, StandardCharsets.UTF_8)); } httpClient.execute(httpPost); PageObjectLogging <START> .log("CONTENT PUSH", "Content posted to: " + URL_STRING, <END> true); } catch (ClientProtocolException e) { PageObjectLogging.log("EXCEPTION", e.toString(), false); throw new WebDriverException(ERROR_MESSAGE); } catch (IOException e) { PageObjectLogging.log("IO EXCEPTION", e.toString(), false); throw new WebDriverException(ERROR_MESSAGE); } catch (URISyntaxException e) { PageObjectLogging.log("URI_SYNTAX EXCEPTION", e.toString(), false); throw new WebDriverException(ERROR_MESSAGE); } }</code><technical_language>please change this message. This api call pushing content</technical_language>

Target:
public void call() { try { URL url = new URL(getURL()); CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = getHtppPost(url); if (getUser() != null) { httpPost.addHeader("Authorization", "Bearer " + Helios.getAccessToken(getUser())); } if (getParams() != null) { httpPost.setEntity(new UrlEncodedFormEntity(getParams(), StandardCharsets.UTF_8)); } httpClient.execute(httpPost); PageObjectLogging.log("CONTENT PUSH", "Content posted to: " + URL_STRING, true); } catch (ClientProtocolException e) { PageObjectLogging.log("EXCEPTION", e.toString(), false); throw new WebDriverException(ERROR_MESSAGE); } catch (IOException e) { PageObjectLogging.log("IO EXCEPTION", e.toString(), false); throw new WebDriverException(ERROR_MESSAGE); } catch (URISyntaxException e) { PageObjectLogging.log("URI_SYNTAX EXCEPTION", e.toString(), false); throw new WebDriverException(ERROR_MESSAGE); } }
Source:
<code>public static byte[] hexStringToBytes(String data) { <START> if (data == null || data.length() < 2) return EMPTY_BYTE_ARRAY; <END> if (data.startsWith("0x")) data = data.substring(2); if (data.length() % 2 == 1) data = "0" + data; return Hex.decode(data); }</code><technical_language>I omit this change</technical_language>

Target:
public static byte[] hexStringToBytes(String data) { if (data == null) return EMPTY_BYTE_ARRAY; if (data.startsWith("0x")) data = data.substring(2); if (data.length() % 2 == 1) data = "0" + data; return Hex.decode(data); }