auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getParameters().getBricks() == null || getParameters().getBricks().size() == 0) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); return false; } if (getGlusterVolume().getVolumeType() == GlusterVolumeType.REPLICATE || getGlusterVolume().getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) { if (getParameters().getReplicaCount() > getGlusterVolume().getReplicaCount() + 1) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_INCREASE_REPLICA_COUNT_MORE_THAN_ONE); } else if (getParameters().getReplicaCount() < getGlusterVolume().getReplicaCount()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_REPLICA_COUNT); } } else if (getGlusterVolume().getVolumeType() == GlusterVolumeType.STRIPE || getGlusterVolume().getVolumeType() == GlusterVolumeType.DISTRIBUTED_STRIPE) { if (getParameters().getStripeCount() > getGlusterVolume().getStripeCount() + 1) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_INCREASE_STRIPE_COUNT_MORE_THAN_ONE); } else if (getParameters().getStripeCount() < getGlusterVolume().getStripeCount()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_STRIPE_COUNT); } } return updateBrickServerNames(getParameters().getBricks(), true); }

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (getParameters().getBricks() == null || getParameters().getBricks().size() == 0) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_BRICKS_REQUIRED); return false; } if (getGlusterVolume().getVolumeType() == GlusterVolumeType.REPLICATE || getGlusterVolume().getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) { if (getParameters().getReplicaCount() > getGlusterVolume().getReplicaCount() + 1) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_INCREASE_REPLICA_COUNT_MORE_THAN_ONE); return false; } else if (getParameters().getReplicaCount() < getGlusterVolume().getReplicaCount()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_REPLICA_COUNT); return false; } } else if (getGlusterVolume().getVolumeType() == GlusterVolumeType.STRIPE || getGlusterVolume().getVolumeType() == GlusterVolumeType.DISTRIBUTED_STRIPE) { if (getParameters().getStripeCount() > getGlusterVolume().getStripeCount() + 1) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_INCREASE_STRIPE_COUNT_MORE_THAN_ONE); return false; } else if (getParameters().getStripeCount() < getGlusterVolume().getStripeCount()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_STRIPE_COUNT); return false; } } return updateBrickServerNames(getParameters().getBricks(), true); }
Source:
public void enqueue(Callback<V> callback) { try { executor.execute(() -> { if (canceled) { return; } call = delegate.get(); AutoCloseable nameReverter = updateThreadName(call.toString()); try { ThrottledCallback<V> throttleCallback = new ThrottledCallback<>(callback, limitListener); call.enqueue(throttleCallback); throttleCallback.await(); } finally { try { nameReverter.close(); } catch (Exception e) { } } }); } catch (Exception e) { limitListener.onIgnore(); throw e; } }

Target:
@Override public void enqueue(Callback<V> callback) { try { executor.execute(new QueuedCall(callback)); } catch (RuntimeException | Error e) { propagateIfFatal(e); limitListener.onIgnore(); throw e; } }
Source:
public void resourceChanged(IResourceChangeEvent event) { if (fViewer.getInput() == null) { return; } IResourceDelta delta= event.getDelta(); if (delta == null) return; for (IResourceDelta pDelta : delta.getAffectedChildren(IResourceDelta.CHANGED)) { if ((pDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) { IProject project= (IProject) pDelta.getResource(); if (needsRefiltering(project)) { final Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay().asyncExec(new Runnable() { @Override public void run() { if (!ctrl.isDisposed()) fViewer.refresh(false); } }); } return; } } } }

Target:
public void resourceChanged(IResourceChangeEvent event) { if (fViewer.getInput() == null) { return; } IResourceDelta delta= event.getDelta(); if (delta == null) return; for (IResourceDelta deltachild : delta.getAffectedChildren(IResourceDelta.CHANGED)) { if ((deltachild.getFlags() & IResourceDelta.DESCRIPTION) != 0) { IProject project= (IProject) deltachild.getResource(); if (needsRefiltering(project)) { final Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay().asyncExec(new Runnable() { @Override public void run() { if (!ctrl.isDisposed()) fViewer.refresh(false); } }); } return; } } } }
Source:
public Map<String, String> getParameters() { Map<String, String> parameters = new HashMap<String, String>(); try { final String scopesAsString = getScopesAsString(); if (StringUtils.isNotBlank(clientId)) { parameters.put(AuthorizeRequestParam.CLIENT_ID, clientId); } if (StringUtils.isNotBlank(scopesAsString)) { parameters.put(AuthorizeRequestParam.SCOPE, scopesAsString); } for (String key : getCustomParameters().keySet()) { parameters.put(key, getCustomParameters().get(key)); } } catch (JSONException e) { e.printStackTrace(); } return parameters; }

Target:
public Map<String, String> getParameters() { Map<String, String> parameters = new HashMap<String, String>(); try { final String scopesAsString = getScopesAsString(); if (StringUtils.isNotBlank(clientId)) { parameters.put(AuthorizeRequestParam.CLIENT_ID, clientId); } if (StringUtils.isNotBlank(scopesAsString)) { parameters.put(AuthorizeRequestParam.SCOPE, scopesAsString); } for (String key : getCustomParameters().keySet()) { parameters.put(key, getCustomParameters().get(key)); } } catch (JSONException e) { LOG.error(e.getMessage(), e); } return parameters; }
Source:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); List<String> inputFields = new ArrayList<>(); List<String> outputFields = new ArrayList<>(); Schema inputSchema = context.getInputSchema(); if (SchemaValidator.validateSchemaIsNotNull(inputSchema, "input")) { inputFields = inputSchema.getFields().stream().map(Schema.Field::getName).collect(Collectors.toList()); } Schema outputSchema = context.getOutputSchema(); if (SchemaValidator.validateSchemaIsNotNull(outputSchema, "output")) { outputFields = outputSchema.getFields().stream().map(Schema.Field::getName).collect(Collectors.toList()); } FieldOperation dataPrepOperation = new FieldTransformOperation("JavaScript", config.script, inputFields, outputFields); context.record(Collections.singletonList(dataPrepOperation)); }

