auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static FieldInfo getIterableField(ClassInfo classInfo, Class<?> parameterType, String relationshipType, Direction relationshipDirection) { final ClassInfo lookupClassInfo = classInfo; final DirectedRelationshipForType directedRelationshipForType = new DirectedRelationshipForType( relationshipType, relationshipDirection, parameterType); final Map<DirectedRelationshipForType, FieldInfo> typeFieldInfoMap = iterableWriterCache .computeIfAbsent(lookupClassInfo, key -> new ConcurrentHashMap<>()); if (typeFieldInfoMap.containsKey(directedRelationshipForType)) { return typeFieldInfoMap.get(directedRelationshipForType); } while (classInfo != null) { FieldInfo fieldInfo = getIterableFieldInfo(classInfo, parameterType, relationshipType, relationshipDirection, STRICT_MODE); if (fieldInfo != null) { cacheIterableFieldWriter(lookupClassInfo, parameterType, relationshipType, relationshipDirection, directedRelationshipForType, fieldInfo, fieldInfo); return fieldInfo; } <START> if (!relationshipDirection.equals(Direction.INCOMING)) { <END> fieldInfo = getIterableFieldInfo(classInfo, parameterType, relationshipType, relationshipDirection, INFERRED_MODE); if (fieldInfo != null) { cacheIterableFieldWriter(lookupClassInfo, parameterType, relationshipType, relationshipDirection, directedRelationshipForType, fieldInfo, fieldInfo); return fieldInfo; } } classInfo = classInfo.directSuperclass(); } return null; }</code><technical_language>suggestion if (relationshipDirection != Direction.INCOMING) {</technical_language>

Target:
public static FieldInfo getIterableField(ClassInfo classInfo, Class<?> parameterType, String relationshipType, Direction relationshipDirection) { final ClassInfo lookupClassInfo = classInfo; final DirectedRelationshipForType directedRelationshipForType = new DirectedRelationshipForType( relationshipType, relationshipDirection, parameterType); final Map<DirectedRelationshipForType, FieldInfo> typeFieldInfoMap = iterableWriterCache .computeIfAbsent(lookupClassInfo, key -> new ConcurrentHashMap<>()); if (typeFieldInfoMap.containsKey(directedRelationshipForType)) { return typeFieldInfoMap.get(directedRelationshipForType); } while (classInfo != null) { FieldInfo fieldInfo = getIterableFieldInfo(classInfo, parameterType, relationshipType, relationshipDirection, STRICT_MODE); if (fieldInfo != null) { cacheIterableFieldWriter(lookupClassInfo, parameterType, relationshipType, relationshipDirection, directedRelationshipForType, fieldInfo, fieldInfo); return fieldInfo; } if (relationshipDirection != Direction.INCOMING) { fieldInfo = getIterableFieldInfo(classInfo, parameterType, relationshipType, relationshipDirection, INFERRED_MODE); if (fieldInfo != null) { cacheIterableFieldWriter(lookupClassInfo, parameterType, relationshipType, relationshipDirection, directedRelationshipForType, fieldInfo, fieldInfo); return fieldInfo; } } classInfo = classInfo.directSuperclass(); } return null; }
Source:
<code>public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) { LookupRequest.Builder lookupRequest = LookupRequest.newBuilder(); lookupRequest.addKey(buildPrimaryKey(table, key)); lookupRequest.getReadOptionsBuilder().setReadConsistency( this.readConsistency); logger.debug("Built lookup request as:\n" + lookupRequest.toString()); LookupResponse response = null; try { response = datastore.lookup(lookupRequest.build()); } catch (DatastoreException exception) { logger.error( String.format("Datastore Exception when reading (%s): %s %s", exception.getMessage(), exception.getMethodName(), exception.getCode())); return new Status("ERROR-" + exception.getCode(), exception.getMessage()); } if (response.getFoundCount() == 0) { return new Status("ERROR-404", "Not Found, key is: " + key); } <START> <END> Entity entity = response.getFound(0).getEntity(); logger.debug("Read entity: " + entity.toString()); Map<String, Value> properties = DatastoreHelper.getPropertyMap(entity); Set<String> propertiesToReturn = (fields == null ? properties.keySet() : fields); for (String name : propertiesToReturn) { if (properties.containsKey(name)) { result.put(name, new StringByteIterator(properties.get(name) .getStringValue())); } } return Status.OK; }</code><technical_language>Is possibility of response.getFoundCount() > 1? This unexpected result, get marked key found</technical_language>

Target:
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) { LookupRequest.Builder lookupRequest = LookupRequest.newBuilder(); lookupRequest.addKey(buildPrimaryKey(table, key)); lookupRequest.getReadOptionsBuilder().setReadConsistency( this.readConsistency); logger.debug("Built lookup request as: " + lookupRequest.toString()); LookupResponse response = null; try { response = datastore.lookup(lookupRequest.build()); } catch (DatastoreException exception) { logger.error( String.format("Datastore Exception when reading (%s): %s %s", exception.getMessage(), exception.getMethodName(), exception.getCode())); return new Status("ERROR-" + exception.getCode(), exception.getMessage()); } if (response.getFoundCount() == 0) { return new Status("ERROR-404", "Not Found, key is: " + key); } else if (response.getFoundCount() > 1) { return Status.UNEXPECTED_STATE; } Entity entity = response.getFound(0).getEntity(); logger.debug("Read entity: " + entity.toString()); Map<String, Value> properties = DatastoreHelper.getPropertyMap(entity); Set<String> propertiesToReturn = (fields == null ? properties.keySet() : fields); for (String name : propertiesToReturn) { if (properties.containsKey(name)) { result.put(name, new StringByteIterator(properties.get(name) .getStringValue())); } } return Status.OK; }
Source:
<code>protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String connectorName = address.getLastElement().getValue(); <START> validateDuplicatedResources(context, address, connectorName, resource); <END> final ModelNode fullModel = Resource.Tools.readModel(resource); launchServices(context, connectorName, fullModel); }</code><technical_language>validation done in stage MODEL runtime</technical_language>

