auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void aggregate() { <START> Object value = selector.get(); <END> if (HllAggregatorFactory.context == HllAggregatorFactory.CONTEXT.COMPLEX) { String k = (String) ((AbstractList) value).get(0); byte[] ibmapByte = Base64.decodeBase64(k); TIntByteHashMap newIbMap; ByteBuffer buffer = ByteBuffer.wrap(ibmapByte); int keylength = buffer.getInt(); int valuelength = buffer.getInt(); if (keylength == 0) { newIbMap = new TIntByteHashMap(); } else { int[] keys = new int[keylength]; byte[] values = new byte[valuelength]; for (int i = 0; i < keylength; i++) { keys[i] = buffer.getInt(); } buffer.get(values); newIbMap = new TIntByteHashMap(keys, values); } int[] indexes = newIbMap.keys(); for (int i = 0; i < indexes.length; i++) { int index_i = indexes[i]; if (ibMap.get(index_i) == ibMap.getNoEntryValue() || newIbMap.get(index_i) > ibMap.get(index_i)) { ibMap.put(index_i, newIbMap.get(index_i)); } } } else { long id = Hashing .murmur3_128() .hashString((String) ((AbstractList) selector.get()).get(0)) .asLong(); final int bucket = (int) (id >>> (Long.SIZE - log2m)); final int zerolength = Long.numberOfLeadingZeros((id << log2m) | (1 << (log2m - 1)) + 1) + 1; if (ibMap.get(bucket) == ibMap.getNoEntryValue() || ibMap.get(bucket) < (byte) zerolength) ibMap.put(bucket, (byte) zerolength); } }</code><technical_language>is a list a single item? is a list a string</technical_language>

Target:
public void aggregate() { Object value = selector.get(); log.info("class name:"+value.getClass()+":value "+value); if (value instanceof TIntByteHashMap) { TIntByteHashMap newIbMap = (TIntByteHashMap) value; int[] indexes = newIbMap.keys(); for (int i = 0; i < indexes.length; i++) { int index_i = indexes[i]; if (ibMap.get(index_i) == ibMap.getNoEntryValue() || newIbMap.get(index_i) > ibMap.get(index_i)) { ibMap.put(index_i, newIbMap.get(index_i)); } } } else { log.info("value "+ selector.get() ); long id = Hashing .murmur3_128() .hashString((String) (selector.get())) .asLong(); final int bucket = (int) (id >>> (Long.SIZE - log2m)); final int zerolength = Long.numberOfLeadingZeros((id << log2m) | (1 << (log2m - 1)) + 1) + 1; if (ibMap.get(bucket) == ibMap.getNoEntryValue() || ibMap.get(bucket) < (byte) zerolength) ibMap.put(bucket, (byte) zerolength); } }
Source:
<code>public Mono<Instant> renewMessageLock(ServiceBusReceivedMessage receivedMessage) { return connectionProcessor .flatMap(connection -> connection.getManagementNode(entityPath)) .flatMap(serviceBusManagementNode -> { return serviceBusManagementNode .renewMessageLock(receivedMessage) <START> .doOnNext(instant -> { <END> receivedMessage.setLockedUntil(instant); }); }); }</code><technical_language>Do next for side effects logging. force part of pipeline, map</technical_language>

Target:
public Mono<Instant> renewMessageLock(ServiceBusReceivedMessage receivedMessage) { return connectionProcessor .flatMap(connection -> connection.getManagementNode(entityPath, entityType)) .flatMap(serviceBusManagementNode -> { return serviceBusManagementNode .renewMessageLock(receivedMessage) .map(instant -> { receivedMessage.setLockedUntil(instant); return instant; }); }); }
Source:
<code><START> private static void encodeArgumentWithSpecialCharactersForWindows(String str, StringBuilder builder) { <END> builder.append("\""); for (int j = 0; j < str.length(); j++) { char c = str.charAt(j); if (c == '\"') { builder.append(c); } builder.append(c); } builder.append("\""); }</code><technical_language>This longer calls sanitizer, is right? is UNIX code wrong</technical_language>

Target:
private static void encodeArgumentWithSpecialCharactersForWindows(String str, StringBuilder builder) { builder.append("\""); builder.append(WindowsCommandLineArgsSanitizer.sanitize(str)); builder.append("\""); }
Source:
<code><START> public static boolean setEnablement(String property, boolean val) { <END> synchronized (MUTEX) { boolean oldVal = isEnabled(property); FEATURE_ENABLEMENT_CACHE.put(property, val); return oldVal; } }</code><technical_language>enable(String property) disable(String property) preferred</technical_language>

