auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public MonetaryAmount deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final MoneyRepresentation moneyRepresentation = deserializationContext.readValue(jsonParser, MoneyRepresentation.class); final String currencyCode = moneyRepresentation.getCurrencyCode(); if(moneyRepresentation instanceof HighPrecisionMoneyRepresentation){ <START> HighPrecisionMoneyRepresentation highPrecisionMoneyRepresentation = ((HighPrecisionMoneyRepresentation) moneyRepresentation); <END> final int scale = highPrecisionMoneyRepresentation.getFractionDigits(); BigDecimal bigDecimal = highPrecisionMoneyRepresentation.getPreciseAmount().movePointLeft(scale); return HighPrecisionMoneyImpl.of(bigDecimal,currencyCode ,scale ); } else { return MoneyImpl.ofCents(moneyRepresentation.getCentAmount(), currencyCode); } }</code><technical_language>Please add final here</technical_language>

Target:
public MonetaryAmount deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final MoneyRepresentation moneyRepresentation = deserializationContext.readValue(jsonParser, MoneyRepresentation.class); final String currencyCode = moneyRepresentation.getCurrencyCode(); if(moneyRepresentation instanceof HighPrecisionMoneyRepresentation){ final HighPrecisionMoneyRepresentation highPrecisionMoneyRepresentation = ((HighPrecisionMoneyRepresentation) moneyRepresentation); final int scale = highPrecisionMoneyRepresentation.getFractionDigits(); final BigDecimal bigDecimal = highPrecisionMoneyRepresentation.getPreciseAmount().movePointLeft(scale); return HighPrecisionMoneyImpl.of(bigDecimal,currencyCode ,scale ); } else { return MoneyImpl.ofCents(moneyRepresentation.getCentAmount(), currencyCode); } }
Source:
<code>private void updateActionAvailability(GlusterVolumeEntity volumeEntity) { boolean allowStartSessionCommand = false; boolean allowResumeSessionCommand = false; boolean allowPauseSessionCommand = false; if(volumeEntity == null) return; if (getSelectedItem() == null) { allowStartSessionCommand = false; allowResumeSessionCommand = false; allowPauseSessionCommand = false; } else if(getSelectedItems().size() == 1) { GlusterGeoRepSession selectedSession = (GlusterGeoRepSession)getSelectedItem(); GeoRepSessionStatus sessionStatus = selectedSession.getStatus(); allowStartSessionCommand = sessionStatus == GeoRepSessionStatus.NOTSTARTED || sessionStatus == GeoRepSessionStatus.STOPPED; allowResumeSessionCommand = sessionStatus == GeoRepSessionStatus.PAUSED; allowPauseSessionCommand = sessionStatus == GeoRepSessionStatus.ACTIVE; } else allowStartSessionCommand = false; getNewSessionCommand().setIsAvailable(true); getRemoveSessionCommand().setIsAvailable(false); getStartSessionCommand().setIsExecutionAllowed(allowStartSessionCommand); <START> getStopSessionCommand().setIsExecutionAllowed(!allowStartSessionCommand); <END> getPauseSessionCommand().setIsExecutionAllowed(allowPauseSessionCommand); getResumeSessionCommand().setIsExecutionAllowed(allowResumeSessionCommand); getSessionOptionsCommand().setIsExecutionAllowed(true); getViewSessionDetailsCommand().setIsAvailable(false); getRefreshSessionsCommand().setIsAvailable(true); }</code><technical_language>allowStopSessionCommand</technical_language>

Target:
private void updateActionAvailability(GlusterVolumeEntity volumeEntity) { boolean allowStartSessionCommand = false; boolean allowStopSessionCommand = false; boolean allowResumeSessionCommand = false; boolean allowPauseSessionCommand = false; if(volumeEntity == null) { return; } if (getSelectedItem() == null) { allowStartSessionCommand = false; allowStopSessionCommand = false; allowResumeSessionCommand = false; allowPauseSessionCommand = false; } else if(getSelectedItems().size() == 1) { GlusterGeoRepSession selectedSession = (GlusterGeoRepSession)getSelectedItem(); GeoRepSessionStatus sessionStatus = selectedSession.getStatus(); allowStartSessionCommand = sessionStatus == GeoRepSessionStatus.NOTSTARTED || sessionStatus == GeoRepSessionStatus.STOPPED; allowStopSessionCommand = !allowStartSessionCommand; allowResumeSessionCommand = sessionStatus == GeoRepSessionStatus.PAUSED; allowPauseSessionCommand = sessionStatus == GeoRepSessionStatus.ACTIVE; } else { allowStartSessionCommand = false; } getNewSessionCommand().setIsAvailable(true); getRemoveSessionCommand().setIsAvailable(false); getStartSessionCommand().setIsExecutionAllowed(allowStartSessionCommand); getStopSessionCommand().setIsExecutionAllowed(allowStopSessionCommand); getPauseSessionCommand().setIsExecutionAllowed(allowPauseSessionCommand); getResumeSessionCommand().setIsExecutionAllowed(allowResumeSessionCommand); getSessionOptionsCommand().setIsExecutionAllowed(true); getViewSessionDetailsCommand().setIsAvailable(false); getRefreshSessionsCommand().setIsAvailable(true); }
Source:
<code>public List<ModemPdpContext> getPdpContextInfo() throws KuraException { List<ModemPdpContext> pdpContextInfo = new ArrayList<>(); synchronized (atLock) { <START> byte[] reply; <END> CommConnection commAtConnection = openSerialPort(getAtPort()); if (!isAtReachable(commAtConnection)) { closeSerialPort(commAtConnection); throw new KuraException(KuraErrorCode.NOT_CONNECTED, MODEM_NOT_AVAILABLE_FOR_AT_CMDS_MSG + TelitHe910.class.getName()); } try { reply = commAtConnection.sendCommand(formGetPdpContextAtCommand().getBytes(), 1000, 100); } catch (IOException e) { closeSerialPort(commAtConnection); throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e); } closeSerialPort(commAtConnection); if (reply != null) { String sreply = this.getResponseString(reply); Scanner scanner = new Scanner(sreply); while (scanner.hasNextLine()) { String[] tokens = scanner.nextLine().split(","); int contextNo = Integer.parseInt(tokens[0].substring("+CGDCONT:".length()).trim()); ModemPdpContextType pdpType = ModemPdpContextType .getContextType(tokens[1].substring(1, tokens[1].length() - 1)); String apn = tokens[2].substring(1, tokens[2].length() - 1); ModemPdpContext modemPdpContext = new ModemPdpContext(contextNo, pdpType, apn); pdpContextInfo.add(modemPdpContext); } scanner.close(); } } return pdpContextInfo; }</code><technical_language>love try-with-resources here..</technical_language>

