auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected Node loadXMLNode() { try { File XMLFile = fFilePath.toFile(); if (XMLFile == null || !XMLFile.exists() || !XMLFile.isFile()) { return null; } DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(XMLFile); doc.getDocumentElement().normalize(); NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER); Element stateproviderNode = null; for (int i = 0; i < stateproviderNodes.getLength(); i++) { Element node = (Element) stateproviderNodes.item(i); String analysisid = node.getAttribute(TmfXmlStrings.ANALYSIS_ID); if (analysisid.equals(fStateId)) { stateproviderNode = node; } } return stateproviderNode; <START> } catch (ParserConfigurationException e) { <END> Activator.logError("Error loading XML file", e); } catch (SAXException e) { Activator.logError(NLS.bind(Messages.XmlUtils_XmlValidationError, e.getLocalizedMessage()), e); } catch (IOException e) { Activator.logError("Error loading XML file", e); } return null; }</code><technical_language>put IOException line handle same, reduces visual bloat. } catch (ParserConfigurationException | IOException e) {</technical_language>

Target:
protected Node loadXMLNode() { try { File XMLFile = fFilePath.toFile(); if (XMLFile == null || !XMLFile.exists() || !XMLFile.isFile()) { return null; } DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(XMLFile); doc.getDocumentElement().normalize(); NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER); Element stateproviderNode = null; for (int i = 0; i < stateproviderNodes.getLength(); i++) { Element node = (Element) stateproviderNodes.item(i); String analysisid = node.getAttribute(TmfXmlStrings.ANALYSIS_ID); if (analysisid.equals(fStateId)) { stateproviderNode = node; } } return stateproviderNode; } catch (ParserConfigurationException | IOException e) { Activator.logError("Error loading XML file", e); } catch (SAXException e) { Activator.logError(NLS.bind(Messages.XmlUtils_XmlValidationError, e.getLocalizedMessage()), e); } return null; }
Source:
<code>public static void escapeJson(final StringBuilder toAppendTo, final int start) { int escapeCount = 0; for (int i = start; i < toAppendTo.length(); i++) { final char c = toAppendTo.charAt(i); switch (c) { case '\b': case '\t': case '\f': case '\n': case '\r': case '"': case '\\': escapeCount++; break; default: if (Character.isISOControl(c)) { escapeCount += 5; } } } int lastChar = toAppendTo.length() - 1; toAppendTo.setLength(toAppendTo.length() + escapeCount); int lastPos = toAppendTo.length() - 1; <START> for (int i = lastChar; i >= start; i--) { <END> final char c = toAppendTo.charAt(i); switch (c) { case '\b': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'b'); break; case '\t': lastPos = escapeAndDecrement(toAppendTo, lastPos, 't'); break; case '\f': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'f'); break; case '\n': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'n'); break; case '\r': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'r'); break; case '"': lastPos = escapeAndDecrement(toAppendTo, lastPos, '"'); break; case '\\': lastPos = escapeAndDecrement(toAppendTo, lastPos, '\\'); break; default: if (Character.isISOControl(c)) { toAppendTo.setCharAt(lastPos - 5, '\\'); toAppendTo.setCharAt(lastPos - 4, 'u'); toAppendTo.setCharAt(lastPos - 3, '0'); toAppendTo.setCharAt(lastPos - 2, '0'); toAppendTo.setCharAt(lastPos - 1, Chars.getUpperCaseHex((c & 0xF0) >> 4)); toAppendTo.setCharAt(lastPos, Chars.getUpperCaseHex(c & 0xF)); lastPos -= 6; } else { toAppendTo.setCharAt(lastPos, c); lastPos--; } } } }</code><technical_language>I change condition i >= start lastPos > i. fast path escape, this loop a no-op. This allows stop iterating escaped unescaped character</technical_language>

Target:
public static void escapeJson(final StringBuilder toAppendTo, final int start) { int escapeCount = 0; for (int i = start; i < toAppendTo.length(); i++) { final char c = toAppendTo.charAt(i); switch (c) { case '\b': case '\t': case '\f': case '\n': case '\r': case '"': case '\\': escapeCount++; break; default: if (Character.isISOControl(c)) { escapeCount += 5; } } } int lastChar = toAppendTo.length() - 1; toAppendTo.setLength(toAppendTo.length() + escapeCount); int lastPos = toAppendTo.length() - 1; for (int i = lastChar; lastPos > i; i--) { final char c = toAppendTo.charAt(i); switch (c) { case '\b': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'b'); break; case '\t': lastPos = escapeAndDecrement(toAppendTo, lastPos, 't'); break; case '\f': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'f'); break; case '\n': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'n'); break; case '\r': lastPos = escapeAndDecrement(toAppendTo, lastPos, 'r'); break; case '"': case '\\': lastPos = escapeAndDecrement(toAppendTo, lastPos, c); break; default: if (Character.isISOControl(c)) { toAppendTo.setCharAt(lastPos--, Chars.getUpperCaseHex(c & 0xF)); toAppendTo.setCharAt(lastPos--, Chars.getUpperCaseHex((c & 0xF0) >> 4)); toAppendTo.setCharAt(lastPos--, '0'); toAppendTo.setCharAt(lastPos--, '0'); toAppendTo.setCharAt(lastPos--, 'u'); toAppendTo.setCharAt(lastPos--, '\\'); } else { toAppendTo.setCharAt(lastPos, c); lastPos--; } } } }
Source:
<code>private void assertMutatesEquivalent(List<Mutation> mutations, InMemoryMap imm1, InMemoryMap imm2) { int mutationKVPairs = countKVPairs(mutations); List<MemKey> memKeys1 = getArrayOfMemKeys(imm1); List<MemKey> memKeys2 = getArrayOfMemKeys(imm2); assertEquals("Not all key value pairs included: " + dumpInMemoryMap(imm1, memKeys1), mutationKVPairs, memKeys1.size()); assertEquals("Not all key value pairs included: " + dumpInMemoryMap(imm2, memKeys2), mutationKVPairs, memKeys2.size()); <START> assertEquals("InMemoryMaps differ in size: " + dumpInMemoryMap(imm1, memKeys1) + "\n" + dumpInMemoryMap(imm2, memKeys2), memKeys1.size(), memKeys2.size()); <END> assertEquals("InMemoryMap did not have distinct kvCounts " + dumpInMemoryMap(imm1, memKeys1), mutationKVPairs, getUniqKVCount(memKeys1).size()); assertEquals("InMemoryMap did not have distinct kvCounts " + dumpInMemoryMap(imm2, memKeys2), mutationKVPairs, getUniqKVCount(memKeys2).size()); }</code><technical_language>this check true if true</technical_language>