Target:
public static boolean setEnablement(String property, boolean val) { synchronized (MUTEX) { boolean oldVal = isEnabled(property); FEATURE_ENABLEMENTS.put(property, val); return oldVal; } }
Source:
<code>public IYAppearance getSeriesAppearance(@NonNull String seriesName) { if (seriesName.equals(getTrace().getName())) <START> { <END> return getPresentationProvider().getAppearance(seriesName, IYAppearance.Type.LINE, DEFAULT_SERIES_WIDTH); } return getPresentationProvider().getAppearance(seriesName, IYAppearance.Type.AREA, DEFAULT_SERIES_WIDTH); }</code><technical_language>ITmfTrace trace = getTrace(); if (seriesName.equals(trace.getName()) || trace.getChild(seriesName) != null) {</technical_language>

Target:
public IYAppearance getSeriesAppearance(@NonNull String seriesName) { if (seriesName.startsWith(CpuUsageDataProvider.TOTAL)) { return getPresentationProvider().getAppearance(seriesName, IYAppearance.Type.LINE, DEFAULT_SERIES_WIDTH); } return getPresentationProvider().getAppearance(seriesName, IYAppearance.Type.AREA, DEFAULT_SERIES_WIDTH); }
Source:
<code>private Set<EventSubscriber> getEventSubscribers(String eventType) { Set<EventSubscriber> eventTypeSubscribers = typedEventSubscribers.get(eventType); Set<EventSubscriber> allEventTypeSubscribers = typedEventSubscribers.get(EventSubscriber.ALL_EVENT_TYPES); <START> Set<EventSubscriber> subscribers = new HashSet<EventSubscriber>(); <END> if (eventTypeSubscribers != null) { subscribers.addAll(eventTypeSubscribers); } if (allEventTypeSubscribers != null) { subscribers.addAll(allEventTypeSubscribers); } return subscribers; }</code><technical_language>> HashSet<>()</technical_language>

Target:
private Set<EventSubscriber> getEventSubscribers(String eventType) { Set<EventSubscriber> eventTypeSubscribers = typedEventSubscribers.get(eventType); Set<EventSubscriber> allEventTypeSubscribers = typedEventSubscribers.get(EventSubscriber.ALL_EVENT_TYPES); Set<EventSubscriber> subscribers = new HashSet<>(); if (eventTypeSubscribers != null) { subscribers.addAll(eventTypeSubscribers); } if (allEventTypeSubscribers != null) { subscribers.addAll(allEventTypeSubscribers); } return subscribers; }
Source:
<code>public void start(final Environment env) throws IOException { try { parseCommandLine(); if (Strings.isNullOrEmpty(commandName)) { StringWriter msg = new StringWriter(); msg.write(usage()); throw new UnloggedFailure(1, msg.toString()); } final CommandProvider p = commands.get(commandName); if (p == null) { <START> String msg = (getName().isEmpty() ? "Gerrit Code Review" : getName()) + ": "; msg += commandName.equals("git-receive-pack") ? "Push operation is not supported on slave" : commandName + ": not found"; <END> throw new UnloggedFailure(1, msg); } final Command cmd = p.getProvider().get(); checkRequiresCapability(cmd); if (cmd instanceof BaseCommand) { final BaseCommand bc = (BaseCommand) cmd; if (getName().isEmpty()) bc.setName(commandName); else bc.setName(getName() + " " + commandName); bc.setArguments(args.toArray(new String[args.size()])); } else if (!args.isEmpty()) { throw new UnloggedFailure(1, commandName + " does not take arguments"); } provideStateTo(cmd); atomicCmd.set(cmd); cmd.start(env); } catch (UnloggedFailure e) { String msg = e.getMessage(); if (!msg.endsWith("\n")) { msg += "\n"; } err.write(msg.getBytes(ENC)); err.flush(); onExit(e.exitCode); } }</code><technical_language>I cleaner bind implementation of a command throws this UnloggedFailure bind git-receive-pack command. DefaultCommandModule is a conditional if (!slaveMode) line 83. bind a throwing command implementation instead</technical_language>

Target:
public void start(final Environment env) throws IOException { try { parseCommandLine(); if (Strings.isNullOrEmpty(commandName)) { StringWriter msg = new StringWriter(); msg.write(usage()); throw new UnloggedFailure(1, msg.toString()); } final CommandProvider p = commands.get(commandName); if (p == null) { String msg = (getName().isEmpty() ? "Gerrit Code Review" : getName()) + ": " + commandName + ": not found"; throw new UnloggedFailure(1, msg); } final Command cmd = p.getProvider().get(); checkRequiresCapability(cmd); if (cmd instanceof BaseCommand) { final BaseCommand bc = (BaseCommand) cmd; if (getName().isEmpty()) bc.setName(commandName); else bc.setName(getName() + " " + commandName); bc.setArguments(args.toArray(new String[args.size()])); } else if (!args.isEmpty()) { throw new UnloggedFailure(1, commandName + " does not take arguments"); } provideStateTo(cmd); atomicCmd.set(cmd); cmd.start(env); } catch (UnloggedFailure e) { String msg = e.getMessage(); if (!msg.endsWith("\n")) { msg += "\n"; } err.write(msg.getBytes(ENC)); err.flush(); onExit(e.exitCode); } }
Source:
<code>public static List<RangePartition> getRangePartitions(Map<String, Object> tableProperties) { requireNonNull(tableProperties); @SuppressWarnings("unchecked") String json = (String) tableProperties.get(RANGE_PARTITIONS); if (json != null) { try { RangePartition[] partitions = mapper.readValue(json, RangePartition[].class); if (partitions == null) { return ImmutableList.of(); } <START> else { <END> return ImmutableList.copyOf(partitions); } } catch (IOException e) { throw new RuntimeException(e); } } else { return ImmutableList.of(); } }</code><technical_language>redundant else</technical_language>

Target:
public static List<RangePartition> getRangePartitions(Map<String, Object> tableProperties) { requireNonNull(tableProperties); @SuppressWarnings("unchecked") String json = (String) tableProperties.get(RANGE_PARTITIONS); if (json != null) { try { RangePartition[] partitions = mapper.readValue(json, RangePartition[].class); if (partitions == null) { return ImmutableList.of(); } return ImmutableList.copyOf(partitions); } catch (IOException e) { throw new RuntimeException(e); } } else { return ImmutableList.of(); } }
Source:
<code>private void resetSystemExports() { BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); for (BundleDescription <START> systemBundle1 : <END> systemBundles) { BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundle1; ExportPackageDescription[] exports = systemBundle.getExportPackages(); List<ExportPackageDescription> newExports = new ArrayList<>(exports.length); for (ExportPackageDescription export : exports) { if (((Integer) export.getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0) { newExports.add(export); } } addSystemExports(newExports); systemBundle.setExportPackages(newExports.toArray(new ExportPackageDescription[newExports.size()])); } }</code><technical_language>rename systemBundle rename systemBundle var systemBundleImpl</technical_language>

Target:
private void resetSystemExports() { BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); for (BundleDescription systemBundle : systemBundles) { BundleDescriptionImpl systemBundleImpl = (BundleDescriptionImpl) systemBundle; ExportPackageDescription[] exports = systemBundleImpl.getExportPackages(); List<ExportPackageDescription> newExports = new ArrayList<>(exports.length); for (ExportPackageDescription export : exports) { if (((Integer) export.getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0) { newExports.add(export); } } addSystemExports(newExports); systemBundleImpl.setExportPackages(newExports.toArray(new ExportPackageDescription[newExports.size()])); } }
Source:
<code>public void visitToken(DetailAST classDef) { <START> if (!isClass(classDef) || !shouldCheckClass(classDef)) { <END> return; } final DetailAST objBlock = classDef.findFirstToken(TokenTypes.OBJBLOCK); DetailAST child = objBlock.getFirstChild(); boolean hasNoArgCtor = false; boolean hasExplicitCtor = false; while (child != null) { if (child.getType() == TokenTypes.CTOR_DEF) { hasExplicitCtor = true; DetailAST ctorParams = child.findFirstToken(TokenTypes.PARAMETERS); if (ctorParams.getChildCount() == 0) { hasNoArgCtor = true; break; } } child = child.getNextSibling(); } if (!hasNoArgCtor && hasExplicitCtor) { log(classDef.getLineNo(), classDef.getColumnNo(), "Class must have a no-argument constructor (with any access modifier)," + " i.e. either explicit or default constructor without arguments."); } }</code><technical_language>IIUC, isClass check is redundant getDefaultTokens() ensures visiting CLASS_DEF items</technical_language>

Target:
public void visitToken(DetailAST classDef) { if (!shouldVisit(classDef)) { return; } DetailAST objBlock = classDef.findFirstToken(TokenTypes.OBJBLOCK); DetailAST child = objBlock.getFirstChild(); boolean hasExplicitCtor = false; while (child != null) { if (child.getType() == TokenTypes.CTOR_DEF) { hasExplicitCtor = true; DetailAST ctorParams = child.findFirstToken(TokenTypes.PARAMETERS); if (ctorParams.getChildCount() == 0) { return; } } child = child.getNextSibling(); } if (hasExplicitCtor) { DetailAST classIdent = classDef.findFirstToken(TokenTypes.LITERAL_CLASS).getNextSibling(); log(classIdent.getLineNo(), classIdent.getColumnNo(), "Class {0} must have a no-argument constructor (with any access modifier)." + " Alternatively, use @NoArgConstructorCheck.Disable annotation.", classIdent.getText()); } }
Source:
<code>protected void onSetUpView() { try { String currentUser = EMChatManager.getInstance().getCurrentUser(); String fromUser = message.getStringAttribute(LMConstant.EXTRA_LUCKY_MONEY_SENDER); String toUser = message.getStringAttribute(LMConstant.EXTRA_LUCKY_MONEY_RECEIVER); String senderId; if (message.direct == EMMessage.Direct.SEND) { if (message.getChatType().equals(EMMessage.ChatType.GroupChat)) { senderId = message.getStringAttribute(LMConstant.EXTRA_LUCKY_MONEY_SENDER_ID); if (senderId.equals(currentUser)) { mTvMessage.setText("你领取了自己的红包"); } else { <START> mTvMessage.setText(String.format("你领取了%s的红包", fromUser)); <END> } } else { mTvMessage.setText(String.format("你领取了%s的红包", fromUser)); } } else { mTvMessage.setText(String.format("%s领取了你的红包", toUser)); } } catch (EaseMobException e) { e.printStackTrace(); } }</code><technical_language>string.xml handle text</technical_language>

Target:
protected void onSetUpView() { try { String currentUser = EMChatManager.getInstance().getCurrentUser(); String fromUser = message.getStringAttribute(LMConstant.EXTRA_LUCKY_MONEY_SENDER); String toUser = message.getStringAttribute(LMConstant.EXTRA_LUCKY_MONEY_RECEIVER); String senderId; if (message.direct == EMMessage.Direct.SEND) { if (message.getChatType().equals(EMMessage.ChatType.GroupChat)) { senderId = message.getStringAttribute(LMConstant.EXTRA_LUCKY_MONEY_SENDER_ID); if (senderId.equals(currentUser)) { mTvMessage.setText(R.string.money_msg_take_money); } else { mTvMessage.setText(String.format(getResources().getString(R.string.money_msg_take_someone_money), fromUser)); } } else { mTvMessage.setText(String.format(getResources().getString(R.string.money_msg_take_someone_money), fromUser)); } } else { mTvMessage.setText(String.format(getResources().getString(R.string.money_msg_someone_take_money), toUser)); } } catch (EaseMobException e) { e.printStackTrace(); } }
Source:
<code><START> private static Boolean cacheGet(final CacheKey key) { <END> final LRUMap<CacheKey, Boolean> cache = SecuredItemImpl.CACHE.get(); return (cache == null) ? null : (Boolean) cache.get(key); }</code><technical_language>is reasoning for making this a static method? While is thread local this is semantically a static method</technical_language>

Target:
private Boolean cacheGet(final CacheKey key) { final LRUMap<CacheKey, Boolean> cache = SecuredItemImpl.CACHE.get(); return (cache == null) ? null : (Boolean) cache.get(key); }
Source:
<code>public void visitNode(Tree tree) { if (!hasSemantic()) { return; } if (tree.is(Tree.Kind.METHOD_INVOCATION)) { checkMethod(tree, methodMatcher -> methodMatcher.matches((MethodInvocationTree) tree)); } else if (tree.is(Tree.Kind.METHOD_REFERENCE)) { checkMethod(tree, methodMatcher -> methodMatcher.matches((MethodReferenceTree) tree)); } else { <START> checkMemberSelect((MemberSelectExpressionTree) tree); <END> } }</code><technical_language>Checking member select is enough, focus identifier. write test subscribing identifiers import static java.lang.System.in; // this raise issue class A { void foo() throws IOException { in.read(); // this raise issue well, usage of "in" } }</technical_language>

Target:
public void visitNode(Tree tree) { if (!hasSemantic()) { return; } if (tree.is(Tree.Kind.METHOD_INVOCATION) && METHOD_MATCHERS.anyMatch((MethodInvocationTree) tree)) { reportIssue(tree); } else if (tree.is(Tree.Kind.METHOD_REFERENCE) && METHOD_MATCHERS.anyMatch((MethodReferenceTree) tree)) { reportIssue(tree); } else if (tree.is(Tree.Kind.IDENTIFIER)) { checkIdentifier((IdentifierTree) tree); } }
Source:
<code>public CqlClient constructClient( TaggedMetricRegistry taggedMetricRegistry, CassandraKeyValueServiceConfig config, boolean initializeAsync) { return config.servers().accept(new CassandraServersConfigs.Visitor<CqlClient>() { @Override public CqlClient visit(CassandraServersConfigs.DefaultConfig defaultConfig) { return ThrowingCqlClientImpl.SINGLETON; } @Override public CqlClient visit(CassandraServersConfigs.CqlCapableConfig cqlCapableConfig) { if (!cqlCapableConfig.validateHosts()) { log.warn("Your CQL capable config is wrong, the hosts for CQL and Thrift are not the same, using " + "async API will result in an exception."); return ThrowingCqlClientImpl.SINGLETON; } Set<InetSocketAddress> servers = cqlCapableConfig.cqlHosts(); Cluster.Builder clusterBuilder = cqlClusterBuilderFactory.get() .addContactPointsWithPorts(servers) .withCredentials(config.credentials().username(), config.credentials().password()) .withCompression(ProtocolOptions.Compression.LZ4) .withRetryPolicy(DefaultRetryPolicy.INSTANCE) .withoutJMXReporting() .withProtocolVersion(ProtocolVersion.V3) .withThreadingOptions(new ThreadingOptions()); Cluster cluster = withLoadBalancingPolicy( withQueryOptions( withPoolingOptions( withSslOptions(clusterBuilder, config), config), config), config, <START> servers).build(); <END> return CqlClientImpl.create( taggedMetricRegistry, cluster, cqlCapableConfig.tuning(), initializeAsync); } }); }</code><technical_language>This is correct. suggest re-assigning builders variable avoid this nesting</technical_language>

Target:
public CqlClient constructClient( TaggedMetricRegistry taggedMetricRegistry, CassandraKeyValueServiceConfig config, boolean initializeAsync) { return config.servers().accept(new CassandraServersConfigs.Visitor<CqlClient>() { @Override public CqlClient visit(CassandraServersConfigs.DefaultConfig defaultConfig) { return ThrowingCqlClientImpl.SINGLETON; } @Override public CqlClient visit(CassandraServersConfigs.CqlCapableConfig cqlCapableConfig) { if (!cqlCapableConfig.validateHosts()) { log.warn("Your CQL capable config is wrong, the hosts for CQL and Thrift are not the same, using " + "async API will result in an exception."); return ThrowingCqlClientImpl.SINGLETON; } Set<InetSocketAddress> servers = cqlCapableConfig.cqlHosts(); Cluster.Builder clusterBuilder = cqlClusterBuilderFactory.get() .addContactPointsWithPorts(servers) .withCredentials(config.credentials().username(), config.credentials().password()) .withCompression(ProtocolOptions.Compression.LZ4) .withRetryPolicy(DefaultRetryPolicy.INSTANCE) .withoutJMXReporting() .withProtocolVersion(ProtocolVersion.V3) .withThreadingOptions(new ThreadingOptions()); clusterBuilder = withSslOptions(clusterBuilder, config); clusterBuilder = withPoolingOptions(clusterBuilder, config); clusterBuilder = withQueryOptions(clusterBuilder, config); clusterBuilder = withLoadBalancingPolicy(clusterBuilder, config, servers); return CqlClientImpl.create( taggedMetricRegistry, clusterBuilder.build(), cqlCapableConfig.tuning(), initializeAsync); } }); }
Source:
<code>private boolean isDiscoDataPaketCompressed(TcpDiscoveryNode node) { return allNodesSupport(IgniteFeatures.DATA_PAKET_COMPRESSION) <START> && IgniteFeatures.allNodesSupports(Collections.singleton(node), IgniteFeatures.DATA_PAKET_COMPRESSION); <END> }</code><technical_language>nodeSupports(ClusterNode clusterNode, IgniteFeatures feature)</technical_language>

Target:
private boolean isDiscoDataPaketCompressed(TcpDiscoveryNode node) { return IgniteFeatures.nodeSupports(node, IgniteFeatures.DATA_PACKET_COMPRESSION) && allNodesSupport(IgniteFeatures.DATA_PACKET_COMPRESSION); }
Source:
<code>protected void refreshVisuals() { boolean stack = false; if (hasNotationView() && (getUMLElement() != null)) { MultiplicityElement mult = (MultiplicityElement) getUMLElement(); boolean isHash = 0 == mult.getLower(); getPrimaryShape().setHashed(isHash); int upper = mult.getUpper(); int lower = mult.getLower(); if <START> (!(upper == 1 && lower == 0) && <END> RTPropertyUtils.isReplicated((Property) getUMLElement())) { stack = true; } getPrimaryShape().setStack(stack); } getPrimaryShape().setLayerNumber(LAYER_NUMBER); getPrimaryShape().setXOffSet(X_OFFSET); getPrimaryShape().setYOffSet(Y_OFFSET); getPrimaryShape().setPathPattern(PATTERN_PATH); getPrimaryShape().setLayerOpacity(isSemanticInherited() ? getLighterAlpha(LAYER_OPACITY) : LAYER_OPACITY); super.refreshVisuals(); }</code><technical_language>this condition coded in a common utility, also, in case display policy changes? Also, 'upper' 1 if replication is a symbolic/expression a constant model. understanding assumption in case is property is replicated show stacking</technical_language>

Target:
protected void refreshVisuals() { boolean stack = false; if (hasNotationView() && (getUMLElement() != null)) { MultiplicityElement mult = (MultiplicityElement) getUMLElement(); boolean isHash = 0 == mult.getLower(); getPrimaryShape().setHashed(isHash); if (RTPropertyUtils.isReplicated((Property) getUMLElement())) { stack = true; } getPrimaryShape().setStack(stack); } getPrimaryShape().setLayerNumber(LAYER_NUMBER); getPrimaryShape().setXOffSet(X_OFFSET); getPrimaryShape().setYOffSet(Y_OFFSET); getPrimaryShape().setPathPattern(PATTERN_PATH); getPrimaryShape().setLayerOpacity(isSemanticInherited() ? getLighterAlpha(LAYER_OPACITY) : LAYER_OPACITY); super.refreshVisuals(); }
Source:
<code>protected boolean supersetOfUniqueIndex(boolean[] eqCols) throws StandardException{ ConglomerateDescriptor[] cds=tableDescriptor.getConglomerateDescriptors(); IndexDescriptor id; for(ConglomerateDescriptor cd : cds){ if(!cd.isIndex()) { if (!cd.isPrimaryKey()) continue; else <START> id = cd.getIndexDescriptor().getIndexDescriptor(); <END> } else { id=cd.getIndexDescriptor(); if(!id.isUnique()){ continue; } } int[] keyColumns=id.baseColumnPositions(); int inner=0; for(;inner<keyColumns.length;inner++){ if(!eqCols[keyColumns[inner]]){ break; } } if(inner==keyColumns.length){ return true; } } return false; }</code><technical_language>id = cd.getIndexDescriptor(); instead of cd.getIndexDescriptor().getIndexDescriptor() achieve goal, smaller version is imo</technical_language>

Target:
protected boolean supersetOfUniqueIndex(boolean[] eqCols) throws StandardException{ ConglomerateDescriptor[] cds=tableDescriptor.getConglomerateDescriptors(); IndexDescriptor id; for(ConglomerateDescriptor cd : cds){ if(!cd.isIndex()) { if (!cd.isPrimaryKey()) continue; else id = cd.getIndexDescriptor(); } else { id=cd.getIndexDescriptor(); if(!id.isUnique()){ continue; } } int[] keyColumns=id.baseColumnPositions(); int inner=0; for(;inner<keyColumns.length;inner++){ if(!eqCols[keyColumns[inner]]){ break; } } if(inner==keyColumns.length){ return true; } } return false; }
Source:
<code>private void saveIssues(InputFile sonarFile, SourceFile squidFile) { Collection<CheckMessage> messages = squidFile.getCheckMessages(); if (messages != null) { for (CheckMessage message : messages) { RuleKey ruleKey = checks.ruleKey((SquidAstVisitor<Grammar>) message.getCheck()); Issuable issuable = resourcePerspectives.as(Issuable.class, sonarFile); if (issuable != null) { Issue issue = issuable.newIssueBuilder() <START> .ruleKey(RuleKey.of(ruleKey.repository(), ruleKey.rule())) <END> .line(message.getLine()) .message(message.getText(Locale.ENGLISH)) .build(); issuable.addIssue(issue); } } } }</code><technical_language>do need create a new instance of RuleKey</technical_language>

Target:
private void saveIssues(InputFile sonarFile, SourceFile squidFile) { Collection<CheckMessage> messages = squidFile.getCheckMessages(); if (messages != null) { for (CheckMessage message : messages) { RuleKey ruleKey = checks.ruleKey((SquidAstVisitor<Grammar>) message.getCheck()); Issuable issuable = resourcePerspectives.as(Issuable.class, sonarFile); if (issuable != null) { Issue issue = issuable.newIssueBuilder() .ruleKey(ruleKey) .line(message.getLine()) .message(message.getText(Locale.ENGLISH)) .build(); issuable.addIssue(issue); } } } }
Source:
<code>public void test_of_reasonMessageExceptionNestedExceptionWithAttributes() { IllegalArgumentException innerEx = new IllegalArgumentException("inner"); IllegalArgumentException ex = new IllegalArgumentException("message", innerEx); FailureItem test = FailureItem.of(FailureReason.INVALID, ex, "my {foo} {bar} failure", "big", "bad"); assertEquals(test.getReason(), FailureReason.INVALID); assertEquals(test.getMessage(), "my big bad failure"); assertEquals(test.getCauseType().isPresent(), true); assertEquals(test.getCauseType().get(), IllegalArgumentException.class); assertEquals(test.getStackTrace().contains(".test_of_reasonMessageExceptionNestedExceptionWithAttributes("), true); <START> assertEquals(test.toString(), "INVALID: my big bad failure: java.lang.IllegalArgumentException: message : {bar=bad, foo=big}"); <END> }</code><technical_language>good test attributes map toString() method</technical_language>

Target:
public void test_of_reasonMessageExceptionNestedExceptionWithAttributes() { IllegalArgumentException innerEx = new IllegalArgumentException("inner"); IllegalArgumentException ex = new IllegalArgumentException("message", innerEx); FailureItem test = FailureItem.of(FailureReason.INVALID, ex, "my {foo} {bar} failure", "big", "bad"); assertEquals(test.getAttributes(), ImmutableMap.of("foo", "big", "bar", "bad")); assertEquals(test.getReason(), FailureReason.INVALID); assertEquals(test.getMessage(), "my big bad failure"); assertEquals(test.getCauseType().isPresent(), true); assertEquals(test.getCauseType().get(), IllegalArgumentException.class); assertEquals(test.getStackTrace().contains(".test_of_reasonMessageExceptionNestedExceptionWithAttributes("), true); assertEquals(test.toString(), "INVALID: my big bad failure: java.lang.IllegalArgumentException: message : {bar=bad, foo=big}"); }
Source:
<code>protected void execute() { for (Entry<String, Meter> entry : meterDeviceConfigurtions.entrySet()) { Meter reader = entry.getValue(); Map<String, DataSet> dataSets = reader.read(); for (Iec6205621MeterBindingProvider provider : providers) { for (String itemName : provider.getItemNames()) { String obis = provider.getObis(itemName); String meterName = provider.getMeterName(itemName); <START> if (obis != null && dataSets.containsKey(obis) && meterName != null && meterName.equals(entry.getKey())) { <END> DataSet dataSet = dataSets.get(obis); Class<? extends Item> itemType = provider .getItemType(itemName); if (itemType.isAssignableFrom(NumberItem.class)) { eventPublisher.postUpdate(itemName, new DecimalType(dataSet.getValue())); } if (itemType.isAssignableFrom(StringItem.class)) { String value = dataSet.getValue(); eventPublisher.postUpdate(itemName, new StringType( value)); } } } } } }</code><technical_language>i implemented Binding, more logical iterate bindings search for meter if if Binding configuration configured. In case name check necessary, right</technical_language>

Target:
protected void execute() { Map<String, Map<String, DataSet>> cache = new HashMap<String, Map<String,DataSet>>(); for (Iec6205621MeterBindingProvider provider : providers) { for (String itemName : provider.getItemNames()) { for (Entry<String, Meter> entry : meterDeviceConfigurtions.entrySet()) { Meter reader = entry.getValue(); String meterName = provider.getMeterName(itemName); if(meterName != null && meterName.equals(entry.getKey())) { Map<String, DataSet> dataSets; if((dataSets = cache.get(meterName)) == null) { if(logger.isDebugEnabled()) logger.debug("Read meter: " + meterName + "; " + reader.getConfig().getSerialPort()); dataSets = reader.read(); cache.put(meterName, dataSets); } String obis = provider.getObis(itemName); if (obis != null && dataSets.containsKey(obis)) { DataSet dataSet = dataSets.get(obis); if(logger.isDebugEnabled()) logger.debug("Updateing item " + itemName + " with OBIS code " + obis + " and value " + dataSet.getValue()); Class<? extends Item> itemType = provider .getItemType(itemName); if (itemType.isAssignableFrom(NumberItem.class)) { eventPublisher.postUpdate(itemName, new DecimalType(dataSet.getValue())); } if (itemType.isAssignableFrom(StringItem.class)) { String value = dataSet.getValue(); eventPublisher.postUpdate(itemName, new StringType( value)); } } } } } } }
Source:
<code>public <TElement extends Element> void updateElement( Graph graph, ExistingElementMutation<TElement> elementMutation, Authorizations authorizations ) { TElement element = elementMutation.getElement(); if (MUTATION_LOGGER.isTraceEnabled()) { MUTATION_LOGGER.trace("updateElement: %s", elementMutation.getId()); } if (!getConfig().isIndexEdges() && elementMutation.getElementType() == ElementType.EDGE) { return; } bulkUpdateService.flushUntilElementIdIsComplete(elementMutation.getId()); addMutationPropertiesToIndex(graph, elementMutation); addUpdateForMutationToBulk(graph, elementMutation); if (elementMutation.getNewElementVisibility() != null && element.getFetchHints().isIncludeExtendedDataTableNames()) { ImmutableSet<String> extendedDataTableNames = element.getExtendedDataTableNames(); if (extendedDataTableNames != null && !extendedDataTableNames.isEmpty()) { extendedDataTableNames.forEach(tableName -> alterExtendedDataElementTypeVisibility( <START> graph, <END> elementMutation, element.getExtendedData(tableName), elementMutation.getOldElementVisibility(), elementMutation.getNewElementVisibility() )); } } }</code><technical_language>wait in BulkUpdateService batch is converted a request</technical_language>

Target:
public <TElement extends Element> void updateElement( Graph graph, ExistingElementMutation<TElement> elementMutation, Authorizations authorizations ) { TElement element = elementMutation.getElement(); if (MUTATION_LOGGER.isTraceEnabled()) { MUTATION_LOGGER.trace("updateElement: %s", elementMutation.getId()); } if (!getConfig().isIndexEdges() && elementMutation.getElementType() == ElementType.EDGE) { return; } addMutationPropertiesToIndex(graph, elementMutation); addUpdateForMutationToBulk(graph, elementMutation); if (elementMutation.getNewElementVisibility() != null && element.getFetchHints().isIncludeExtendedDataTableNames()) { ImmutableSet<String> extendedDataTableNames = element.getExtendedDataTableNames(); if (extendedDataTableNames != null && !extendedDataTableNames.isEmpty()) { extendedDataTableNames.forEach(tableName -> alterExtendedDataElementTypeVisibility( graph, elementMutation, element.getExtendedData(tableName), elementMutation.getOldElementVisibility(), elementMutation.getNewElementVisibility() )); } } if (getConfig().isAutoFlush()) { flush(graph); } }
Source:
<code>public static void closeEditor(IRepositoryViewObject viewObj, boolean save) { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorReference[] editorReferences = activePage.getEditorReferences(); for (IEditorReference ref : editorReferences) { if (ref != null) { try { IEditorInput editorInput = ref.getEditorInput(); if (editorInput instanceof IRepositoryViewEditorInput) { Item inputItem = ((IRepositoryViewEditorInput) editorInput).getInputItem(); if (inputItem != null) { IRepositoryViewObject vObj = ContainerCacheService.get(inputItem.getProperty()); if (vObj != null && vObj.equals(viewObj)) { activePage.closeEditors(new IEditorReference[] { ref }, save); } } } else if (editorInput instanceof URIEditorInput) { URIEditorInput uriEditorInput = (URIEditorInput) editorInput; String name = uriEditorInput.getName(); if (name.equals(viewObj.getLabel() + "-" + viewObj.getVersion() + ".proc")) { activePage.closeEditors(new IEditorReference[] { ref }, false); } URI uri = uriEditorInput.getURI(); <START> System.out.println(uri); <END> } } catch (PartInitException e) { LOG.error(e.getMessage(), e); } } } }</code><technical_language>Please remove debug statement</technical_language>

Target:
public static void closeEditor(IRepositoryViewObject viewObj, boolean save) { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorReference[] editorReferences = activePage.getEditorReferences(); for (IEditorReference ref : editorReferences) { if (ref != null) { try { IEditorInput editorInput = ref.getEditorInput(); if (editorInput instanceof IRepositoryViewEditorInput) { Item inputItem = ((IRepositoryViewEditorInput) editorInput).getInputItem(); if (inputItem != null) { IRepositoryViewObject vObj = ContainerCacheService.get(inputItem.getProperty()); if (vObj != null && vObj.equals(viewObj)) { activePage.closeEditors(new IEditorReference[] { ref }, save); } } } } catch (PartInitException e) { LOG.error(e.getMessage(), e); } } } }
Source:
<code>public void initialize(ExtensionContext context) { <START> final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, ModelVersion.create(4, 1)); <END> final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(IORootDefinition.INSTANCE); registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE, false); subsystem.registerXMLElementWriter(IOSubsystemParser_2_0::new); }</code><technical_language>@stuartwdouglas bumped for WF Core 4 part of <LINK_0></technical_language>

