auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected ResultIterator newIterator(ParallelScanGrouper scanGrouper) throws SQLException { ResultIterator scanner = new ResultIterator() { private final Iterator<Tuple> tupleIterator = tuples.iterator(); private boolean closed = false; private int count = 0; @Override public void close() throws SQLException { this.closed = true;; } @Override public Tuple next() throws SQLException { while (!this.closed && (offset != null && count < offset) && tupleIterator.hasNext()) { <START> count++; <END> tupleIterator.next(); } if (!this.closed && (limit == null || count++ < limit) && tupleIterator.hasNext()) { return tupleIterator.next(); } return null; } @Override public void explain(List<String> planSteps) { } }; if (context.getSequenceManager().getSequenceCount() > 0) { scanner = new SequenceResultIterator(scanner, context.getSequenceManager()); } return scanner; }</code><technical_language>I meant this "count++" work LIMIT(below) together. LIMIT number of rows returned starting OFFSET row, right</technical_language>

Target:
protected ResultIterator newIterator(ParallelScanGrouper scanGrouper) throws SQLException { ResultIterator scanner = new ResultIterator() { private final Iterator<Tuple> tupleIterator = tuples.iterator(); private boolean closed = false; private int count = 0; private int offsetCount = 0; @Override public void close() throws SQLException { this.closed = true;; } @Override public Tuple next() throws SQLException { while (!this.closed && (offset != null && offsetCount < offset) && tupleIterator.hasNext()) { offsetCount++; tupleIterator.next(); } if (!this.closed && (limit == null || count++ < limit) && tupleIterator.hasNext()) { return tupleIterator.next(); } return null; } @Override public void explain(List<String> planSteps) { } }; if (context.getSequenceManager().getSequenceCount() > 0) { scanner = new SequenceResultIterator(scanner, context.getSequenceManager()); } return scanner; }
Source:
<code>public boolean apply(Game game, Ability source) { Map<UUID, Integer> destroyedArtifactPerPlayer = new HashMap<>(); for (UUID targetID : this.targetPointer.getTargets(game, source)) { Permanent permanent = game.getPermanent(targetID); if (permanent != null) { if (permanent.destroy(source.getSourceId(), game, false)) { if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) { destroyedArtifactPerPlayer.merge(permanent.getControllerId(), 1, Integer::sum); } } } } for (Map.Entry<UUID, Integer> entry : destroyedArtifactPerPlayer.entrySet()) { <START> Player player = game.getState().getPlayer(entry.getKey()); <END> player.damage(entry.getValue(), source.getSourceId(), game, false, true); } return true; }</code><technical_language>game.getPlayer(). check if player object is != null</technical_language>

Target:
public boolean apply(Game game, Ability source) { Map<UUID, Integer> destroyedArtifactPerPlayer = new HashMap<>(); for (UUID targetID : this.targetPointer.getTargets(game, source)) { Permanent permanent = game.getPermanent(targetID); if (permanent != null) { if (permanent.destroy(source.getSourceId(), game, false)) { if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) { destroyedArtifactPerPlayer.merge(permanent.getControllerId(), 1, Integer::sum); } } } } for (Map.Entry<UUID, Integer> entry : destroyedArtifactPerPlayer.entrySet()) { Player player = game.getPlayer(entry.getKey()); if(player != null) { player.damage(entry.getValue(), source.getSourceId(), game, false, true); } } return true; }
Source:
<code>public void mucRoleTestForReceivingModerator() throws Exception { EntityBareJid mucAddress = getRandomRoom("smack-inttest-"); MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress); MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress); final ResultSyncPoint<String, Exception> resultSyncPoint = new ResultSyncPoint<>(); mucAsSeenByTwo.addUserStatusListener(new UserStatusListener() { @Override public void moderatorGranted() { resultSyncPoint.signal("done"); } }); MucCreateConfigFormHandle handle = mucAsSeenByOne.createOrJoin(Resourcepart.from("one-" + randomString)); try { if (handle != null) { handle.makeInstant(); } <START> final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString); <END> mucAsSeenByTwo.join(nicknameTwo); mucAsSeenByOne.grantModerator(nicknameTwo); resultSyncPoint.waitForResult(timeout); } finally { tryDestroy(mucAsSeenByOne); } }</code><technical_language>line appears overly long, add a line break 120 chars</technical_language>