Target:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); List<String> inputFields = new ArrayList<>(); List<String> outputFields = new ArrayList<>(); Schema inputSchema = context.getInputSchema(); if (SchemaValidator.canRecordLineage(inputSchema, "input")) { inputFields = inputSchema.getFields().stream().map(Schema.Field::getName).collect(Collectors.toList()); } Schema outputSchema = context.getOutputSchema(); if (SchemaValidator.canRecordLineage(outputSchema, "output")) { outputFields = outputSchema.getFields().stream().map(Schema.Field::getName).collect(Collectors.toList()); } FieldOperation dataPrepOperation = new FieldTransformOperation("JavaScript", config.script, inputFields, outputFields); context.record(Collections.singletonList(dataPrepOperation)); }
Source:
public void addHost(final Host host) { logger.debug("Adding tracker for {}", host); HostLatencyTracker old = latencies.putIfAbsent(host, new HostLatencyTracker(scale, (30L * minMeasure) / 100L)); if (old == null && hostMetricsEnabled()) { String metricName = MetricsUtil.hostMetricName("LatencyAwarePolicy.latencies.", host); if (!metrics.getRegistry().getNames().contains(metricName)) { logger.info("Adding gauge " + metricName); metrics.getRegistry().register( metricName, new Gauge<Long>() { @Override public Long getValue() { TimestampedAverage latency = latencyTracker.latencyOf(host); return (latency == null) ? -1 : latency.average; } }); } } }

Target:
public void addHost(final Host host) { logger.debug("Adding tracker for {}", host); HostLatencyTracker old = latencies.putIfAbsent(host, new HostLatencyTracker(scale, (30L * minMeasure) / 100L)); if (old == null && hostMetricsEnabled()) { String metricName = MetricsUtil.hostMetricName("LatencyAwarePolicy.latencies.", host); if (!metrics.getRegistry().getNames().contains(metricName)) { logger.debug("Adding gauge " + metricName); metrics.getRegistry().register( metricName, new Gauge<Long>() { @Override public Long getValue() { TimestampedAverage latency = latencyTracker.latencyOf(host); return (latency == null) ? -1 : latency.average; } }); } } }
Source:
private ContainerCascadingMetaData(ValueExtractorManager valueExtractorManager, CascadingMetaDataBuilder cascadingMetaDataBuilder) { this( cascadingMetaDataBuilder.getEnclosingType(), cascadingMetaDataBuilder.getTypeParameter(), cascadingMetaDataBuilder.getDeclaredContainerClass(), cascadingMetaDataBuilder.getDeclaredTypeParameter(), cascadingMetaDataBuilder.getContainerElementTypesCascadingMetaData().entrySet().stream() .map( entry -> new ContainerCascadingMetaData( valueExtractorManager, entry.getValue() ) ) .collect( Collectors.collectingAndThen( Collectors.toList(), CollectionHelper::toImmutableList ) ), cascadingMetaDataBuilder.isCascading(), GroupConversionHelper.of( cascadingMetaDataBuilder.getGroupConversions() ), cascadingMetaDataBuilder.isMarkedForCascadingOnAnnotatedObjectOrContainerElements() ); }

Target:
private ContainerCascadingMetaData(ValueExtractorManager valueExtractorManager, CascadingMetaDataBuilder cascadingMetaDataBuilder) { this( valueExtractorManager, cascadingMetaDataBuilder.getEnclosingType(), cascadingMetaDataBuilder.getTypeParameter(), cascadingMetaDataBuilder.getDeclaredContainerClass(), cascadingMetaDataBuilder.getDeclaredTypeParameter(), cascadingMetaDataBuilder.getContainerElementTypesCascadingMetaData().entrySet().stream() .map( entry -> new ContainerCascadingMetaData( valueExtractorManager, entry.getValue() ) ) .collect( Collectors.collectingAndThen( Collectors.toList(), CollectionHelper::toImmutableList ) ), cascadingMetaDataBuilder.isCascading(), GroupConversionHelper.of( cascadingMetaDataBuilder.getGroupConversions() ), cascadingMetaDataBuilder.isMarkedForCascadingOnAnnotatedObjectOrContainerElements() ); }
Source:
protected int checkCommon(long hash, boolean rejoining, VoltTable resultTables[], VoltMessage message) { if (!rejoining) { if (m_responseHash == null) { m_responseHash = Long.valueOf(hash); } else if (!m_responseHash.equals(hash)) { } m_lastResponse = message; m_lastResultTables = resultTables; } if (m_lastResponse == null) { m_lastResponse = message; m_lastResultTables = resultTables; } m_expectedHSIds.remove(message.m_sourceHSId); if (m_expectedHSIds.size() == 0) { tmLog.info("satisfied"); return DONE; } else { return WAITING; } }

Target:
protected int checkCommon(long hash, boolean rejoining, VoltTable resultTables[], VoltMessage message) { if (!rejoining) { if (m_responseHash == null) { m_responseHash = Long.valueOf(hash); } else if (!m_responseHash.equals(hash)) { tmLog.fatal("Stored procedure " + getStoredProcedureName() + " generated different SQL queries at different partitions." + " Shutting down to preserve data integrity."); String msg = String.format("HASH MISMATCH COMPARING: %d to %d\n" + "PREV MESSAGE: %s\n" + "CURR MESSAGE: %s\n", hash, m_responseHash, m_lastResponse.toString(), message.toString()); tmLog.error(msg); return MISMATCH; } m_lastResponse = message; m_lastResultTables = resultTables; } if (m_lastResponse == null) { m_lastResponse = message; m_lastResultTables = resultTables; } m_expectedHSIds.remove(message.m_sourceHSId); if (m_expectedHSIds.size() == 0) { return DONE; } else { return WAITING; } }
Source:
private static void findComponentCyclesRecursion( Stack<String> stack, Map<String, Set<String>> edgesOut, Set<String> seen, List<List<String>> cycles) { if (stack.isEmpty()) { return; } String compId1 = stack.peek(); if (!edgesOut.containsKey(compId1) || edgesOut.get(compId1).isEmpty()) { stack.pop(); return; } Set<String> children = new HashSet<>(edgesOut.get(compId1)); for (String compId2: children) { if (seen.contains(compId2)) { List<String> cycle = new ArrayList<>(); if (compId1.equals(compId2)) { cycle.add(compId2); } else if (edgesOut.get(compId2).contains(compId1)) { cycle.addAll(Arrays.asList(compId1, compId2)); } else { List<String> tmp = Collections.list(stack.elements()); int prevIdx = tmp.indexOf(compId2); if (prevIdx >= 0) { tmp.subList(prevIdx, tmp.size()); } tmp.add(compId2); cycle.addAll(tmp); } cycles.add(cycle); edgesOut.get(compId1).remove(compId2); continue; } seen.add(compId2); stack.push(compId2); findComponentCyclesRecursion(stack, edgesOut, seen, cycles); } stack.pop(); }

