auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void onConnectionResumed(HueBridge bridge) throws IOException, ApiException { logger.debug("Bridge connection resumed. Updating thing status to ONLINE."); <START> FullConfig fullConfig = bridge.getFullConfig(); <END> Config config = fullConfig.getConfig(); if (config != null) { Map<String, String> properties = editProperties(); properties.put(Thing.PROPERTY_SERIAL_NUMBER, config.getMACAddress().replaceAll(":", "").toLowerCase()); properties.put(Thing.PROPERTY_FIRMWARE_VERSION, config.getSoftwareVersion()); updateProperties(properties); } updateStatus(ThingStatus.ONLINE); }</code><technical_language>Is safe do this here? some smell me... Note this is expensive, potentially long-running blocking call</technical_language>

Target:
private void onConnectionResumed(HueBridge bridge) throws IOException, ApiException { logger.debug("Bridge connection resumed. Updating thing status to ONLINE."); if (!propertiesInitializedSuccessfully) { FullConfig fullConfig = bridge.getFullConfig(); Config config = fullConfig.getConfig(); if (config != null) { Map<String, String> properties = editProperties(); properties.put(Thing.PROPERTY_SERIAL_NUMBER, config.getMACAddress().replaceAll(":", "").toLowerCase()); properties.put(Thing.PROPERTY_FIRMWARE_VERSION, config.getSoftwareVersion()); updateProperties(properties); propertiesInitializedSuccessfully = true; } } updateStatus(ThingStatus.ONLINE); }
Source:
<code>public void onEntityDeath(EntityDeathEvent event) { if (event instanceof PlayerDeathEvent) { onPlayerDeath((PlayerDeathEvent) event, (Player) event.getEntity()); } else if (monsters.hasPet(event.getEntity())) { monsters.removePet(event.getEntity()); } else if (monsters.removeMonster(event.getEntity())) { onMonsterDeath(event); } else if (monsters.removeMount(event.getEntity())) { onMountDeath(event); } else if (monsters.removeGolem(event.getEntity())) { arena.announce(Msg.GOLEM_DIED); } <START> else if (event.getEntity() instanceof Projectile) { arena.getProjectileManager().removeProjectile((Projectile) event.getEntity()); } <END> }</code><technical_language>deal sanity checks. assume projectile shot a player in _this_ arena</technical_language>

Target:
public void onEntityDeath(EntityDeathEvent event) { if (event instanceof PlayerDeathEvent) { onPlayerDeath((PlayerDeathEvent) event, (Player) event.getEntity()); } else if (monsters.hasPet(event.getEntity())) { monsters.removePet(event.getEntity()); } else if (monsters.removeMonster(event.getEntity())) { onMonsterDeath(event); } else if (monsters.removeMount(event.getEntity())) { onMountDeath(event); } else if (monsters.removeGolem(event.getEntity())) { arena.announce(Msg.GOLEM_DIED); } else if (event.getEntity() instanceof Projectile) { Projectile projectile = (Projectile) event.getEntity(); if(projectile.getShooter() instanceof Player) { Player player = (Player) projectile.getShooter(); if(!arena.isRunning()) return; if(!arena.inArena(player) && !arena.inLobby(player)) return; arena.getProjectileManager().removeProjectile(projectile); } } }
Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; boolean persistentAuth = "persistent-auth".equals(req.getHeader("Prefer")); if (persistentAuth && req.getHeader("Authorization") != null) { if (req.getSession(false) != null) { <START> req.getSession().setAttribute(FiltersHelper.Constants.AUTHENTICATED_KEY, "false"); <END> } } chain.doFilter(request, response); HttpSession session = req.getSession(false); if (session != null && Boolean.TRUE.equals(session.getAttribute(FiltersHelper.Constants.AUTHENTICATED_KEY))) { String engineSessionId = (String) session.getAttribute(FiltersHelper.Constants.ENGINE_SESSION_ID_KEY); if (!persistentAuth) { try { InitialContext ctx = new InitialContext(); VdcActionParametersBase params = new VdcActionParametersBase(); params.setSessionId(engineSessionId); FiltersHelper.getBackend(ctx).runAction(VdcActionType.LogoutBySession, params); session.invalidate(); } catch (Exception ex) { log.error(String.format("Error in logout. Message is: %1$s", ex.getMessage())); if (log.isDebugEnabled()) { log.debug("", ex); } } } else { Cookie cookie = new Cookie("JESSIONID", engineSessionId); resp.addCookie(cookie); } } }</code><technical_language>please explain put false? absent of property is a good marker... is to</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; boolean persistentAuth = "persistent-auth".equals(req.getHeader("Prefer")); if (persistentAuth && (req.getHeader("Authorization") != null || !containsJessionId(req))) { if (req.getSession(false) != null) { req.getSession().removeAttribute(FiltersHelper.Constants.AUTHENTICATED_KEY); } } chain.doFilter(request, response); HttpSession session = req.getSession(false); if (session != null && Boolean.TRUE.equals(session.getAttribute(FiltersHelper.Constants.AUTHENTICATED_KEY))) { String engineSessionId = (String) session.getAttribute(FiltersHelper.Constants.ENGINE_SESSION_ID_KEY); if (!persistentAuth) { try { InitialContext ctx = new InitialContext(); VdcActionParametersBase params = new VdcActionParametersBase(); params.setSessionId(engineSessionId); FiltersHelper.getBackend(ctx).runAction(VdcActionType.LogoutBySession, params); session.invalidate(); FiltersHelper.closeContext(ctx); } catch (Exception ex) { log.error(String.format("Error in logout. Message is: %1$s", ex.getMessage())); if (log.isDebugEnabled()) { log.debug("", ex); } } } else { Cookie cookie = new Cookie("JESSIONID", engineSessionId); cookie.setPath("/api"); resp.addCookie(cookie); } } }
Source:
<code>private void setRelationships() { if (this.data != null) { this.relationships = new LinkedHashSet<>(); EntityDictionary dictionary = this.requestScope.getDictionary(); this.data.entrySet().stream() .filter(entry -> dictionary.isRelation(this.entityClass, entry.getKey())) .forEach(entry -> { String relationshipName = entry.getKey(); Class<?> relationshipClass = dictionary.getParameterizedType(this.entityClass, relationshipName); <START> EntityProjection relationshipProjection = <END> projection.getRelationship(relationshipName).isPresent() ? projection.getRelationship(relationshipName).get().getProjection() : EntityProjection.builder() .type(relationshipClass) .build(); Set<Entity> relationshipEntities = new LinkedHashSet<>(); if (dictionary.getRelationshipType(this.entityClass, relationshipName).isToOne()) { relationshipEntities.add(new Entity( Optional.of(this), ((Map<String, Object>) entry.getValue()), relationshipProjection, this.requestScope)); } else { for (Map<String, Object> row : (List<Map<String, Object>>) entry.getValue()) { relationshipEntities.add(new Entity( Optional.of(this), row, relationshipProjection, this.requestScope)); } } this.relationships.add(new Relationship(relationshipName, relationshipEntities)); }); } }</code><technical_language>relationship exist in projection tree</technical_language>