Target:
public void initialize(ExtensionContext context) { final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, ModelVersion.create(4)); final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(IORootDefinition.INSTANCE); registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE, false); subsystem.registerXMLElementWriter(IOSubsystemParser_2_0::new); }
Source:
<code>public void setConnectionTtlToMinusOne() { page.switchToConnectionManagementTab(); <START> page.edit().text("connectionTTL", "-1"); <END> page.clickButton("Save"); WebElement webElement = browser.findElement(By.className("form-item-error-desc")); Assert.assertNull("Test failed due to HAL-1382.", webElement); }</code><technical_language>I suggest AbstractMessagingTestCase#editTextAndVerify for test logic implementation for model change verification</technical_language>

Target:
public void setConnectionTtlToMinusOne() throws Exception { page.selectInTable("InVmConnectionFactory"); page.switchToConnectionManagementTab(); editTextAndVerify(IN_VM_CONNECTOR_ADDRESS, "connectionTTL", "connection-ttl", -1L) ; }
Source:
<code>private Object getAdapter(Object sourceObject, Class adapterType) { Assert.isNotNull(adapterType); <START> if (sourceObject == null) { <END> return null; } if (adapterType.isInstance(sourceObject)) { return sourceObject; } if (sourceObject instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) sourceObject; Object result = adaptable.getAdapter(adapterType); if (result != null) { Assert.isTrue(adapterType.isInstance(result)); return result; } } if (!(sourceObject instanceof PlatformObject)) { Object result = Platform.getAdapterManager().getAdapter( sourceObject, adapterType); if (result != null) { return result; } } return null; }</code><technical_language>style nit: braces</technical_language>