Target:
public List<ModemPdpContext> getPdpContextInfo() throws KuraException { List<ModemPdpContext> pdpContextInfo = new ArrayList<>(); synchronized (this.atLock) { byte[] reply; CommConnection commAtConnection = openSerialPort(getAtPort()); if (!isAtReachable(commAtConnection)) { closeSerialPort(commAtConnection); throw new KuraException(KuraErrorCode.NOT_CONNECTED, MODEM_NOT_AVAILABLE_FOR_AT_CMDS_MSG + TelitHe910.class.getName()); } try { reply = commAtConnection.sendCommand(formGetPdpContextAtCommand().getBytes(), 1000, 100); } catch (IOException e) { closeSerialPort(commAtConnection); throw new KuraException(KuraErrorCode.CONNECTION_FAILED, e); } closeSerialPort(commAtConnection); if (reply != null) { String sreply = this.getResponseString(reply); Scanner scanner = new Scanner(sreply); while (scanner.hasNextLine()) { String[] tokens = scanner.nextLine().split(","); if (!tokens[0].startsWith("+CGDCONT:")) { continue; } int contextNo = Integer.parseInt(tokens[0].substring("+CGDCONT:".length()).trim()); ModemPdpContextType pdpType = ModemPdpContextType .getContextType(tokens[1].substring(1, tokens[1].length() - 1)); String apn = tokens[2].substring(1, tokens[2].length() - 1); ModemPdpContext modemPdpContext = new ModemPdpContext(contextNo, pdpType, apn); pdpContextInfo.add(modemPdpContext); } scanner.close(); } } return pdpContextInfo; }
Source:
<code>public abstract void sendJob(LaserJob job, ProgressListener pl, List<String> warnings) throws IllegalJobException, Exception; <START> public abstract void saveJob(LaserJob job) throws IllegalJobException, Exception; <END> public boolean isAutoFocus() { return false; }</code><technical_language>making this abstract, LaserCutter implement feature. implement in drivers now, this method throw exception overriden</technical_language>

Target:
public abstract void sendJob(LaserJob job, ProgressListener pl, List<String> warnings) throws IllegalJobException, Exception; public void saveJob(java.io.PrintStream fileOutputStream, LaserJob job) throws NotImplementedException, IllegalJobException, Exception { System.err.println("Your driver does not implement saveJob(LaserJob job)"); throw new NotImplementedException(); }
Source:
<code>public static DSMRPortSettings getPortSettingsFromString(String portSettings) { Matcher m = Pattern.compile(PORT_SETTING_REGEX).matcher(portSettings); if (m.find()) { int baudrate = Integer.parseInt(m.group(1)); int databits = Integer.parseInt(m.group(2)); int parity; int stopbits; char parityChar = m.group(3).toUpperCase().charAt(0); switch (parityChar) { case 'E': parity = SerialPort.PARITY_EVEN; break; case 'O': parity = SerialPort.PARITY_ODD; break; case 'N': parity = SerialPort.PARITY_NONE; break; default: <START> logger.error("Invalid parity (" + parityChar + "), ignoring fixed port settings."); <END> return null; } String stopbitsString = m.group(4); if (stopbitsString.equals("1")) { stopbits = SerialPort.STOPBITS_1; } else if (stopbitsString.equals("1.5")) { stopbits = SerialPort.STOPBITS_1_5; } else if (stopbitsString.equals("2")) { stopbits = SerialPort.STOPBITS_2; } else { logger.error("Invalid stop bits(" + stopbitsString + "), ignoring fixed port settings."); return null; } return new DSMRPortSettings(baudrate, databits, parity, stopbits); } else { return null; } }</code><technical_language>Please parameterized logging instead of string concatenation</technical_language>

Target:
public static DSMRPortSettings getPortSettingsFromString(String portSettings) { Matcher m = Pattern.compile(PORT_SETTING_REGEX).matcher(portSettings); if (m.find()) { int baudrate = Integer.parseInt(m.group(1)); int databits = Integer.parseInt(m.group(2)); int parity; int stopbits; char parityChar = m.group(3).toUpperCase().charAt(0); switch (parityChar) { case 'E': parity = SerialPort.PARITY_EVEN; break; case 'O': parity = SerialPort.PARITY_ODD; break; case 'N': parity = SerialPort.PARITY_NONE; break; default: logger.error("Invalid parity ({}), ignoring fixed port settings.", parityChar); return null; } String stopbitsString = m.group(4); if (stopbitsString.equals("1")) { stopbits = SerialPort.STOPBITS_1; } else if (stopbitsString.equals("1.5")) { stopbits = SerialPort.STOPBITS_1_5; } else if (stopbitsString.equals("2")) { stopbits = SerialPort.STOPBITS_2; } else { logger.error("Invalid stop bits({}), ignoring fixed port settings.", stopbitsString); return null; } return new DSMRPortSettings(baudrate, databits, parity, stopbits); } else { return null; } }
Source:
<code>private String sendToZeppelinHubViaProxy(HttpRequestBase request, String json, String token, boolean withResponse) throws IOException { request.setHeader(ZEPPELIN_TOKEN_HEADER, token); if (request.getMethod().equals(HttpPost.METHOD_NAME)) { HttpPost post = (HttpPost) request; StringEntity content = new StringEntity(json, "application/json;charset=UTF-8"); post.setEntity(content); } if (request.getMethod().equals(HttpPut.METHOD_NAME)) { HttpPut put = (HttpPut) request; StringEntity content = new StringEntity(json, "application/json;charset=UTF-8"); put.setEntity(content); } String body = StringUtils.EMPTY; if (proxyClient != null) { body = proxyClient.sendToZeppelinHub(request, withResponse); } else { <START> LOG.error("Proxy client request was submitted while not correctly initialized"); <END> } return body; }</code><technical_language>this a warning perhaps? ignore</technical_language>