Target:
private void setRelationships() { if (this.data != null) { this.relationships = new LinkedHashSet<>(); EntityDictionary dictionary = this.requestScope.getDictionary(); this.data.entrySet().stream() .filter(entry -> dictionary.isRelation(this.entityClass, entry.getKey())) .forEach(entry -> { String relationshipName = entry.getKey(); Class<?> relationshipClass = dictionary.getParameterizedType(this.entityClass, relationshipName); Set<Entity> relationshipEntities = new LinkedHashSet<>(); if (dictionary.getRelationshipType(this.entityClass, relationshipName).isToOne()) { relationshipEntities.add(new Entity( Optional.of(this), ((Map<String, Object>) entry.getValue()), relationshipClass, this.requestScope)); } else { for (Map<String, Object> row : (List<Map<String, Object>>) entry.getValue()) { relationshipEntities.add(new Entity( Optional.of(this), row, relationshipClass, this.requestScope)); } } this.relationships.add(new Relationship(relationshipName, relationshipEntities)); }); } }
Source:
<code>protected static String getPointsInEqualShareFormatAsHtml(int points, boolean inline) { int delta = 0; if (points == Const.POINTS_NOT_SUBMITTED || points == Const.INT_UNINITIALIZED) { return "<span class=\"badge background-color-white color_neutral\">N/A</span>"; } else if (points == Const.POINTS_NOT_SURE) { return "<span class=\"badge background-color-white color-negative\">Not sure</span>"; } else if (points == 0) { return "<span class=\"badge background-color-white color-negative\">0%</span>"; } else if (points > 100) { delta = points - 100; if (inline) { return "<span class=\"badge background-color-white color-positive\"> E +" + delta + "%</span>"; } else { return "Equal Share<br /><span class=\"badge background-color-white color-positive\"> + " + delta + "%</span>"; } } else if (points < 100) { delta = 100 - points; if (inline) { return "<span class=\"badge background-color-white color-negative\"> E -" + delta + "%</span>"; } else { return "Equal Share<br /><span class=\"badge background-color-white color-negative\"> - " + delta + "%</span>"; <START> } <END> } else { return "<span class=\"badge background-color-white color-positive\"> E </span>"; } }</code><technical_language>this a ternary return, i.e: java return inline ? "<span ..." : "Equal ..."</technical_language>

Target:
protected static String getPointsInEqualShareFormatAsHtml(int points, boolean inline) { int delta = 0; if (points == Const.POINTS_NOT_SUBMITTED || points == Const.INT_UNINITIALIZED) { return "<span class=\"badge background-color-white color_neutral\">N/A</span>"; } else if (points == Const.POINTS_NOT_SURE) { return "<span class=\"badge background-color-white color-negative\">Not sure</span>"; } else if (points == 0) { return "<span class=\"badge background-color-white color-negative\">0%</span>"; } else if (points > 100) { delta = points - 100; return inline ? "<span class=\"badge background-color-white color-positive\"> E +" + delta + "%</span>" : "Equal Share<br /><span class=\"badge background-color-white color-positive\"> + " + delta + "%</span>"; } else if (points < 100) { delta = 100 - points; return inline ? "<span class=\"badge background-color-white color-negative\"> E -" + delta + "%</span>" : "Equal Share<br /><span class=\"badge background-color-white color-negative\"> - " + delta + "%</span>"; } else { return "<span class=\"badge background-color-white color-positive\"> E </span>"; } }
Source:
<code>public final @Nullable TileMultiBlock getMasterBlock() { if (masterBlock != null && !isStructureValid()) { <START> masterBlock.isMaster = false; <END> masterBlock = null; sendUpdateToClient(); } return masterBlock; }</code><technical_language>this. slaves job determine a master is a master</technical_language>

Target:
public final @Nullable TileMultiBlock getMasterBlock() { if (masterBlock != null && !isStructureValid()) { masterBlock = null; sendUpdateToClient(); } return masterBlock; }
Source:
<code>public FactoryDto createFactoryFromDevfile(String devfileLocation) throws BadRequestException { if (devfileLocation != null) { final String devfileYamlContent = urlFetcher.fetch(devfileLocation); if (!Strings.isNullOrEmpty(devfileYamlContent)) { try { WorkspaceConfigImpl wsConfig = devfileManager.validateAndConvert(devfileYamlContent, false); return newDto(FactoryDto.class) .withV(CURRENT_VERSION) .withWorkspace(DtoConverter.asDto(wsConfig)); } catch (DevfileFormatException e) { throw new BadRequestException(e.getMessage()); } catch (IOException x) { <START> throw new IllegalStateException(x.getLocalizedMessage(), x); <END> } } } return null; }</code><technical_language>is good idea throw runtime exception here? I is good case for ServerException</technical_language>