Target:
private void assertMutatesEquivalent(List<Mutation> mutations, InMemoryMap imm1, InMemoryMap imm2) { int mutationKVPairs = countKVPairs(mutations); List<MemKey> memKeys1 = getArrayOfMemKeys(imm1); List<MemKey> memKeys2 = getArrayOfMemKeys(imm2); assertEquals("Not all key value pairs included: " + dumpInMemoryMap(imm1, memKeys1), mutationKVPairs, memKeys1.size()); assertEquals("InMemoryMaps differ in size: " + dumpInMemoryMap(imm1, memKeys1) + "\n" + dumpInMemoryMap(imm2, memKeys2), memKeys1.size(), memKeys2.size()); assertEquals("InMemoryMap did not have distinct kvCounts " + dumpInMemoryMap(imm1, memKeys1), mutationKVPairs, getUniqKVCount(memKeys1)); assertEquals("InMemoryMap did not have distinct kvCounts " + dumpInMemoryMap(imm2, memKeys2), mutationKVPairs, getUniqKVCount(memKeys2)); }
Source:
<code>public Map<String, String> getOrcSchemaMapping() { <START> String prefix = "secor.orc.schema.mapfile.topic"; <END> return getKeyValueFromPrefix(prefix); }</code><technical_language>lines combined one</technical_language>

Target:
public Map<String, String> getOrcSchemaMapping() { return getKeyValueFromPrefix("secor.orc.schema.mapfile.topic"); }
Source:
<code>public void cleanup() { logger.debug("EventHubBolt cleanup"); try { ehClient.close().whenCompleteAsync((voidargs, error) -> { try { if (error != null) { <START> logger.error("Exception during EventHubBolt cleanup phase" + error.toString()); <END> } if (sender != null) { sender.closeSync(); } } catch (Exception e) { logger.error("Exception during EventHubBolt cleanup phase" + e.toString()); } }).get(); executorService.shutdown(); } catch (InterruptedException | ExecutionException e) { logger.error("Exception occured during cleanup phase" + e.toString()); } finally { sender = null; ehClient = null; } }</code><technical_language>Consider logging exception toString lose stack trace, i.e. logger.error("Some message", error). This a problem in a places</technical_language>

Target:
public void cleanup() { logger.debug("EventHubBolt cleanup"); if (sender != null) { try { sender.closeSync(); } catch (EventHubException e) { logger.error("Exception occurred while cleaning up sender" + e.toString()); } finally { sender = null; } } if (ehClient != null) { try { ehClient.closeSync(); } catch (EventHubException e) { logger.error("Exception occurred during EventHubClient cleanup phase" + e.toString()); } finally { ehClient = null; } } if (executorService != null) { executorService.shutdown(); try { executorService.awaitTermination(2, TimeUnit.SECONDS); } catch (InterruptedException e) { logger.warn("Exception occurred while terminating ExecutorService: " + e.toString()); } finally { executorService = null; } } }
Source:
<code>public String toString(List<? extends DocTree> tags, Element element) { if (tags.size() == 0) { return null; } StringBuilder buf = new StringBuilder(String.format("%n<dl><dt><span class=\"strong\">%s</span></dt>%n", getHeader())); for (DocTree t : tags) { <START> String text = ((UnknownBlockTagTree) t).getContent().get(0).toString(); <END> buf.append(" <dd>").append(genLink(text)).append("</dd><br/>"); } return buf.toString(); }</code><technical_language>fine fail fast here</technical_language>

Target:
public String toString(List<? extends DocTree> tags, Element element) { if (tags.size() == 0) { return null; } StringBuilder buf = new StringBuilder(String.format("<dl><dt><span class=\"strong\">%s</span></dt>", getHeader())); for (DocTree tag : tags) { String text = ((UnknownBlockTagTree) tag).getContent().get(0).toString(); buf.append("<dd>").append(genLink(text)).append("</dd>"); } return buf.toString(); }
Source:
<code>public java.util.List<List<Alert>> filterAlertsByRiskLevel( ExtensionExportReport extension, List<List<Alert>> alerts) { ArrayList<String> selectedRisks = extension.getIncludedAlertSeverity(); ArrayList<String> alertRisks = extension.getAlertSeverity(); boolean isSelected; for (int i = alerts.size() - 1; i >= 0; i--) { List<Alert> alertList = alerts.get(i); isSelected = false; for (int j = alertList.size() - 1; j >= 0; j--) { Alert alert = alertList.get(j); <START> for (int k = 0; k < selectedRisks.size(); k++) { <END> if (alertRisks.get(alert.getRisk()).equals(selectedRisks.get(k))) { isSelected = true; } } if (!isSelected) { alertList.remove(j); } } if (alerts.get(i).size() == 0) { alerts.remove(i); } } return alerts; }</code><technical_language>replaced selectedRisks.contains(alertRisks.get(alert.getRisk()))</technical_language>

Target:
public java.util.List<List<Alert>> filterAlertsByRiskLevel( ExtensionExportReport extension, List<List<Alert>> alerts) { ArrayList<String> selectedRisks = extension.getIncludedAlertSeverity(); ArrayList<String> alertRisks = extension.getAlertSeverity(); for (int i = alerts.size() - 1; i >= 0; i--) { List<Alert> alertList = alerts.get(i); for (int j = alertList.size() - 1; j >= 0; j--) { Alert alert = alertList.get(j); if (!selectedRisks.contains(alertRisks.get(alert.getRisk()))) { alertList.remove(j); } } if (alerts.get(i).size() == 0) { alerts.remove(i); } } return alerts; }
Source:
<code>protected <T> Stream<Object> resolveEventTargets(EventMessage message, T parentEntity, Member member, ForwardingMode eventForwardingMode) { <START> Map<?, Object> fieldValue = ReflectionUtils.getMemberValue(member, parentEntity); <END> return fieldValue == null ? Stream.empty() : eventForwardingMode.filterCandidates(message, fieldValue.values().stream()); }</code><technical_language>rename this variable memberValue</technical_language>