Target:
private Object getAdapter(Object sourceObject, Class adapterType) { Assert.isNotNull(adapterType); if (sourceObject == null) return null; if (adapterType.isInstance(sourceObject)) return sourceObject; if (sourceObject instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) sourceObject; Object result = adaptable.getAdapter(adapterType); if (result != null) { Assert.isTrue(adapterType.isInstance(result)); return result; } } if (!(sourceObject instanceof PlatformObject)) { Object result = Platform.getAdapterManager().getAdapter( sourceObject, adapterType); if (result != null) return result; } return null; }
Source:
<code>public void noopQueries() { Term t = new Term("test", "foo"); Query[] queries = new Query[] { new TermQuery(t), new FuzzyQuery(t, 1, 1, 1, false), new RegexpQuery(t), new WildcardQuery(t), new PrefixQuery(t), new CommonTermsQuery(Occur.SHOULD, Occur.MUST, .5f), new ExtendedCommonTermsQuery(Occur.SHOULD, Occur.MUST, .5f, false, null), new XConstantScoreQuery(new TermFilter(t)), pq("1", "2", "3"), mpq(new String[] {"1", "2"}, new String[] {"3"}, new String[] {"a", "Adsfa"}), multiPhrasePrefixQuery(new String[] {"1", "2"}, new String[] {"3"}, new String[] {"a", "Adsfa"}), new FieldMaskingSpanQuery(new SpanTermQuery(t), "test"), <START> new SpanMultiTermQueryWrapper<PrefixQuery>(new PrefixQuery(t)), <END> new SpanNearQuery(new SpanQuery[] {new SpanTermQuery(t)}, 1, true), new PayloadNearQuery(new SpanQuery[] {new SpanTermQuery(t)}, 1, true), new SpanNotQuery(new SpanTermQuery(t), new SpanTermQuery(t)), new SpanOrQuery(new SpanTermQuery(t), new SpanTermQuery(t)), new SpanNearPayloadCheckQuery(new SpanNearQuery(new SpanQuery[] {new SpanTermQuery(t)}, 1, true), Collections.<byte[]>emptyList()), new SpanPayloadCheckQuery(new SpanTermQuery(t), Collections.<byte[]>emptyList()), new SpanPositionRangeQuery(new SpanTermQuery(t), 1, 20), new SpanFirstQuery(new SpanTermQuery(t), 10), new SpanTermQuery(t), new AllTermQuery(t), new PayloadTermQuery(t, new MaxPayloadFunction()), }; for (Query query: queries) { query.setBoost(getRandom().nextFloat()); assertEquals(query, new Safeifier(true).safeify(query)); } }</code><technical_language>diamond <></technical_language>