Target:
private static void findComponentCyclesRecursion( Stack<String> stack, Map<String, Set<String>> edgesOut, Set<String> seen, List<List<String>> cycles) { if (stack.isEmpty()) { return; } String compId1 = stack.peek(); if (!edgesOut.containsKey(compId1) || edgesOut.get(compId1).isEmpty()) { stack.pop(); return; } Set<String> children = new HashSet<>(edgesOut.get(compId1)); for (String compId2: children) { if (seen.contains(compId2)) { List<String> possibleCycle = new ArrayList<>(); if (compId1.equals(compId2)) { possibleCycle.add(compId2); } else if (edgesOut.get(compId2) != null && edgesOut.get(compId2).contains(compId1)) { possibleCycle.addAll(Arrays.asList(compId1, compId2)); } else { List<String> tmp = Collections.list(stack.elements()); int prevIdx = tmp.indexOf(compId2); if (prevIdx >= 0) { tmp = tmp.subList(prevIdx, tmp.size()); tmp.add(compId2); possibleCycle.addAll(tmp); } } if (!possibleCycle.isEmpty()) { cycles.add(possibleCycle); edgesOut.get(compId1).remove(compId2); continue; } } seen.add(compId2); stack.push(compId2); findComponentCyclesRecursion(stack, edgesOut, seen, cycles); } stack.pop(); }
Source:
private List<Port> getAllInheritedPorts(org.eclipse.uml2.uml.Class aClass) { ArrayList<Port> ports = new ArrayList<Port>(); ports.addAll(aClass.getOwnedPorts()); for (org.eclipse.uml2.uml.Classifier parent : aClass.allParents()) { if (parent instanceof org.eclipse.uml2.uml.Class) { ports.addAll(getAllInheritedPorts((org.eclipse.uml2.uml.Class)parent)); } } return ports; }

Target:
private List<Port> getAllInheritedPorts(org.eclipse.uml2.uml.Class aClass) { List<Port> ports = new ArrayList<Port>(); ports.addAll(aClass.getOwnedPorts()); for (org.eclipse.uml2.uml.Classifier parent : aClass.allParents()) { if (parent instanceof org.eclipse.uml2.uml.Class) { ports.addAll(getAllInheritedPorts((org.eclipse.uml2.uml.Class)parent)); } } return ports; }
Source:
private PageableResult searchStartsWith(RequestContext context, String codeOrName, List<ConceptSource> conceptSources){ Set<ConceptReferenceTerm> resultTerms = new LinkedHashSet<ConceptReferenceTerm>(); int count = 0; if (codeOrName != null && StringUtils.isNotEmpty(codeOrName)) { for (ConceptSource conceptSource : conceptSources) { resultTerms.addAll(conceptService.getConceptReferenceTerms(codeOrName, conceptSource, context.getStartIndex(), context.getLimit(), context.getIncludeAll())); count += conceptService.getCountOfConceptReferenceTerms(codeOrName, conceptSource, context.getIncludeAll()); } } else { for (ConceptSource conceptSource : conceptSources) { resultTerms.addAll(conceptService.getConceptReferenceTerms(null, conceptSource, context.getStartIndex(), context.getLimit(), context.getIncludeAll())); count += conceptService.getCountOfConceptReferenceTerms(null, conceptSource, context.getIncludeAll()); } } if (resultTerms.isEmpty()){ return new EmptySearchResult(); } else { boolean hasMore = count > (context.getStartIndex() + context.getLimit()); List<ConceptReferenceTerm> listResult = new ArrayList<ConceptReferenceTerm>(); listResult.addAll(resultTerms); return new AlreadyPaged<ConceptReferenceTerm>(context, listResult, hasMore); } }

Target:
private PageableResult searchStartsWith(RequestContext context, String codeOrName, List<ConceptSource> conceptSources){ Set<ConceptReferenceTerm> resultTerms = new LinkedHashSet<ConceptReferenceTerm>(); int count = 0; if (StringUtils.isNotEmpty(codeOrName)) { for (ConceptSource conceptSource : conceptSources) { resultTerms.addAll(conceptService.getConceptReferenceTerms(codeOrName, conceptSource, context.getStartIndex(), context.getLimit(), context.getIncludeAll())); count += conceptService.getCountOfConceptReferenceTerms(codeOrName, conceptSource, context.getIncludeAll()); } } else { for (ConceptSource conceptSource : conceptSources) { resultTerms.addAll(conceptService.getConceptReferenceTerms(null, conceptSource, context.getStartIndex(), context.getLimit(), context.getIncludeAll())); count += conceptService.getCountOfConceptReferenceTerms(null, conceptSource, context.getIncludeAll()); } } if (resultTerms.isEmpty()){ return new EmptySearchResult(); } else { boolean hasMore = count > (context.getStartIndex() + context.getLimit()); List<ConceptReferenceTerm> listResult = new ArrayList<ConceptReferenceTerm>(); listResult.addAll(resultTerms); return new AlreadyPaged<ConceptReferenceTerm>(context, listResult, hasMore); } }
Source:
private JSONObject leadSectionPayload(Page page) { SparseArray<String> localizedStrings = localizedStrings(page); try { return new JSONObject() .put("sequence", currentSequenceNum) .put("title", page.getDisplayTitle()) .put("section", page.getSections().get(0).toJSON()) .put("string_page_similar_titles", localizedStrings.get(R.string.page_similar_titles)) .put("string_page_issues", localizedStrings.get(R.string.button_page_issues)) .put("string_table_infobox", localizedStrings.get(R.string.table_infobox)) .put("string_table_other", localizedStrings.get(R.string.table_other)) .put("string_table_close", localizedStrings.get(R.string.table_close)) .put("string_expand_refs", localizedStrings.get(R.string.expand_refs)) .put("isBeta", app.getReleaseType() != RELEASE_PROD) .put("siteLanguage", model.getTitle().getSite().getLanguageCode()) .put("isMainPage", page.isMainPage()) .put("apiLevel", Build.VERSION.SDK_INT); } catch (JSONException e) { throw new RuntimeException(e); } }