Target:
public Optional<FactoryDto> createFactoryFromDevfile(String devfileLocation) throws BadRequestException, ServerException { if (devfileLocation == null) { return Optional.empty(); } final String devfileYamlContent = urlFetcher.fetch(devfileLocation); if (Strings.isNullOrEmpty(devfileYamlContent)) { return Optional.empty(); } try { Devfile devfile = devfileManager.parse(devfileYamlContent, false); WorkspaceConfigImpl wsConfig = devfileManager.createWorkspaceConfig(devfile); return Optional.of( newDto(FactoryDto.class) .withV(CURRENT_VERSION) .withWorkspace(DtoConverter.asDto(wsConfig))); } catch (DevfileFormatException e) { throw new BadRequestException(e.getMessage()); } catch (IOException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
Source:
<code><START> public synchronized int delete(Uri uri, String selection, String[] selectionArgs) { <END> SqlArguments args = new SqlArguments(uri, selection, selectionArgs); synchronized (mLock) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count = db.delete(args.table, args.where, args.args); if (count > 0) sendNotify(uri); return count; } }</code><technical_language>synchronizing "this" if synchronizing lock below</technical_language>

Target:
public int delete(Uri uri, String selection, String[] selectionArgs) { SqlArguments args = new SqlArguments(uri, selection, selectionArgs); synchronized (mLock) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count = db.delete(args.table, args.where, args.args); if (count > 0) sendNotify(uri); return count; } }
Source:
<code><START> SortedMap<String, Long> getUsedCapacityBySegment() { <END> SortedMap<String, Long> usedCapacityBySegments = new TreeMap<>(); LogSegment logSegment = log.getFirstSegment(); while (logSegment != null) { usedCapacityBySegments.put(logSegment.getName(), logSegment.getEndOffset()); logSegment = log.getNextSegment(logSegment); } return usedCapacityBySegments; }</code><technical_language>map needs sorted</technical_language>

Target:
public SortedMap<String, Long> getUsedCapacityBySegment() { SortedMap<String, Long> usedCapacityBySegments = new TreeMap<>(); LogSegment logSegment = log.getFirstSegment(); while (logSegment != null) { usedCapacityBySegments.put(logSegment.getName(), logSegment.getEndOffset()); logSegment = log.getNextSegment(logSegment); } return usedCapacityBySegments; }
Source:
<code>private CompletableFuture<Channel> bootstrapClient(Address address) { CompletableFuture<Channel> future = new OrderedFuture<>(); final InetAddress resolvedAddress = address.address(true); if (resolvedAddress == null) { final String errorMessage = String.format("Cannot bootstrap client for address %s as it cannot be resolved", address.toString()); <START> future.completeExceptionally(new IllegalStateException(errorMessage)); <END> return future; } Bootstrap bootstrap = new Bootstrap(); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(10 * 32 * 1024, 10 * 64 * 1024)); bootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 1024); bootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 1024); bootstrap.option(ChannelOption.SO_KEEPALIVE, true); bootstrap.option(ChannelOption.TCP_NODELAY, true); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000); bootstrap.group(clientGroup); bootstrap.channel(clientChannelClass); bootstrap.remoteAddress(resolvedAddress, address.port()); if (enableNettyTls) { try { bootstrap.handler(new SslClientChannelInitializer(future, address)); } catch (SSLException e) { return Futures.exceptionalFuture(e); } } else { bootstrap.handler(new BasicClientChannelInitializer(future)); } bootstrap.connect().addListener(f -> { if (!f.isSuccess()) { future.completeExceptionally(f.cause()); } }); return future; }</code><technical_language>simplify this java future.completeExceptionally(new IllegalStateException("Failed bootstrap client (address " + address.toString() + " resolved)"));</technical_language>

Target:
private CompletableFuture<Channel> bootstrapClient(Address address) { CompletableFuture<Channel> future = new OrderedFuture<>(); final InetAddress resolvedAddress = address.address(true); if (resolvedAddress == null) { future.completeExceptionally(new IllegalStateException("Failed to bootstrap client (address " + address.toString() + " cannot be resolved)")); return future; } Bootstrap bootstrap = new Bootstrap(); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(10 * 32 * 1024, 10 * 64 * 1024)); bootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 1024); bootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 1024); bootstrap.option(ChannelOption.SO_KEEPALIVE, true); bootstrap.option(ChannelOption.TCP_NODELAY, true); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000); bootstrap.group(clientGroup); bootstrap.channel(clientChannelClass); bootstrap.remoteAddress(resolvedAddress, address.port()); if (enableNettyTls) { try { bootstrap.handler(new SslClientChannelInitializer(future, address)); } catch (SSLException e) { return Futures.exceptionalFuture(e); } } else { bootstrap.handler(new BasicClientChannelInitializer(future)); } bootstrap.connect().addListener(f -> { if (!f.isSuccess()) { future.completeExceptionally(f.cause()); } }); return future; }
Source:
<code>private List<Long> getChromosomesByFittest() { List<Long> orderChromKeysByFittest = new ArrayList(); String orderDirection = "desc"; if (config.isHigherFitnessValueFitter() == false) { <START> orderDirection = "asc"; <END> } String fittestSQL = "select _key from Chromosome order by fitnessScore " + orderDirection; QueryCursor<List<?>> cursor = populationCache.query(new SqlFieldsQuery(fittestSQL)); List<List<?>> res = cursor.getAll(); for (List row : res) { Long key = (Long)row.get(0); orderChromKeysByFittest.add(key); } return orderChromKeysByFittest; }</code><technical_language>braces style this expression improved: if (!config.isHigherFitnessValueFitter()) orderDirection = "asc";</technical_language>

Target:
private List<Long> getChromosomesByFittest() { List<Long> orderChromKeysByFittest = new ArrayList<Long>(); String orderDirection = "desc"; if (!config.isHigherFitnessValueFitter()) orderDirection = "asc"; String fittestSQL = "select _key from Chromosome order by fitnessScore " + orderDirection; QueryCursor<List<?>> cursor = populationCache.query(new SqlFieldsQuery(fittestSQL)); List<List<?>> res = cursor.getAll(); for (List row : res) { Long key = (Long)row.get(0); orderChromKeysByFittest.add(key); } return orderChromKeysByFittest; }
Source:
<code>public CommitCompareItem createSimpleCompareItem(String projectId, String commitId, String filePath, IProgressMonitor monitor) { GetContentFromCommitCommand getContent = gerrit.getContentFromCommit(projectId, commitId, filePath); String fileContent = ""; try { fileContent = getContent.call(); } catch (ClientProtocolException | EGerritException e) { <START> e.printStackTrace(); <END> } return new CommitCompareItem(commitId, filePath, StringUtils.newStringUtf8(Base64.decodeBase64(fileContent))); }</code><technical_language>logger log error e.printStack.</technical_language>