Target:
protected <T> Stream<Object> resolveEventTargets(EventMessage message, T parentEntity, Member member, ForwardingMode eventForwardingMode) { Map<?, Object> memberValue = ReflectionUtils.getMemberValue(member, parentEntity); return memberValue == null ? Stream.empty() : eventForwardingMode.filterCandidates(message, memberValue.values().stream()); }
Source:
<code>public void setDisableHyperLink() { if <START> (!selectHyperLinkLabel.isDisposed()) <END> { selectHyperLinkLabel.setEnabled(false); } if (!clearHyperLinkLabel.isDisposed()) { clearHyperLinkLabel.setEnabled(false); } }</code><technical_language>selectHyperLinkLabel null</technical_language>

Target:
public void setDisableHyperLink() { if (selectHyperLinkLabel != null && !selectHyperLinkLabel.isDisposed()) { selectHyperLinkLabel.setEnabled(false); } if (clearHyperLinkLabel != null && !clearHyperLinkLabel.isDisposed()) { clearHyperLinkLabel.setEnabled(false); } }
Source:
<code>private void updatePatchedValues(Context context, EPersonRest ePersonRest, EPerson ePerson) throws SQLException, AuthorizeException { if (ePersonRest.getPassword() != null) { es.setPassword(ePerson, ePersonRest.getPassword()); } if (ePersonRest.isRequireCertificate() != ePerson.getRequireCertificate()) { ePerson.setRequireCertificate(ePersonRest.isRequireCertificate()); } if (ePersonRest.isCanLogIn() != ePerson.canLogIn()) { ePerson.setCanLogIn(ePersonRest.isCanLogIn()); } if (ePersonRest.getNetid() != null) { <START> if (!ePersonRest.getNetid().equals(ePerson.getName())) { <END> ePerson.setNetid(ePersonRest.getNetid()); } } es.update(context, ePerson); }</code><technical_language>this odd</technical_language>

Target:
private void updatePatchedValues(Context context, EPersonRest ePersonRest, EPerson ePerson) throws SQLException, AuthorizeException { if (ePersonRest.getPassword() != null) { es.setPassword(ePerson, ePersonRest.getPassword()); } if (ePersonRest.isRequireCertificate() != ePerson.getRequireCertificate()) { ePerson.setRequireCertificate(ePersonRest.isRequireCertificate()); } if (ePersonRest.isCanLogIn() != ePerson.canLogIn()) { ePerson.setCanLogIn(ePersonRest.isCanLogIn()); } if (!Objects.equals(ePersonRest.getNetid(), ePerson.getNetid())) { ePerson.setNetid(ePersonRest.getNetid()); } es.update(context, ePerson); }
Source:
<code>public Optional<StorageFile> getFile() { if (layout == StorageFileLayout.BUNDLE) { if (parts.length < 2) { return Optional.empty(); } val gnosId = getGnosId(); val fileName = getFilename(); return context.getFilesByGnosId(gnosId).stream() .filter(file -> file.getFileName().equals(fileName)) .findFirst(); } else if (layout == StorageFileLayout.OBJECT_ID) { if (parts.length == 0) { return Optional.empty(); } val fileName = getFilename(); <START> if (fileName.endsWith(".bai")) { <END> val bamObjectId = fileName.replace(".bai", ""); return context.getBaiFile(bamObjectId); } else if (fileName.endsWith(".tbi")) { val vcfObjectId = fileName.replace(".tbi", ""); return context.getTbiFile(vcfObjectId); } return Optional.ofNullable(context.getFile(fileName)); } return null; }</code><technical_language>Replace block with: java if (IndexFileType.isIndexFile(fileName)) { val indexFileType = IndexFileType.fromPath(fileName); // TODO: Verify if this works for other layout types other OBJECT_ID! val objectId = IndexFileType.getFileName(fileName); // convention fileName is objectId FUSE side return context.getIndexFile(objectId, indexFileType) }</technical_language>

Target:
public Optional<StorageFile> getFile() { if (layout == StorageFileLayout.BUNDLE) { if (parts.length < 2) { return Optional.empty(); } val gnosId = getGnosId(); val fileName = getFilename(); return context.getFilesByGnosId(gnosId).stream() .filter(file -> file.getFileName().equals(fileName)) .findFirst(); } else if (layout == StorageFileLayout.OBJECT_ID) { if (parts.length == 0) { return Optional.empty(); } val fileName = getFilename(); val indexFileType = IndexFileType.fromPath(fileName); if (indexFileType.isPresent()) { val objectId = IndexFileType.getFileName(fileName); return context.getIndexFile(objectId, indexFileType.get()); } return Optional.ofNullable(context.getFile(fileName)); } return null; }
Source:
<code>public void testInvalidInput() { assertNotNull(new <START> XmlPatternStateProvider(new TmfTraceStub(), "Bla", <END> Path.fromOSString(""), (@NonNull ISegment segment) -> { })); }</code><technical_language>CtfTmfTestTraceUtils.getTrace(getTrace()) instead probably. teardown method of base class dispose getTrace() test uses</technical_language>

Target:
public void testInvalidInput() { assertNotNull(new XmlPatternStateProvider(CtfTmfTestTraceUtils.getTrace(getTrace()), "Bla", Path.fromOSString(""), (@NonNull ISegment segment) -> { })); }
Source:
<code>public String resolveExpression() { String expr = getType().getMetricExpression(); if (expr == null || expr.isEmpty()) { expr = "$metric"; } if (expr.contains("$metric")) { StringBuilder metricString = new StringBuilder(); if (getMetricFamily() != null) { metricString.append(getMetricFamily()); } if (getMetricLabels() != null && !getMetricLabels().isEmpty()) { String comma = ""; metricString.append("{"); for (Map.Entry<String, String> label : getMetricLabels().entrySet()) { metricString.append(comma) .append(label.getKey()) .append("=\"") .append(label.getValue()) .append("\""); comma = ","; } metricString.append("}"); } <START> expr = expr.replaceAll("\\$metric", metricString.toString()); <END> } return expr; }</code><technical_language>I expr.replace() opposed replaceAll(). need deal regex here</technical_language>

Target:
public String resolveExpression() { String expr = getType().getMetricExpression(); if (expr == null || expr.isEmpty()) { expr = "$metric"; } if (expr.contains("$metric")) { StringBuilder metricString = new StringBuilder(); if (getMetricFamily() != null) { metricString.append(getMetricFamily()); } if (getMetricLabels() != null && !getMetricLabels().isEmpty()) { String comma = ""; metricString.append("{"); for (Map.Entry<String, String> label : getMetricLabels().entrySet()) { metricString.append(comma) .append(label.getKey()) .append("=\"") .append(label.getValue()) .append("\""); comma = ","; } metricString.append("}"); } expr = expr.replace("$metric", metricString.toString()); } return expr; }
Source:
<code><START> public SchemaRegistryAvroSerializer buildSyncClient() { <END> return new SchemaRegistryAvroSerializer( this.registryUrl, this.credential, this.schemaGroup, this.autoRegisterSchemas, this.maxSchemaMapSize); }</code><technical_language>Validate inputs check if required fields registryUrl credential set</technical_language>

Target:
public SchemaRegistryAvroSerializer buildSyncClient() { CachedSchemaRegistryClient client = new CachedSchemaRegistryClientBuilder() .endpoint(registryUrl) .credential(credential) .maxSchemaMapSize(maxSchemaMapSize) .buildClient(); return new SchemaRegistryAvroSerializer(client, this.schemaGroup, this.autoRegisterSchemas); }
Source:
<code><START> public boolean equals(Object obj) { <END> if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ContentValuesEntry other = (ContentValuesEntry) obj; return areEqual(key, other.key) && areEqual(value, other.value); }</code><technical_language>Annotations line method declaration</technical_language>

Target:
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ContentValuesEntry other = (ContentValuesEntry) obj; return areEqual(key, other.key) && areEqual(value, other.value); }
Source:
<code>public static int randomIntInRange(final int from, final int to) { if (from > to) { <START> throw new ValidationException(String.format("From (%d) must be less than to (%d)", from, to), "from", "to"); <END> } else if (from == to) { throw new ValidationException(String.format("From (%d) must be different to (%d)", from, to), "from", "to"); } return from + Randoms.randomInt(to - from); }</code><technical_language>ValidationException is reserved for domain logic invalid input. For a general purpose 'commons' method, IllegalArgumentException more appropriate</technical_language>