Target:
private String sendToZeppelinHubViaProxy(HttpRequestBase request, String json, String token, boolean withResponse) throws IOException { request.setHeader(ZEPPELIN_TOKEN_HEADER, token); if (request.getMethod().equals(HttpPost.METHOD_NAME)) { HttpPost post = (HttpPost) request; StringEntity content = new StringEntity(json, "application/json;charset=UTF-8"); post.setEntity(content); } if (request.getMethod().equals(HttpPut.METHOD_NAME)) { HttpPut put = (HttpPut) request; StringEntity content = new StringEntity(json, "application/json;charset=UTF-8"); put.setEntity(content); } String body = StringUtils.EMPTY; if (proxyClient != null) { body = proxyClient.sendToZeppelinHub(request, withResponse); } else { LOG.warn("Proxy client request was submitted while not correctly initialized"); } return body; }
Source:
<code>private List<DiffCommitFile> getCommitDiffFiles(RevCommit revCommit, String pattern) throws IOException { TreeWalk tw = null; List<DiffEntry> diffs = null; TreeFilter filter = null; if (pattern != null && !pattern.isEmpty()) { filter = AndTreeFilter.create(PathFilterGroup.createFromStrings(Collections.singleton(pattern)), TreeFilter.ANY_DIFF); } <START> List<DiffCommitFile> commitFilesList = new ArrayList<DiffCommitFile>(); <END> try { tw = new TreeWalk(repository); tw.setRecursive(true); if (revCommit.getParentCount() > 0) { RevCommit parent = parseCommit(revCommit.getParent(0)); tw.reset(parent.getTree(), revCommit.getTree()); if (filter != null) { tw.setFilter(filter); } else { tw.setFilter(TreeFilter.ANY_DIFF); } diffs = DiffEntry.scan(tw); } else { RevWalk rw = null; DiffFormatter diffFormat = null; try { rw = new RevWalk(repository); diffFormat = new DiffFormatter(NullOutputStream.INSTANCE); diffFormat.setRepository(repository); if (filter != null) { diffFormat.setPathFilter(filter); } diffs = diffFormat.scan(new EmptyTreeIterator(), new CanonicalTreeParser(null, rw.getObjectReader(), revCommit.getTree())); } finally { if (diffFormat != null) { diffFormat.close(); } if (rw != null) { rw.close(); } } } } finally { if (tw != null) { tw.close(); } } if (diffs != null) { commitFilesList.addAll(diffs.stream().map(diff -> newDto(DiffCommitFile.class).withOldPath(diff.getOldPath()) .withNewPath(diff.getNewPath()) .withChangeType(diff.getChangeType().name())) .collect(Collectors.toList())); } return commitFilesList; }</code><technical_language>Please change new ArrayList<DiffCommitFile>() new ArrayList<>()</technical_language>

Target:
private List<DiffCommitFile> getCommitDiffFiles(RevCommit revCommit, String pattern) throws IOException { List<DiffEntry> diffs; TreeFilter filter = null; if (!isNullOrEmpty(pattern)) { filter = AndTreeFilter.create(PathFilterGroup.createFromStrings(Collections.singleton(pattern)), TreeFilter.ANY_DIFF); } List<DiffCommitFile> commitFilesList = new ArrayList<>(); try (TreeWalk tw = new TreeWalk(repository)){ tw.setRecursive(true); if (revCommit.getParentCount() > 0) { RevCommit parent = parseCommit(revCommit.getParent(0)); tw.reset(parent.getTree(), revCommit.getTree()); if (filter != null) { tw.setFilter(filter); } else { tw.setFilter(TreeFilter.ANY_DIFF); } diffs = DiffEntry.scan(tw); } else { try (RevWalk rw = new RevWalk(repository); DiffFormatter diffFormat = new DiffFormatter(NullOutputStream.INSTANCE)) { diffFormat.setRepository(repository); if (filter != null) { diffFormat.setPathFilter(filter); } diffs = diffFormat.scan(new EmptyTreeIterator(), new CanonicalTreeParser(null, rw.getObjectReader(), revCommit.getTree())); } } } if (diffs != null) { commitFilesList.addAll(diffs.stream().map(diff -> newDto(DiffCommitFile.class).withOldPath(diff.getOldPath()) .withNewPath(diff.getNewPath()) .withChangeType(diff.getChangeType().name())) .collect(Collectors.toList())); } return commitFilesList; }
Source:
<code>public TableDefinition refresh( Connection connection, TableId tableId ) throws SQLException { TableDefinition dbTable = dialect.describeTable(connection, tableId); if (dbTable != null) { log.info("Refreshing metadata for table to {}", tableId, dbTable); cache.put(dbTable.id(), dbTable); <START> } <END> return dbTable; }</code><technical_language>log a warn in else block task failed describe table? hard follow "absence of logs" connectors typically running a large number of tables</technical_language>

Target:
public TableDefinition refresh( Connection connection, TableId tableId ) throws SQLException { TableDefinition dbTable = dialect.describeTable(connection, tableId); if (dbTable != null) { log.info("Refreshing metadata for table to {}", tableId, dbTable); cache.put(dbTable.id(), dbTable); } else { log.warn("Failed to refresh metadata for table {}", tableId); } return dbTable; }
Source:
<code>public List<String> getAcceptedEvents() { if (acceptedEvents == null) { synchronized (this) { if (acceptedEvents == null) { DirectoryService directoryService = Framework.getService(DirectoryService.class); Directory dir = directoryService.getDirectory(RetentionConstants.EVENTS_DIRECTORY_NAME); try (Session session = dir.getSession()) { Map<String, Serializable> filter = new HashMap<>(); filter.put(RetentionConstants.OBSOLETE_FIELD_ID, Long.valueOf(0)); List<String> evts = session.getProjection(filter, session.getIdField()); if (evts.isEmpty()) { log.trace("Empty accepted events, not chaching anything"); return evts; } acceptedEvents = evts; log.debug("Accepted events {}", acceptedEvents::toString); } } } <START> } <END> return acceptedEvents; }</code><technical_language>chaching -> caching i wrong :)</technical_language>