Target:
public CommitCompareItem createSimpleCompareItem(String projectId, String commitId, String filePath, IProgressMonitor monitor) { GetContentFromCommitCommand getContent = gerrit.getContentFromCommit(projectId, commitId, filePath); String fileContent = ""; try { fileContent = getContent.call(); } catch (ClientProtocolException | EGerritException e) { logger.debug("Exception retrieving commitId", e); } return new CommitCompareItem(commitId, filePath, StringUtils.newStringUtf8(Base64.decodeBase64(fileContent))); }
Source:
<code>private void verifyWriterOutput(File outputFile, ReferenceSource refSource, int nRecs, boolean verifySupplementalFiles) { <START> if (true == verifySupplementalFiles) { <END> final File indexFile = SamFiles.findIndex(outputFile); indexFile.deleteOnExit(); final File md5File = new File(outputFile.getParent(), outputFile.getName() + ".md5"); md5File.deleteOnExit(); Assert.assertTrue(indexFile.length() > 0); Assert.assertTrue(md5File.length() > 0); } SamReaderFactory factory = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.LENIENT); if (refSource != null) { factory.referenceSource(refSource); } SamReader reader = factory.open(outputFile); SAMRecordIterator it = reader.iterator(); int count = 0; for (; it.hasNext(); it.next()) { count++; } Assert.assertTrue(count == nRecs); }</code><technical_language>this if ( verifySupplementalFiles )</technical_language>

Target:
private void verifyWriterOutput(File outputFile, ReferenceSource refSource, int nRecs, boolean verifySupplementalFiles) { if (verifySupplementalFiles) { final File indexFile = SamFiles.findIndex(outputFile); indexFile.deleteOnExit(); final File md5File = new File(outputFile.getParent(), outputFile.getName() + ".md5"); md5File.deleteOnExit(); Assert.assertTrue(indexFile.length() > 0); Assert.assertTrue(md5File.length() > 0); } SamReaderFactory factory = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.LENIENT); if (refSource != null) { factory.referenceSource(refSource); } SamReader reader = factory.open(outputFile); SAMRecordIterator it = reader.iterator(); int count = 0; for (; it.hasNext(); it.next()) { count++; } Assert.assertTrue(count == nRecs); }
Source:
<code>private void restart() { <START> log.info("Waiting to restart Google Pubsub subscriber"); <END> try { Thread.sleep(1000); } catch (InterruptedException e) { } start(); }</code><technical_language>add more context this log statement well</technical_language>

Target:
private void restart() { log.info("Waiting to restart Google Pubsub subscriber for {}", formatSubscriptionName(project, subscriptionName)); try { Thread.sleep(1000); } catch (InterruptedException e) { } start(); }
Source:
<code>public List<ICodeSystemVersion> getCodeSystemVersions(final String shortName) { checkNotNull(shortName, "Short name may not be null."); final ICodeSystem codeSystem = getCodeSystem(shortName); if (codeSystem == null) { throw new CodeSystemNotFoundException(shortName); } <START> final Collection<com.b2international.snowowl.datastore.ICodeSystemVersion> versions = new CodeSystemRequests(codeSystem.getRepositoryUuid()) <END> .prepareSearchCodeSystemVersion() .setCodeSystemShortName(shortName) .build(IBranchPath.MAIN_BRANCH) .executeSync(getEventBus()) .getVersions(); return toSortedCodeSystemVersionList(versions); }</code><technical_language>Duplicate code: private getCodeSystemVersions() method in this class</technical_language>

Target:
public List<ICodeSystemVersion> getCodeSystemVersions(final String shortName) { checkNotNull(shortName, "Short name may not be null."); final ICodeSystem codeSystem = getCodeSystem(shortName); if (codeSystem == null) { throw new CodeSystemNotFoundException(shortName); } final Collection<com.b2international.snowowl.datastore.ICodeSystemVersion> versions = getCodeSystemVersions(shortName, codeSystem.getRepositoryUuid()); return toSortedCodeSystemVersionList(versions); }
Source:
<code>public String toString() { return "ClientEvent{" + "uuid='" + uuid + '\'' <START> + ", eventType=" + eventType <END> + ", address=" + address + ", clientType=" + clientType + ", name =" + name + '}'; }</code><technical_language>print attributes well</technical_language>

Target:
public String toString() { return "ClientEvent{" + "uuid='" + uuid + '\'' + ", eventType=" + eventType + ", address=" + address + ", clientType=" + clientType + ", name='" + name + '\'' + ", attributes=" + attributes + '}'; }
Source:
<code>public Mono<AmqpSendLink> createProducer( <START> String linkName, String entityPath, Duration timeout, AmqpRetryPolicy retry, <END> boolean idempotentPartitionPublishing, PartitionPublishingState publishingState) { Objects.requireNonNull(linkName, "'linkName' cannot be null."); Objects.requireNonNull(entityPath, "'entityPath' cannot be null."); Objects.requireNonNull(timeout, "'timeout' cannot be null."); Objects.requireNonNull(retry, "'retry' cannot be null."); Symbol[] desiredCapabilities = null; Map<Symbol, Object> properties = null; if (idempotentPartitionPublishing) { desiredCapabilities = new Symbol[]{ENABLE_IDEMPOTENT_PRODUCER}; properties = new HashMap<>(); properties.put(PRODUCER_EPOCH, publishingState.getOwnerLevel()); properties.put(PRODUCER_ID, publishingState.getProducerGroupId()); properties.put(PRODUCER_SEQUENCE_NUMBER, publishingState.getSequenceNumber()); } return createProducer(linkName, entityPath, timeout, retry, properties, desiredCapabilities) .cast(AmqpSendLink.class); }</code><technical_language>I weird a new line arguments. consistent here</technical_language>