Target:
private JSONObject leadSectionPayload(Page page) { SparseArray<String> localizedStrings = localizedStrings(page); try { return new JSONObject() .put("sequence", currentSequenceNum) .put("title", page.getDisplayTitle()) .put("section", page.getSections().get(0).toJSON()) .put("string_page_similar_titles", localizedStrings.get(R.string.page_similar_titles)) .put("string_page_issues", localizedStrings.get(R.string.button_page_issues)) .put("string_table_infobox", localizedStrings.get(R.string.table_infobox)) .put("string_table_other", localizedStrings.get(R.string.table_other)) .put("string_table_close", localizedStrings.get(R.string.table_close)) .put("string_expand_refs", localizedStrings.get(R.string.expand_refs)) .put("isBeta", app.isPreProdRelease()) .put("siteLanguage", model.getTitle().getSite().getLanguageCode()) .put("isMainPage", page.isMainPage()) .put("apiLevel", Build.VERSION.SDK_INT); } catch (JSONException e) { throw new RuntimeException(e); } }
Source:
public void testApplication() throws Exception { try { LocalMode lma = LocalMode.newInstance(); lma.prepareDAG(new ThroughputBasedApplication(), getConfig()); LocalMode.Controller lc = lma.getController(); lc.runAsync(); while (!checkFilesCopied(numFiles)) { System.out.println("Waiting for files to get copied."); Thread.sleep(1000); } verifyCopiedData(); } catch (ConstraintViolationException e) { Assert.fail("constraint violations: " + e.getConstraintViolations()); } }

Target:
public void testApplication() throws Exception { try { LocalMode lma = LocalMode.newInstance(); lma.prepareDAG(new ThroughputBasedApplication(), getConfig()); LocalMode.Controller lc = lma.getController(); lc.runAsync(); while (!checkFilesCopied(numFiles)) { System.out.println("Waiting for files to get copied."); Thread.sleep(1000); } lc.shutdown(); verifyCopiedData(); } catch (ConstraintViolationException e) { Assert.fail("constraint violations: " + e.getConstraintViolations()); } }
Source:
private Map<Method, Handler> methodHandlersFor(Class<?> sqlObjectType, Handlers registry, HandlerDecorators decorators) { return handlersCache.computeIfAbsent(sqlObjectType, type -> { final Map<Method, Handler> handlers = new HashMap<>(); handlers.putAll(handlerEntry((t, a, h) -> sqlObjectType.getName() + '@' + Integer.toHexString(t.hashCode()), Object.class, "toString")); handlers.putAll(handlerEntry((t, a, h) -> t == a[0], Object.class, "equals", Object.class)); handlers.putAll(handlerEntry((t, a, h) -> System.identityHashCode(t), Object.class, "hashCode")); handlers.putAll(handlerEntry((t, a, h) -> h.getHandle(), SqlObject.class, "getHandle")); try { handlers.putAll(handlerEntry((t, a, h) -> null, sqlObjectType, "finalize")); } catch (IllegalStateException expected) { } for (Method method : sqlObjectType.getMethods()) { if (Modifier.isStatic(method.getModifiers())) { continue; } handlers.computeIfAbsent(method, m -> buildMethodHandler(sqlObjectType, m, registry, decorators)); } handlers.keySet().stream() .filter(m -> !m.isSynthetic()) .collect(Collectors.groupingBy(m -> Arrays.asList(m.getName(), Arrays.asList(m.getParameterTypes())))) .values() .stream() .filter(l -> l.size() > 1) .findAny() .ifPresent(ms -> { throw new UnableToCreateSqlObjectException(sqlObjectType + " has ambiguous methods " + ms); }); return handlers; }); }

Target:
private Map<Method, Handler> methodHandlersFor(Class<?> sqlObjectType, Handlers registry, HandlerDecorators decorators) { return handlersCache.computeIfAbsent(sqlObjectType, type -> { final Map<Method, Handler> handlers = new HashMap<>(); handlers.putAll(handlerEntry((t, a, h) -> sqlObjectType.getName() + '@' + Integer.toHexString(t.hashCode()), Object.class, "toString")); handlers.putAll(handlerEntry((t, a, h) -> t == a[0], Object.class, "equals", Object.class)); handlers.putAll(handlerEntry((t, a, h) -> System.identityHashCode(t), Object.class, "hashCode")); handlers.putAll(handlerEntry((t, a, h) -> h.getHandle(), SqlObject.class, "getHandle")); try { handlers.putAll(handlerEntry((t, a, h) -> null, sqlObjectType, "finalize")); } catch (IllegalStateException expected) { } for (Method method : sqlObjectType.getMethods()) { if (Modifier.isStatic(method.getModifiers())) { continue; } handlers.computeIfAbsent(method, m -> buildMethodHandler(sqlObjectType, m, registry, decorators)); } handlers.keySet().stream() .filter(m -> !m.isSynthetic()) .collect(Collectors.groupingBy(m -> Arrays.asList(m.getName(), Arrays.asList(m.getParameterTypes())))) .values() .stream() .filter(l -> l.size() > 1) .findAny() .ifPresent(ms -> { throw new UnableToCreateSqlObjectException(sqlObjectType + " has ambiguous methods " + ms + ", please resolve with an explicit override"); }); return handlers; }); }
Source:
public void forEach(IntConsumer action) { if (action instanceof CacheAware) { ((CacheAware) action).injectCache(registry.getComponent(Cache.class)); } createStream().forEach(action); }

Target:
public void forEach(IntConsumer action) { injectCache(action); createStream().forEach(action); }
Source:
public String asString() { return value; }

Target:
public String asString() { return StringEscapeUtils.unescapeJava(value); }
Source:
private void readManifest(final URL url) throws IOException { try (InputStream is = url.openStream()) { if (is != null) { final Manifest mf = new Manifest(); mf.read(is); final Attributes atts = mf.getMainAttributes(); Optional.ofNullable(atts.getValue(Attributes.Name.IMPLEMENTATION_TITLE)).ifPresent(t -> LOG.debug("Implementation Title: {}", t)); Optional.ofNullable(atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION)).ifPresent(t -> LOG.debug("Implementation Version: {}", t)); Optional.ofNullable(atts.getValue(COMMIT)).ifPresent(t -> LOG.debug("Git commit: {}", t)); } } }