Target:
public List<String> getAcceptedEvents() { if (acceptedEvents == null) { synchronized (this) { if (acceptedEvents == null) { DirectoryService directoryService = Framework.getService(DirectoryService.class); Directory dir = directoryService.getDirectory(RetentionConstants.EVENTS_DIRECTORY_NAME); try (Session session = dir.getSession()) { Map<String, Serializable> filter = new HashMap<>(); filter.put(RetentionConstants.OBSOLETE_FIELD_ID, Long.valueOf(0)); List<String> evts = session.getProjection(filter, session.getIdField()); if (evts.isEmpty()) { log.trace("Empty accepted events, not catching anything"); return evts; } acceptedEvents = evts; log.debug("Accepted events {}", acceptedEvents::toString); } } } } return acceptedEvents; }
Source:
<code><START> private static final boolean attributeNotBinary(AttributeDescriptor attributeDescriptor) { <END> return !AttributeType.AttributeFormat.BINARY.equals( attributeDescriptor.getType().getAttributeFormat()); }</code><technical_language>methods final</technical_language>

Target:
private static boolean attributeNotBinary(AttributeDescriptor attributeDescriptor) { return !AttributeType.AttributeFormat.BINARY.equals( attributeDescriptor.getType().getAttributeFormat()); }
Source:
<code>public PersistenceConfiguration create() { <START> List<StoreConfiguration> stores = new LinkedList<StoreConfiguration>(); <END> for (StoreConfigurationBuilder<?, ?> loader : this.stores) stores.add(loader.create()); return new PersistenceConfiguration(passivation, stores); }</code><technical_language>This this before, this List<StoreConfiguration> stores = new ArrayList<StoreConfiguration>(stores.size()); instead. LinkedList removing adding tail</technical_language>

Target:
public PersistenceConfiguration create() { List<StoreConfiguration> stores = new ArrayList<StoreConfiguration>(this.stores.size()); for (StoreConfigurationBuilder<?, ?> loader : this.stores) stores.add(loader.create()); return new PersistenceConfiguration(passivation, stores); }
Source:
<code>public TimeBoundary getTimeBoundaryForTable(String table) { try { String responseBody = sendHttpGetToBroker(table, String.format(TIME_BOUNDARY_API_TEMPLATE, table)); return timeBoundaryJsonCodec.fromJson(responseBody); } catch (Exception e) { if ((e instanceof PinotException)) { <START> String[] errMsgSplits = e.getMessage().split(" "); <END> if (errMsgSplits.length >= 4 && errMsgSplits[3].equalsIgnoreCase(TIME_BOUNDARY_NOT_FOUND_ERROR_CODE)) { return timeBoundaryJsonCodec.fromJson("{}"); } } throw e; } }</code><technical_language>s/errMsgSplits/errorMessageSplits/g minor thing, Presto abbreviation in variable name</technical_language>

Target:
public TimeBoundary getTimeBoundaryForTable(String table) { try { String responseBody = sendHttpGetToBroker(table, String.format(TIME_BOUNDARY_API_TEMPLATE, table)); return timeBoundaryJsonCodec.fromJson(responseBody); } catch (Exception e) { if ((e instanceof PinotException)) { String[] errorMessageSplits = e.getMessage().split(" "); if (errorMessageSplits.length >= 4 && errorMessageSplits[3].equalsIgnoreCase(TIME_BOUNDARY_NOT_FOUND_ERROR_CODE)) { return timeBoundaryJsonCodec.fromJson("{}"); } } throw e; } }
Source:
<code>public void updateHash(String newHash) { if (processed) { this.oldHash = this.hash; this.hash = newHash; if (!StringUtils.equals(this.oldHash, this.hash)) { processed = false; } } else { <START> this.hash = newHash; <END> } }</code><technical_language>I if processed flag set true if this.hash == this.oldHash</technical_language>

Target:
public void updateHash(String newHash) { if (processed) { this.oldHash = this.hash; this.hash = newHash; if (!StringUtils.equals(this.oldHash, this.hash)) { processed = false; } } else { this.hash = newHash; if (StringUtils.equals(this.oldHash, this.hash)) { processed = true; } } }
Source:
<code>@Override public int selectString(Options options) throws IOException { Object peeked = (stackSize != 0 ? stack[stackSize - 1] : null); String peekedString; <START> if ((peeked instanceof String)) { <END> peekedString = (String) peeked; } else { if (peeked == JSON_READER_CLOSED) { throw new IllegalStateException("JsonReader is closed"); } return -1; } for (int i = 0, length = options.strings.length; i < length; i++) { if (options.strings[i].equals(peekedString)) { remove(); return i; } } return -1; }</code><technical_language>or, if invert this if, if (!(peeked instance of String)) { ... } avoid separate declaration & assignment for peekedString</technical_language>

Target:
@Override public int selectString(Options options) throws IOException { Object peeked = (stackSize != 0 ? stack[stackSize - 1] : null); if (!(peeked instanceof String)) { if (peeked == JSON_READER_CLOSED) { throw new IllegalStateException("JsonReader is closed"); } return -1; } String peekedString = (String) peeked; for (int i = 0, length = options.strings.length; i < length; i++) { if (options.strings[i].equals(peekedString)) { remove(); return i; } } return -1; }
Source:
<code>protected void initPreferences() { configureSharingAndMoreButtonsPreferences(); mLabelPreference = (SummaryEditTextPreference) findPreference(getString(R.string.publicize_label)); <START> mButtonStylePreference = (DetailListPreference) findPreference(getString(R.string.publicize_button_style)); <END> setDetailListPreferenceValue(mButtonStylePreference, mSiteSettings.getSharingButtonStyle(getActivity()), mSiteSettings.getSharingButtonStyleDisplayText(getActivity())); mButtonStylePreference.setEntries(getResources().getStringArray(R.array.sharing_button_style_display_array)); mButtonStylePreference.setEntryValues(getResources().getStringArray(R.array.sharing_button_style_array)); mReblogButtonPreference = (WPSwitchPreference) findPreference(getString(R.string.pref_key_reblog)); mLikeButtonPreference = (WPSwitchPreference) findPreference(getString(R.string.pref_key_like)); mCommentLikesPreference = (WPSwitchPreference) findPreference(getString(R.string.pref_key_comment_likes)); mTwitterUsernamePreference = (SummaryEditTextPreference) findPreference(getString(R.string.pref_key_twitter_username)); mTwitterPreferenceCategory = (PreferenceCategory) findPreference(getString(R.string.pref_key_twitter_category)); }</code><technical_language>Thanks for this clean</technical_language>