Target:
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String connectorName = address.getLastElement().getValue(); final ModelNode fullModel = Resource.Tools.readModel(resource); launchServices(context, connectorName, fullModel); }
Source:
<code>public HttpDirectDownloadCommand(String url, Long templateId, PrimaryDataStoreTO destPool, String checksum, Map<String, String> headers, int connectTimeout, int soTimeout) { super(url, templateId, destPool, checksum, headers); <START> setConnectTimeout(connectTimeout); <END> setSoTimeout(soTimeout); }</code><technical_language>set DrectDownloadCommand constructor</technical_language>

Target:
public HttpDirectDownloadCommand(String url, Long templateId, PrimaryDataStoreTO destPool, String checksum, Map<String, String> headers, int connectTimeout, int soTimeout) { super(url, templateId, destPool, checksum, headers, connectTimeout, soTimeout, null); }
Source:
<code>public int getEventSize() { <START> return event.toString().getBytes(StandardCharsets.UTF_8).length; <END> }</code><technical_language>I original string eventsAsString in order avoid calling toString is costly</technical_language>

Target:
public int getEventSize() { return eventSize; }
Source:
<code>public static Debug getDebug(String name) { if (!name.startsWith("/")) name = "/" + name; DebugTrace trace = null; <START> Activator activator = Activator.getDefault(); <END> Bundle bundle; BundleContext ctx; if (activator != null && (bundle = activator.getBundle()) != null && (ctx = bundle.getBundleContext()) != null) { ServiceReference<DebugOptions> ref = ctx.getServiceReference(DebugOptions.class); if (ref != null) { DebugOptions options = ctx.getService(ref); if (options.isDebugEnabled() && options.getBooleanOption(Activator.PLUGIN_ID + name, false)) { trace = options.newDebugTrace(Activator.PLUGIN_ID); } ctx.ungetService(ref); } } return new Debug(trace, name); }</code><technical_language>FrameWorkUtil here</technical_language>

Target:
public static Debug getDebug(String name) { if (!name.startsWith("/")) name = "/" + name; DebugTrace trace = null; Bundle bundle = FrameworkUtil.getBundle(Activator.class); BundleContext ctx; if (bundle != null && (ctx = bundle.getBundleContext()) != null) { ServiceReference<DebugOptions> ref = ctx.getServiceReference(DebugOptions.class); if (ref != null) { DebugOptions options = ctx.getService(ref); if (options.isDebugEnabled() && options.getBooleanOption(Activator.PLUGIN_ID + name, false)) { trace = options.newDebugTrace(Activator.PLUGIN_ID); } ctx.ungetService(ref); } } return new Debug(trace, name); }
Source:
<code>public Void visit(GenContext state, Invocation ast) { <START> return null; <END> }</code><technical_language>This is a method call - need</technical_language>

Target:
public Void visit(GenContext state, Invocation ast) { if (ast.getArgument() != null) { ast.getArgument().acceptVisitor(this, state); } if (ast.getArgument() != null) { ast.getReceiver().acceptVisitor(this, state); } return null; }
Source:
<code>public void theUserClicksOnButtonInTheHeader(String button) throws Throwable { <START> switch (button) { <END> case "epam-logo": driverProvider.getDriver().findElement(By.cssSelector("img.img-rounded")).click(); break; case "Beállítások-icon": driverProvider.getDriver().findElement(By.id("settings_link")).click(); break; case "Beállítások-text": driverProvider.getDriver().findElement(By.linkText("Beállítások")).click(); break; case "Kilépés-icon": driverProvider.getDriver().findElement(By.id("logout_link")).click(); break; case "Kilépés-text": driverProvider.getDriver().findElement(By.linkText("Kilépés")).click(); break; } }</code><technical_language>eliminate switch statements later, introducing Page Object pattern</technical_language>

Target:
public void theUserClicksOnButtonInTheHeader(String button) throws Throwable { switch (button) { case "epam-logo": getDriver().findElement(By.cssSelector("img.img-rounded")).click(); break; case "Beállítások-icon": getDriver().findElement(By.id("settings_link")).click(); break; case "Beállítások-text": getDriver().findElement(By.linkText("Beállítások")).click(); break; case "Kilépés-icon": getDriver().findElement(By.id("logout_link")).click(); break; case "Kilépés-text": getDriver().findElement(By.linkText("Kilépés")).click(); break; } }
Source:
<code>public BlockLoc getBlock() { <START> return (BlockLoc) getPos(); <END> }</code><technical_language>A MC BlockPos is a Sponge BlockLoc</technical_language>

Target:
public BlockLoc getBlock() { return new BlockWrapper(getWorld(), getPos().getX(), getPos().getY(), getPos().getZ()); }
Source:
<code>private void insertJVMAargs() { String flowName = node.getParentFlow().getFlowId(); String jobId = node.getId(); String jobJVMArgs = String.format( "-Dazkaban.flowid=%s -Dazkaban.execid=%s -Dazkaban.jobid=%s", flowName, executionId, jobId); String previousJVMArgs = props.get(JavaProcessJob.JVM_PARAMS); if (previousJVMArgs == null) { previousJVMArgs = jobJVMArgs; } else { <START> previousJVMArgs += " " + jobJVMArgs; <END> } logger.info("job JVM args: " + previousJVMArgs); props.put(JavaProcessJob.JVM_PARAMS, previousJVMArgs); }</code><technical_language>I easier read if combined this jobJVMArgs += (previousJVMArgs == null) ? "" : " " + previousJVMArgs jobJVMArgs instead of previousJVMArgs. I "ps -ef" output easier read if put -Dazkaban... JVM params first, previousJVMArgs</technical_language>

Target:
private void insertJVMAargs() { String flowName = node.getParentFlow().getFlowId(); String jobId = node.getId(); String jobJVMArgs = String.format( "-Dazkaban.flowid=%s -Dazkaban.execid=%s -Dazkaban.jobid=%s", flowName, executionId, jobId); String previousJVMArgs = props.get(JavaProcessJob.JVM_PARAMS); jobJVMArgs += (previousJVMArgs == null) ? "" : " " + previousJVMArgs; logger.info("job JVM args: " + jobJVMArgs); props.put(JavaProcessJob.JVM_PARAMS, jobJVMArgs); }
Source:
<code><START> protected <END> T doGetValue() { if (isListening) { return value; } return calculate(); }</code><technical_language>final</technical_language>