Target:
private void readManifest(final URL url) throws IOException { try (InputStream is = url.openStream()) { final Manifest mf = new Manifest(); mf.read(is); final Attributes atts = mf.getMainAttributes(); LOG.debug("Starting up: version - built from commit {}", atts.getValue(Attributes.Name.IMPLEMENTATION_TITLE), atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION), atts.getValue(COMMIT) ); } }
Source:
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { current.setNode(qName); if (current.isEntryNode()) { vendor = null; product = null; hasPreviousVersion = false; final String reject = attributes.getValue("reject"); skip = "1".equals(reject); if (!skip) { vulnerability = attributes.getValue("name"); software = new ArrayList<VulnerableSoftware>(); } else { vulnerability = null; software = null; } } else if (!skip && current.isProdNode()) { vendor = attributes.getValue("vendor"); product = attributes.getValue("name"); } else if (!skip && current.isVersNode()) { final String prev = attributes.getValue("prev"); if (prev != null && "1".equals(prev)) { hasPreviousVersion = true; final String edition = attributes.getValue("edition"); final String num = attributes.getValue("num"); final StringBuilder cpe = new StringBuilder(); cpe.append("cpe:/a:").append(vendor).append(':').append(product); if (num != null) { cpe.append(':').append(num); } if (edition != null) { cpe.append(':').append(edition); } final VulnerableSoftware vs = new VulnerableSoftware(); vs.setCpe(cpe.toString()); vs.setPreviousVersion(prev); software.add(vs); } } else if (current.isNVDNode()) { final String nvdVer = attributes.getValue("nvd_xml_version"); if (!CURRENT_SCHEMA_VERSION.equals(nvdVer)) { throw new SAXNotSupportedException("Schema version " + nvdVer + " is not supported"); } vulnerabilities = new HashMap<String, List<VulnerableSoftware>>(); } }

Target:
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { current.setNode(qName); if (current.isEntryNode()) { vendor = null; product = null; hasPreviousVersion = false; final String reject = attributes.getValue("reject"); skip = "1".equals(reject); if (!skip) { vulnerability = attributes.getValue("name"); software = new ArrayList<VulnerableSoftware>(); } else { vulnerability = null; software = null; } } else if (!skip && current.isProdNode()) { vendor = attributes.getValue("vendor"); product = attributes.getValue("name"); } else if (!skip && current.isVersNode()) { final String prev = attributes.getValue("prev"); if (prev != null && "1".equals(prev)) { hasPreviousVersion = true; final String edition = attributes.getValue("edition"); final String num = attributes.getValue("num"); final int cpeLen = 8 + vendor.length() + product.length() + (null != num ? (1 + num.length()) : 0) + (null != edition ? (1 + edition.length()) : 0); final StringBuilder cpe = new StringBuilder(cpeLen); cpe.append("cpe:/a:").append(vendor).append(':').append(product); if (num != null) { cpe.append(':').append(num); } if (edition != null) { cpe.append(':').append(edition); } final VulnerableSoftware vs = new VulnerableSoftware(); vs.setCpe(cpe.toString()); vs.setPreviousVersion(prev); software.add(vs); } } else if (current.isNVDNode()) { final String nvdVer = attributes.getValue("nvd_xml_version"); if (!CURRENT_SCHEMA_VERSION.equals(nvdVer)) { throw new SAXNotSupportedException("Schema version " + nvdVer + " is not supported"); } vulnerabilities = new HashMap<String, List<VulnerableSoftware>>(); } }
Source:
public JLoadScenario jaagerSmokeTest() { return new JaggerSmokeTest().jTestSuites(); }

Target:
public JLoadScenario jaagerSmokeTest() { return new JaggerSmokeTest().getJaggerScenario(); }
Source:
private void resolveGetterConflicts(Map<String, List<Method>> conflictingGetters) { for (Entry<String, List<Method>> entry : conflictingGetters.entrySet()) { Method winner = null; String propName = entry.getKey(); boolean isAmbiguous = false; for (Method candidate : entry.getValue()) { if (winner == null) { winner = candidate; continue; } Class<?> winnerType = winner.getReturnType(); Class<?> candidateType = candidate.getReturnType(); if (candidateType.equals(winnerType)) { if (!boolean.class.equals(candidateType)) { isAmbiguous = true; break; } else if (candidate.getName().startsWith("is")) { winner = candidate; } } else if (candidateType.isAssignableFrom(winnerType)) { } else if (winnerType.isAssignableFrom(candidateType)) { winner = candidate; } else { isAmbiguous = true; break; } } if (winner != null) { addGetMethod(propName, winner, isAmbiguous); } } }

Target:
private void resolveGetterConflicts(Map<String, List<Method>> conflictingGetters) { for (Entry<String, List<Method>> entry : conflictingGetters.entrySet()) { Method winner = null; String propName = entry.getKey(); boolean isAmbiguous = false; for (Method candidate : entry.getValue()) { if (winner == null) { winner = candidate; continue; } Class<?> winnerType = winner.getReturnType(); Class<?> candidateType = candidate.getReturnType(); if (candidateType.equals(winnerType)) { if (!boolean.class.equals(candidateType)) { isAmbiguous = true; break; } else if (candidate.getName().startsWith("is")) { winner = candidate; } } else if (candidateType.isAssignableFrom(winnerType)) { } else if (winnerType.isAssignableFrom(candidateType)) { winner = candidate; } else { isAmbiguous = true; break; } } addGetMethod(propName, winner, isAmbiguous); } }
Source:
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String annotationName, boolean runtimeVisible) { if (typePath != null) { if (typeRef == 335544320) { discoverer.startMethodTypeAnnotation(methodName, typePath.toString(), methodSignatureMap.get(ASMModParser.EnumMethodAdditionalInfo.RETURN_VALUE_TYPE).get(typePath.toString()), annotationName, ASMModParser.EnumMethodAdditionalInfo.RETURN_VALUE_TYPE); return new ModAnnotationVisitor(discoverer); } else if (typeRef == 369098752) { discoverer.startMethodTypeAnnotation(methodName, typePath.toString(), methodSignatureMap.get(ASMModParser.EnumMethodAdditionalInfo.PARAMETER_TYPE).get(typePath.toString()), annotationName, ASMModParser.EnumMethodAdditionalInfo.PARAMETER_TYPE); return new ModAnnotationVisitor(discoverer); } return null; } else { return null; } }