Target:
public void initPreferences() { configureSharingAndMoreButtonsPreferences(); mLabelPreference = (SummaryEditTextPreference) findPreference(getString(R.string.publicize_label)); mButtonStylePreference = (DetailListPreference) findPreference(getString(R.string.publicize_button_style)); setDetailListPreferenceValue(mButtonStylePreference, mSiteSettings.getSharingButtonStyle(getActivity()), mSiteSettings.getSharingButtonStyleDisplayText(getActivity())); mButtonStylePreference.setEntries(getResources().getStringArray(R.array.sharing_button_style_display_array)); mButtonStylePreference.setEntryValues(getResources().getStringArray(R.array.sharing_button_style_array)); mReblogButtonPreference = (WPSwitchPreference) findPreference(getString(R.string.pref_key_reblog)); mLikeButtonPreference = (WPSwitchPreference) findPreference(getString(R.string.pref_key_like)); mCommentLikesPreference = (WPSwitchPreference) findPreference(getString(R.string.pref_key_comment_likes)); mTwitterUsernamePreference = (SummaryEditTextPreference) findPreference(getString(R.string.pref_key_twitter_username)); mTwitterPreferenceCategory = (PreferenceCategory) findPreference(getString(R.string.pref_key_twitter_category)); }
Source:
<code>public static void addHyperLink(XWPFParagraph paragraph, String hyperlinkAnchor, String hyperlinkText) { CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); <START> cLink.setAnchor(hyperlinkAnchor.replaceAll(" ", "_")); <END> CTText ctText = CTText.Factory.newInstance(); ctText.setStringValue(hyperlinkText); CTR ctr = CTR.Factory.newInstance(); ctr.setTArray(new CTText[]{ctText}); cLink.setRArray(new CTR[]{ctr}); }</code><technical_language>Is able handle whitespace, e.g. tabs, non-breaking-whitespace newlines</technical_language>

Target:
public static void addHyperLink(XWPFParagraph paragraph, String hyperlinkAnchor, String hyperlinkText) { CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); cLink.setAnchor(hyperlinkAnchor); CTText ctText = CTText.Factory.newInstance(); ctText.setStringValue(hyperlinkText); CTR ctr = CTR.Factory.newInstance(); ctr.setTArray(new CTText[]{ctText}); CTRPr rpr = ctr.addNewRPr(); CTColor colour = CTColor.Factory.newInstance(); colour.setVal("0000FF"); rpr.setColor(colour); CTRPr rpr1 = ctr.addNewRPr(); rpr1.addNewU().setVal(STUnderline.SINGLE); cLink.setRArray(new CTR[]{ctr}); }
Source:
<code>public void testMultiSitePartitionedRead() throws IOException { long txnId = 1234l; int batch_size = 3; Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage( 0, -1, (txnId -1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false); int hsids = 6; buddyHSId = 0; long[] non_local = configureHSIds(hsids); MpTestPlan plan = createTestPlan(batch_size, true, false, false, non_local); Mailbox mailbox = mock(Mailbox.class); SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class); MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false); dut.setupProcedureResume(true, plan.depsToResume); dut.createLocalFragmentWork(plan.localWork, false); dut.createAllParticipatingFragmentWork(plan.remoteWork); <START> non_local = configureHSIdsForMailbox(hsids, buddyHSId); <END> verify(mailbox).send(eq(non_local), (VoltMessage)any()); verify(mailbox).send(eq(new long[] {buddyHSId}), (VoltMessage)any()); for (FragmentResponseMessage msg : plan.generatedResponses) { dut.offerReceivedFragmentResponse(msg); } Map<Integer, List<VoltTable>> results = dut.recursableRun(siteConnection); verify(mailbox).send(eq(buddyHSId), (BorrowTaskMessage)any()); assertEquals(batch_size, results.size()); System.out.println(results); }</code><technical_language>Curious needed this change</technical_language>

Target:
public void testMultiSitePartitionedRead() throws IOException { long txnId = 1234l; int batch_size = 3; Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage( 0, -1, (txnId -1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false); int hsids = 6; buddyHSId = 0; long[] non_local = configureHSIds(hsids); MpTestPlan plan = createTestPlan(batch_size, true, false, false, non_local); Mailbox mailbox = mock(Mailbox.class); SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class); MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false); dut.setupProcedureResume(true, plan.depsToResume); dut.createLocalFragmentWork(plan.localWork, false); dut.createAllParticipatingFragmentWork(plan.remoteWork); verify(mailbox).send(eq(non_local), (VoltMessage)any()); for (FragmentResponseMessage msg : plan.generatedResponses) { dut.offerReceivedFragmentResponse(msg); } Map<Integer, List<VoltTable>> results = dut.recursableRun(siteConnection); verify(mailbox).send(eq(buddyHSId), (BorrowTaskMessage)any()); assertEquals(batch_size, results.size()); System.out.println(results); }
Source:
<code>protected boolean processEntry(CanonicalTreeParser base, CanonicalTreeParser ours, CanonicalTreeParser theirs, DirCacheBuildIterator index, WorkingTreeIterator work, boolean ignoreConflicts) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { return processEntry(base, ours, theirs, index, work, ignoreConflicts, <START> null); <END> }</code><technical_language>pass empty Attributes set in order avoid this parameter needs @Nullable</technical_language>

Target:
protected boolean processEntry(CanonicalTreeParser base, CanonicalTreeParser ours, CanonicalTreeParser theirs, DirCacheBuildIterator index, WorkingTreeIterator work, boolean ignoreConflicts) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { return processEntry(base, ours, theirs, index, work, ignoreConflicts, new Attributes()); }
Source:
<code>public void testIsResourcesFolderContainsCorrectNumberOfJsonFiles() { List<File> jsonFiles = findFilesByFileFilter(getEndWithFileFilter(JSON_FILE_EXTENSION)); <START> Assert.assertEquals(10, jsonFiles.size()); <END> }</code><technical_language>10 is a nontrivial constant need change if current resource design change. a private static member</technical_language>

Target:
public void testIsResourcesFolderContainsCorrectNumberOfJsonFiles() { List<File> jsonFiles = findFilesByFileFilter(getEndWithFileFilter(JSON_FILE_EXTENSION)); Assert.assertEquals(JSON_FILES_NUMBER, jsonFiles.size()); }
Source:
<code>public static int getEstimatedWorkerCountForRASTopo(Map<String, Object> topoConf, StormTopology topology) throws InvalidTopologyException { Double defaultWorkerMaxHeap = ObjectReader.getDouble(topoConf.get(Config.WORKER_HEAP_MEMORY_MB)); <START> Double topologyWorkerMaxHeap = ObjectReader.getDouble(topoConf.get(Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB)); <END> Double maxHeapSize = topologyWorkerMaxHeap != null && topologyWorkerMaxHeap != 0 ? topologyWorkerMaxHeap : defaultWorkerMaxHeap; return (int) Math.ceil(getEstimatedTotalHeapMemoryRequiredByTopo(topoConf, topology) / maxHeapSize); }</code><technical_language>topoConf.get(Config.WORKER_HEAP_MEMORY_MB) null? If so, this throw exception IllegalArgumentException("Don't convert null double");</technical_language>