Target:
public static int randomIntInRange(final int from, final int to) { int returnValue; if (from > to) { throw new IllegalArgumentException(String.format("From (%d) must be less than to (%d)", from, to)); } else { returnValue = from + Randoms.randomInt(to - from); } return returnValue; }
Source:
<code>public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_description_edit, container, false); unbinder = ButterKnife.bind(this, view); <START> source = getArguments().getInt(ARG_INVOKE_SOURCE, InvokeSource.PAGE_ACTIVITY.ordinal()); <END> editView.setTranslationEdit(source == InvokeSource.EDIT_FEED_TRANSLATE_TITLE_DESC.ordinal()); editView.setTranslationSourceLanguageDescription(getArguments().getCharSequence(ARG_TRANSLATION_SOURCE_LANG_DESC)); editView.setPageTitle(pageTitle); editView.setHighlightText(highlightText); editView.setCallback(new EditViewCallback()); if (reviewEnabled) { loadPageSummary(savedInstanceState); } if (funnel != null) { funnel.logReady(); } return view; }</code><technical_language>type of source field InvokeSource instead of int</technical_language>

Target:
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_description_edit, container, false); unbinder = ButterKnife.bind(this, view); editView.setTranslationEdit(invokeSource == EDIT_FEED_TRANSLATE_TITLE_DESC); editView.setTranslationSources(getArguments().getCharSequence(ARG_TRANSLATION_SOURCE_DESCRIPTION), getArguments().getString(ARG_TRANSLATION_SOURCE_LANGUAGE_CODE)); editView.setPageTitle(pageTitle); editView.setHighlightText(highlightText); editView.setCallback(new EditViewCallback()); editView.editTaskEnabled(reviewEnabled); if (reviewEnabled) { editView.setVisibility(View.GONE); editView.showProgressBar(true); loadPageSummary(savedInstanceState); } if (funnel != null) { funnel.logReady(); } return view; }
Source:
<code>void processAnnotatedType(@Observes ProcessAnnotatedType<NoAnnotationBean> bean) { <START> if(classToProcess.contains(bean.getAnnotatedType().getJavaClass())) { <END> AnnotatedTypeWrapper<NoAnnotationBean> wrapper = new AnnotatedTypeWrapper<NoAnnotationBean>(bean); wrapper.addAnnotation(new TransactionalLiteral()); bean.setAnnotatedType(wrapper); } }</code><technical_language>This if list removed completely</technical_language>

Target:
void processAnnotatedType(@Observes ProcessAnnotatedType<NoAnnotationBean> bean) { AnnotatedTypeWrapper<NoAnnotationBean> wrapper = new AnnotatedTypeWrapper<NoAnnotationBean>(bean); wrapper.addAnnotation(new TransactionalLiteral()); bean.setAnnotatedType(wrapper); }
Source:
<code>private void addSubmodule(String url, String name, String revision, List<CopyFile> copyfiles) throws SAXException { if (repo.isBare()) { Project proj = new Project(url, name, revision, null); proj.copyfiles.addAll(copyfiles); bareProjects.add(proj); } else { SubmoduleAddCommand add = git .submoduleAdd() .setPath(name) .setURI(url); if (monitor != null) add.setProgressMonitor(monitor); try { Repository subRepo = add.call(); if (revision != null) { Git git = new Git(subRepo); git.checkout().setName(findRef(revision, subRepo)).call(); git.add().addFilepattern(name).call(); } for (CopyFile copyfile : copyfiles) { copyfile.copy(); <START> this.git.add().addFilepattern(copyfile.dest).call(); <END> } } catch (GitAPIException e) { throw new SAXException(e); } catch (IOException e) { throw new SAXException(e); } } }</code><technical_language>this. is unnecessary</technical_language>