Target:
protected final T doGetValue() { if (isListening) { return value; } return calculate(); }
Source:
<code>public void onReceive(Context context, Intent intent) { if (!SyncthingService.alwaysRunInBackground(context)) return; Intent i = new Intent(context, SyncthingService.class); String action = intent.getAction(); if (action.equals("android.net.wifi.WIFI_AP_STATE_CHANGED")) { <START> int state = intent.getIntExtra("wifi_state", 0); <END> boolean apon = state == WIFI_AP_STATE_ENABLED; i.putExtra(DeviceStateHolder.EXTRA_AP_ON, apon); } else { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean isWifiConnected = (wifiInfo != null && wifiInfo.isConnected()); Log.v(TAG, "Received wifi " + (isWifiConnected ? "connected" : "disconnected") + " event"); i.putExtra(DeviceStateHolder.EXTRA_HAS_WIFI, isWifiConnected); } context.startService(i); }</code><technical_language>0 = WIFI_AP_STATE_DISABLED? log this in a similar else branch please</technical_language>

Target:
public void onReceive(Context context, Intent intent) { if (!SyncthingService.alwaysRunInBackground(context)) return; Intent i = new Intent(context, SyncthingService.class); String action = intent.getAction(); if (action.equals("android.net.wifi.WIFI_AP_STATE_CHANGED")) { int state = intent.getIntExtra("wifi_state", 0); boolean apon = state == WIFI_AP_STATE_ENABLED; i.putExtra(DeviceStateHolder.EXTRA_AP_ENABLED, apon); } else { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean isWifiConnected = (wifiInfo != null && wifiInfo.isConnected()); Log.v(TAG, "Received wifi " + (isWifiConnected ? "connected" : "disconnected") + " event"); i.putExtra(DeviceStateHolder.EXTRA_HAS_WIFI, isWifiConnected); } context.startService(i); }
Source:
<code>public boolean shouldThrottle(RestRequest restRequest) { <START> return quotaMap.get(restRequest.getRestMethod()).shouldThrottle(1); <END> }</code><technical_language>i treat entry in map -1 (don't reject if is throttler for rest method)</technical_language>

Target:
public boolean shouldThrottle(RestRequest restRequest) { RejectThrottler throttler = quotaMap.get(restRequest.getRestMethod()); return throttler != null && throttler.shouldThrottle(1); }
Source:
<code>protected boolean shouldSplit() { for (HStore store : region.getStores()) { <START> if (!store.canSplit()) { <END> return false; } } return isExceedSize(desiredMaxFileSize, ""); }</code><technical_language>Move this check for loops _isExceedSize_, do do extra iteration for stores in case returns false for _canSplit_</technical_language>

Target:
protected boolean shouldSplit() { if (!canSplit()) { return false; } return isExceedSize(desiredMaxFileSize); }
Source:
<code>protected void fillDescription(final DiscountCodeViewModel viewModel, final DiscountCode discountCode) { final String displayDescription = Optional.of(discountCode.getDescription()) .flatMap(description -> description.find(userLanguage.locales())) .orElse(null); <START> viewModel.setDescription(displayDescription); <END> }</code><technical_language>try DiscountCodeViewModel.description LocalizedString simply call: viewModel.setDescription(discount.getDescription());</technical_language>

Target:
protected void fillDescription(final DiscountCodeViewModel viewModel, final DiscountCode discountCode) { viewModel.setDescription(discountCode.getDescription()); }
Source:
<code>ManagedIdentityCredential(String clientId, IdentityClientOptions identityClientOptions) { IdentityClient identityClient = new IdentityClientBuilder() .clientId(clientId) .identityClientOptions(identityClientOptions) .build(); Configuration configuration = Configuration.getGlobalConfiguration().clone(); if (configuration.contains(Configuration.PROPERTY_IDENTITY_ENDPOINT)) { if (configuration.contains(Configuration.PROPERTY_IDENTITY_HEADER)) { managedIdentityServiceCredential = new AppServiceMsiCredential(clientId, identityClient); <START> } else if (configuration.contains(PROPERTY_IMDS_ENDPOINT)) { <END> managedIdentityServiceCredential = new ArcIdentityCredential(clientId, identityClient); } else { managedIdentityServiceCredential = null; } } else if (configuration.contains(Configuration.PROPERTY_MSI_ENDPOINT)) { managedIdentityServiceCredential = new AppServiceMsiCredential(clientId, identityClient); } else { managedIdentityServiceCredential = new VirtualMachineMsiCredential(clientId, identityClient); } LoggingUtil.logAvailableEnvironmentVariables(logger, configuration); }</code><technical_language>Environment variable IMDS_ENDPOINT is in ArcIdentityCredential, is normal</technical_language>

Target:
ManagedIdentityCredential(String clientId, IdentityClientOptions identityClientOptions) { IdentityClient identityClient = new IdentityClientBuilder() .clientId(clientId) .identityClientOptions(identityClientOptions) .build(); Configuration configuration = Configuration.getGlobalConfiguration().clone(); if (configuration.contains(Configuration.PROPERTY_IDENTITY_ENDPOINT)) { if (configuration.contains(Configuration.PROPERTY_IDENTITY_HEADER)) { if (configuration.contains(PROPERTY_IDENTITY_SERVER_THUMBPRINT)) { managedIdentityServiceCredential = new ServiceFabricMsiCredential(clientId, identityClient); } else { managedIdentityServiceCredential = new VirtualMachineMsiCredential(clientId, identityClient); } } else if (configuration.contains(PROPERTY_IMDS_ENDPOINT)) { managedIdentityServiceCredential = new ArcIdentityCredential(clientId, identityClient); } else { managedIdentityServiceCredential = new VirtualMachineMsiCredential(clientId, identityClient); } } else if (configuration.contains(Configuration.PROPERTY_MSI_ENDPOINT)) { managedIdentityServiceCredential = new AppServiceMsiCredential(clientId, identityClient); } else { managedIdentityServiceCredential = new VirtualMachineMsiCredential(clientId, identityClient); } LoggingUtil.logAvailableEnvironmentVariables(logger, configuration); }
Source:
<code>public void enqueue(Callback callback) { <START> doEnqueueAndHandleErrorsAndRetries(callback); <END> }</code><technical_language>thoughts inlining this? if want descriptive method name, in sync execute() method</technical_language>

Target:
public void enqueue(Callback callback) { super.enqueue(new Callback() { @Override public void onFailure(Call call, IOException exception) { if (!backoffStrategy.nextBackoff().isPresent()) { callback.onFailure(call, new IOException("Failed to complete the request due to an " + "IOException", exception)); return; } Optional<HttpUrl> redirectTo = urls.redirectToNext(request().url()); if (!redirectTo.isPresent()) { callback.onFailure(call, new IOException("Failed to determine valid failover URL" + "for '" + request().url() + "' and base URLs " + urls.getBaseUrls())); return; } Request redirectedRequest = request().newBuilder() .url(redirectTo.get()) .build(); RemotingOkHttpCall retryCall = client.newCallWithMutableState(redirectedRequest, backoffStrategy, maxNumRelocations - 1); retryCall.enqueue(callback); } @Override public void onResponse(Call call, Response response) throws IOException { if (response.code() / 100 <= 2) { callback.onResponse(call, response); return; } Optional<QosException> qosError = qosHandler.handle(response); if (qosError.isPresent()) { qosError.get().accept(createQosVisitor(callback, call)); return; } Optional<RemoteException> httpError = remoteExceptionHandler.handle(response); if (httpError.isPresent()) { callback.onFailure(call, new IoRemoteException(httpError.get())); return; } Optional<IOException> ioException = ioExceptionHandler.handle(response); if (ioException.isPresent()) { callback.onFailure(call, ioException.get()); return; } callback.onFailure(call, new IOException("Failed to handle request, this is an http-remoting bug.")); } }); }
Source:
<code><START> public boolean isSameContentIgnoreOrder(List a, List b) { <END> String expectedListAsString = Joiner.on("\t").join(a); String actualListAsString = Joiner.on("\t").join(b); List<String> expectedStringTypeList = new ArrayList<String>( Arrays.asList(expectedListAsString.split("\t"))); List<String> actualStringTypeList = new ArrayList<String>( Arrays.asList(actualListAsString.split("\t"))); Collections.sort(expectedStringTypeList); Collections.sort(actualStringTypeList); return expectedStringTypeList.equals(actualStringTypeList); }</code><technical_language>this a static method? way, need create a TestHelper object</technical_language>

Target:
public static boolean isSameContentIgnoreOrder(List a, List b) { String expectedListAsString = Joiner.on("\t").join(a); String actualListAsString = Joiner.on("\t").join(b); List<String> expectedStringTypeList = new ArrayList<String>( Arrays.asList(expectedListAsString.split("\t"))); List<String> actualStringTypeList = new ArrayList<String>( Arrays.asList(actualListAsString.split("\t"))); Collections.sort(expectedStringTypeList); Collections.sort(actualStringTypeList); return expectedStringTypeList.equals(actualStringTypeList); }
Source:
<code>private void remove0(HeaderEntry<K, V> entry) { int i = index(entry.hash); HeaderEntry<K, V> e = entries[i]; if (e == entry) { entries[i] = entry.next; } entry.remove(); <START> } <END></code><technical_language>I need call --size; please adjust unit test check for this</technical_language>

Target:
private void remove0(HeaderEntry<K, V> entry) { int i = index(entry.hash); HeaderEntry<K, V> e = entries[i]; if (e == entry) { entries[i] = entry.next; } entry.remove(); --size; }
Source:
<code>protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) { <START> final PathAddress hostAddress = PathAddress.pathAddress(operation.get(OP_ADDR)).getParent(); <END> final PathAddress serverAddress = hostAddress.getParent(); final String hostName = hostAddress.getLastElement().getValue(); final String serverName = serverAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName); context.removeService(serviceName); }</code><technical_language>big deal, context.getCurrentAddress() is preferred idiom PathAddress.pathAddress(operation.get(OP_ADDR))</technical_language>