Target:
public Mono<AmqpSendLink> createProducer(String linkName, String entityPath, Duration timeout, AmqpRetryPolicy retry, boolean idempotentPartitionPublishing, PartitionPublishingState publishingState) { Objects.requireNonNull(linkName, "'linkName' cannot be null."); Objects.requireNonNull(entityPath, "'entityPath' cannot be null."); Objects.requireNonNull(timeout, "'timeout' cannot be null."); Objects.requireNonNull(retry, "'retry' cannot be null."); Symbol[] desiredCapabilities = null; Map<Symbol, Object> properties = null; if (idempotentPartitionPublishing) { desiredCapabilities = new Symbol[]{ClientConstants.ENABLE_IDEMPOTENT_PRODUCER}; properties = new HashMap<>(); properties.put(ClientConstants.PRODUCER_EPOCH, publishingState.getOwnerLevel()); properties.put(ClientConstants.PRODUCER_ID, publishingState.getProducerGroupId()); properties.put(ClientConstants.PRODUCER_SEQUENCE_NUMBER, publishingState.getSequenceNumber()); } return createProducer(linkName, entityPath, timeout, retry, properties, desiredCapabilities) .cast(AmqpSendLink.class); }
Source:
<code>static String parseRegistryUrl(final String url) { if (url.equals("docker.io") || url.equals("index.docker.io")) { return DEFAULT_REGISTRY_URL; } else if (url.matches("(^|(\\w+)\\.)gcr\\.io$") || url.equals("gcr.kubernetes.io")) { return "https://" + url; } else if (url.equals("quay.io")) { return "quay.io"; } else if (!url.contains("http://") && !url.contains("https://")) { <START> return "http://" + url; <END> } else { return url; } }</code><technical_language>assume http? I https is a smarter assumption make</technical_language>

Target:
static String parseRegistryUrl(final String url) { if (url.equals("docker.io") || url.equals("index.docker.io")) { return DEFAULT_REGISTRY_URL; } else if (url.matches("(^|(\\w+)\\.)gcr\\.io$") || url.equals("gcr.kubernetes.io")) { return "https://" + url; } else if (url.equals("quay.io")) { return "quay.io"; } else if (!url.contains("http://") && !url.contains("https://")) { return "https://" + url; } else { return url; } }
Source:
<code>private Metacard addAttributeValue(Metacard metacard, Map.Entry<String, Object> entry) { final Object value = entry.getValue(); LOGGER.debug( <START> "Adding attribute \"{}\" with value \"{}\" to metacard from map...", entry.getKey(), value); <END> if (value instanceof Serializable) { metacard.setAttribute(new AttributeImpl(entry.getKey(), (Serializable) value)); } else if (value instanceof List) { metacard.setAttribute(new AttributeImpl(entry.getKey(), (List<Serializable>) value)); } return metacard; }</code><technical_language>ellipsis</technical_language>

Target:
private void addAttributeValue(Metacard metacard, Map.Entry<String, Object> entry) { final Object value = entry.getValue(); LOGGER.trace( "The map key \"{}\" with value \"{}\" is being added to the metacard.", entry.getKey(), value); if (value instanceof Serializable) { metacard.setAttribute(new AttributeImpl(entry.getKey(), (Serializable) value)); } else if (value instanceof List) { metacard.setAttribute(new AttributeImpl(entry.getKey(), (List<Serializable>) value)); } else { LOGGER.debug("The value was expected to be Serializable or a list of Serializable items."); } }
Source:
<code>private void init(IMultiDiagramEditor editor) { serviceRegistry = editor.getServicesRegistry(); if (serviceRegistry == null) { throw new <START> IllegalArgumentException(Messages.ModelExplorerView_ExceptionMissingServiceRegistry); <END> } try { saveAndDirtyService = serviceRegistry.getService(ISaveAndDirtyService.class); undoContext = serviceRegistry.getService(IUndoContext.class); } catch (ServiceException e) { Activator.log.error(e); } }</code><technical_language>Exception Message logs internationalize // NLS...</technical_language>

Target:
private void init(IMultiDiagramEditor editor) { serviceRegistry = editor.getServicesRegistry(); if (serviceRegistry == null) { throw new IllegalArgumentException("The editor should have a ServiceRegistry."); } try { saveAndDirtyService = serviceRegistry.getService(ISaveAndDirtyService.class); undoContext = serviceRegistry.getService(IUndoContext.class); } catch (ServiceException e) { Activator.log.error(e); } }
Source:
<code>private void buildRoad(UserBean user, GameBean game, String edgeId) throws PlayException, GameException { EdgeBean edgeToBuildOn = (EdgeBean) buildUtil.getValidMapElementByIdToBuildOn(edgeId, new ArrayList<MapElement>(game.getEdges())); <START> buildUtil.validateUserCanBuildRoanOnEdge(user, edgeToBuildOn); <END> buildUtil.buildRoadOnEdge(user, edgeToBuildOn); preparationStageUtil.updateCurrentCycleInitialBuildingNumber(game); }</code><technical_language>bad naming. "Road", "Roan"</technical_language>