Target:
private void addSubmodule(String url, String name, String revision, List<CopyFile> copyfiles) throws SAXException { if (repo.isBare()) { Project proj = new Project(url, name, revision, null); proj.copyfiles.addAll(copyfiles); bareProjects.add(proj); } else { SubmoduleAddCommand add = git .submoduleAdd() .setPath(name) .setURI(url); if (monitor != null) add.setProgressMonitor(monitor); try { Repository subRepo = add.call(); if (revision != null) { Git sub = new Git(subRepo); sub.checkout().setName(findRef(revision, subRepo)).call(); git.add().addFilepattern(name).call(); } for (CopyFile copyfile : copyfiles) { copyfile.copy(); git.add().addFilepattern(copyfile.dest).call(); } } catch (GitAPIException e) { throw new SAXException(e); } catch (IOException e) { throw new SAXException(e); } } }
Source:
<code>public void finish(TimePeriod timeout) { new PushButton("Finish").click(); new WaitWhile(new ShellWithTextIsActive(TITLE), TimePeriod.NORMAL, false); try { activate(); new PushButton("Resolve All Later").click(); new PushButton("Finish").click(); } catch (Exception e) { } try { new DefaultShell("Incomplete Maven Goal Execution"); new PushButton("OK").click(); } catch (CoreLayerException | SWTLayerException e) { } new WaitWhile(new ShellWithTextIsAvailable(TITLE), TimePeriod.LONG); new WaitWhile(new JobIsRunning(), timeout); <START> AbstractWait.sleep(TimePeriod.NORMAL); <END> new WaitWhile(new JobIsRunning(), TimePeriod.LONG); AbstractWait.sleep(TimePeriod.NORMAL); }</code><technical_language>AbstractWaits removed</technical_language>

Target:
public void finish(TimePeriod timeout) { Shell shell = new DefaultShell(TITLE); new PushButton("Finish").click(); new WaitWhile(new ShellIsAvailable(shell), TimePeriod.NORMAL); try { ResolveDialog dialog = new ResolveDialog(); dialog.resolveAllLater(); dialog.finish(); } catch (Exception e) { } try { IncompleteDialog dialog = new IncompleteDialog(); dialog.ok(); } catch (CoreLayerException | SWTLayerException e) { } new WaitUntil(new JobIsRunning(), TimePeriod.NORMAL, false); new WaitWhile(new JobIsRunning(), timeout); }
Source:
<code>public ThingUID getThingUID(ServiceInfo info) { if (info != null) { logger.trace("ServiceInfo: " + info); ThingTypeUID typeUID = getThingTypeUID(info); if (typeUID != null) { if (info.getType() != null) { <START> if (info.getType().equals(getServiceType())) { <END> logger.trace("Discovered a Bose SoundTouch thing with name '{}'", info.getName()); byte[] mac = getMacAddress(info); if (mac != null) { return new ThingUID(typeUID, new String(mac)); } else { return null; } } } } } return null; }</code><technical_language>3 if conditions merged</technical_language>

Target:
public ThingUID getThingUID(ServiceInfo info) { logger.trace("ServiceInfo: {}", info); ThingTypeUID typeUID = getThingTypeUID(info); if (typeUID != null) { if (info.getType() != null) { if (info.getType().equals(getServiceType())) { logger.trace("Discovered a Bose SoundTouch thing with name '{}'", info.getName()); byte[] mac = getMacAddress(info); if (mac != null) { return new ThingUID(typeUID, new String(mac)); } else { return null; } } } } return null; }
Source:
<code>private UserProfile translateUser(String translateFrom) { int separator = -1; UserProfile result = new UserProfile(); if (userNameFormat == UserNameFormat.UPN && translateFrom.indexOf("\\") == -1) { separator = translateFrom.lastIndexOf("@"); result.userName = translateFrom.substring(0, separator); result.profile = translateFrom.substring(separator+1); } else if (userNameFormat == UserNameFormat.RESTAPI_SPECIFIC && translateFrom.indexOf("@") == -1) { separator = translateFrom.indexOf("\\"); result.profile = translateFrom.substring(0, separator); <START> result.userName = translateFrom.substring(separator+1); <END> } return result; }</code><technical_language>supports '@' notation, no</technical_language>

Target:
private UserProfile translateUser(String translateFrom) { int separator = -1; UserProfile result = new UserProfile(); if (userNameFormat == UserNameFormat.UPN) { separator = translateFrom.lastIndexOf("@"); result.userName = translateFrom.substring(0, separator); result.profile = translateFrom.substring(separator+1); } else if (userNameFormat == UserNameFormat.RESTAPI_SPECIFIC) { separator = translateFrom.indexOf("\\"); result.profile = translateFrom.substring(0, separator); result.userName = translateFrom.substring(separator+1); } return result; }
Source:
<code>public static String getResponseBodyContent(final HttpEntity entity) throws IOException, ParseException { <START> if (entity == null) { <END> throw new IllegalArgumentException("HTTP entity may not be null."); } InputStream instream = entity.getContent(); if (entity.getContentLength() > Integer.MAX_VALUE) { throw new IllegalArgumentException("HTTP entity too large to be buffered in memory."); } String charset = getContentCharSet(entity); if (charset == null) { charset = HTTP.DEFAULT_CONTENT_CHARSET; } Reader reader = new InputStreamReader(instream, charset); StringBuilder buffer = new StringBuilder(); try { char[] bufferSize = new char[1024]; int length; while ((length = reader.read(bufferSize)) != -1) { buffer.append(bufferSize, 0, length); } } finally { reader.close(); } return buffer.toString(); }</code><technical_language>get rid of this null check too, I believe</technical_language>