Target:
public void noopQueries() { Term t = new Term("test", "foo"); Query[] queries = new Query[] { new TermQuery(t), new FuzzyQuery(t, 1, 1, 1, false), new RegexpQuery(t), new WildcardQuery(t), new PrefixQuery(t), new CommonTermsQuery(Occur.SHOULD, Occur.MUST, .5f), new ExtendedCommonTermsQuery(Occur.SHOULD, Occur.MUST, .5f, false, null), new XConstantScoreQuery(new TermFilter(t)), pq("1", "2", "3"), mpq(new String[] {"1", "2"}, new String[] {"3"}, new String[] {"a", "Adsfa"}), multiPhrasePrefixQuery(new String[] {"1", "2"}, new String[] {"3"}, new String[] {"a", "Adsfa"}), new FieldMaskingSpanQuery(new SpanTermQuery(t), "test"), new SpanMultiTermQueryWrapper<>(new PrefixQuery(t)), new SpanNearQuery(new SpanQuery[] {new SpanTermQuery(t)}, 1, true), new PayloadNearQuery(new SpanQuery[] {new SpanTermQuery(t)}, 1, true), new SpanNotQuery(new SpanTermQuery(t), new SpanTermQuery(t)), new SpanOrQuery(new SpanTermQuery(t), new SpanTermQuery(t)), new SpanNearPayloadCheckQuery(new SpanNearQuery(new SpanQuery[] {new SpanTermQuery(t)}, 1, true), Collections.<byte[]>emptyList()), new SpanPayloadCheckQuery(new SpanTermQuery(t), Collections.<byte[]>emptyList()), new SpanPositionRangeQuery(new SpanTermQuery(t), 1, 20), new SpanFirstQuery(new SpanTermQuery(t), 10), new SpanTermQuery(t), new AllTermQuery(t), new PayloadTermQuery(t, new MaxPayloadFunction()), }; for (Query query: queries) { query.setBoost(getRandom().nextFloat()); assertEquals(query, new Safeifier(true).safeify(query)); } }
Source:
<code>static void close(Set<?> set) { set.stream() <START> .filter(o -> o instanceof Closeable) <END> .map(c -> (Closeable) c) .forEach(c -> { try { c.close(); } catch (Throwable t) { log.errorClosingCloseable(c, t); } }); }</code><technical_language>filter(Closeable.class::isInstance).map(Closeable.class::cast)</technical_language>