Target:
private void buildRoad(UserBean user, GameBean game, String edgeId) throws PlayException, GameException { EdgeBean edgeToBuildOn = (EdgeBean) buildUtil.getValidMapElementByIdToBuildOn(edgeId, new ArrayList<MapElement>(game.getEdges())); buildUtil.validateUserCanBuildRoadOnEdge(user, edgeToBuildOn); buildUtil.buildRoadOnEdge(user, edgeToBuildOn); preparationStageUtil.updateCurrentCycleInitialBuildingNumber(game); }
Source:
<code>public void testCreateWithoutWritePermissions() throws Exception { BaseUser user = server.addUser("test", "password"); Configuration configuration = new Configuration(); configuration.set("fs.defaultFS", "ftp:/ configuration.set("fs.ftp.host", "localhost"); configuration.setInt("fs.ftp.host.port", server.getPort()); configuration.set("fs.ftp.user.localhost", user.getName()); configuration.set("fs.ftp.password.localhost", user.getPassword()); configuration.set("fs.ftp.impl.disable.cache", "true"); FileSystem fs = FileSystem.get(configuration); byte[] bytesExpected = "hello world".getBytes(StandardCharsets.UTF_8); try (FSDataOutputStream outputStream = fs.create(new Path("test1.txt"))) { <START> outputStream.write(bytesExpected); <END> } catch (IOException ioException) { assertThat( ioException.getMessage(), is("Unable to create file: test1.txt, Aborting") ); } }</code><technical_language>LambdaTestUtils#intercept fail write()</technical_language>

Target:
public void testCreateWithoutWritePermissions() throws Exception { BaseUser user = server.addUser("test", "password"); Configuration configuration = new Configuration(); configuration.set("fs.defaultFS", "ftp:/ configuration.set("fs.ftp.host", "localhost"); configuration.setInt("fs.ftp.host.port", server.getPort()); configuration.set("fs.ftp.user.localhost", user.getName()); configuration.set("fs.ftp.password.localhost", user.getPassword()); configuration.setBoolean("fs.ftp.impl.disable.cache", true); FileSystem fs = FileSystem.get(configuration); byte[] bytesExpected = "hello world".getBytes(StandardCharsets.UTF_8); LambdaTestUtils.intercept( IOException.class, "Unable to create file: test1.txt, Aborting", () -> { try (FSDataOutputStream out = fs.create(new Path("test1.txt"))) { out.write(bytesExpected); } } ); }
Source:
<code>public void deleteObsThatReference(Order order) { int orderId; if (order != null) { orderId = order.getOrderId(); Criteria crit = sessionFactory.getCurrentSession().createCriteria(Obs.class); crit.add(Restrictions.eq("order", order)); <START> sessionFactory.getCurrentSession().createQuery("delete Obs where order = :orderId").setInteger("orderId", <END> order.getOrderId()).executeUpdate(); } }</code><technical_language>This line in this method, not-null check. I understand orderId criteria - needed all? Also, I thought query "delete Obs order = :order"), :order is Order object, hibernate do thing</technical_language>

Target:
public void deleteObsThatReference(Order order) { if (order != null) { sessionFactory.getCurrentSession().createQuery("delete Obs where order = :order").setInteger("order", order.getOrderId()).executeUpdate(); } }
Source:
<code>public DataSet next(int num) { INDArray features = Nd4j.create(new int[]{num, 10, 16}, 'f'); INDArray labels = Nd4j.create(new int[]{num, 10, 16}, 'f'); INDArray featuresMask = null; INDArray labelsMask = null; for (int i =0; i < num && iter.hasNext(); i ++) { String featureStr = iter.next(); currentCursor ++; featureStr = featureStr.replaceAll(",", ""); String[] featureAry = featureStr.split(""); for (int j = 0; j < featureAry.length - 1; j ++) { int feature = Integer.parseInt(featureAry[j]); int label = Integer.parseInt(featureAry[j + 1]); features.putScalar(new int[]{i, feature, j}, 1.0); labels.putScalar(new int[]{i, label, j}, 1.0); } } DataSet result = new DataSet(features, labels, featuresMask, labelsMask); <START> return result; <END> }</code><technical_language>return new DataSet(features, labels, featuresMask, labelsMask);</technical_language>

Target:
public DataSet next(int num) { INDArray features = Nd4j.create(new int[]{num, 10, 16}, 'f'); INDArray labels = Nd4j.create(new int[]{num, 10, 16}, 'f'); INDArray featuresMask = null; INDArray labelsMask = null; for (int i =0; i < num && iter.hasNext(); i ++) { String featureStr = iter.next(); currentCursor ++; featureStr = featureStr.replaceAll(",", ""); String[] featureAry = featureStr.split(""); for (int j = 0; j < featureAry.length - 1; j ++) { int feature = Integer.parseInt(featureAry[j]); int label = Integer.parseInt(featureAry[j + 1]); features.putScalar(new int[]{i, feature, j}, 1.0); labels.putScalar(new int[]{i, label, j}, 1.0); } } return new DataSet(features, labels, featuresMask, labelsMask); }
Source:
<code>public SphereApiConfig getConfig() { <START> return null; <END> }</code><technical_language>is returning null? configuration client</technical_language>

Target:
public SphereApiConfig getConfig() { return this.delegate.getConfig(); }
Source:
<code>private static void doBindChildrenInFilter(Component[] shadows) { for (Component shadow : shadows) { if (shadow instanceof ShadowElement) { ShadowElement se = (ShadowElement) shadow; if (!se.getDistributedChildren().isEmpty() || !((ShadowElementCtrl) se).isDynamicValue()) continue; List<Component> children = shadow.getChildren(); <START> if (shadow.getChildren().size() == 0) { <END> Events.sendEvent(new Event("onBindInit", (Component) se)); Events.sendEvent(new Event("onBindingReady", (Component) se)); children = shadow.getChildren(); } if (children.size() > 0) doBindChildrenInFilter(children.toArray(new Component[children.size()])); } } }</code><technical_language>duplicate List<Component> children = shadow.getChildren();</technical_language>

Target:
private static void doBindChildrenInFilter(Component[] shadows) { for (Component shadow : shadows) { if (shadow instanceof ShadowElement) { ShadowElement se = (ShadowElement) shadow; if (!se.getDistributedChildren().isEmpty() || !((ShadowElementCtrl) se).isDynamicValue()) continue; List<Component> children = shadow.getChildren(); if (children.size() == 0) { Events.sendEvent(new Event("onBindInit", (Component) se)); Events.sendEvent(new Event("onBindingReady", (Component) se)); children = shadow.getChildren(); } if (children.size() > 0) doBindChildrenInFilter(children.toArray(new Component[children.size()])); } } }
Source:
<code>public static FileUtils.FileCopyResult unzip(final File pulledFile, final File outDir) throws IOException { if (!(outDir.exists() && outDir.isDirectory())) { throw new ISE("outDir[%s] must exist and be a directory", outDir); } log.info("Unzipping file[%s] to [%s]", pulledFile, outDir); final FileUtils.FileCopyResult result = new FileUtils.FileCopyResult(); try (final ZipFile zipFile = new ZipFile(pulledFile)) { final Enumeration<? extends ZipEntry> enumeration = zipFile.entries(); while (enumeration.hasMoreElements()) { final ZipEntry entry = enumeration.nextElement(); <START> File outFile = new File(outDir, entry.getName()); <END> result.addFiles( FileUtils.retryCopy( new ByteSource() { @Override public InputStream openStream() throws IOException { return new BufferedInputStream(zipFile.getInputStream(entry)); } }, outFile, FileUtils.IS_EXCEPTION, DEFAULT_RETRY_COUNT ).getFiles() ); } } return result; }</code><technical_language>final</technical_language>

Target:
public static FileUtils.FileCopyResult unzip(final File pulledFile, final File outDir) throws IOException { if (!(outDir.exists() && outDir.isDirectory())) { throw new ISE("outDir[%s] must exist and be a directory", outDir); } log.info("Unzipping file[%s] to [%s]", pulledFile, outDir); final FileUtils.FileCopyResult result = new FileUtils.FileCopyResult(); try (final ZipFile zipFile = new ZipFile(pulledFile)) { final Enumeration<? extends ZipEntry> enumeration = zipFile.entries(); while (enumeration.hasMoreElements()) { final ZipEntry entry = enumeration.nextElement(); final File outFile = new File(outDir, entry.getName()); result.addFiles( FileUtils.retryCopy( new ByteSource() { @Override public InputStream openStream() throws IOException { return new BufferedInputStream(zipFile.getInputStream(entry)); } }, outFile, FileUtils.IS_EXCEPTION, DEFAULT_RETRY_COUNT ).getFiles() ); } } return result; }
Source:
<code>public void checkVertxHttpBoosterProjectCommands() { consoles.executeCommandFromProjectExplorer( VERTX_HTTP_BOOSTER, BUILD_GOAL, BUILD_COMMAND, BUILD_SUCCESS); consoles.executeCommandFromProjectExplorer( VERTX_HTTP_BOOSTER, RUN_GOAL, RUN_COMMAND, "[INFO] INFO: Succeeded in deploying verticle"); <START> consoles.checkWebElementVisibilityAtPreviewPage(By.id("_vert_x_health_check_booster")); <END> consoles.closeProcessTabWithAskDialog(RUN_COMMAND); consoles.executeCommandFromProcessesArea( "dev-machine", DEBUG_GOAL, DEBUG_COMMAND, "[INFO] Listening for transport dt_socket at address: 5005"); consoles.closeProcessTabWithAskDialog(DEBUG_COMMAND); }</code><technical_language>interesting checking _vert_x_health_check_booster while project is _http_ boosting</technical_language>

Target:
public void checkVertxHttpBoosterProjectCommands() { By textOnPreviewPage = By.id("_http_booster"); consoles.executeCommandFromProjectExplorer( HEALTH_HTTP_BOOSTER_PROJECT, BUILD_GOAL, BUILD_COMMAND, BUILD_SUCCESS); consoles.executeCommandFromProjectExplorer( HEALTH_HTTP_BOOSTER_PROJECT, RUN_GOAL, RUN_COMMAND, "[INFO] INFO: Succeeded in deploying verticle"); checkApplicationPage(textOnPreviewPage); consoles.closeProcessTabWithAskDialog(RUN_COMMAND); consoles.executeCommandFromProcessesArea( "dev-machine", DEBUG_GOAL, DEBUG_COMMAND, "[INFO] Listening for transport dt_socket at address: 5005"); consoles.closeProcessTabWithAskDialog(DEBUG_COMMAND); }
Source:
<code>protected void executeCommand() { int selectedId = 1; List<Integer> map = LinqUtils.foreach(vds_spm_id_mapList, new Function<vds_spm_id_map, Integer>() { @Override public Integer eval(vds_spm_id_map vds_spm_id_map) { return vds_spm_id_map.getvds_spm_id(); } }); Collections.sort(map); <START> <END> ListIterator<Integer> iterator = map.listIterator(); for (VdsStatic vds : getParameters().getVdss()) { while (iterator.hasNext()) { if (selectedId == iterator.next()) { selectedId++; iterator.remove(); } else { iterator.previous(); break; } } vds_spm_id_map newMap = new vds_spm_id_map(getParameters().getStoragePoolId(), vds.getId(), selectedId); DbFacade.getInstance().getVdsSpmIdMapDao().save(newMap); if (getParameters().isCompensationEnabled()) { getCompensationContext().snapshotNewEntity(newMap); getCompensationContext().stateChanged(); } selectedId++; } setSucceeded(true); }</code><technical_language>array, numbers 1 N, some numbers missing, want find numbers. solve a problem? is written lines 72-83 is solution</technical_language>

Target:
protected void executeCommand() { List<Integer> vdsSpmIds = LinqUtils.foreach(vds_spm_id_mapList, new Function<vds_spm_id_map, Integer>() { @Override public Integer eval(vds_spm_id_map vds_spm_id_map) { return vds_spm_id_map.getvds_spm_id(); } }); IntRange intRange = new IntRange(1, Config.<Integer> GetValue(ConfigValues.MaxNumberOfHostsInStoragePool).intValue()); List<Integer> idsForUse = Arrays.asList(ArrayUtils.toObject(intRange.toArray())); idsForUse.removeAll(vdsSpmIds); int selectedId = 0; for (VdsStatic vds : getParameters().getVdss()) { vds_spm_id_map newMap = new vds_spm_id_map(getParameters().getStoragePoolId(), vds.getId(), idsForUse.get(selectedId)); DbFacade.getInstance().getVdsSpmIdMapDao().save(newMap); if (getParameters().isCompensationEnabled()) { getCompensationContext().snapshotNewEntity(newMap); getCompensationContext().stateChanged(); } selectedId++; } setSucceeded(true); }
Source:
<code>public boolean removeGameRule(String gameRule) { if (DEFAULT.contains(gameRule)) { <START> return false; <END> } return this.theGameRules.remove(gameRule) != null; }</code><technical_language>sense simply reset game rules default if removed? (Basically behavior if removed added default values)</technical_language>

Target:
public boolean removeGameRule(String gameRule) { if (DEFAULT_GAME_RULES.hasRule(gameRule)) { this.setOrCreateGameRule(gameRule, DEFAULT_GAME_RULES.getString(gameRule)); return true; } return this.theGameRules.remove(gameRule) != null; }
Source:
<code>public List<Project.NameKey> getParents(final Project.NameKey allProjectsName) { if (name.equals(allProjectsName)) { <START> return null; <END> } if (parents == null || parents.size() == 0) { List<Project.NameKey> r = new ArrayList<Project.NameKey>(); r.add(allProjectsName); return r; } return parents; }</code><technical_language>Collections.emptyList() more sense null</technical_language>

Target:
public List<Project.NameKey> getParents(final Project.NameKey allProjectsName) { if (name.equals(allProjectsName)) { return Collections.emptyList(); } if (parents == null || parents.size() == 0) { List<Project.NameKey> r = new ArrayList<Project.NameKey>(1); r.add(allProjectsName); return r; } return parents; }
Source:
<code>public void fullConstructorShouldPreserveAllValues() { ApiException error = new ApiException(anyMessage, anyErrorCode, anyMoreInfo, anyHttpStatus, details, anyCause); assertEquals("Message", anyMessage, error.getMessage()); assertSame("Cause", anyCause, error.getCause()); assertEquals("More info", anyMoreInfo, error.getMoreInfo()); assertEquals("Error code", anyErrorCode, error.getCode().intValue()); assertEquals("Status code", anyHttpStatus, error.getStatusCode().intValue()); <START> assertEquals("Details", error.getDetails(), details); <END> }</code><technical_language>nit: assertEquals("Details", details, error.getDetails());</technical_language>

Target:
public void fullConstructorShouldPreserveAllValues() { ApiException error = new ApiException(anyMessage, anyErrorCode, anyMoreInfo, anyHttpStatus, anyCause); assertEquals("Message", anyMessage, error.getMessage()); assertSame("Cause", anyCause, error.getCause()); assertEquals("More info", anyMoreInfo, error.getMoreInfo()); assertEquals("Error code", anyErrorCode, error.getCode().intValue()); assertEquals("Status code", anyHttpStatus, error.getStatusCode().intValue()); }
Source:
<code>public void onPostUploaded(OnPostUploaded event) { if (event.isError()) { <START> if (event.error != null && event.error != null) { <END> FailReason reason = new FailReason(event.error); addFailedReasonToFailedPosts(event.post, reason); } } else { removeFailedReasonForPost(event.post); } stopServiceIfUploadsComplete(); }</code><technical_language>checking event.error != null - drop this entire line, event.isError() is a event.error != null check</technical_language>

Target:
public void onPostUploaded(OnPostUploaded event) { if (event.isError()) { UploadError reason = new UploadError(event.error); addUploadErrorToFailedPosts(event.post, reason); } else { removeUploadErrorForPost(event.post); } stopServiceIfUploadsComplete(); }
Source:
<code>public List<SearchSuggestion> getSuggestions(String namespace, String input) { List<SearchSuggestion> suggestions = new ArrayList<>(); for(SearchProvider provider : graphSearchProviders){ if (provider.canSuggest(graphService, namespace)){ suggestions.addAll(provider.getSuggestions(graphService, namespace, input)); } } <START> suggestions.sort(Comparator.naturalOrder()); <END> return suggestions; }</code><technical_language>Yes, need ensure unique. this is if introduce technical id mentioned earlier. point of view uniqueness is context internal id. need a more complex search suggestion implementation differentiate better</technical_language>

Target:
public List<SearchSuggestion> getSuggestions(String namespace, String input) { if(input == null || input.length() < MIN_CHAR_FOR_SEARCH) { return Collections.emptyList(); } SearchContext context = SearchContext.builder() .graphService(graphService) .suggestionsLimit(10) .build(); Set<SearchSuggestion> suggestions = new TreeSet<>(Comparator.comparing(SearchSuggestion::getLabel) .thenComparing(SearchSuggestion::getContext)); for(SearchProvider provider : graphSearchProviders.values()){ if (provider.canSuggest(graphService, namespace)){ List<SearchSuggestion> suggestionsOfProvider = provider.getSuggestions(context, namespace, input); if(suggestionsOfProvider == null) { LOG.warn("Provider does not work properly, received null suggestion list.", provider.getProviderId()); } else { suggestions.addAll(suggestionsOfProvider); } } } return new ArrayList<>(suggestions); }
Source:
<code>public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } GenericMapData that = (GenericMapData) o; <START> return Arrays.deepEquals(map.keySet().toArray(), that.map.keySet().toArray()) && Arrays.deepEquals(map.values().toArray(), that.map.values().toArray()); <END> }</code><technical_language>this. Arrays.deepEquals compare elements in order. However, map.keySet() guarentee order. simply Objects.equals(map, that.map) here. byte[] map key</technical_language>

Target:
public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof GenericMapData)) { return false; } return deepEquals(map, ((GenericMapData) o).map); }
Source:
<code>public Parser getParser() { return inputStream -> { JSONObject response = JsonReader.toJsonObject(inputStream); List<BibEntry> entries = new ArrayList<>(); BibEntry entry = jsonItemToBibEntry(response); entries.add(entry); <START> return entries; <END> }; }</code><technical_language>4 lines done shorter is a single entry: suggestion return Collections.singleton(jsonITemToBibEntry(response));</technical_language>

Target:
public Parser getParser() { return inputStream -> { JSONObject response = JsonReader.toJsonObject(inputStream); if (response.isEmpty()) { return Collections.emptyList(); } return Collections.singletonList(jsonItemToBibEntry(response)); }; }