Target:
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String annotationName, boolean runtimeVisible) { if (typePath != null) { if (typeRef == TypeReference.newTypeReference(TypeReference.METHOD_RETURN).getValue()) { discoverer.startMethodTypeAnnotation(methodName, typePath.toString(), methodSignatureMap.get(TypeReference.METHOD_RETURN).get(typePath.toString()), annotationName, "METHOD_RETURN"); return new ModAnnotationVisitor(discoverer); } else if (typeRef == TypeReference.newTypeReference(TypeReference.METHOD_FORMAL_PARAMETER).getValue()) { discoverer.startMethodTypeAnnotation(methodName, typePath.toString(), methodSignatureMap.get(TypeReference.METHOD_FORMAL_PARAMETER).get(typePath.toString()), annotationName, "METHOD_FORMAL_PARAMETER"); return new ModAnnotationVisitor(discoverer); } return null; } else { return null; } }
Source:
protected String getYesterdayHttpDate(Calendar calendar) { calendar.add(Calendar.DAY_OF_MONTH, -1); SimpleDateFormat dateFormat = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone(GMT)); return dateFormat.format(calendar.getTime()); }

Target:
protected String getYesterdayHttpDate(Calendar calendar) { calendar.add(Calendar.DAY_OF_MONTH, -1); return formatUsLocaleGMTZone(calendar); }
Source:
public static boolean isDefaultName(String name) { if (name != null) { return false; } else if (name.equals(DEFAULT_NAME)) { return false; } else if (name.equals("(Default)")) { return false; } return true; }

Target:
public static boolean isDefaultName(String name) { if ("(Default)".equals(name)) { return true; } return DEFAULT_NAME.equals(name); }
Source:
private void writeConfig(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) throws KuraException { String interfaceName = netInterfaceConfig.getName(); List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig .getNetInterfaceAddresses(); if (netInterfaceAddressConfigs != null && !netInterfaceAddressConfigs.isEmpty()) { for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) { if (netInterfaceAddressConfig instanceof WifiInterfaceAddressConfigImpl) { List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs(); NetInterfaceStatus netInterfaceStatus = NetInterfaceStatus.netIPv4StatusDisabled; WifiConfig apConfig = null; String interfaceDriver = null; if (netConfigs != null) { for (NetConfig netConfig : netConfigs) { try { if (netConfig instanceof WifiConfig) { if (((WifiConfig) netConfig).getMode() == WifiMode.MASTER) { logger.debug("Found wifiConfig with mode set to master"); interfaceDriver = ((WifiConfig) netConfig).getDriver(); if (interfaceDriver != null) { logger.debug("Writing wifiConfig: {}", netConfig); apConfig = (WifiConfig) netConfig; } else { logger.error("Can't generate hostapd config - no driver specified"); } } } else if (netConfig instanceof NetConfigIP4) { netInterfaceStatus = ((NetConfigIP4) netConfig).getStatus(); } } catch (Exception e) { logger.error("Failed to configure Hostapd"); throw KuraException.internalError(e); } } if (netInterfaceStatus == NetInterfaceStatus.netIPv4StatusDisabled || netInterfaceStatus == NetInterfaceStatus.netIPv4StatusUnmanaged) { logger.info( "Network interface status for is - not overwriting hostapd configuration file", interfaceName, netInterfaceStatus); return; } if (apConfig != null) { try { generateHostapdConf(apConfig, interfaceName, interfaceDriver); } catch (Exception e) { logger.error("Failed to generate hostapd configuration file for interface", interfaceName); throw KuraException.internalError(e); } } } } } } }

Target:
private void writeConfig(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) throws KuraException { if (netInterfaceConfig == null) { return; } List<NetConfig> netConfigs = ((AbstractNetInterface<?>) netInterfaceConfig).getNetConfigs(); if (netConfigs.isEmpty()) { return; } String interfaceName = netInterfaceConfig.getName(); WifiConfig apConfig = getAccessPointConfig(netConfigs); NetInterfaceStatus netInterfaceStatus = getNetInterfaceStatus(netConfigs); if (!isInterfaceEnabled(netInterfaceStatus)) { logger.info("Network interface status for is - not overwriting hostapd configuration file", interfaceName, netInterfaceStatus); return; } if (apConfig != null) { try { generateHostapdConf(apConfig, interfaceName); } catch (Exception e) { logger.error("Failed to generate hostapd configuration file for interface", interfaceName); throw KuraException.internalError(e); } } }
Source:
public static RealVector convertINDArrayToApacheVector(@Nonnull final INDArray vector) { if (!vector.isVector()) { throw new IllegalArgumentException("Input INDArray is not a vector."); } final int length = vector.length(); final RealVector out = new ArrayRealVector(length); for (int i=0; i<length; i++) { out.setEntry(i, vector.getDouble(i)); } return out; }