Target:
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) { final PathAddress hostAddress = context.getCurrentAddress().getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String hostName = hostAddress.getLastElement().getValue(); final String serverName = serverAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName); context.removeService(serviceName); }
Source:
<code>public boolean equals(Object object) { <START> if (object == null || object.getClass() != getClass()) { <END> return false; } if (object == this) { return true; } Result rhs = (Result) object; return new EqualsBuilder() .append(this.syntaxId, rhs.syntaxId) .append(this.test, rhs.test) .append(this.isSyntaxInputTest, rhs.isSyntaxInputTest) .isEquals(); }</code><technical_language>Result is designed extended, a slight improvement if (!(object instanceof Result)) (it instance of Result if null)</technical_language>

Target:
public boolean equals(Object object) { if (!(object instanceof Result)) { return false; } if (object == this) { return true; } Result rhs = (Result) object; return new EqualsBuilder() .append(this.syntaxId, rhs.syntaxId) .append(this.test, rhs.test) .append(this.isSyntaxInputTest, rhs.isSyntaxInputTest) .isEquals(); }
Source:
<code>public void testCachingExpiresUsingETag() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/bookstore/books/response3/123"; CacheControlFeature cacheControlFeature = new CacheControlFeature(); cacheControlFeature.setCacheResponseInputStream(true); Client client = ClientBuilder.newBuilder() .register(cacheControlFeature) .build(); WebTarget target = client.target(endpointAddress); Response response = target.request().get(); assertEquals(200, response.getStatus()); Book book = response.readEntity(Book.class); assertEquals(123L, book.getId()); MultivaluedMap<String, Object> headers = response.getMetadata(); assertFalse(headers.isEmpty()); Object etag = headers.getFirst("ETag"); assertNotNull(etag); assertTrue(etag.toString().startsWith("\"")); assertTrue(etag.toString().endsWith("\"")); Object cacheControl = headers.getFirst("Cache-Control"); assertNotNull(cacheControl); assertTrue(cacheControl.toString().contains("private")); assertTrue(cacheControl.toString().contains("max-age=1")); <START> Thread.sleep(1500L); <END> response = target.request().get(); assertEquals(304, response.getStatus()); assertFalse(response.hasEntity()); cacheControlFeature.close(); }</code><technical_language>.. client re-use cached payload is correct anymore</technical_language>