Target:
static void close(Set<?> set) { set.stream() .filter(Closeable.class::isInstance) .map(Closeable.class::cast) .forEach(c -> { try { c.close(); } catch (Exception e) { log.errorClosingCloseable(c, e); } }); }
Source:
<code>public static void main(String[] args) { String masc = ""; String output = ""; String type = ""; String analysis = ""; if (args.length > 0) { masc = args[0]; output = args[1]; analysis = args[2]; <START> type = args[3]; <END> } else { logger.info("No arguments, using defaults."); masc = "MASC-3.0.0/data/written/"; output = "output/new_illinois_result_wn5.txt"; analysis = "analysis/new_illinois_result_wn5.txt"; type = "illinois"; } MASCevaluation m = new MASCevaluation(masc); LemmatizerInterface lem = initLemmatizer(type); lem.initLemmatizer(); MASCevaluationResult[] lem_result = m.evaluation(lem); try { File file = new File(analysis); FileWriter writer = new FileWriter(file, false); PrintWriter out = new PrintWriter(writer); out.println(MASCevaluationResult.getOverallAnalytics(lem_result)); } catch (Exception e) { e.printStackTrace(); } try { File file = new File(output); FileWriter writer = new FileWriter(file, false); PrintWriter out = new PrintWriter(writer); int total = 0; int correct = 0; for (MASCevaluationResult aLem_result1 : lem_result) { total += aLem_result1.getTotal(); correct += aLem_result1.getCorrect(); } out.printf("Overall Accuracy: %f %%\n", (double) correct / (double) total * 100); for (MASCevaluationResult aLem_result : lem_result) out.println(aLem_result.toString()); out.close(); } catch (Exception e) { e.printStackTrace(); } }</code><technical_language>main() STDOUT</technical_language>