Target:
public void mucRoleTestForReceivingModerator() throws Exception { EntityBareJid mucAddress = getRandomRoom("smack-inttest"); MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress); MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress); final ResultSyncPoint<String, Exception> resultSyncPoint = new ResultSyncPoint<>(); mucAsSeenByTwo.addUserStatusListener(new UserStatusListener() { @Override public void moderatorGranted() { resultSyncPoint.signal("done"); } }); createMUC(mucAsSeenByOne, "one-" + randomString); final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString); mucAsSeenByTwo.join(nicknameTwo); mucAsSeenByOne.grantModerator(nicknameTwo); try { resultSyncPoint.waitForResult(timeout); } catch (TimeoutException e) { throw new AssertionError("Failed to receive presence"); } finally { tryDestroy(mucAsSeenByOne); } }
Source:
<code>public void testCreateIDoc() throws Exception { File file = new File("data/testRegistry.ecore"); IDocUtil.loadRegistry(file); EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage("<LINK_0>"); assertNotNull("Failded to load base IDoc package", ePackage); ePackage = EPackage.Registry.INSTANCE.getEPackage("<LINK_0>/NPL/HRMD_B01 assertNotNull("Failed to load derived IDoc package", ePackage); Document document = IDocUtil.createDocument("NPL", "HRMD_B01", null, "31G", null); assertNotNull("Failed to create IDoc document", document); assertEquals("New IDoc document has incorrect IDoc type", "HRMD_B01", document.getIDocType()); assertEquals("New IDoc document has incorrect IDoc type extension", "", document.getIDocTypeExtension()); Segment rootSegment = document.getRootSegment(); assertEquals("New IDoc document has incorrect root segment type", "ROOT", rootSegment.getType()); assertEquals("Root segment of new IDoc document has incorrect hierarchy level", 1, rootSegment.getHierarchyLevel()); <START> assertNotNull("Document reference not assinged to root segment", rootSegment.getDocument()); <END> }</code><technical_language>typo assinged -> assigned</technical_language>

Target:
public void testCreateIDoc() throws Exception { File file = new File("data/testRegistry.ecore"); IDocUtil.loadRegistry(file); EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage("<LINK_0>"); assertNotNull("Failded to load base IDoc package", ePackage); ePackage = EPackage.Registry.INSTANCE.getEPackage("<LINK_0>/NPL/HRMD_B01 assertNotNull("Failed to load derived IDoc package", ePackage); Document document = IDocUtil.createDocument("NPL", "HRMD_B01", null, "31G", null); assertNotNull("Failed to create IDoc document", document); assertEquals("New IDoc document has incorrect IDoc type", "HRMD_B01", document.getIDocType()); assertEquals("New IDoc document has incorrect IDoc type extension", "", document.getIDocTypeExtension()); Segment rootSegment = document.getRootSegment(); assertEquals("New IDoc document has incorrect root segment type", "ROOT", rootSegment.getType()); assertEquals("Root segment of new IDoc document has incorrect hierarchy level", 1, rootSegment.getHierarchyLevel()); assertNotNull("Document reference not assigned to root segment", rootSegment.getDocument()); }
Source:
<code>public void engineIsRunningNotification() { try { log.debug("DWH Heart Beat - Start"); TransactionSupport.executeInScope(TransactionScopeOption.RequiresNew, () -> { heartBeatVar.setDateTime(new Date()); dwhHistoryTimekeepingDao.save(heartBeatVar); <START> log.debug("DWH Heart Beat - End"); <END> return null; }); } catch (Exception ex) { log.error("Error updating DWH Heart Beat: {}", ex.getMessage()); log.debug("Exception", ex); } }</code><technical_language>Is a need log.debug transaction scope</technical_language>

Target:
public void engineIsRunningNotification() { try { log.debug("DWH Heart Beat - Start"); TransactionSupport.executeInScope(TransactionScopeOption.RequiresNew, () -> { heartBeatVar.setDateTime(new Date()); dwhHistoryTimekeepingDao.save(heartBeatVar); return null; }); log.debug("DWH Heart Beat - End"); } catch (Exception ex) { log.error("Error updating DWH Heart Beat: {}", ex.getMessage()); log.debug("Exception", ex); } }
Source:
<code><START> public synchronized boolean deregister(String method) { <END> oneToOneHandlers.remove(method); oneToManyHandlers.remove(method); oneToNoneHandlers.remove(method); manyToOneHandlers.remove(method); manyToManyHandlers.remove(method); manyToNoneHandlers.remove(method); noneToOneHandlers.remove(method); noneToManyHandlers.remove(method); noneToNoneHandlers.remove(method); return methodToCategory.remove(method) != null; }</code><technical_language>I handle this more accurate here: get category method's name methodToCategory knowing category remove method handler map of handlers, do think</technical_language>

Target:
public synchronized boolean deregister(String method) { Category category = methodToCategory.remove(method); if (category == null) { return false; } switch (category) { case ONE_TO_ONE: oneToOneHandlers.remove(method); break; case ONE_TO_MANY: oneToManyHandlers.remove(method); break; case ONE_TO_NONE: oneToNoneHandlers.remove(method); break; case MANY_TO_ONE: manyToOneHandlers.remove(method); break; case MANY_TO_MANY: manyToManyHandlers.remove(method); break; case MANY_TO_NONE: manyToNoneHandlers.remove(method); break; case NONE_TO_ONE: noneToOneHandlers.remove(method); break; case NONE_TO_MANY: noneToManyHandlers.remove(method); break; case NONE_TO_NONE: noneToNoneHandlers.remove(method); } return true; }
Source:
<code>public void executeCommand(Command command, ExecutionHandlerContext context) { if (command.getProcessedCommand().size() < 2) { command .setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETEXECUTOR)); return; } ByteArrayWrapper key = command.getKey(); checkDataType(key, RedisDataType.REDIS_STRING, context); <START> Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion(); <END> ByteArrayWrapper wrapper = r.get(key); respondBulkStrings(command, context, wrapper); }</code><technical_language>r</technical_language>

Target:
public void executeCommand(Command command, ExecutionHandlerContext context) { if (command.getProcessedCommand().size() < 2) { command .setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETEXECUTOR)); return; } ByteArrayWrapper key = command.getKey(); checkDataType(key, RedisDataType.REDIS_STRING, context); Region<ByteArrayWrapper, ByteArrayWrapper> region = context.getRegionProvider().getStringsRegion(); ByteArrayWrapper wrapper = region.get(key); respondBulkStrings(command, context, wrapper); }
Source:
<code>private void shareEmbroideryFile() { if (stageListener.embroideryList.size() > 1) { String filename = FileMetaDataExtractor.encodeSpecialCharsForFileSystem(ProjectManager.getInstance().getCurrentProject().getName()); DSTFileGenerator dstFileGenerator = new DSTFileGenerator(stageListener.embroideryList); <START> File dstFile = new File(Constants.CACHE_DIR, filename + ".dst"); <END> if (dstFile.exists()) { dstFile.delete(); } try { if (dstFile.createNewFile()) { dstFileGenerator.writeToDSTFile(dstFile); new ExportEmbroideryFileLauncher(stageActivity, dstFile).startActivity(); } } catch (IOException e) { ToastUtil.showError(stageActivity, R.string.error_embroidery_file_export); Log.e(TAG, "Writing to dst file failed"); } } dismiss(); }</code><technical_language>please put ".dst" Constants</technical_language>