Target:
public void testCachingExpiresUsingETag() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/bookstore/books/response3/123"; try (CacheControlFeature cacheControlFeature = new CacheControlFeature()) { cacheControlFeature.setCacheResponseInputStream(true); Client client = ClientBuilder.newBuilder() .register(cacheControlFeature) .build(); WebTarget target = client.target(endpointAddress); Response response = target.request().get(); assertEquals(200, response.getStatus()); response.bufferEntity(); Book book = response.readEntity(Book.class); assertEquals(123L, book.getId()); MultivaluedMap<String, Object> headers = response.getMetadata(); assertFalse(headers.isEmpty()); Object etag = headers.getFirst("ETag"); assertNotNull(etag); assertTrue(etag.toString().startsWith("\"")); assertTrue(etag.toString().endsWith("\"")); Object cacheControl = headers.getFirst("Cache-Control"); assertNotNull(cacheControl); assertTrue(cacheControl.toString().contains("private")); assertTrue(cacheControl.toString().contains("max-age=1")); Thread.sleep(1500L); Response response2 = target.request().get(); assertEquals(304, response2.getStatus()); assertFalse(response2.hasEntity()); Book book2 = response.readEntity(Book.class); assertEquals(123L, book2.getId()); } }
Source:
<code>public void visit(DataChartNumericalDescriptor<?, ? extends Number> desc) { <START> setType(EnumSet.of(DescriptorType.NUMERICAL)); <END> }</code><technical_language>fType.add(DescriptorType.NUMERICAL);</technical_language>

Target:
public void visit(DataChartNumericalDescriptor<?, ? extends Number> desc) { fType.add(DescriptorType.NUMERICAL); }
Source:
<code>public void testWriteReadExistsDeleteCas() throws Exception { SourceDocument doc = makeSourceDocument(1l, 1l); JCas cas = JCasFactory.createText("This is a test"); casStorageSession.add("cas", EXCLUSIVE_WRITE_ACCESS, cas.getCas()); String user = "test"; sut.writeCas(doc, cas.getCas(), user); assertThat(sut.getCasFile(doc, user)).exists(); assertThat(sut.existsCas(doc, user)).isTrue(); CAS cas2 = sut.readCas(doc, user); assertThat(cas2.getDocumentText()).isEqualTo(cas.getDocumentText()); sut.deleteCas(doc, user); assertThat(sut.getCasFile(doc, user)).doesNotExist(); assertThat(sut.existsCas(doc, user)).isFalse(); <START> assertThat(casStorageSession.contains(cas.getCas())).isFalse(); <END> }</code><technical_language>This test asserting wrong CAS - original template CAS, CAS read (into session) deleted. I changed assert renamed variables clearer</technical_language>

Target:
public void testWriteReadExistsDeleteCas() throws Exception { SourceDocument doc = makeSourceDocument(1l, 1l); JCas templateCas = JCasFactory.createText("This is a test"); casStorageSession.add("cas", EXCLUSIVE_WRITE_ACCESS, templateCas.getCas()); String user = "test"; sut.writeCas(doc, templateCas.getCas(), user); assertThat(sut.getCasFile(doc, user)).exists(); assertThat(sut.existsCas(doc, user)).isTrue(); CAS cas = sut.readCas(doc, user); assertThat(cas.getDocumentText()).isEqualTo(templateCas.getDocumentText()); sut.deleteCas(doc, user); assertThat(sut.getCasFile(doc, user)).doesNotExist(); assertThat(sut.existsCas(doc, user)).isFalse(); assertThat(casStorageSession.contains(cas)).isFalse(); }
Source:
<code><START> private Dataset<Row> fixupColumnNames(JoinOperation op, JoinType joinType, <END> Dataset<Row> leftDF, Dataset<Row> rightDF, Dataset<Row> joinedDF) { if (!joinProjectsOnlyLeftTableColumns(joinType) && !op.wasRightOuterJoin && op.getLeftRow().nColumns() > leftDF.schema().length()) { int adjColNo = op.getLeftRow().nColumns(); int baseColNo = leftDF.schema().length(); StringBuilder expression = new StringBuilder(); String[] expressions = new String[op.getLeftRow().nColumns() + rightDF.schema().length()]; for (int i = 0; i < leftDF.schema().length(); i++) { String fieldName = ValueRow.getNamedColumn(i); expression.setLength(0); expression.append(fieldName); expressions[i] = expression.toString(); } for (int i = leftDF.schema().length(); i < op.getLeftRow().nColumns(); i++) { String fieldName = ValueRow.getNamedColumn(i); DataType dataType; try { dataType = op.getLeftRow().getColumn(i + 1).getStructField(fieldName).dataType(); } catch (StandardException e) { throw new RuntimeException(e); } expression.setLength(0); expression.append("CAST(null as "); expression.append(dataType.typeName()); expression.append(")"); expressions[i] = expression.toString(); } for (int i = 0; i < rightDF.schema().length(); i++) { String fieldName = ValueRow.getNamedColumn(i + baseColNo); expression.setLength(0); expression.append(fieldName); expression.append(" as "); expression.append(ValueRow.getNamedColumn(i + adjColNo)); expressions[i + adjColNo] = expression.toString(); } joinedDF = joinedDF.selectExpr(expressions); } return joinedDF; }</code><technical_language>nit: a new line methods</technical_language>