Target:
public static int getEstimatedWorkerCountForRASTopo(Map<String, Object> topoConf, StormTopology topology) throws InvalidTopologyException { Double defaultWorkerMaxHeap = ObjectReader.getDouble(topoConf.get(Config.WORKER_HEAP_MEMORY_MB), 768d); Double topologyWorkerMaxHeap = ObjectReader.getDouble(topoConf.get(Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB), defaultWorkerMaxHeap); return (int) Math.ceil(getEstimatedTotalHeapMemoryRequiredByTopo(topoConf, topology) / topologyWorkerMaxHeap); }
Source:
<code>public void run() { log.startedClouderaManagerConfigMonitor(interval); isActive = true; while (isActive) { try { final List<String> clustersToStopMonitoring = new ArrayList<>(); for (Map.Entry<String, List<String>> entry : configCache.getClusterNames().entrySet()) { String address = entry.getKey(); for (String clusterName : entry.getValue()) { log.checkingClusterConfiguration(clusterName, address); if (!clusterReferencesExist(address, clusterName)) { clustersToStopMonitoring.add(address + FQCN_DELIM + clusterName); continue; } final List<StartEvent> relevantEvents = getRelevantEvents(address, clusterName); if (!relevantEvents.isEmpty()) { if (hasConfigChanged(address, clusterName, relevantEvents)) { notifyChangeListener(address, clusterName); } } } } for (String fqcn : clustersToStopMonitoring) { String[] parts = fqcn.split(FQCN_DELIM); stopMonitoring(parts[0], parts[1]); } clustersToStopMonitoring.clear(); waitFor(interval); <START> } catch (Throwable t) { <END> log.clouderaManagerConfigurationChangesMonitoringError(t); } } log.stoppedClouderaManagerConfigMonitor(); }</code><technical_language>Exception? This catch runtime exceptions? overly broad</technical_language>

Target:
public void run() { log.startedClouderaManagerConfigMonitor(interval); isActive = true; while (isActive) { try { final List<String> clustersToStopMonitoring = new ArrayList<>(); for (Map.Entry<String, List<String>> entry : configCache.getClusterNames().entrySet()) { String address = entry.getKey(); for (String clusterName : entry.getValue()) { log.checkingClusterConfiguration(clusterName, address); if (!clusterReferencesExist(address, clusterName)) { clustersToStopMonitoring.add(address + FQCN_DELIM + clusterName); continue; } final List<StartEvent> relevantEvents = getRelevantEvents(address, clusterName); if (!relevantEvents.isEmpty()) { if (hasConfigChanged(address, clusterName, relevantEvents)) { notifyChangeListener(address, clusterName); } } } } for (String fqcn : clustersToStopMonitoring) { String[] parts = fqcn.split(FQCN_DELIM); stopMonitoring(parts[0], parts[1]); } clustersToStopMonitoring.clear(); waitFor(interval); } catch (Exception e) { log.clouderaManagerConfigurationChangesMonitoringError(e); } } log.stoppedClouderaManagerConfigMonitor(); }
Source:
<code>@DataBoundSetter public void setExcludes(String excludes) { <START> this.excludes = excludes; <END> }</code><technical_language>Util.fixEmpty. a mismatch "" saved GUI form null returned a default instance. This result in a gratuitous groovy excludes: '' added in **Snippet Generator** for Pipeline. For freestyle projects, result in a gratuitous xml <excludes></excludes></technical_language>

Target:
@DataBoundSetter public void setExcludes(String excludes) { this.excludes = Util.fixEmpty(excludes); }
Source:
<code>public Optional<PlanNodeStatsEstimate> calculate(UnnestNode node, StatsProvider statsProvider, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate sourceStats = statsProvider.getStats(node.getSource()); PlanNodeStatsEstimate.Builder calculatedStats = PlanNodeStatsEstimate.builder(); if (sourceStats.getOutputRowCount() <= UPPER_BOUND_ROW_COUNT_FOR_ESTIMATION) { calculatedStats.setOutputRowCount(sourceStats.getOutputRowCount()); } else { calculatedStats.setOutputRowCount(NaN); } for (Symbol symbol : node.getReplicateSymbols()) { calculatedStats.addSymbolStatistics(symbol, sourceStats.getSymbolStatistics(symbol)); } for (Map.Entry<Symbol, List<Symbol>> entry : node.getUnnestSymbols().entrySet()) { List<Symbol> unnestToSymbols = entry.getValue(); SymbolStatsEstimate stats = sourceStats.getSymbolStatistics(entry.getKey()); for (Symbol symbol : unnestToSymbols) { calculatedStats.addSymbolStatistics( symbol, SymbolStatsEstimate.builder() .setNullsFraction(stats.getNullsFraction()) .setAverageRowSize(stats.getAverageRowSize()) <START> .setDistinctValuesCount(stats.getDistinctValuesCount()) <END> .build()); } } if (node.getOrdinalitySymbol().isPresent()) { calculatedStats.addSymbolStatistics( node.getOrdinalitySymbol().get(), SymbolStatsEstimate.builder() .setAverageRowSize(8) .setLowValue(0) .setNullsFraction(0) .build()); } return Optional.of(calculatedStats.build()); }</code><technical_language>In fact more distinct values in input column. Consider column values ARRAY[1,2,3] ARRAY[4,5,6]. 2 distinct arrays, un-nested 6 distinct values</technical_language>