Target:
private void shareEmbroideryFile() { if (stageListener.embroideryList.size() > 1) { String filename = FileMetaDataExtractor.encodeSpecialCharsForFileSystem(ProjectManager.getInstance().getCurrentProject().getName()); DSTFileGenerator dstFileGenerator = new DSTFileGenerator(stageListener.embroideryList); File dstFile = new File(Constants.CACHE_DIR, filename + Constants.EMBROIDERY_FILE_EXTENSION); if (dstFile.exists()) { dstFile.delete(); } try { if (dstFile.createNewFile()) { dstFileGenerator.writeToDSTFile(dstFile); new ExportEmbroideryFileLauncher(stageActivity, dstFile).startActivity(); } } catch (IOException e) { ToastUtil.showError(stageActivity, R.string.error_embroidery_file_export); Log.e(TAG, "Writing to dst file failed"); } } dismiss(); }
Source:
<code>public void start() { if (isRunning()) { return; } try { InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(this.defaultPartitionSuffix); config.addAdditionalBindCredentials("uid=admin,ou=system", "secret"); config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", this.port)); config.setEnforceSingleStructuralObjectClass(false); config.setEnforceAttributeSyntaxCompliance(true); DN dn = new DN(this.defaultPartitionSuffix); Entry entry = new Entry(dn); entry.addAttribute("objectClass", "top", "domain", "extensibleObject"); entry.addAttribute("dc", dn.getRDN().getAttributeValues()[0]); InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config); directoryServer.add(entry); importLdif(directoryServer); directoryServer.startListening(); this.port = directoryServer.getListenPort(); this.directoryServer = directoryServer; this.running = true; } catch (LDAPException ex) { throw new RuntimeException("Server startup failed", ex); <START> } catch (IllegalArgumentException ex){ <END> throw ex; } }</code><technical_language>caught exception is immediately re-thrown, means this code redundant</technical_language>

Target:
public void start() { if (isRunning()) { return; } try { InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(this.defaultPartitionSuffix); config.addAdditionalBindCredentials("uid=admin,ou=system", "secret"); config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", this.port)); config.setEnforceSingleStructuralObjectClass(false); config.setEnforceAttributeSyntaxCompliance(true); DN dn = new DN(this.defaultPartitionSuffix); Entry entry = new Entry(dn); entry.addAttribute("objectClass", "top", "domain", "extensibleObject"); entry.addAttribute("dc", dn.getRDN().getAttributeValues()[0]); InMemoryDirectoryServer directoryServer = new InMemoryDirectoryServer(config); directoryServer.add(entry); importLdif(directoryServer); directoryServer.startListening(); this.port = directoryServer.getListenPort(); this.directoryServer = directoryServer; this.running = true; } catch (LDAPException ex) { throw new RuntimeException("Server startup failed", ex); } }
Source:
<code>private void addListeners(ListModel<Label> labelList) { labelList.getItemsChangedEvent().addListener((ev, sender, args) -> { if (labelList.getSelectedItems() == null) { labelList.setSelectedItems(new ArrayList<>()); } getListWidget().refreshItems(); <START> boolean labelsAvailable = labelList.getItems() != null && !labelList.getItems().isEmpty(); <END> getAddSelectedItemButton().setEnabled(labelsAvailable); getSelectionWidget().getFilterListEditor().setEnabled(labelsAvailable); }); labelList.getSelectedItemsChangedEvent().addListener((ev, sender, args) -> { if (labelList.getSelectedItems() != null) { getListWidget().refreshItems(); } }); }</code><technical_language>labelList.getItems() is null ensured null above</technical_language>

Target:
private void addListeners(ListModel<Label> labelList) { labelList.getItemsChangedEvent().addListener((ev, sender, args) -> { if (labelList.getSelectedItems() == null) { labelList.setSelectedItems(new ArrayList<>()); } getListWidget().refreshItems(); boolean labelsAvailable = !labelList.getItems().isEmpty(); getAddSelectedItemButton().setEnabled(labelsAvailable); getSelectionWidget().getFilterListEditor().setEnabled(labelsAvailable); }); labelList.getSelectedItemsChangedEvent().addListener((ev, sender, args) -> { if (labelList.getSelectedItems() != null) { getListWidget().refreshItems(); } }); }
Source:
<code>private boolean setDrawableArtwork(Drawable drawable) { <START> if(drawable instanceof BitmapDrawable) { <END> return setArtworkFromBitmap(((BitmapDrawable) drawable)); } else { artworkView.setImageDrawable(drawable); } return true; }</code><technical_language>Is this code path necessary? I thinking pass BitmapDrawable drawable setImageDrawable right happen, special case this get bitmap out again</technical_language>

Target:
private boolean setDrawableArtwork(Drawable drawable) { if(drawable != null) { artworkView.setImageDrawable(drawable); if(contentFrame != null) { contentFrame.setAspectRatio(0); } } return true; }
Source:
<code>ConjureJerseyFeature() { <START> TaggedMetricRegistry registry = DefaultTaggedMetricRegistry.getDefault(); <END> ConjureServerMetrics conjureServerMetrics = ConjureServerMetrics.of(registry); this.internalExceptionMeter = conjureServerMetrics.exception(); }</code><technical_language>I this guy is deprecated... mind flipping SharedTaggedMetricRgistry thing? <LINK_0></technical_language>

Target:
ConjureJerseyFeature() { JerseyServerMetrics jerseyServerMetrics = JerseyServerMetrics.of(SharedTaggedMetricRegistries.getSingleton()); this.internalErrorMeter = jerseyServerMetrics.internalerrorAll(); }
Source:
<code>public int getLeftX() { try { <START> return (int) Math.round(Double.parseDouble(getPropertyValue(PROPERTY_NAME_X))); <END> } catch (NumberFormatException e) { return 0; } }</code><technical_language>this return x re-parsing property</technical_language>

Target:
public int getLeftX() { return x; }
Source:
<code>public void update(ViewerCell cell) { Object element = cell.getElement(); int columnNumber = cell.getColumnIndex(); <START> if (columnNumber == 0) { <END> cell.setImage(getColumnImage(element, columnNumber)); cell.setText(getColumnText(element, columnNumber)); } else { if (columnNumber == 3) { cell.setText(getColumnText(element, columnNumber)); } else { cell.setImage(getColumnImage(element, columnNumber)); } } }</code><technical_language>Magic number</technical_language>

Target:
public void update(ViewerCell cell) { Object element = cell.getElement(); int columnNumber = cell.getColumnIndex(); if (columnNumber == DESCRIPTION_COLUMN) { cell.setImage(getColumnImage(element, columnNumber)); cell.setText(getColumnText(element, columnNumber)); } else { if (columnNumber == INCOMING_CHANGES_COLUMN) { cell.setText(getColumnText(element, columnNumber)); } else { cell.setImage(getColumnImage(element, columnNumber)); } } }
Source:
<code><START> private Method getMethod(Class<?> testClass, String methodName) { <END> try { return testClass.getMethod(methodName); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }</code><technical_language>static</technical_language>

Target:
private static Method getMethod(Class<?> testClass, String methodName) { try { return testClass.getMethod(methodName); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }
Source:
<code>public GMeterInfoDto makeGMeterInfoDto() { <START> final GMeterInfoDto result = new GMeterInfoDto(1, "todo"); <END> return result; }</code><technical_language>Ok, more sense: final GMeterInfoDto result = new GMeterInfoDto(1, "deviceIndentifcation"); final GMeterInfoDto result = new GMeterInfoDto(1, "EXXXX001692675614");</technical_language>

Target:
public GMeterInfoDto makeGMeterInfoDto() { return new GMeterInfoDto(1, "EXXXX001692675614"); }
Source:
<code>public ImmutableSet<Publisher> getEnabledReadSources() { <START> return ImmutableSet.copyOf( <END> Iterables.transform( Iterables.filter(this.getReads(), ENABLED_READS_FILTER), SOURCEREADS_TO_PUBLISHER)); }</code><technical_language>ApplicationSources immutable cached sense create this set in constructor</technical_language>

Target:
public ImmutableSet<Publisher> getEnabledReadSources() { return this.enabledReadSources; }
Source:
<code>public AirSweep(final Player player) { super(player); this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) { return; } if (this.bPlayer.isOnCooldown(this)) { return; } this.damage = getConfig().getDouble("Abilities.Air.AirSweep.Damage"); this.range = getConfig().getDouble("Abilities.Air.AirSweep.Range"); this.speed = getConfig().getDouble("Abilities.Air.AirSweep.Speed"); this.knockback = getConfig().getDouble("Abilities.Air.AirSweep.Knockback"); this.cooldown = getConfig().getLong("Abilities.Air.AirSweep.Cooldown"); <START> this.hitRadius = getConfig().getDouble("Abilities.Air.AirSweep.HitRadius"); <END> if (this.bPlayer.isAvatarState()) { this.cooldown = 0; this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Damage"); this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Range"); this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Knockback"); } this.bPlayer.addCooldown(this); this.start(); }</code><technical_language>typically this option called 'Radius' in other moves. worth changing for consistency's sake</technical_language>

Target:
public AirSweep(final Player player) { super(player); this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) { return; } if (this.bPlayer.isOnCooldown(this)) { return; } this.damage = getConfig().getDouble("Abilities.Air.AirSweep.Damage"); this.range = getConfig().getDouble("Abilities.Air.AirSweep.Range"); this.speed = getConfig().getDouble("Abilities.Air.AirSweep.Speed"); this.knockback = getConfig().getDouble("Abilities.Air.AirSweep.Knockback"); this.cooldown = getConfig().getLong("Abilities.Air.AirSweep.Cooldown"); this.radius = getConfig().getDouble("Abilities.Air.AirSweep.Radius"); if (this.bPlayer.isAvatarState()) { this.cooldown = 0; this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Damage"); this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Range"); this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSweep.Knockback"); } this.bPlayer.addCooldown(this); this.start(); }
Source:
<code>@Override public ClientClusterGroup forNodes(Collection<? extends ClusterNode> nodes) { A.notNull(nodes, "nodes"); ClientClusterGroupImpl grp = forProjectionFilters(projectionFilters.forNodeIds(new HashSet<>(F.nodeIds(nodes)))); <START> grp.cachedNodes.putAll(nodes.stream().collect(Collectors.toMap(ClusterNode::id, Function.identity()))); <END> return grp; }</code><technical_language>Is reason simple for loop? ConcurrentHashMap#putAll do -- iterates keyset of input map. Is reason create HashMap simply iterate over? a do work some more work additionally</technical_language>

Target:
@Override public ClientClusterGroup forNodes(Collection<? extends ClusterNode> nodes) { A.notNull(nodes, "nodes"); ClientClusterGroupImpl grp = forProjectionFilters(projectionFilters.forNodeIds(new HashSet<>(F.nodeIds(nodes)))); for (ClusterNode node : nodes) grp.cachedNodes.put(node.id(), node); return grp; }
Source:
<code>@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMetricsUpdateFrequency(METRIC_UPDATE_FREQUENCY); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); boolean client = igniteInstanceName.startsWith("client"); <START> cfg.setClientMode(client); <END> return cfg; }</code><technical_language>refactor this cfg.setClientMode(igniteInstanceName.startsWith("client"));</technical_language>

Target:
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setClientMode(igniteInstanceName.startsWith("client")); return cfg; }
Source:
<code>public void refresh() { final Timer.Context context = m_loadFullTimer.time(); try { resetContainer(); <START> m_nodeToOnmsSnmpMap = new HashMap<Integer, Map<Integer,OnmsSnmpInterface>>(); <END> m_nodeToOnmsIpPrimaryMap = new HashMap<Integer, OnmsIpInterface>(); m_macToNodeidMap = new HashMap<String, Integer>(); m_macToOnmsIpMap = new HashMap<String, OnmsIpInterface>(); m_macToOnmsSnmpMap = new HashMap<String, OnmsSnmpInterface>(); doRefresh(); } finally { context.stop(); } LOG.info("refresh: Found groups", getGroups().size()); LOG.info("refresh: Found vertices", getVerticesWithoutGroups().size()); LOG.info("refresh: Found edges", getEdges().size()); }</code><technical_language>Diamond Operator m_nodeToOnmsSnmpMap = new HashMap<>() instead; opt invoke m_nodeToOnmsSnmpMap.clear() initialize in constructor directly</technical_language>

Target:
public void refresh() { final Timer.Context context = m_loadFullTimer.time(); try { resetContainer(); m_nodeToOnmsSnmpMap.clear(); m_nodeToOnmsIpPrimaryMap.clear(); m_macToNodeidMap.clear(); m_macToOnmsIpMap.clear(); m_macToOnmsSnmpMap.clear(); doRefresh(); } finally { context.stop(); } LOG.info("refresh: Found groups", getGroups().size()); LOG.info("refresh: Found vertices", getVerticesWithoutGroups().size()); LOG.info("refresh: Found edges", getEdges().size()); }
Source:
<code>public void load(List<List<Object>> batch) throws SQLException { for (List<Object> row : batch) { int pos = 1; for (Object value : row) { <START> preparedStatement.setObject(pos, value); <END> ++pos; } preparedStatement.addBatch(); } executeBatchWithVerification(preparedStatement, batch); }</code><technical_language>checkArgument number of objects in row matches columnsCount</technical_language>

Target:
public void load(List<List<Object>> batch) throws SQLException { if (batch.size() == 0) { return; } for (List<Object> row : batch) { checkArgument(row.size() == columnsCount, "Unexpected columns count: %d vs %d", row.size(), columnsCount); int pos = 1; for (Object value : row) { preparedStatement.setObject(pos, value); ++pos; } preparedStatement.addBatch(); } int[] insertCounts = preparedStatement.executeBatch(); for (int rowIndex = 0; rowIndex < insertCounts.length; ++rowIndex) { if (insertCounts[rowIndex] != 1) { throw new RuntimeException("could not insert values=" + batch.get(rowIndex)); } } }
Source:
<code>public static void chunkedCopy(InputStream src, File dest) throws IOException { final RandomAccessFile raf = new RandomAccessFile(dest, "rwd"); final int fd = getfd(raf.getFD()); final byte[] buf = new byte[1024 * 1024 * 8]; int numBytes; long offset = 0; LOG.info("Started chunked copy to " + dest); while ((numBytes = src.read(buf)) > 0) { <START> LOG.info("Writing " + numBytes + " at offset " + offset); <END> raf.write(buf, 0, numBytes); trySkipCache(fd, offset, numBytes); offset = raf.getFilePointer(); } LOG.info("Done chunkedCopy"); raf.close(); }</code><technical_language>this log unreadable, reason log this info</technical_language>

Target:
public static void chunkedCopy(InputStream src, File dest) throws IOException { final byte[] buf = new byte[8 << 20]; long offset = 0; try ( final RandomAccessFile raf = new RandomAccessFile(dest, "rwd") ) { final int fd = getfd(raf.getFD()); for (int numBytes = 0, bytesRead = 0; bytesRead > -1; ) { bytesRead = src.read(buf, numBytes, buf.length - numBytes); if (numBytes >= buf.length || bytesRead == -1) { raf.write(buf, 0, numBytes); trySkipCache(fd, offset, numBytes); offset = raf.getFilePointer(); numBytes = 0; } numBytes += bytesRead; } } }
Source:
<code>private List<String> determineListOfDownloadsToProcess() { List<String> list = new ArrayList<>(); if (!Config.getBoolConfigProperty(ConfigProperty.DOWNLOAD_DEPENDENCIES)) { return list; } if (SystemUtils.IS_OS_WINDOWS) { if (!checkForPresenceOf(ConfigProperty.SELENIUM_IEDRIVER_PATH, SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY, SeLionConstants.IE_DRIVER)) { <START> Config.setConfigProperty(ConfigProperty.SELENIUM_IEDRIVER_PATH, SeLionConstants.selionHomeDir <END> + SeLionConstants.IE_DRIVER); list.add("iedriver"); } } if (!checkForPresenceOf(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH, SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY, SeLionConstants.CHROME_DRIVER)) { Config.setConfigProperty(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH, SeLionConstants.selionHomeDir + SeLionConstants.CHROME_DRIVER); list.add("chromedriver"); } if (!checkForPresenceOf(ConfigProperty.SELENIUM_PHANTOMJS_PATH, SeLionConstants.WEBDRIVER_PHANTOMJS_DRIVER_PROPERTY, SeLionConstants.PHANTOMJS_DRIVER)) { Config.setConfigProperty(ConfigProperty.SELENIUM_PHANTOMJS_PATH, SeLionConstants.selionHomeDir + SeLionConstants.PHANTOMJS_DRIVER); list.add("phantomjs"); } return list; }</code><technical_language>a fan of codacy suggestion change here. I exception for this constant</technical_language>

Target:
private List<String> determineListOfDownloadsToProcess() { List<String> list = new ArrayList<>(); if (!Config.getBoolConfigProperty(ConfigProperty.DOWNLOAD_DEPENDENCIES)) { return list; } if (SystemUtils.IS_OS_WINDOWS && !checkForPresenceOf(ConfigProperty.SELENIUM_IEDRIVER_PATH, SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY, SeLionConstants.IE_DRIVER)) { Config.setConfigProperty(ConfigProperty.SELENIUM_IEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR + SeLionConstants.IE_DRIVER); list.add("iedriver"); } if (!checkForPresenceOf(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH, SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY, SeLionConstants.CHROME_DRIVER)) { Config.setConfigProperty(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR + SeLionConstants.CHROME_DRIVER); list.add("chromedriver"); } if (!checkForPresenceOf(ConfigProperty.SELENIUM_PHANTOMJS_PATH, SeLionConstants.WEBDRIVER_PHANTOMJS_DRIVER_PROPERTY, SeLionConstants.PHANTOMJS_DRIVER)) { Config.setConfigProperty(ConfigProperty.SELENIUM_PHANTOMJS_PATH, SeLionConstants.SELION_HOME_DIR + SeLionConstants.PHANTOMJS_DRIVER); list.add("phantomjs"); } return list; }
Source:
<code>protected void link() { super.link(); try { BaseEntityRef.OnDelete deleteHandler = getBlobSoftRef().getDeleteHandler(); if (deleteHandler == BaseEntityRef.OnDelete.CASCADE) { getReferencedDescriptors().forEach(entityDescriptor -> entityDescriptor.addCascadeDeleteHandler(this::onDeleteCascade)); } else if (deleteHandler == BaseEntityRef.OnDelete.SET_NULL) { if (!isNullable()) { Mixing.LOG.WARN("Error in property %s of %s: The field is not marked as NullAllowed," + " therefore SET_NULL is not a valid delete handler!", this, getDescriptor()); } getReferencedDescriptors().forEach(entityDescriptor -> entityDescriptor.addCascadeDeleteHandler(this::onDeleteSetNull)); } else if (deleteHandler == BaseEntityRef.OnDelete.REJECT) { <START> throw new IllegalArgumentException("BlobSoftRef references do not accept REJECT as deleteHandler."); <END> } } catch (Exception e) { Mixing.LOG.WARN("Error when linking property %s of %s: %s (%s)", this, getDescriptor(), e.getMessage(), e.getClass().getSimpleName()); } }</code><technical_language>I throw exception in constructor of ref thrown right a ref is introduced development a deletion occurs (which testing in production)</technical_language>

Target:
protected void link() { super.link(); try { BaseEntityRef.OnDelete deleteHandler = getBlobSoftRef().getDeleteHandler(); if (deleteHandler == BaseEntityRef.OnDelete.CASCADE) { forEachBlobType(entityDescriptor -> entityDescriptor.addCascadeDeleteHandler(this::onDeleteCascade)); } else if (deleteHandler == BaseEntityRef.OnDelete.SET_NULL) { if (!isNullable()) { Mixing.LOG.WARN("Error in property %s of %s: The field is not marked as NullAllowed," + " therefore SET_NULL is not a valid delete handler!", this, getDescriptor()); } forEachBlobType(entityDescriptor -> entityDescriptor.addCascadeDeleteHandler(this::onDeleteSetNull)); } } catch (Exception e) { Mixing.LOG.WARN("Error when linking property %s of %s: %s (%s)", this, getDescriptor(), e.getMessage(), e.getClass().getSimpleName()); } }
Source:
<code>private static <T extends Comparable<T>> IBlockState getReplantState(IBlockState sappyState) { if (hasRubberToHarvest(sappyState)) { for (Map.Entry<IProperty<?>, Comparable<?>> wetPropertyEntry : sappyState.getProperties().entrySet()) { <START> if (wetPropertyEntry.getKey() instanceof PropertyBool && wetPropertyEntry.getKey().getName().equals("hassap")) { <END> return sappyState.withProperty(PropertyBool.create("hassap"), false); } String valueWetString = wetPropertyEntry.getValue().toString(); String valueDryString = valueWetString.replace("wet", "dry"); IProperty<?> property = wetPropertyEntry.getKey(); IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState(); IBlockState dryState = getStateWithValue(baseState, property, valueDryString); if (dryState != null) { return dryState; } } } return sappyState.getBlock().getDefaultState(); }</code><technical_language>this IProperty<?> property = wetPropertyEntry.getKey();, property instead of calling getKey() more times</technical_language>

Target:
private static <T extends Comparable<T>> IBlockState getReplantState(IBlockState sappyState) { if (hasRubberToHarvest(sappyState)) { for (Map.Entry<IProperty<?>, Comparable<?>> wetPropertyEntry : sappyState.getProperties().entrySet()) { String valueWetString = wetPropertyEntry.getValue().toString(); String valueDryString = valueWetString.replace("wet", "dry"); IProperty<?> property = wetPropertyEntry.getKey(); if (property instanceof PropertyBool && property.getName().equals("hassap")) { return sappyState.withProperty(PropertyBool.create("hassap"), false); } IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState(); IBlockState dryState = getStateWithValue(baseState, property, valueDryString); if (dryState != null) { return dryState; } } } return sappyState.getBlock().getDefaultState(); }
Source:
<code>public int[] getAcceptableTokens() { return new int[] { TokenTypes.LITERAL_TRY, TokenTypes.LITERAL_IF, TokenTypes.LITERAL_ELSE, TokenTypes.LITERAL_SWITCH, TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.METHOD_DEF, TokenTypes.CTOR_DEF, TokenTypes.LITERAL_FOR, TokenTypes.LITERAL_WHILE, TokenTypes.LITERAL_DO, TokenTypes.STATIC_INIT, TokenTypes.INSTANCE_INIT, TokenTypes.ANNOTATION_DEF, <START> TokenTypes.ENUM_DEF, <END> }; }</code><technical_language>tokens blocks here: TokenTypes.ANNOTATION_ARRAY_INIT, TokenTypes.ANNOTATION_DEF, TokenTypes.ARRAY_INIT, TokenTypes.CASE_GROUP, TokenTypes.CLASS_DEF, TokenTypes.CTOR_DEF, TokenTypes.ENUM_CONSTANT_DEF, TokenTypes.ENUM_DEF, TokenTypes.INSTANCE_INIT, TokenTypes.INTERFACE_DEF, TokenTypes.LAMBDA, TokenTypes.LITERAL_CASE, TokenTypes.LITERAL_CATCH, TokenTypes.LITERAL_DEFAULT, TokenTypes.LITERAL_DO, TokenTypes.LITERAL_ELSE, TokenTypes.LITERAL_FINALLY, TokenTypes.LITERAL_FOR, TokenTypes.LITERAL_IF, TokenTypes.LITERAL_NEW, TokenTypes.LITERAL_SWITCH, TokenTypes.LITERAL_SYNCHRONIZED, TokenTypes.LITERAL_TRY, TokenTypes.LITERAL_WHILE, TokenTypes.METHOD_DEF, TokenTypes.SLIST, TokenTypes.STATIC_INIT,</technical_language>

Target:
public int[] getAcceptableTokens() { return new int[] { TokenTypes.ANNOTATION_ARRAY_INIT, TokenTypes.ANNOTATION_DEF, TokenTypes.ARRAY_INIT, TokenTypes.CASE_GROUP, TokenTypes.CLASS_DEF, TokenTypes.CTOR_DEF, TokenTypes.ENUM_CONSTANT_DEF, TokenTypes.ENUM_DEF, TokenTypes.INSTANCE_INIT, TokenTypes.INTERFACE_DEF, TokenTypes.LAMBDA, TokenTypes.LITERAL_CASE, TokenTypes.LITERAL_CATCH, TokenTypes.LITERAL_DEFAULT, TokenTypes.LITERAL_DO, TokenTypes.LITERAL_ELSE, TokenTypes.LITERAL_FINALLY, TokenTypes.LITERAL_FOR, TokenTypes.LITERAL_IF, TokenTypes.LITERAL_NEW, TokenTypes.LITERAL_SWITCH, TokenTypes.LITERAL_SYNCHRONIZED, TokenTypes.LITERAL_TRY, TokenTypes.LITERAL_WHILE, TokenTypes.METHOD_DEF, TokenTypes.SLIST, TokenTypes.STATIC_INIT, }; }
Source:
<code>public List<Tree.Kind> nodesToVisit() { <START> return Collections.singletonList(SWITCH_EXPRESSION); <END> }</code><technical_language>decided a SWITCH_EXPRESSION here. SWITCH_STATEMENT a SWITCH_EXPRESSION unique child, point of view rule apply switch statement. A switch expression return a wrong</technical_language>

Target:
public List<Tree.Kind> nodesToVisit() { return Collections.singletonList(SWITCH_STATEMENT); }
Source:
<code>public Batch getNextEmptyBatch() { <START> for (;batches[emptyBatch].getNumEvents() != 0; emptyBatch = (emptyBatch + 1) % (poolSize)); <END> return batches[emptyBatch]; }</code><technical_language>Is a custom SpinWait? I agree migration BusySpinWait locks is worth a separate commit for existing processors, this is a new code. Do do looping here? A semaphore of size poolSize</technical_language>

Target:
public Batch getNextEmptyBatch() throws InterruptedException { synchronized(availableBatches) { while (availableBatches.isEmpty()) { availableBatches.wait(); } Integer batchIdx = availableBatches.pop(); return batches[batchIdx]; } }
Source:
<code>public void createHost(UUID hostId, HostDirectory.Metadata metadata) throws StateAccessException, SerializationException { zk.multi(prepareCreate(hostId, metadata)); log.debug("Host was <START> created successfully", <END> hostId); }</code><technical_language>nit: registered in NSDB? Thinking sounds for operator</technical_language>

Target:
public void createHost(UUID hostId, HostDirectory.Metadata metadata) throws StateAccessException, SerializationException { zk.multi(prepareCreate(hostId, metadata)); log.info("Host registered to NSDB", hostId); }
Source:
<code>public void testNestedValid() { Validator validator = getValidator(); Set<ConstraintViolation<EmailAddressMap>> constraintViolations = validator.validate( EmailAddressMap.validEmailAddressMap() ); assertNumberOfViolations( constraintViolations, 0 ); constraintViolations = validator.validate( EmailAddressMap.invalidEmailAddressMap() ); <START> assertNumberOfViolations( constraintViolations, 2 ); <END> assertCorrectPropertyPaths( constraintViolations, "map[invalid].[1].email", "map[invalid].[2].email" ); assertCorrectConstraintTypes( constraintViolations, Email.class, Email.class ); }</code><technical_language>I assertion number is helpful. 1 actually, is missing. if omit this assertion, actual paths in next statement</technical_language>

Target:
public void testNestedValid() { Validator validator = getValidator(); Set<ConstraintViolation<EmailAddressMap>> constraintViolations = validator.validate( EmailAddressMap.validEmailAddressMap() ); assertNumberOfViolations( constraintViolations, 0 ); constraintViolations = validator.validate( EmailAddressMap.invalidEmailAddressMap() ); assertCorrectPropertyPaths( constraintViolations, "map[invalid].<map value>[1].email", "map[invalid].<map value>[2].email" ); assertCorrectConstraintTypes( constraintViolations, Email.class, Email.class ); assertThat( constraintViolations ).containsOnlyPaths( pathWith() .property( "map" ) .typeArgument( "<map value>", true, "invalid", null ) .property( "email", true, null, 1 ), pathWith() .property( "map" ) .typeArgument( "<map value>", true, "invalid", null ) .property( "email", true, null, 2 ) ); }
Source:
<code>public void remove(final List<String> ids){ mLock.readLock().lock(); try { HashMap<String, Integer> itemsPositionMap = getPositionMap(mItems); boolean foundInItems = false; for (String id: ids){ if (itemsPositionMap.containsKey(id)){ foundInItems = true; break; } } if (!foundInItems){ return; } } finally{ mLock.readLock().unlock(); } mHandler.post(new Runnable() { @Override public void run() { final Lock writeLock = mLock.writeLock(); writeLock.lock(); HashSet<String> idsRemoved = new HashSet<String>(ids.size()); try { final ArrayList<Integer> indexesRemoved = new ArrayList<Integer>(ids.size()); HashMap<String, Integer> mItemsPositionMap = getPositionMap(mItems); for (String id : ids) { Integer index = mItemsPositionMap.get(id); if (index != null) { idsRemoved.add(id); indexesRemoved.add(index); } } final ArrayList<BoxItem> listWithoutRemovedIds = new ArrayList<BoxItem>(mItems.size() - idsRemoved.size()); for (BoxItem item : mItems) { if (!idsRemoved.contains(item.getId())) { listWithoutRemovedIds.add(item); } } boolean removedItems = false; if (indexesRemoved.size() <= REMOVE_LIMIT) { for (Integer index : indexesRemoved) { <START> notifyItemRemoved(index); <END> } removedItems = true; } mItems.clear(); mItems.addAll(listWithoutRemovedIds); if (removedItems && mItems.size() > 0) { notifyItemRangeChanged(0, mItems.size()); } else { notifyDataSetChanged(); } } finally { writeLock.unlock(); } } }); }</code><technical_language>Sort reverse notifying maintain index</technical_language>

Target:
public void remove(final List<String> ids){ mLock.readLock().lock(); try { HashMap<String, Integer> itemsPositionMap = getPositionMap(mItems); boolean foundInItems = false; for (String id: ids){ if (itemsPositionMap.containsKey(id)){ foundInItems = true; break; } } if (!foundInItems){ return; } } finally{ mLock.readLock().unlock(); } mHandler.post(new Runnable() { @Override public void run() { final Lock writeLock = mLock.writeLock(); writeLock.lock(); HashSet<String> idsRemoved = new HashSet<String>(ids.size()); try { final ArrayList<Integer> indexesRemoved = new ArrayList<Integer>(ids.size()); HashMap<String, Integer> mItemsPositionMap = getPositionMap(mItems); for (String id : ids) { Integer index = mItemsPositionMap.get(id); if (index != null) { idsRemoved.add(id); indexesRemoved.add(index); } } final ArrayList<BoxItem> listWithoutRemovedIds = new ArrayList<BoxItem>(mItems.size() - idsRemoved.size()); for (BoxItem item : mItems) { if (!idsRemoved.contains(item.getId())) { listWithoutRemovedIds.add(item); } } boolean removedItems = false; if (indexesRemoved.size() <= REMOVE_LIMIT) { Collections.sort(indexesRemoved); for (int i=indexesRemoved.size() -1; i >= 0; i--){ notifyItemRemoved(indexesRemoved.get(i)); } removedItems = true; } mItems.clear(); mItems.addAll(listWithoutRemovedIds); if (removedItems && mItems.size() > 0) { notifyItemRangeChanged(0, mItems.size()); } else { notifyDataSetChanged(); } } finally { writeLock.unlock(); } } }); }
Source:
<code>public BenchmarkSuite get() { BenchmarkSuite benchmarkSuite; ImmutableList.Builder<BenchmarkQuery> benchmarkQueries = ImmutableList.builder(); try (Handle handle = jdbi.open()) { BenchmarkSuiteDao benchmarkDao = handle.attach(BenchmarkSuiteDao.class); BenchmarkSuiteInfo benchmarkSuiteInfo = benchmarkDao.getBenchmarkSuiteInfo(suitesTableName, suite); <START> benchmarkQueries.addAll(benchmarkDao.getBenchmarkQueries(queriesTableName, benchmarkSuiteInfo.getQuerySet())); <END> benchmarkSuite = new BenchmarkSuite(benchmarkSuiteInfo, benchmarkQueries.build()); } return benchmarkSuite; }</code><technical_language>benchmarkDao.getBenchmarkQueries returns a list. do need create empty list elements</technical_language>

Target:
public BenchmarkSuite get() { BenchmarkSuite benchmarkSuite; try (Handle handle = jdbi.open()) { BenchmarkSuiteDao benchmarkDao = handle.attach(BenchmarkSuiteDao.class); BenchmarkSuiteInfo benchmarkSuiteInfo = benchmarkDao.getBenchmarkSuiteInfo(suitesTableName, suite); benchmarkSuite = new BenchmarkSuite(benchmarkSuiteInfo, benchmarkDao.getBenchmarkQueries(queriesTableName, benchmarkSuiteInfo.getQuerySet())); } return benchmarkSuite; }
Source:
<code>public static void onConfigChange(OnConfigChangedEvent cce) { if (BCModules.isBcMod(cce.getModID())) { <START> EnumRestartRequirement req = EnumRestartRequirement.NONE; <END> if (Loader.instance().isInState(LoaderState.AVAILABLE)) { req = EnumRestartRequirement.WORLD; } reloadConfig(req); } }</code><technical_language>restart requirement NONE, is applied instantly need a world reload start/stop rendering</technical_language>

Target:
public static void onConfigChange(OnConfigChangedEvent cce) { if (BCModules.isBcMod(cce.getModID())) { reloadConfig(EnumRestartRequirement.NONE); } }
Source:
<code>private static String readFromFile(String filePath) { String encoding = StandardCharsets.UTF_8.name(); String content = ""; File file = new File(filePath.trim()); if (file.isFile() && file.exists()) { try { <START> content = FileUtils.readFileToString(file, encoding); <END> } catch (IOException e) { LOGGER.error("Failed to read from File {}", filePath); throw new IllegalArgumentException("Failed to read from File " + filePath); } } else { throw new IllegalArgumentException(filePath + " is a directory or does not exist"); } return content; }</code><technical_language>inline encoding</technical_language>

Target:
private static String readFromFile(String filePath) { String content = ""; File file = new File(filePath.trim()); if (file.isFile() && file.exists()) { try { content = FileUtils.readFileToString(file, StandardCharsets.UTF_8.name()); } catch (IOException e) { LOGGER.error("Failed to read from File {}", filePath); throw new IllegalArgumentException("Failed to read from File " + filePath); } } else { throw new IllegalArgumentException(filePath + " is a directory or does not exist"); } return content; }
Source:
<code>public void testDefaults() { assertRecordedDefaults(recordDefaults(StaticMetastoreConfig.class) <START> .setMetastoreUris(null).setHiveUserName(null)); <END> }</code><technical_language>Put a separate line java .setMetastoreUris(null) .setHiveUserName(null));</technical_language>

Target:
public void testDefaults() { assertRecordedDefaults(recordDefaults(StaticMetastoreConfig.class) .setMetastoreUris(null) .setMetastoreUsername(null)); }
Source:
<code>private TrieNode constructTrie(Map<String, InstanceConfig> instanceConfigMap, final String[] topologyKeys) { TrieNode rootNode = new TrieNode("", "ROOT"); Map<String, Map<String, String>> instanceDomainsMap = new HashMap<>(); instanceConfigMap.entrySet().forEach( entry -> instanceDomainsMap.put(entry.getKey(), entry.getValue().getDomainAsMap())); for (Map.Entry<String, Map<String, String>> entry : instanceDomainsMap.entrySet()) { TrieNode curNode = rootNode; <START> String path = ""; <END> for (int i = 0; i < topologyKeys.length; i++) { String key = topologyKeys[i] + CONNECTOR + entry.getValue().get(topologyKeys[i]); path = path + DELIMITER + key; TrieNode nextNode = curNode.getChildren().get(key); if (nextNode == null) { nextNode = new TrieNode(path, topologyKeys[i]); } curNode.addChild(key, nextNode); curNode = nextNode; } } return rootNode; }</code><technical_language>StringBuilder for performance</technical_language>

Target:
private TrieNode constructTrie(Map<String, InstanceConfig> instanceConfigMap, final String[] topologyKeys) { TrieNode rootNode = new TrieNode("", "ROOT"); Map<String, Map<String, String>> instanceDomainsMap = new HashMap<>(); instanceConfigMap.entrySet().forEach( entry -> instanceDomainsMap.put(entry.getKey(), entry.getValue().getDomainAsMap())); for (Map.Entry<String, Map<String, String>> entry : instanceDomainsMap.entrySet()) { TrieNode curNode = rootNode; StringBuilder path = new StringBuilder(); for (int i = 0; i < topologyKeys.length; i++) { String key = topologyKeys[i] + CONNECTOR + entry.getValue().get(topologyKeys[i]); path.append(DELIMITER).append(key); TrieNode nextNode = curNode.getChildren().get(key); if (nextNode == null) { nextNode = new TrieNode(path.toString(), topologyKeys[i]); } curNode.addChild(key, nextNode); curNode = nextNode; } } return rootNode; }