Target:
private Dataset<Row> fixupColumnNames(JoinOperation op, JoinType joinType, Dataset<Row> leftDF, Dataset<Row> rightDF, Dataset<Row> joinedDF) { boolean needsFixup = leftDFOfJoinProjectsFewerColumnsThanDefined(op, joinType, leftDF); if (!needsFixup) return joinedDF; int adjColNo = op.getLeftRow().nColumns(); int baseColNo = leftDF.schema().length(); StringBuilder expression = new StringBuilder(); String[] expressions = new String[op.getLeftRow().nColumns() + rightDF.schema().length()]; for (int i = 0; i < leftDF.schema().length(); i++) { String fieldName = ValueRow.getNamedColumn(i); expression.setLength(0); expression.append(fieldName); expressions[i] = expression.toString(); } for (int i = leftDF.schema().length(); i < op.getLeftRow().nColumns(); i++) { String fieldName = ValueRow.getNamedColumn(i); DataType dataType; try { dataType = op.getLeftRow().getColumn(i + 1).getStructField(fieldName).dataType(); } catch (StandardException e) { throw new RuntimeException(e); } expression.setLength(0); expression.append("CAST(null as "); expression.append(dataType.typeName()); expression.append(")"); expressions[i] = expression.toString(); } for (int i = 0; i < rightDF.schema().length(); i++) { String fieldName = ValueRow.getNamedColumn(i + baseColNo); expression.setLength(0); expression.append(fieldName); expression.append(" as "); expression.append(ValueRow.getNamedColumn(i + adjColNo)); expressions[i + adjColNo] = expression.toString(); } joinedDF = joinedDF.selectExpr(expressions); return joinedDF; }
Source:
<code>default boolean containsAnyLiquids(AABB aabb) { <START> <END> }</code><technical_language>default implemented methods throw exceptions for implement</technical_language>

Target:
default boolean containsAnyLiquids(AABB aabb) { final Vector3d max = aabb.getMax(); final Vector3d min = aabb.getMin(); return this.shadow$containsAnyLiquid(new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ())); }
Source:
<code>public <START> synchronized Map<Guid, <END> AsyncTaskStatus> pollTasks(Set<Guid> taskIds) { if (taskIds == null) { return Collections.emptyMap(); } return taskIds.stream().collect(Collectors.toMap(Function.identity(), this::getTaskStatus)); }</code><technical_language>is this needed</technical_language>

Target:
public Map<Guid, AsyncTaskStatus> pollTasks(Set<Guid> taskIds) { if (taskIds == null) { return Collections.emptyMap(); } return taskIds.stream().collect(Collectors.toMap(Function.identity(), this::getTaskStatus)); }
Source:
<code><START> public void deleteLogsByDate() throws InterruptedException { <END> Date testStartDate = new Date(); KieSession kieSession = createKSession(HELLO_WORLD_PROCESS); startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 4); List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery() .startDateRangeStart(testStartDate) .build() .getResultList(); Assertions.assertThat(resultList) .hasSize(4) .extracting("processId") .containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID); Set<Date> startDates = new HashSet<>(); resultList.stream().skip(1).forEach(s -> startDates.add(s.getStart())); int resultCount = startDates.stream().map( s -> auditService.processInstanceLogDelete() .startDate(s) .build() .execute()) .collect(Collectors.summingInt(Integer::intValue)); Assertions.assertThat(resultCount).isEqualTo(3); resultCount = auditService.processInstanceLogDelete() .startDate(new Date()) .build() .execute(); Assertions.assertThat(resultCount).isEqualTo(0); List<ProcessInstanceLog> resultList2 = auditService.processInstanceLogQuery() .startDateRangeStart(testStartDate) .build() .getResultList(); Assertions.assertThat(resultList2).hasSize(1); Assertions.assertThat(resultList2.get(0)).isEqualTo(resultList.get(0)); }</code><technical_language>yes, a method more clear. delay is much, 5-10 ms is enough precision is millisecond</technical_language>

Target:
public void deleteLogsByDate() throws InterruptedException { Date testStartDate = new Date(); KieSession kieSession = createKSession(HELLO_WORLD_PROCESS); startProcess(kieSession, HELLO_WORLD_PROCESS_ID, 4, 5); List<ProcessInstanceLog> resultList = auditService.processInstanceLogQuery() .startDateRangeStart(testStartDate) .build() .getResultList(); Assertions.assertThat(resultList) .hasSize(4) .extracting("processId") .containsExactly(HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID, HELLO_WORLD_PROCESS_ID); Set<Date> startDates = new HashSet<>(); resultList.stream().skip(1).forEach(s -> startDates.add(s.getStart())); int resultCount = startDates.stream().map( s -> auditService.processInstanceLogDelete() .startDate(s) .build() .execute()) .collect(Collectors.summingInt(Integer::intValue)); Assertions.assertThat(resultCount).isEqualTo(3); resultCount = auditService.processInstanceLogDelete() .startDate(new Date()) .build() .execute(); Assertions.assertThat(resultCount).isEqualTo(0); List<ProcessInstanceLog> resultList2 = auditService.processInstanceLogQuery() .startDateRangeStart(testStartDate) .build() .getResultList(); Assertions.assertThat(resultList2).hasSize(1); Assertions.assertThat(resultList2.get(0)).isEqualTo(resultList.get(0)); }
Source:
<code>private long download(T object, File outFile, int tryCount) throws IOException { try (final InputStream is = openObjectFunction.open(object); final OutputStream os = new FileOutputStream(outFile)) { <START> return IOUtils.copyLarge(is, os); <END> } catch (IOException e) { final int nextTry = tryCount + 1; if (!Thread.currentThread().isInterrupted() && nextTry < maxFetchRetry) { LOG.error(e, "Failed to download object[%s], retrying (%d of %d)", object, nextTry, maxFetchRetry); outFile.delete(); return download(object, outFile, nextTry); } else { LOG.error(e, "Failed to download object[%s], retries exhausted, aborting", object); throw e; } } }</code><technical_language>reuse buffer for downloads in this Fetcher</technical_language>