Target:
public Optional<PlanNodeStatsEstimate> calculate(UnnestNode node, StatsProvider statsProvider, Lookup lookup, Session session, TypeProvider types) { PlanNodeStatsEstimate sourceStats = statsProvider.getStats(node.getSource()); PlanNodeStatsEstimate.Builder calculatedStats = PlanNodeStatsEstimate.builder(); if (sourceStats.getOutputRowCount() > UPPER_BOUND_ROW_COUNT_FOR_ESTIMATION) { return Optional.empty(); } calculatedStats.setOutputRowCount(sourceStats.getOutputRowCount()); for (Symbol symbol : node.getReplicateSymbols()) { calculatedStats.addSymbolStatistics(symbol, sourceStats.getSymbolStatistics(symbol)); } for (Map.Entry<Symbol, List<Symbol>> entry : node.getUnnestSymbols().entrySet()) { List<Symbol> unnestToSymbols = entry.getValue(); SymbolStatsEstimate stats = sourceStats.getSymbolStatistics(entry.getKey()); for (Symbol symbol : unnestToSymbols) { calculatedStats.addSymbolStatistics( symbol, SymbolStatsEstimate.builder() .setAverageRowSize(stats.getAverageRowSize()) .build()); } } if (node.getOrdinalitySymbol().isPresent()) { calculatedStats.addSymbolStatistics( node.getOrdinalitySymbol().get(), SymbolStatsEstimate.builder() .setLowValue(0) .setNullsFraction(0) .build()); } return Optional.of(calculatedStats.build()); }
Source:
<code>private <C extends org.atlasapi.content.Content> C setContentFields(C c, Content input) { c.setYear(input.getYear()); c.setLanguages(input.getLanguages()); c.setTags(translateTopicRefs(input.getTopicRefs())); c.setGenericDescription(input.getGenericDescription()); c.setEventRefs(translateEventRefs(input.events())); c.setCertificates(Iterables.transform( input.getCertificates(), new Function<Certificate, org.atlasapi.content.Certificate>() { @Override public org.atlasapi.content.Certificate apply(Certificate input) { return new org.atlasapi.content.Certificate( input.classification(), input.country() ); } } )); c.setClips( Optional.ofNullable(input.getClips()).orElse(ImmutableList.of()).stream().map( legacyClip -> { org.atlasapi.content.Clip newClip = new org.atlasapi.content.Clip( legacyClip.getCanonicalUri(), legacyClip.getCanonicalUri(), legacyClip.getPublisher() ); newClip.setClipOf(legacyClip.getClipOf()); return newClip; } ).collect(Collectors.toList()) ); c.setPeople( input.people().stream() .map(legacyCrewMemberTransformer::apply) <START> .filter(java.util.Objects::isNull) <END> .collect(Collectors.toList()) ); transformEncodings(c, input.getVersions()); return c; }</code><technical_language>guess want exact of this, this'll get a list of nulls</technical_language>

Target:
private <C extends org.atlasapi.content.Content> C setContentFields(C c, Content input) { c.setYear(input.getYear()); c.setLanguages(input.getLanguages()); c.setTags(translateTopicRefs(input.getTopicRefs())); c.setGenericDescription(input.getGenericDescription()); c.setEventRefs(translateEventRefs(input.events())); c.setCertificates(Iterables.transform( input.getCertificates(), new Function<Certificate, org.atlasapi.content.Certificate>() { @Override public org.atlasapi.content.Certificate apply(Certificate input) { return new org.atlasapi.content.Certificate( input.classification(), input.country() ); } } )); c.setClips( Optional.ofNullable(input.getClips()).orElse(ImmutableList.of()).stream().map( legacyClip -> { org.atlasapi.content.Clip newClip = new org.atlasapi.content.Clip( legacyClip.getCanonicalUri(), legacyClip.getCanonicalUri(), legacyClip.getPublisher() ); newClip.setClipOf(legacyClip.getClipOf()); return newClip; } ).collect(Collectors.toList()) ); c.setPeople( input.people().stream() .map(legacyCrewMemberTransformer::apply) .filter(java.util.Objects::nonNull) .collect(Collectors.toList()) ); transformEncodings(c, input.getVersions()); return c; }
Source:
<code>public void testAsFastqRecord() throws Exception { final SAMRecord record = new SAMRecordSetBuilder().addFrag("test", 0, 1, false, false, "10M", null, 2); record.setReadPairedFlag(true); record.setFirstOfPairFlag(true); testRecord(record.getReadName() + FastqConstants.FIRST_OF_PAIR, FastqEncoder.asFastqRecord(record), record); record.setFirstOfPairFlag(false); record.setSecondOfPairFlag(true); testRecord(record.getReadName() + FastqConstants.SECOND_OF_PAIR, FastqEncoder.asFastqRecord(record), record); record.setSecondOfPairFlag(false); testRecord(record.getReadName(), FastqEncoder.asFastqRecord(record), record); <START> record.setAttribute("CO", "Comment in SAM tag"); <END> testRecord(record.getReadName(), FastqEncoder.asFastqRecord(record), record); }</code><technical_language>SAMTag.CO.name()</technical_language>

Target:
public void testAsFastqRecord() throws Exception { final SAMRecord record = new SAMRecordSetBuilder().addFrag("test", 0, 1, false, false, "10M", null, 2); record.setReadPairedFlag(true); record.setFirstOfPairFlag(true); testRecord(record.getReadName() + FastqConstants.FIRST_OF_PAIR, FastqEncoder.asFastqRecord(record), record); record.setFirstOfPairFlag(false); record.setSecondOfPairFlag(true); testRecord(record.getReadName() + FastqConstants.SECOND_OF_PAIR, FastqEncoder.asFastqRecord(record), record); record.setSecondOfPairFlag(false); testRecord(record.getReadName(), FastqEncoder.asFastqRecord(record), record); record.setAttribute(SAMTag.CO.name(), "Comment in SAM tag"); testRecord(record.getReadName(), FastqEncoder.asFastqRecord(record), record); }
Source:
<code>private String readContent(HttpResponse response) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); } catch (IOException e) { e.printStackTrace(); } <START> return reader.lines().collect(Collectors.joining()); <END> }</code><technical_language>This fail null pointer exception, hide errors reading response, log 2 errors for issue (e..g print stack trace reading fails, return empty string fail parsing json). Lets this code raise IOException handle in caller - wrap calls in try/catch block</technical_language>