Target:
public static String getResponseBodyContent(final HttpEntity entity) throws IOException, ParseException { InputStream instream = entity.getContent(); if (entity.getContentLength() > Integer.MAX_VALUE) { throw new IllegalArgumentException("HTTP entity too large to be buffered in memory."); } String charset = getContentCharSet(entity); if (charset == null) { charset = HTTP.DEFAULT_CONTENT_CHARSET; } Reader reader = new InputStreamReader(instream, charset); StringBuilder buffer = new StringBuilder(); try { char[] bufferSize = new char[1024]; int length; while ((length = reader.read(bufferSize)) != -1) { buffer.append(bufferSize, 0, length); } } finally { reader.close(); } return buffer.toString(); }
Source:
<code>public void writeTuples(final ReadableTable tuples) throws IOException { final String[] row = new String[tuples.numColumns()]; Schema tbsc = tuples.getSchema(); for (int i = 0; i < tuples.numTuples(); ++i) { for (int j = 0; j < tuples.numColumns(); ++j) { Type type = tbsc.getColumnType(j); if (type.equals(Type.BLOB_TYPE)) { <START> String filename = UUID.randomUUID().toString(); <END> ByteBuffer bb = tuples.getBlob(j, i); writeBBtoFile(bb, filename); row[j] = filename; } else { row[j] = tuples.getObject(j, i).toString(); } } csvPrinter.printRecord((Object[]) row); } }</code><technical_language>understanding is writing a temp file? File.createTempFile() if case. UUID is a random ID</technical_language>

Target:
public void writeTuples(final ReadableTable tuples) throws IOException { final String[] row = new String[tuples.numColumns()]; Schema tbsc = tuples.getSchema(); for (int i = 0; i < tuples.numTuples(); ++i) { for (int j = 0; j < tuples.numColumns(); ++j) { Type type = tbsc.getColumnType(j); if (type.equals(Type.BLOB_TYPE)) { ByteBuffer bb = tuples.getBlob(j, i); String filename = writeToTempFile(bb); row[j] = filename; } else { row[j] = tuples.getObject(j, i).toString(); } } csvPrinter.printRecord((Object[]) row); } }
Source:
<code>String elementToString(String qName, Attributes attributes, boolean isEndElement) { StringBuilder returnValue = new StringBuilder("<"); if (isEndElement) { returnValue.append('/'); } returnValue.append(qName); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { returnValue.append(" "); returnValue.append(attributes.getQName(i)); String value = attributes.getValue(i); <START> if (value != null) { <END> returnValue.append("=\""); returnValue.append(value); returnValue.append('"'); } } } returnValue.append(">"); return returnValue.toString(); }</code><technical_language>Strings.isValid(value)</technical_language>

Target:
private String elementToString(String qName, Attributes attributes, boolean isEndElement) { StringBuilder returnValue = new StringBuilder("<"); if (isEndElement) { returnValue.append('/'); } returnValue.append(qName); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { returnValue.append(" "); returnValue.append(attributes.getQName(i)); String value = attributes.getValue(i); if (Strings.isValid(value)) { returnValue.append("=\""); returnValue.append(value); returnValue.append('"'); } } } returnValue.append(">"); return returnValue.toString(); }
Source:
<code><START> public OneOriginContainer finish () { <END> return new OneOriginContainer(travelTimes, accessibilityAccumulator); }</code><technical_language>I kind of prefer name - a "container" anything, in this case contains computation results</technical_language>

Target:
public OneOriginResult finish () { return new OneOriginResult(travelTimeResult, accessibilityResult); }
Source:
<code>public static void delete(final File f, int options) throws IOException { if ((options & SKIP_MISSING) != 0 && !f.exists()) return; if ((options & RECURSIVE) != 0 && f.isDirectory()) { final File[] items = f.listFiles(); if (items != null) { for (File c : items) delete(c, options); } } boolean delete = false; <START> if ((options & EMPTY_DIRECTORY) != 0) <END> if (f.isDirectory()) delete = true; else { if ((options & IGNORE_ERRORS) == 0) throw new IOException(MessageFormat.format( JGitText.get().deleteFileFailed, f.getAbsolutePath())); } else delete = true; if (delete && !f.delete()) { if ((options & RETRY) != 0 && f.exists()) { for (int i = 1; i < 10; i++) { try { Thread.sleep(100); } catch (InterruptedException e) { } if (f.delete()) return; } } if ((options & IGNORE_ERRORS) == 0) throw new IOException(MessageFormat.format( JGitText.get().deleteFileFailed, f.getAbsolutePath())); } }</code><technical_language>add braces for if? kind of hard read in this case</technical_language>

Target:
public static void delete(final File f, int options) throws IOException { if ((options & SKIP_MISSING) != 0 && !f.exists()) return; if ((options & RECURSIVE) != 0 && f.isDirectory()) { final File[] items = f.listFiles(); if (items != null) { for (File c : items) delete(c, options); } } boolean delete = false; if ((options & EMPTY_DIRECTORIES_ONLY) != 0) { if (f.isDirectory()) { delete = true; } else { if ((options & IGNORE_ERRORS) == 0) throw new IOException(MessageFormat.format( JGitText.get().deleteFileFailed, f.getAbsolutePath())); } } else { delete = true; } if (delete && !f.delete()) { if ((options & RETRY) != 0 && f.exists()) { for (int i = 1; i < 10; i++) { try { Thread.sleep(100); } catch (InterruptedException e) { } if (f.delete()) return; } } if ((options & IGNORE_ERRORS) == 0) throw new IOException(MessageFormat.format( JGitText.get().deleteFileFailed, f.getAbsolutePath())); } }
Source:
<code>private static String getCacheKey(String url, Integer userid) { String key = "api_responses_" + url; if (userid != null) { <START> key += userid; <END> } return key; }</code><technical_language>I add _ in userid url, if URL ends integer, difficult decifer userid url. issue up, I thought bring up</technical_language>

Target:
private static String getCacheKey(String url, Integer userid) { String key = "api_responses_" + url; if (userid != null) { key += "_" + userid; } return key; }
Source:
<code>public static void setupClass() { TestBase.setupClass(); if (TEST_MODE == TestMode.PLAYBACK) { return; } Reader indexData = new InputStreamReader(Objects.requireNonNull(AutocompleteSyncTests.class .getClassLoader() .getResourceAsStream(HOTELS_TESTS_INDEX_DATA_JSON))); try { SearchIndex index = new ObjectMapper().readValue(indexData, SearchIndex.class); Field searchIndexName = index.getClass().getDeclaredField("name"); AccessController.doPrivileged((PrivilegedAction<Object>) () -> { searchIndexName.setAccessible(true); return null; }); <START> searchIndexName.set(index, INDEX_NAME); <END> searchIndexClient = new SearchIndexClientBuilder() .endpoint(ENDPOINT) .credential(new AzureKeyCredential(API_KEY)) .retryPolicy(new RetryPolicy(new ExponentialBackoff(3, Duration.ofSeconds(10), Duration.ofSeconds(30)))) .buildClient(); searchIndexClient.createOrUpdateIndex(index); uploadDocumentsJson(searchIndexClient.getSearchClient(INDEX_NAME), HOTELS_DATA_JSON); } catch (Throwable ex) { throw new RuntimeException(ex); } }</code><technical_language>change name in hotel json file modify serialization? other test classes similar structure, SuggestSyncTests SearchSyncTest</technical_language>