Target:
private long download(T object, File outFile, int tryCount) throws IOException { try (final InputStream is = openObjectFunction.open(object); final OutputStream os = new FileOutputStream(outFile)) { return IOUtils.copyLarge(is, os, buffer); } catch (IOException e) { final int nextTry = tryCount + 1; if (!Thread.currentThread().isInterrupted() && nextTry < maxFetchRetry) { LOG.error(e, "Failed to download object[%s], retrying (%d of %d)", object, nextTry, maxFetchRetry); outFile.delete(); return download(object, outFile, nextTry); } else { LOG.error(e, "Failed to download object[%s], retries exhausted, aborting", object); throw e; } } }
Source:
<code>private String getFixedCommitMsgWithChangeId(String errMsg, RevCommit c) { final String changeId = "Change-Id:"; StringBuilder sb = new StringBuilder(); sb.append("ERROR: ").append(errMsg); sb.append("\n"); sb.append("Suggestion for commit message:\n"); if (c.getFullMessage().indexOf(changeId)==-1) { sb.append(c.getFullMessage()); sb.append("\n"); sb.append(changeId).append(" I").append(c.name()); } else { String lines[] = c.getFullMessage().trim().split("\n"); String lastLine = lines.length > 0 ? lines[lines.length - 1] : ""; if (lastLine.indexOf(changeId)==0) { for (int i = 0; i < lines.length - 1; i++) { sb.append(lines[i]); sb.append("\n"); } sb.append("\n"); sb.append(lastLine); } else { sb.append(c.getFullMessage()); sb.append("\n"); sb.append(changeId).append(" I").append(c.name()); sb.append("\nHint: A potential Change-Id was found, but it was not in the footer of the commit message."); } } sb.append("\n"); sb.append("Hint: To automatically add a Change-Id to commit messages, install the commit-msg hook:\n"); <START> sb.append(" $ scp -p -P 29418 review.example.com:hooks/commit-msg .git/hooks/"); <END> return sb.toString(); }</code><technical_language>cool if provide actual hostname instead of 'review.example.com'. nice include username of current user this command ('user@host')</technical_language>

Target:
private String getFixedCommitMsgWithChangeId(String errMsg, RevCommit c) { final String changeId = "Change-Id:"; StringBuilder sb = new StringBuilder(); sb.append("ERROR: ").append(errMsg); sb.append("\n"); sb.append("Suggestion for commit message:\n"); if (c.getFullMessage().indexOf(changeId)==-1) { sb.append(c.getFullMessage()); sb.append("\n"); sb.append(changeId).append(" I").append(c.name()); } else { String lines[] = c.getFullMessage().trim().split("\n"); String lastLine = lines.length > 0 ? lines[lines.length - 1] : ""; if (lastLine.indexOf(changeId)==0) { for (int i = 0; i < lines.length - 1; i++) { sb.append(lines[i]); sb.append("\n"); } sb.append("\n"); sb.append(lastLine); } else { sb.append(c.getFullMessage()); sb.append("\n"); sb.append(changeId).append(" I").append(c.name()); sb.append("\nHint: A potential Change-Id was found, but it was not in the footer of the commit message."); } } String host; if (canonicalWebUrl != null) { try { host = new URL(canonicalWebUrl).getHost(); } catch (MalformedURLException e) { host = SystemReader.getInstance().getHostname(); } } else { host = SystemReader.getInstance().getHostname(); } sb.append("\n"); sb.append("Hint: To automatically add a Change-Id to commit messages, install the commit-msg hook:\n"); sb.append(" $ scp -p -P 29418 " + currentUser.getUserName() + "@" + host + ":hooks/commit-msg .git/hooks/"); return sb.toString(); }
Source:
<code>public static void deleteSilentlyRecursively(final Path path) { if (path != null) { try { deleteRecursively(path); } catch (IOException ioex) { <START> DeploymentRepositoryLogger.ROOT_LOGGER.errorf(ioex, "Error deleting file %s", path); <END> } } }</code><technical_language>This i18n</technical_language>

Target:
public static void deleteSilentlyRecursively(final Path path) { if (path != null) { try { deleteRecursively(path); } catch (IOException ioex) { DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(ioex, path); } } }
Source:
<code>public void captureWithMinLatency_jpegQualityIs95() throws InterruptedException { <START> final Semaphore semaphore = new Semaphore(0); AtomicBoolean hasJpegQuality = new AtomicBoolean(); <END> ImageCapture imageCapture = createImageCapture(); mInstrumentation.runOnMainSync(() -> bind(imageCapture)); FakeCameraControl fakeCameraControl = ((FakeCameraControl) mFakeCamera.getCameraControlInternal()); fakeCameraControl.setOnNewCaptureRequestListener(captureConfigs -> { hasJpegQuality.set(hasJpegQuality(captureConfigs, (byte) 95)); semaphore.release(); }); mInstrumentation.runOnMainSync( () -> imageCapture.takePicture(CameraXExecutors.mainThreadExecutor(), mock(ImageCapture.OnImageCapturedCallback.class))); assertThat(semaphore.tryAcquire(1, TimeUnit.SECONDS)).isTrue(); assertThat(hasJpegQuality.get()).isTrue(); }</code><technical_language>switch this mockito.verify() ArgumentCaptor more consistent rest of code</technical_language>

Target:
public void captureWithMinLatency_jpegQualityIs95() throws InterruptedException { ImageCapture imageCapture = createImageCapture(); mInstrumentation.runOnMainSync(() -> bind(imageCapture)); FakeCameraControl fakeCameraControl = ((FakeCameraControl) mFakeCamera.getCameraControlInternal()); FakeCameraControl.OnNewCaptureRequestListener mockCaptureRequestListener = mock(FakeCameraControl.OnNewCaptureRequestListener.class); fakeCameraControl.setOnNewCaptureRequestListener(mockCaptureRequestListener); mInstrumentation.runOnMainSync( () -> imageCapture.takePicture(CameraXExecutors.mainThreadExecutor(), mock(ImageCapture.OnImageCapturedCallback.class))); ArgumentCaptor<List<CaptureConfig>> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(mockCaptureRequestListener, timeout(1000).times(1)).onNewCaptureRequests(argumentCaptor.capture()); assertThat(hasJpegQuality(argumentCaptor.getValue(), (byte) 95)).isTrue(); }
Source:
<code>public boolean isModified(DirCacheEntry entry, boolean forceContentCheck) { switch (compareMetadata(entry)) { case DIFFER_BY_TIMESTAMP: if (forceContentCheck) return contentCheck(entry); else return true; case SMUDGED: return contentCheck(entry); case EQUAL: return false; case NOT_EQUAL: return true; <START> default: <END> return true; } }</code><technical_language>This IllegalStateException some other sort of RuntimeException. If is a new added enum, fail returning true</technical_language>