Target:
public static void main(String[] args) { String masc = ""; String output = ""; String type = ""; String analysis = ""; if (args.length > 0) { masc = args[0]; output = args[1]; analysis = args[2]; type = args[3]; } else { System.out.println("No arguments, using defaults."); masc = "MASC-3.0.0/data/written/"; output = "output/new_illinois_result_wn5.txt"; analysis = "analysis/new_illinois_result_wn5.txt"; type = "illinois"; } MASCevaluation m = new MASCevaluation(masc); LemmatizerInterface lem = initLemmatizer(type); lem.initLemmatizer(); MASCevaluationResult[] lem_result = m.evaluation(lem); try { File file = new File(analysis); FileWriter writer = new FileWriter(file, false); PrintWriter out = new PrintWriter(writer); out.println(MASCevaluationResult.getOverallAnalytics(lem_result)); } catch (Exception e) { e.printStackTrace(); } try { File file = new File(output); FileWriter writer = new FileWriter(file, false); PrintWriter out = new PrintWriter(writer); int total = 0; int correct = 0; for (MASCevaluationResult aLem_result1 : lem_result) { total += aLem_result1.getTotal(); correct += aLem_result1.getCorrect(); } out.printf("Overall Accuracy: %f %%\n", (double) correct / (double) total * 100); for (MASCevaluationResult aLem_result : lem_result) out.println(aLem_result.toString()); out.close(); } catch (Exception e) { e.printStackTrace(); } }
Source:
<code>private InputStream getInputStreamFromJar(String fileName) { final Locale locale = Locale.getDefault(); final String languageTag = BrowserLocaleManager.getLanguageTag(locale); String url = getSearchPluginsJarURL(languageTag, fileName); final InputStream in = GeckoJarReader.getStream(url); if (in != null) { return in; } <START> final String language = locale.getLanguage(); <END> if (languageTag.equals(language)) { return null; } url = getSearchPluginsJarURL(language, fileName); return GeckoJarReader.getStream(url); }</code><technical_language>mentioned in previous review, this wrong for Indonesian, Hebrew, Yiddish</technical_language>