Target:
public static void setupClass() { TestBase.setupClass(); if (TEST_MODE == TestMode.PLAYBACK) { return; } searchIndexClient = setupSharedIndex(INDEX_NAME); }
Source:
<code>public void testSearchFieldsMetadata() throws Exception { client().prepareIndex("my-index").setId("1") .setRouting("1") .setSource(jsonBuilder().startObject().field("field1", "value").endObject()) .setRefreshPolicy(IMMEDIATE) .get(); SearchResponse searchResponse = client().prepareSearch("my-index") .addStoredField("field1").addStoredField("_routing") .get(); assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).field("field1"), nullValue()); <START> assertThat(searchResponse.getHits().getAt(0).isMetadataField("_routing"), equalTo(true)); <END> assertThat(searchResponse.getHits().getAt(0).field("_routing").getValue().toString(), equalTo("1")); }</code><technical_language>Do need test "_routing" is a meta data field here</technical_language>

Target:
public void testSearchFieldsMetadata() throws Exception { client().prepareIndex("my-index").setId("1") .setRouting("1") .setSource(jsonBuilder().startObject().field("field1", "value").endObject()) .setRefreshPolicy(IMMEDIATE) .get(); SearchResponse searchResponse = client().prepareSearch("my-index") .addStoredField("field1").addStoredField("_routing") .get(); assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).field("field1"), nullValue()); assertThat(searchResponse.getHits().getAt(0).field("_routing").getValue().toString(), equalTo("1")); }
Source:
<code>public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (closeFrameSent(ctx)) { <START> return; <END> } if (msg instanceof CloseWebSocketFrame) { ctx.channel().attr(CLOSE_FRAME_SENT_ATTR_KEY).set(true); } super.write(ctx, msg, promise); }</code><technical_language>imho call writeAndFlush(...) attach a ChannelFutureListener close channel write is done. need schedule some timeout close if write complete in a period of time</technical_language>

Target:
public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (closeSent != null) { ReferenceCountUtil.release(msg); promise.setFailure(new ClosedChannelException()); return; } if (msg instanceof CloseWebSocketFrame) { promise = promise.unvoid(); closeSent = promise; } super.write(ctx, msg, promise); }
Source:
<code>private static boolean getSigned(CommonTree rightNode) throws ParseException { boolean ret = false; CommonTree firstChild = (CommonTree) rightNode.getChild(0); <START> if (firstChild.getType() == CTFParser.UNARY_EXPRESSION_STRING) { <END> String strval = concatenateUnaryStrings(rightNode.getChildren()); if (strval.equals(CTFStrings.TRUE) || strval.equals(CTFStrings.TRUE2)) { ret = true; } else if (strval.equals(CTFStrings.FALSE) || strval.equals(CTFStrings.FALSE2)) { ret = false; } else { throw new ParseException("Invalid boolean value " + firstChild.getChild(0).getText()); } } else if (isUnaryInteger(firstChild)) { if (rightNode.getChildCount() > 1) { throw new ParseException("Invalid boolean value"); } long intval = parseUnaryInteger(firstChild); if (intval == 1) { ret = true; } else if (intval == 0) { ret = false; } else { throw new ParseException("Invalid boolean value " + firstChild.getChild(0).getText()); } } else { throw new ParseException(); } return ret; }</code><technical_language>I prefer keeping helper function, if decides muck specs for ctf 1.9, need easy support it</technical_language>

Target:
private static boolean getSigned(CommonTree rightNode) throws ParseException { boolean ret = false; CommonTree firstChild = (CommonTree) rightNode.getChild(0); if (isUnaryString(firstChild)) { String strval = concatenateUnaryStrings(rightNode.getChildren()); if (strval.equals(CTFStrings.TRUE) || strval.equals(CTFStrings.TRUE2)) { ret = true; } else if (strval.equals(CTFStrings.FALSE) || strval.equals(CTFStrings.FALSE2)) { ret = false; } else { throw new ParseException("Invalid boolean value " + firstChild.getChild(0).getText()); } } else if (isUnaryInteger(firstChild)) { if (rightNode.getChildCount() > 1) { throw new ParseException("Invalid boolean value"); } long intval = parseUnaryInteger(firstChild); if (intval == 1) { ret = true; } else if (intval == 0) { ret = false; } else { throw new ParseException("Invalid boolean value " + firstChild.getChild(0).getText()); } } else { throw new ParseException(); } return ret; }
Source:
<code>protected boolean isOperationHidden(Method method) { io.swagger.v3.oas.annotations.Operation apiOperation = ReflectionUtils.getAnnotation(method, io.swagger.v3.oas.annotations.Operation.class); if (apiOperation != null && apiOperation.hidden()) { return true; } Hidden hidden = method.getAnnotation(Hidden.class); if (hidden != null) { return true; } <START> return config != null && !Boolean.TRUE.equals(config.isReadAllResources()) && apiOperation == null; <END> }</code><technical_language>if this is more readable previous version</technical_language>

Target:
protected boolean isOperationHidden(Method method) { io.swagger.v3.oas.annotations.Operation apiOperation = ReflectionUtils.getAnnotation(method, io.swagger.v3.oas.annotations.Operation.class); if (apiOperation != null && apiOperation.hidden()) { return true; } Hidden hidden = method.getAnnotation(Hidden.class); if (hidden != null) { return true; } if (config != null && !Boolean.TRUE.equals(config.isReadAllResources()) && apiOperation == null) { return true; } return false; }
Source:
<code>private void readHealthUpdate(ByteBuffer buffer) { List<GameObjectDAO> healths = new ArrayList<>(); do { <START> int ID = buffer.getInt(); <END> int maxHealth = buffer.getInt(); int healthValue = buffer.getInt(); GameObjectDAO objectHealth = new GameObjectDAO(); objectHealth.objectId = ID; objectHealth.maxHealth = maxHealth; objectHealth.healthValue = healthValue; healths.add(objectHealth); } while (buffer.get() == 31); map.updateHealths(healths); }</code><technical_language>this is a silly</technical_language>