Target:
public static RealVector convertINDArrayToApacheVector(@Nonnull final INDArray vector) { Utils.validateArg(vector.isVector(), "Input INDArray is not a vector."); return new ArrayRealVector(vector.isView() ? vector.dup().data().asDouble() : vector.data().asDouble(), false); }
Source:
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { try{ Session session = request.getResourceResolver().adaptTo(Session.class); final String vanityPath = request.getParameter("vanityPath"); final String pagePath = request.getParameter("pagePath"); try { QueryManager qm = session.getWorkspace().getQueryManager(); String xpath = " Query query = qm.createQuery(xpath, Query.XPATH); logger.debug("Xpath Query Statement is {}", query.getStatement()); QueryResult result = query.execute(); NodeIterator nodes = result.getNodes(); TidyJSONWriter tidyJSONWriter = new TidyJSONWriter(response.getWriter()); tidyJSONWriter.object(); tidyJSONWriter.key("vanitypaths").array(); response.setContentType("text/html"); while (nodes.hasNext()) { Node node = nodes.nextNode(); if(node != null && node.getPath().contains("/content")) { if(node.getPath().equals(pagePath)) { } else { tidyJSONWriter.value(node.getPath()); } } } tidyJSONWriter.endArray(); tidyJSONWriter.endObject(); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); } catch(RepositoryException re){ logger.error( "Error in doGet", re ); } } catch (JSONException e) { logger.error( "Error in doGet", e ); } }

Target:
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { try{ Session session = request.getResourceResolver().adaptTo(Session.class); final String vanityPath = request.getParameter("vanityPath"); final String pagePath = request.getParameter("pagePath"); try { QueryManager qm = session.getWorkspace().getQueryManager(); String xpath = " Query query = qm.createQuery(xpath, Query.XPATH); log.debug("Xpath Query Statement is {}", query.getStatement()); QueryResult result = query.execute(); NodeIterator nodes = result.getNodes(); TidyJSONWriter tidyJSONWriter = new TidyJSONWriter(response.getWriter()); tidyJSONWriter.object(); tidyJSONWriter.key("vanitypaths").array(); while (nodes.hasNext()) { Node node = nodes.nextNode(); if(node != null && node.getPath().startsWith("/content")) { if(node.getPath().equals(pagePath)) { } else { tidyJSONWriter.value(node.getPath()); } } } tidyJSONWriter.endArray(); tidyJSONWriter.endObject(); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); } catch(RepositoryException re){ log.error( "Error in doGet", re ); } } catch (JSONException e) { log.error( "Error in doGet", e ); } }
Source:
public static void main(String[] args) throws Exception { FProtocolFactory protocolFactory = new FProtocolFactory(new TBinaryProtocol.Factory()); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); Connection connection = connectionFactory.createConnection(); connection.start(); FSubscriberTransportFactory subscriberFactory = new FJmsSubscriberTransport.Factory(connection, "Consumer.frugal-examples.VirtualTopic."); FScopeProvider provider = new FScopeProvider(null, subscriberFactory, protocolFactory); AlbumWinnersSubscriber.Iface subscriber = new AlbumWinnersSubscriber.Client(provider); subscriber.subscribeWinner((ctx, album) -> System.out.println("You won! " + album)); subscriber.subscribeContestStart((ctx, albums) -> System.out.println("Contest started, available albums: " + albums)); System.out.println("Subscriber started..."); }

Target:
public static void main(String[] args) throws Exception { FProtocolFactory protocolFactory = new FProtocolFactory(new TBinaryProtocol.Factory()); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); Connection connection = connectionFactory.createConnection(); connection.start(); FSubscriberTransportFactory subscriberFactory = new FJmsSubscriberTransport.Factory(connection, "Consumer.frugal-examples.VirtualTopic.", true); FScopeProvider provider = new FScopeProvider(null, subscriberFactory, protocolFactory); AlbumWinnersSubscriber.Iface subscriber = new AlbumWinnersSubscriber.Client(provider); subscriber.subscribeWinner((ctx, album) -> System.out.println("You won! " + album)); subscriber.subscribeContestStart((ctx, albums) -> System.out.println("Contest started, available albums: " + albums)); System.out.println("Subscriber started..."); }
Source:
default String getFactsString() { return String.join(", ", Arrays.stream(getFacts()) .map(o -> (o == null) ? null : o.toString()) .toArray(CharSequence[]::new)); }

Target:
default String getFactsString() { return Arrays.stream(getFacts()) .map(o -> (o == null) ? null : o.toString()) .collect(Collectors.joining(", ")); }
Source:
private void onSave() { if (getProgress() != null) { return; } if (!validate()) { return; } flush(); startProgress(null); Frontend.getInstance().runAction(VdcActionType.AddSubnetToProvider, new AddExternalSubnetParameters(subnet, getNetwork().getSelectedItem().getId()), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { VdcReturnValueBase returnValue = result.getReturnValue(); stopProgress(); if (returnValue != null && returnValue.getSucceeded()) { cancel(); } } }, this, true); }

Target:
private void onSave() { if (!validate()) { return; } flush(); startProgress(null); Frontend.getInstance().runAction(VdcActionType.AddSubnetToProvider, new AddExternalSubnetParameters(subnet, getNetwork().getSelectedItem().getId()), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { VdcReturnValueBase returnValue = result.getReturnValue(); stopProgress(); if (returnValue != null && returnValue.getSucceeded()) { cancel(); } } }, this, true); }
Source:
public void load(@Nonnull NamespacedKey namespace, @Nonnull ItemStack itemStack) { reset(); if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { return; } final ItemMeta meta = itemStack.getItemMeta(); if (meta != null) { load(namespace, meta); } }

Target:
public void load(@Nonnull NamespacedKey namespace, @Nonnull ItemStack itemStack) { clear(); if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { return; } ItemMeta meta; if (itemStack.hasItemMeta() && (meta = itemStack.getItemMeta()) != null) { load(namespace, meta); } }
Source:
public static <T> QosClient.QueryWeigher<T> readWeigher(Function<T, Long> bytesRead, Function<T, Integer> numRows) { return new QosClient.QueryWeigher<T>() { @Override public QueryWeight estimate() { return DEFAULT_ESTIMATED_WEIGHT; } @Override public QueryWeight weigh(T result, long timeTakenNanos) { return ImmutableQueryWeight.builder() .numBytes(safeGetNumBytesOrDefault(() -> bytesRead.apply(result))) .timeTakenNanos((int) timeTakenNanos) .numDistinctRows(numRows.apply(result)) .build(); } }; }

Target:
public static <T> QosClient.QueryWeigher<T> readWeigher(Function<T, Long> bytesRead, Function<T, Integer> numRows) { return new QosClient.QueryWeigher<T>() { @Override public QueryWeight estimate() { return DEFAULT_ESTIMATED_WEIGHT; } @Override public QueryWeight weigh(T result, long timeTakenNanos) { return ImmutableQueryWeight.builder() .numBytes(safeGetNumBytesOrDefault(() -> bytesRead.apply(result))) .timeTakenNanos(timeTakenNanos) .numDistinctRows(numRows.apply(result)) .build(); } }; }
Source:
private ByteBuf retain0(final int increment) { int adjustIncrement = increment << 1; int oldRef = refCntUpdater.getAndAdd(this, adjustIncrement); if ((oldRef & 1) != 0) { throw new IllegalReferenceCountException(0, increment); } else if (oldRef <= 0 ? oldRef + adjustIncrement > 0 : oldRef + adjustIncrement < oldRef) { refCntUpdater.getAndAdd(this, -increment); throw new IllegalReferenceCountException(realRef(oldRef), increment); } return this; }

Target:
private ByteBuf retain0(final int increment) { int adjustedIncrement = increment << 1; int oldRef = refCntUpdater.getAndAdd(this, adjustedIncrement); if ((oldRef & 1) != 0) { throw new IllegalReferenceCountException(0, increment); } if ((oldRef <= 0 && oldRef + adjustedIncrement >= 0) || (oldRef >= 0 && oldRef + adjustedIncrement < oldRef)) { refCntUpdater.getAndAdd(this, -adjustedIncrement); throw new IllegalReferenceCountException(realRefCnt(oldRef), increment); } return this; }
Source:
public static Property getPropertyDefinitionInWorkspace(String pdname) { Injector injector = IResourceServiceProvider.Registry.INSTANCE .getResourceServiceProvider(URI.createFileURI("dummy.aadl")).get(Injector.class); final ResourceDescriptionsProvider resourceDescriptionsProvider = injector .getInstance(ResourceDescriptionsProvider.class); final IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider .getResourceDescriptions(OsateResourceUtil.getResourceSet()); for (IEObjectDescription eobjDesc : resourceDescriptions .getExportedObjectsByType(Aadl2Package.eINSTANCE.getProperty())) { if (eobjDesc.getName().toString("::").equalsIgnoreCase(pdname)) { EObject res = eobjDesc.getEObjectOrProxy(); res = EcoreUtil.resolve(res, OsateResourceUtil.getResourceSet()); if (!Aadl2Util.isNull(res)) { return (Property) res; } } } throw new TbException( "Error: " + pdname + " does not correspond to any " + "system implementation in the workspace.\n"); }

Target:
public static Property getPropertyDefinitionInWorkspace(String pdname) { Injector injector = IResourceServiceProvider.Registry.INSTANCE .getResourceServiceProvider(URI.createFileURI("dummy.aadl")).get(Injector.class); final ResourceDescriptionsProvider resourceDescriptionsProvider = injector .getInstance(ResourceDescriptionsProvider.class); final IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider .getResourceDescriptions(new XtextResourceSet()); for (IEObjectDescription eobjDesc : resourceDescriptions .getExportedObjectsByType(Aadl2Package.eINSTANCE.getProperty())) { if (eobjDesc.getName().toString("::").equalsIgnoreCase(pdname)) { EObject res = eobjDesc.getEObjectOrProxy(); res = EcoreUtil.resolve(res, OsateResourceUtil.getResourceSet()); if (!Aadl2Util.isNull(res)) { return (Property) res; } } } throw new TbException( "Error: " + pdname + " does not correspond to any " + "system implementation in the workspace.\n"); }
Source:
public void testLockedStreamTxInsideConsumer() { for (int i = 0; i < 5; i++) { cache.put(i, "value" + i); } cache.getAdvancedCache().lockedStream().forEach((c, e) -> { TransactionManager tm = c.getAdvancedCache().getTransactionManager(); try { tm.begin(); c.put(e.getKey(), e.getValue() + "-changed"); tm.commit(); } catch (Exception e1) { throw new RuntimeException(e1); } }); for (int i = 0; i < 5; i++) { assertEquals("value" + i + "-changed", cache.get(i)); } }

Target:
public void testLockedStreamTxInsideConsumer() { for (int i = 0; i < 5; i++) { cache.put(i, "value" + i); } cache.getAdvancedCache().lockedStream().forEach((c, e) -> { try { TestingUtil.withTx(c.getAdvancedCache().getTransactionManager(), () -> c.put(e.getKey(), e.getValue() + "-changed")); } catch (Exception e1) { throw new RuntimeException(e1); } }); for (int i = 0; i < 5; i++) { assertEquals("value" + i + "-changed", cache.get(i)); } }
Source:
public DBSSession(DBSRepository repository) { this.repository = repository; transaction = new DBSTransactionState(repository, this); FulltextConfiguration fulltextConfiguration = repository.getFulltextConfiguration(); fulltextSearchDisabled = fulltextConfiguration == null || fulltextConfiguration.fulltextSearchDisabled; saveTimer = registry.timer(MetricRegistry.name("nuxeo", "repositories", repository.getName(), "saves")); queryTimer = registry.timer(MetricRegistry.name("nuxeo", "repositories", repository.getName(), "queries")); LOG_MIN_DURATION_NS = Long.parseLong(Framework.getProperty(LOG_MIN_DURATION_KEY, "-1")) * 1000000; isLatestVersionDisabled = Boolean.parseBoolean(Framework.getProperty(DISABLED_ISLATESTVERSION_PROPERTY, "false")); }

Target:
public DBSSession(DBSRepository repository) { this.repository = repository; transaction = new DBSTransactionState(repository, this); FulltextConfiguration fulltextConfiguration = repository.getFulltextConfiguration(); fulltextSearchDisabled = fulltextConfiguration == null || fulltextConfiguration.fulltextSearchDisabled; saveTimer = registry.timer(MetricRegistry.name("nuxeo", "repositories", repository.getName(), "saves")); queryTimer = registry.timer(MetricRegistry.name("nuxeo", "repositories", repository.getName(), "queries")); LOG_MIN_DURATION_NS = Long.parseLong(Framework.getProperty(LOG_MIN_DURATION_KEY, "-1")) * 1000000; isLatestVersionDisabled = Framework.isBooleanPropertyTrue(DISABLED_ISLATESTVERSION_PROPERTY); }
Source:
public void shouldNotChangeProjectAndTitleWhenContextChange() throws Exception { presenter.changeProjectAndTitleWhenContextChange(new WorkspaceProjectContextChangeEvent() { @Override public WorkspaceProject getWorkspaceProject() { return null; } }); verify(view, never()).setTitle("module name"); }

Target:
public void shouldNotChangeProjectAndTitleWhenContextChange() throws Exception { presenter.changeProjectAndTitleWhenContextChange(new WorkspaceProjectContextChangeEvent() { @Override public WorkspaceProject getWorkspaceProject() { return null; } }); verify(view, never()).setTitle(any()); }