Target:
private InputStream getInputStreamFromJar(String fileName) { final Locale locale = Locale.getDefault(); final String languageTag = BrowserLocaleManager.getLanguageTag(locale); String url = getSearchPluginsJarURL(languageTag, fileName); final InputStream in = GeckoJarReader.getStream(url); if (in != null) { return in; } final String language = BrowserLocaleManager.getLanguage(locale); if (languageTag.equals(language)) { return null; } url = getSearchPluginsJarURL(language, fileName); return GeckoJarReader.getStream(url); }
Source:
<code>public void onReceiveBuildingUpgradeEvent(UpgradeBuildingEvent upgradeBuildingEvent, EntityRef player) { buildingToUpgrade.send(new CloseUpgradeScreenEvent()); logger.info("adding building upgrade task"); ConstructedBuildingComponent buildingComponent = buildingToUpgrade.getComponent(ConstructedBuildingComponent.class); TaskComponent taskComponent = new TaskComponent(); taskComponent.assignedTaskType = AssignedTaskType.Upgrade; <START> taskComponent.taskRegion = buildingComponent.boundingRegions.get(86); <END> taskComponent.buildingToUpgrade = buildingToUpgrade; taskComponent.taskCompletionTime = taskMangementSystem.getTaskCompletionTime(AssignedTaskType.Upgrade); EntityRef task = entityManager.create(taskComponent); taskMangementSystem.addTask(player, task); }</code><technical_language>"86"? a constant describes this number represents</technical_language>

Target:
public void onReceiveBuildingUpgradeEvent(UpgradeBuildingEvent upgradeBuildingEvent, EntityRef player) { buildingToUpgrade.send(new CloseUpgradeScreenEvent()); logger.info("adding building upgrade task"); ConstructedBuildingComponent buildingComponent = buildingToUpgrade.getComponent(ConstructedBuildingComponent.class); TaskComponent taskComponent = new TaskComponent(); taskComponent.assignedTaskType = AssignedTaskType.Upgrade; taskComponent.taskRegion = buildingComponent.boundingRegions.get(Constants.DINER_CHAIR_REGION_INDEX); taskComponent.buildingToUpgrade = buildingToUpgrade; taskComponent.taskCompletionTime = taskMangementSystem.getTaskCompletionTime(AssignedTaskType.Upgrade); EntityRef task = entityManager.create(taskComponent); taskMangementSystem.addTask(player, task); }
Source:
<code>public Map<Client, PaxosLong> apply(Set<Client> requestedClients) { clientsSeenSoFar.addAll(requestedClients); int attempt = 0; while (attempt < 3) { TimestampedAcceptorCacheKey timestampedCacheKey = cacheKey.get(); try { if (timestampedCacheKey == null) { return populateNewCache(requestedClients); } else { return populateExistingCache( timestampedCacheKey, cacheKeysToCaches.get(timestampedCacheKey.cacheKey()), requestedClients); } } catch (InvalidAcceptorCacheKeyException e) { log.info("Cache key is invalid, invalidating cache and retrying", SafeArg.of("attempt", attempt), e); cacheKey.compareAndSet(timestampedCacheKey, null); attempt++; } } <START> throw new SafeIllegalStateException("could not request complete request due to contention in the cache"); <END> }</code><technical_language>nit: double request in message I _think_ this is safe 3 attempts, leader churn strangely behind</technical_language>

Target:
public Map<Client, PaxosLong> apply(Set<Client> requestedClients) { clientsSeenSoFar.addAll(requestedClients); int attempt = 0; while (attempt < 3) { TimestampedAcceptorCacheKey timestampedCacheKey = latestCacheKey.get(); try { if (timestampedCacheKey == null) { return populateNewCache(requestedClients); } else { return populateExistingCache( timestampedCacheKey, cacheKeysToCaches.get(timestampedCacheKey.cacheKey()), requestedClients); } } catch (InvalidAcceptorCacheKeyException e) { log.info("Cache key is invalid, invalidating cache and retrying", SafeArg.of("attempt", attempt), e); latestCacheKey.compareAndSet(timestampedCacheKey, null); attempt++; } } throw new SafeIllegalStateException("could not complete request due to contention in the cache"); }