Target:
public boolean isModified(DirCacheEntry entry, boolean forceContentCheck) { MetadataDiff diff = compareMetadata(entry); switch (diff) { case DIFFER_BY_TIMESTAMP: if (forceContentCheck) return contentCheck(entry); else return true; case SMUDGED: return contentCheck(entry); case EQUAL: return false; case DIFFER_BY_METADATA: return true; default: throw new IllegalStateException(MessageFormat.format( JGitText.get().unexpectedCompareResult, diff.name())); } }
Source:
<code>public void variantsSetup(Set<String> enabledFields) throws Exception { <START> String sectionName = "variants"; <END> Set<String> present = this.enabledHeaderIdsBySection.get("genes"); if (present == null || present.isEmpty() || !enabledFields.remove(sectionName)) { return; } List<String> columns = Arrays.asList("gene", "cdna", "protein", "transcript", "dbsnp", "zygosity", "effect", "interpretation", "inheritance", "evidence", "segregation", "sanger", "chromosome", "start_position", "end_position", "reference_genome"); this.enabledHeaderIdsBySection.put(sectionName + "_variants", new LinkedHashSet<>(columns)); }</code><technical_language>Excel export includes variants this change. sectionName changed in next methods, variantsHeader variantsBody,</technical_language>

Target:
public void variantsSetup(Set<String> enabledFields) throws Exception { String sectionName = "variants"; Set<String> present = this.enabledHeaderIdsBySection.get("genes"); if (present == null || present.isEmpty() || !enabledFields.remove(sectionName)) { return; } List<String> columns = Arrays.asList("gene", "cdna", "protein", "transcript", "dbsnp", "zygosity", "effect", "interpretation", "inheritance", "evidence", "segregation", "sanger", "chromosome", "start_position", "end_position", "reference_genome"); this.enabledHeaderIdsBySection.put(sectionName, new LinkedHashSet<>(columns)); }
Source:
<code>public void getWorkerUUIDs_must_be_retrieved_from_ceworkerfactory() { CeWorkerFactory ceWorkerFactory = mock(CeWorkerFactory.class); <START> Set<String> workerUUIDs = new HashSet<>(); <END> workerUUIDs.addAll(Arrays.asList("1", "2", "3")); when(ceWorkerFactory.getWorkerUUIDs()).thenReturn(workerUUIDs); StandaloneCeDistributedInformation ceCluster = new StandaloneCeDistributedInformation(ceWorkerFactory); ceCluster.broadcastWorkerUUIDs(); assertThat(ceCluster.getWorkerUUIDs()).isEqualTo(workerUUIDs); }</code><technical_language>inline lines either: Set<String> workerUuids = new HashSet<>(Arrays.asList("1", "2", "3")); Set<String> workerUUIDs = ImmutableSet.of("1", "2", "3");</technical_language>

Target:
public void getWorkerUUIDs_must_be_retrieved_from_ceworkerfactory() { CeWorkerFactory ceWorkerFactory = mock(CeWorkerFactory.class); Set<String> workerUUIDs = ImmutableSet.of("1", "2", "3"); when(ceWorkerFactory.getWorkerUUIDs()).thenReturn(workerUUIDs); StandaloneCeDistributedInformation ceCluster = new StandaloneCeDistributedInformation(ceWorkerFactory); ceCluster.broadcastWorkerUUIDs(); assertThat(ceCluster.getWorkerUUIDs()).isEqualTo(workerUUIDs); }
Source:
<code>private SetOptions parseOptionalParameters(List<byte[]> optionalParameterBytes) throws IllegalArgumentException { boolean keepTTL = false; SetOptions.Exists existsOption = SetOptions.Exists.NONE; long expiration = 0L; List<String> optionalParametersStrings = optionalParameterBytes.stream() .map(item -> Coder.bytesToString(item).toUpperCase()) .collect(Collectors.toList()); throwExceptionIfUnknownParameter(optionalParametersStrings); throwExceptionIfIncompatableParamaterOptions(optionalParametersStrings); if (optionalParametersStrings.contains("KEEPTL")) { keepTTL = true; } if (optionalParametersStrings.contains("PX")) { <START> int index = optionalParametersStrings.indexOf("PX"); <END> if (optionalParametersStrings.size() <= index + 1) { throw new IllegalArgumentException(ERROR_SYNTAX); } String expirationTime = optionalParametersStrings.get(index + 1); expiration = parseExpirationTime("PX", expirationTime); } else if (optionalParametersStrings.contains("EX")) { int index = optionalParametersStrings.indexOf("EX"); if (optionalParametersStrings.size() <= index + 1) { throw new IllegalArgumentException(ERROR_SYNTAX); } String expirationTime = optionalParametersStrings.get(index + 1); expiration = parseExpirationTime("EX", expirationTime); } if (optionalParametersStrings.contains("NX")) { existsOption = SetOptions.Exists.NX; } else if (optionalParametersStrings.contains("XX")) { existsOption = SetOptions.Exists.XX; } return new SetOptions(existsOption, expiration, keepTTL); }</code><technical_language>consider a method called getNextParameter("PX") do indexOf, size check get return it. this type of code like: if (optionalParametersStrings.contains("PX")) { String expirationTime = getNextParameter(optionalParametersStrings, "PX");</technical_language>

Target:
private SetOptions parseOptionalParameters(List<byte[]> optionalParameterBytes) throws IllegalArgumentException { boolean keepTTL = false; SetOptions.Exists existsOption = SetOptions.Exists.NONE; long millisecondsUntilExpiration = 0L; List<String> optionalParametersStrings = optionalParameterBytes.stream() .map(item -> Coder.bytesToString(item).toUpperCase()) .collect(Collectors.toList()); throwExceptionIfIncompatableParameterOptions(optionalParametersStrings); throwErrorIfNumberInWrongPosition(optionalParametersStrings); throwExceptionIfUnknownParameter(optionalParametersStrings); if (optionalParametersStrings.contains("PX")) { millisecondsUntilExpiration = handleExpiration(optionalParametersStrings, "PX"); } else if (optionalParametersStrings.contains("EX")) { millisecondsUntilExpiration = handleExpiration(optionalParametersStrings, "EX"); } if (optionalParametersStrings.contains("NX")) { existsOption = SetOptions.Exists.NX; } else if (optionalParametersStrings.contains("XX")) { existsOption = SetOptions.Exists.XX; } return new SetOptions(existsOption, millisecondsUntilExpiration, keepTTL); }