Target:
private void readHealthUpdate(ByteBuffer buffer) { List<GameObjectDAO> healths = new ArrayList<>(); do { GameObjectDAO objectHealth = new GameObjectDAO(); objectHealth.objectId = buffer.getInt(); objectHealth.maxHealth = buffer.getInt(); objectHealth.healthValue = buffer.getInt(); healths.add(objectHealth); } while (buffer.get() == 31); map.updateHealths(healths); }
Source:
<code><K, V> Ehcache<K, V> retrieve(Class<K> refKeyType, Class<V> refValueType) { if (keyType == refKeyType && valueType == refValueType) { <START> if(cache == null) { <END> synchronized (this) { boolean interrupted = false; try { while(cache == null) { try { wait(); } catch (InterruptedException e) { interrupted = true; } } } finally { if(interrupted) { Thread.currentThread().interrupt(); } } } } return (Ehcache<K, V>)cache; } else { throw new IllegalArgumentException(); } }</code><technical_language>is it....space "if" not? lines style. I vote for a space :-)</technical_language>

Target:
<K, V> Ehcache<K, V> retrieve(Class<K> refKeyType, Class<V> refValueType) { if (!isValueSet) { synchronized (this) { boolean interrupted = false; try { while(!isValueSet) { try { wait(); } catch (InterruptedException e) { interrupted = true; } } } finally { if(interrupted) { Thread.currentThread().interrupt(); } } } } if (keyType == refKeyType && valueType == refValueType) { return (Ehcache<K, V>)cache; } else { throw new IllegalArgumentException(); } }
Source:
<code>public void testPutAsync() throws Exception { Future<String> f = c.putAsync("k", "v"); testFuture(f, null); testK("v"); f = c.putAsync("k", "v2"); testFuture(f, "v"); <START> assertEquals("v2", c.get("k")); <END> }</code><technical_language>code consistency, testK("v2");</technical_language>

Target:
public void testPutAsync() throws Exception { Future<String> f = c.putAsync("k", "v"); testFuture(f, null); testK("v"); f = c.putAsync("k", "v2"); testFuture(f, "v"); testK("v2"); }
Source:
<code>public void resetRuleConfigValue(String key) { if (ruleConfigs.containsKey(key)) { <START> ruleConfigs.get(key).setValue(ruleConfigs.get(key).getDefaultValue()); <END> } else { throw new InvalidParameterException("No such key"); } }</code><technical_language>reset in config file too</technical_language>

Target:
public void resetRuleConfigValue(String key) { if (ruleConfigs.containsKey(key)) { String value = ruleConfigs.get(key).getDefaultValue(); ruleConfigs.get(key).setValue(value); this.getConfig().setProperty(key, value); } else { throw new IllegalArgumentException("No such key"); } }
Source:
<code>public void run(String[] args) { setNinjaMode(NinjaModeHelper.determineModeFromSystemPropertiesOrProdIfNotSet()); setPort(tryToGetPortFromSystemPropertyOrReturnDefault()); setHost(System.getProperty(COMMAND_LINE_PARAMETER_NINJA_HOST, DEFAULT_HOST)); setNinjaContextPath(tryToGetContextPathFromSystemPropertyOrReturnDefault()); setJettyConfiguration(System.getProperty(COMMAND_LINE_PARAMETER_NINJA_JETTY_CONFIGURATION)); try { this.start(); } catch (Exception cause) { <START> System.err.println("Unable to start server. "); <END> cause.printStackTrace(System.err); System.exit(1); } Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { shutdown(); } }); try { server.join(); } catch (InterruptedException e) { } }</code><technical_language>done a logger</technical_language>

Target:
public void run(String[] args) { setNinjaMode(NinjaModeHelper.determineModeFromSystemPropertiesOrProdIfNotSet()); setPort(tryToGetPortFromSystemPropertyOrReturnDefault()); setHost(System.getProperty(COMMAND_LINE_PARAMETER_NINJA_HOST, DEFAULT_HOST)); setNinjaContextPath(tryToGetContextPathFromSystemPropertyOrReturnDefault()); setJettyConfiguration(System.getProperty(COMMAND_LINE_PARAMETER_NINJA_JETTY_CONFIGURATION)); try { this.start(); } catch (Exception e) { logger.error("Unable to start server.", e); System.exit(1); } Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { shutdown(); } }); try { server.join(); } catch (InterruptedException e) { logger.error("Server interrupted (likely server is just shutting down)", e); } }
Source:
<code>protected BaseRealm(RealmConfiguration configuration) { this.threadId = Thread.currentThread().getId(); this.configuration = configuration; this.sharedRealm = SharedRealm.getInstance(configuration, !(this instanceof Realm) ? null : new SharedRealm.SchemaVersionListener() { @Override public void onSchemaVersionChanged(long currentVersion) { RealmCache.updateSchemaCache((Realm) BaseRealm.this); } }, true); this.schema = new StandardRealmSchema(this); <START> ObjectServerFacade.getSyncFacadeIfPossible().downloadServerChangesIfNeeded(configuration); <END> }</code><technical_language>Currently operations in RealmCache is locked RealmCache.class, means this block opening other RealmConfigurations. mind, i is OK, i add a lock individual RealmCache in getInstanceAsync() PR</technical_language>

Target:
BaseRealm(RealmConfiguration configuration) { this.threadId = Thread.currentThread().getId(); this.configuration = configuration; this.realmCache = null; this.sharedRealm = SharedRealm.getInstance(configuration, !(this instanceof Realm) ? null : new SharedRealm.SchemaVersionListener() { @Override public void onSchemaVersionChanged(long currentVersion) { if (realmCache != null) { realmCache.updateSchemaCache((Realm) BaseRealm.this); } } }, true); this.schema = new StandardRealmSchema(this); }