Target:
private String readContent(HttpResponse response) throws IOException { BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); return reader.lines().collect(Collectors.joining()); }
Source:
<code>private boolean endResponse(LastHttpContent trailer) { synchronized (conn) { HttpClientRequestImpl req = request; if (conn.metrics != null) { Object reqMetric = req.metric(); if (req.exceptionOccurred != null) { conn.metrics.requestReset(reqMetric); } else { conn.metrics.responseEnd(reqMetric, response); } } VertxTracer tracer = context.tracer(); if (tracer != null) { <START> List<Map.Entry<String, String>> tags = Collections.singletonList(new AbstractMap.SimpleEntry<>("http.status_code", "" + response.statusCode())); <END> tracer.receiveResponse(context, response, trace, null, tags); } trailers = new HeadersAdaptor(trailer.trailingHeaders()); if (queue.isEmpty() && !queue.isPaused()) { response.handleEnd(trailers); } responseEnded = true; conn.close |= !conn.options.isKeepAlive(); conn.doResume(); return requestEnded; } }</code><technical_language>similarly here, data policy, allocating objects used. tracer decide do instead (certainly brave would)</technical_language>

Target:
private boolean endResponse(LastHttpContent trailer) { synchronized (conn) { HttpClientRequestImpl req = request; if (conn.metrics != null) { Object reqMetric = req.metric(); if (req.exceptionOccurred != null) { conn.metrics.requestReset(reqMetric); } else { conn.metrics.responseEnd(reqMetric, response); } } VertxTracer tracer = context.tracer(); if (tracer != null) { tracer.receiveResponse(context, response, trace, null, HttpUtils.CLIENT_RESPONSE_TAG_EXTRACTOR); } trailers = new HeadersAdaptor(trailer.trailingHeaders()); if (queue.isEmpty() && !queue.isPaused()) { response.handleEnd(trailers); } responseEnded = true; conn.close |= !conn.options.isKeepAlive(); conn.doResume(); return requestEnded; } }
Source:
<code>private <K, V> void forward(final ProcessorNode<K, V> child, final K key, final V value) { setCurrentNode(child); child.process(key, value); <START> if (child.children().isEmpty()) { <END> streamTask.maybeRecordE2ELatency(timestamp(), child.name()); } }</code><technical_language>prop: For sake of readability, extract this check a method named isTerminalNode()? add a method named isTerminalNode() ProcessorNode in ProcessorTopology</technical_language>

Target:
private <K, V> void forward(final ProcessorNode<K, V> child, final K key, final V value) { setCurrentNode(child); child.process(key, value); if (child.isTerminalNode()) { streamTask.maybeRecordE2ELatency(timestamp(), child.name()); } }
Source:
<code>public ASTNode visit(Configuration node, Void _) { Cell cell = new Cell(); cell.setLabel(MetaK.Constants.pathCondition); cell.setEllipses(Ellipses.NONE); if (PC) { <START> Variable pc = new Variable(PC_VAR, Sort.of("Bool")); <END> cell.setContents(pc); context.configVarSorts.put(pc.getName(), pc.getSort()); } else cell.setContents(BoolBuiltin.TRUE); Term body = node.getBody(); if (body instanceof Cell) { Cell topCell = (Cell) body; if (topCell.getLabel() .equals(MetaK.Constants.generatedTopCellLabel)) { node = node.shallowCopy(); node.setBody(addSubcellToCell(topCell, cell)); return node; } } return node; }</code><technical_language>is a Sort.BOOL</technical_language>

Target:
public ASTNode visit(Configuration node, Void _) { Cell cell = new Cell(); cell.setLabel(MetaK.Constants.pathCondition); cell.setEllipses(Ellipses.NONE); if (PC) { Variable pc = new Variable(PC_VAR, Sort.BOOL); cell.setContents(pc); context.configVarSorts.put(pc.getName(), pc.getSort()); } else cell.setContents(BoolBuiltin.TRUE); Term body = node.getBody(); if (body instanceof Cell) { Cell topCell = (Cell) body; if (topCell.getLabel() .equals(MetaK.Constants.generatedTopCellLabel)) { node = node.shallowCopy(); node.setBody(addSubcellToCell(topCell, cell)); return node; } } return node; }
Source:
<code>public static JSONObject expandKeysInPlace (JSONObject base) throws JSONException { for (String key: JSONObject.getNames(base)) { Object value = base.get(key); <START> if (value == null) { <END> System.out.println("Key: " + key + "Base: " + base); } if (value instanceof JSONObject) expandKeysInPlace((JSONObject) value); if (value instanceof JSONArray) expandKeysInPlace((JSONArray) value); String[] subKeys = key.split("\\."); if (subKeys.length > 1) { base.remove(key); JSONObject target = base; for (int i=0; i<subKeys.length-1; ++i) { if (!target.has(subKeys[i])) target.put(subKeys[i], new JSONObject()); if (!(target.get(subKeys[i]) instanceof JSONObject)) throw new JSONException("Impossible to expand keys - location "+subKeys[i]+" already exists, and is not an object."); target = target.getJSONObject(subKeys[i]); } target.put(subKeys[subKeys.length-1], value); } } return base; }</code><technical_language>This a temporary debugging statement - leave in</technical_language>

Target:
public static JSONObject expandKeysInPlace (JSONObject base) throws JSONException { for (String key: JSONObject.getNames(base)) { Object value = base.get(key); if (value instanceof JSONObject) expandKeysInPlace((JSONObject) value); if (value instanceof JSONArray) expandKeysInPlace((JSONArray) value); String[] subKeys = key.split("\\."); if (subKeys.length > 1) { base.remove(key); JSONObject target = base; for (int i=0; i<subKeys.length-1; ++i) { if (!target.has(subKeys[i])) target.put(subKeys[i], new JSONObject()); if (!(target.get(subKeys[i]) instanceof JSONObject)) throw new JSONException("Impossible to expand keys - location "+subKeys[i]+" already exists, and is not an object."); target = target.getJSONObject(subKeys[i]); } target.put(subKeys[subKeys.length-1], value); } } return base; }
Source:
<code>private AuditLogable createAuditLogable(AnsibleCommandConfig command, String taskName) { return AuditLogableImpl.createHostEvent( command.hosts().get(0), command.correlationId(), <START> new HashMap<>() { { put("Message", taskName); put("PlayAction", command.playAction()); } } <END> ); }</code><technical_language>I safe java > 9 Map.of("key1","value1", "key2", "value2");</technical_language>

Target:
private AuditLogable createAuditLogable(AnsibleCommandConfig command, String taskName) { return AuditLogableImpl.createHostEvent( command.hosts().get(0), command.correlationId(), Map.of("Message", taskName, "PlayAction", command.playAction()) ); }