auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>String getName(GuidedDecisionTable52 dt, List<DTCellValue52> row, Number num) { <START> final DTCellValue52 dtCellValue52 = row.get(RULE_NAME_COLUMN_INDEX); <END> if (hasStringValue(dtCellValue52)) { return dtCellValue52.getStringValue(); } else { return String.format("Row %d %s", num.longValue(), dt.getTableName()); } }</code><technical_language>I ask a naming improvement? I 'dtCellValue52' is more 'ruleNameValue52'? is opinion</technical_language>

Target:
String getName(GuidedDecisionTable52 dt, List<DTCellValue52> row, Number num) { final DTCellValue52 ruleNameValue = row.get(RULE_NAME_COLUMN_INDEX); if (hasStringValue(ruleNameValue)) { return ruleNameValue.getStringValue(); } else { return String.format("Row %d %s", num.longValue(), dt.getTableName()); } }
Source:
<code>static Supplier<Object> supplierFromObjectSelector(final BaseObjectColumnValueSelector<?> selector) { <START> if (selector == null) { <END> return null; } final Class<?> clazz = selector.classOfObject(); if (Number.class.isAssignableFrom(clazz) || String.class.isAssignableFrom(clazz)) { return selector::getObject; } else if (clazz.isAssignableFrom(Number.class) || clazz.isAssignableFrom(String.class)) { return () -> { final Object val = selector.getObject(); if (val instanceof Number || val instanceof String) { return val; } else { return null; } }; } else { return null; } }</code><technical_language>ColumnSelectorFactory.makeColumnValueSelector() returns non-null now, I accept nulls</technical_language>

Target:
static Supplier<Object> supplierFromObjectSelector(final BaseObjectColumnValueSelector<?> selector) { if (selector instanceof NilColumnValueSelector) { return null; } final Class<?> clazz = selector.classOfObject(); if (Number.class.isAssignableFrom(clazz) || String.class.isAssignableFrom(clazz)) { return selector::getObject; } else if (clazz.isAssignableFrom(Number.class) || clazz.isAssignableFrom(String.class)) { return () -> { final Object val = selector.getObject(); if (val instanceof Number || val instanceof String) { return val; } else { return null; } }; } else { return null; } }
Source:
<code>public Set<RelColumnOrigin> getColumnOrigins( Aggregate rel, int iOutputColumn) { if (iOutputColumn < rel.getGroupCount()) { return invokeGetColumnOrigins( rel.getInput(), iOutputColumn); } if (rel.indicator) { if (iOutputColumn < rel.getGroupCount() + rel.getIndicatorCount()) { <START> return new HashSet<RelColumnOrigin>(); <END> } } AggregateCall call = rel.getAggCallList().get(iOutputColumn - rel.getGroupCount() - rel.getIndicatorCount()); Set<RelColumnOrigin> set = new HashSet<RelColumnOrigin>(); for (Integer iInput : call.getArgList()) { Set<RelColumnOrigin> inputSet = invokeGetColumnOrigins( rel.getInput(), iInput); inputSet = createDerivedColumnOrigins(inputSet); if (inputSet != null) { set.addAll(inputSet); } } return set; }</code><technical_language>ImmutableSet.of(). point creating a new object</technical_language>

Target:
public Set<RelColumnOrigin> getColumnOrigins( Aggregate rel, int iOutputColumn) { if (iOutputColumn < rel.getGroupCount()) { return invokeGetColumnOrigins( rel.getInput(), iOutputColumn); } if (rel.indicator) { if (iOutputColumn < rel.getGroupCount() + rel.getIndicatorCount()) { return ImmutableSet.of(); } } AggregateCall call = rel.getAggCallList().get(iOutputColumn - rel.getGroupCount() - rel.getIndicatorCount()); Set<RelColumnOrigin> set = new HashSet<RelColumnOrigin>(); for (Integer iInput : call.getArgList()) { Set<RelColumnOrigin> inputSet = invokeGetColumnOrigins( rel.getInput(), iInput); inputSet = createDerivedColumnOrigins(inputSet); if (inputSet != null) { set.addAll(inputSet); } } return set; }
Source:
<code>public static File getRevisionFile(AbstractBuild build) { <START> return new File(build.getRootDir(),"revision.txt"); <END> }</code><technical_language>return getRevisionFile((Run)build);</technical_language>

Target:
public static File getRevisionFile(AbstractBuild build) { return getRevisionFile((Run) build); }
Source:
<code><START> int getSize() { <END> return events.size(); }</code><technical_language>I worry name is potentially confusing; size interpreted size of batch, in bytes, number of events in batch. brain trouble reconciling code. consider numberOfEvents countOfEvents</technical_language>

Target:
public int getSize() { return events.size(); }
Source:
<code>PackageBinding combineWithSiblings(PackageBinding childPackage, char[] name, ModuleBinding module) { ModuleBinding primaryModule = <START> childPackage != null ? <END> childPackage.enclosingModule : this.enclosingModule; boolean activeSave = primaryModule.isPackageLookupActive; primaryModule.isPackageLookupActive = true; try { char[] flatName = CharOperation.concatWith(childPackage.compoundName, '.'); for (PackageBinding incarnation : this.incarnations) { ModuleBinding moduleBinding = incarnation.enclosingModule; if (moduleBinding == module) continue; if (childPackage.isDeclaredIn(moduleBinding)) continue; PackageBinding next = moduleBinding.getDeclaredPackage(flatName); childPackage = combine(next, childPackage, primaryModule); } return childPackage; } finally { primaryModule.isPackageLookupActive = activeSave; } }</code><technical_language>childPackage null here</technical_language>

Target:
PackageBinding combineWithSiblings(PackageBinding childPackage, char[] name, ModuleBinding module) { ModuleBinding primaryModule = childPackage.enclosingModule; boolean activeSave = primaryModule.isPackageLookupActive; primaryModule.isPackageLookupActive = true; try { char[] flatName = CharOperation.concatWith(childPackage.compoundName, '.'); for (PackageBinding incarnation : this.incarnations) { ModuleBinding moduleBinding = incarnation.enclosingModule; if (moduleBinding == module) continue; if (childPackage.isDeclaredIn(moduleBinding)) continue; PackageBinding next = moduleBinding.getDeclaredPackage(flatName); childPackage = combine(next, childPackage, primaryModule); } return childPackage; } finally { primaryModule.isPackageLookupActive = activeSave; } }
Source:
<code>private Jedis getJedisResource() { if (jedisSentinelPool != null) { <START> return jedisSentinelPool.getResource(); <END> } return jedisPool.getResource(); }</code><technical_language>if statements, jedisPool instance of common parent, Pool<Jedis></technical_language>

Target:
private Jedis getJedisResource() { return jedisPool.getResource(); }
Source:
<code>public ColumnBuilderFactory(@NonNull ColumnDefinitions<T> columnDefinitions) { this.columnDefinitions = columnDefinitions; id = Syncable.MISSING_ID; <START> uuid = Syncable.Companion.getMISSING_UUID(); <END> columnType = 0; syncState = new DefaultSyncState(); customOrderId = 0; }</code><technical_language>@JvmStatic annotation (in Syncable whatever) this a cleaner for Java side</technical_language>

Target:
public ColumnBuilderFactory(@NonNull ColumnDefinitions<T> columnDefinitions) { this.columnDefinitions = columnDefinitions; id = Keyed.MISSING_ID; uuid = Keyed.Companion.getMISSING_UUID(); columnType = 0; syncState = new DefaultSyncState(); customOrderId = 0; }
Source:
<code>protected Object getEntity() { try { Method m = resolveGet(); if (m == null) { return null; } Object entity = m.invoke(this); return getEntityWithIdAndHref(entity); } catch (Exception e) { log.error("Getting resource after action failed: {}", e.getMessage()); <START> log.debug("Exception", e); <END> return null; } }</code><technical_language>stack trace level message</technical_language>

Target:
protected Object getEntity() { try { Method m = resolveGet(); if (m == null) { return null; } Object entity = m.invoke(this); return getEntityWithIdAndHref(entity); } catch (Exception e) { log.error("Getting resource after action failed.", e); return null; } }
Source:
<code>public void canAddToEmptyWallet() { final SDBClient client = Mockito.mock(SDBClient.class); final AmazonSimpleDB aws = Mockito.mock(AmazonSimpleDB.class); Mockito.doReturn(aws).when(client).get(); final GetAttributesResult gar = Mockito.mock(GetAttributesResult.class); Mockito.doReturn(gar).when(aws) <START> .getAttributes( <END> Mockito.any(GetAttributesRequest.class) ); Mockito.doReturn(new ArrayList<Attribute>()).when(gar).getAttributes(); Mockito.doNothing().when(aws).putAttributes( Mockito.any( PutAttributesRequest.class ) ); final Wallet wlt = new Wallet.Empty(); final ItemSpinbox box = new ItemSpinbox(wlt, "test", client); final long deposit = Tv.EIGHT; final long balance = box.add(deposit); Mockito.verify(aws).getAttributes( Mockito.any( GetAttributesRequest.class ) ); Mockito.verify(aws).putAttributes( Mockito.any( PutAttributesRequest.class ) ); MatcherAssert.assertThat(balance, Matchers.equalTo(deposit)); }</code><technical_language>break lines here, write this: Mockito.doReturn(gar).when(aws).getAttributes( // ... );</technical_language>

Target:
public void canAddToEmptyWallet() { final SDBClient client = Mockito.mock(SDBClient.class); final AmazonSimpleDB aws = Mockito.mock(AmazonSimpleDB.class); Mockito.doReturn(aws).when(client).get(); final GetAttributesResult gar = Mockito.mock(GetAttributesResult.class); Mockito.doReturn(gar).when(aws).getAttributes( Mockito.any(GetAttributesRequest.class) ); Mockito.doReturn(new ArrayList<Attribute>(0)).when(gar).getAttributes(); Mockito.doNothing().when(aws).putAttributes( Mockito.any( PutAttributesRequest.class ) ); final Wallet wlt = new Wallet.Empty(); final ItemSpinbox box = new ItemSpinbox(wlt, "test", client); final long deposit = Tv.EIGHT; final long balance = box.add(deposit); Mockito.verify(aws).getAttributes( Mockito.any( GetAttributesRequest.class ) ); Mockito.verify(aws).putAttributes( Mockito.any( PutAttributesRequest.class ) ); MatcherAssert.assertThat(balance, Matchers.equalTo(deposit)); }
Source:
<code>public static int defaultMaxConnections() { <START> return AsyncPropertiesHelper.getAysncHttpClientConfig().getInt(ASYNC_CLIENT + "maxConnections"); <END> }</code><technical_language>good. reloading config for method call. Reloading happen reloadProperties</technical_language>

Target:
public static int defaultMaxConnections() { return AsyncPropertiesHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT + "maxConnections"); }
Source:
<code>public Collection<Measurement> executeSensors() { <START> LOG.info("----------------------------------"); <END> try { for (TopologyAPI.Config.KeyValue kv : physicalPlanProvider.get().getTopology().getTopologyConfig().getKvsList()) { if (kv.getKey().endsWith(":runtime")) { LOG.fine("kv:runtime " + kv.getKey() + " -> " + kv.getValue()); if (kv.getKey().equals(policyIdRuntime)) { try { PolicyMode val = PolicyMode.valueOf(kv.getValue()); if (!policyMode.equals(val)) { policyMode = val; LOG.info("policy " + policyId + " status changed to " + policyMode); } else { LOG.fine("policy " + policyId + " status remains same " + policyMode); } break; } catch (IllegalArgumentException e) { LOG.warning("policy " + policyId + " status does not change " + policyMode + "; unknown input " + kv.getValue()); } } } } } catch (Exception e) { LOG.warning( "failed to fetch the latest physical plan and skip policy toggle update: " + e.toString()); } if (policyMode.equals(PolicyMode.activated)) { return super.executeSensors(); } else { return Collections.EMPTY_LIST; } }</code><technical_language>is this log needed</technical_language>

Target:
public Collection<Measurement> executeSensors() { LOG.fine("--------- policy: " + policyId + " ---------"); try { for (TopologyAPI.Config.KeyValue kv : physicalPlanProvider.get().getTopology().getTopologyConfig().getKvsList()) { if (kv.getKey().endsWith(":runtime")) { LOG.fine("kv:runtime " + kv.getKey() + " -> " + kv.getValue()); if (kv.getKey().equals(policyIdRuntime)) { try { PolicyMode val = PolicyMode.valueOf(kv.getValue()); if (!policyMode.equals(val)) { policyMode = val; LOG.info("policy " + policyId + " status changed to " + policyMode); } else { LOG.fine("policy " + policyId + " status remains same " + policyMode); } break; } catch (IllegalArgumentException e) { LOG.warning("policy " + policyId + " status does not change " + policyMode + "; unknown input " + kv.getValue()); } } } } } catch (Exception e) { LOG.warning( "failed to fetch the latest physical plan and skip policy toggle update: " + e.toString()); } if (policyMode.equals(PolicyMode.activated)) { return super.executeSensors(); } else { return Collections.EMPTY_LIST; } }
Source:
<code><START> public File tryFindHook(Repository repository, final Hook hook) { <END> final File gitDir = repository.getDirectory(); final File[] hookDirCandidates = gitDir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().equals("hooks"); } }); if (hookDirCandidates.length < 1) return null; final File[] matchingHooks = hookDirCandidates[0] .listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().equals(hook.getName()); } }); if (matchingHooks.length < 1) return null; return matchingHooks[0]; }</code><technical_language>Missing @since</technical_language>

Target:
public File tryFindHook(Repository repository, final Hook hook) { final File gitDir = repository.getDirectory(); final File[] hookDirCandidates = gitDir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().equals("hooks"); } }); if (hookDirCandidates == null || hookDirCandidates.length < 1) return null; final File[] matchingHooks = hookDirCandidates[0] .listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().equals(hook.getName()); } }); if (matchingHooks == null || matchingHooks.length < 1) return null; return matchingHooks[0]; }
Source:
<code>public double getInflationRate(final Double firstTime, final Double secondTime) { <START> ArgumentChecker.isTrue(firstTime < secondTime, "firstTime should be before secondTime"); <END> return this.getPriceIndex(secondTime) / this.getPriceIndex(firstTime) - 1.0; }</code><technical_language>Do want display dates well? in message maybe</technical_language>

Target:
public double getInflationRate(final Double firstTime, final Double secondTime) { ArgumentChecker.isTrue(firstTime < secondTime, "first time should be before second time {}", firstTime, secondTime); return this.getPriceIndex(secondTime) / this.getPriceIndex(firstTime) - 1.0; }
Source:
<code>public GraphQLSchema build() { <START> return build(null); <END> }</code><technical_language>I prefer null ... a empty set assert null</technical_language>

Target:
public GraphQLSchema build() { return build(Collections.<GraphQLType>emptySet()); }
Source:
<code><START> public RuntimeException translateException(Exception exception) { <END> RuntimeException runtimeException = exception instanceof RuntimeException ? (RuntimeException) exception : new RuntimeException(exception.getMessage(), exception); RuntimeException potentiallyTranslatedException = exceptionTranslator .translateExceptionIfPossible(runtimeException); return potentiallyTranslatedException != null ? potentiallyTranslatedException : runtimeException; }</code><technical_language>Nit: this method private asks for it. utility client callback</technical_language>

Target:
private RuntimeException translateException(Exception exception) { RuntimeException runtimeException = exception instanceof RuntimeException ? (RuntimeException) exception : new RuntimeException(exception.getMessage(), exception); RuntimeException potentiallyTranslatedException = exceptionTranslator .translateExceptionIfPossible(runtimeException); return potentiallyTranslatedException != null ? potentiallyTranslatedException : runtimeException; }
Source:
<code>public void handleOutgoingSessionNegotiation( final OutgoingSessionNegotiation negotiation) { executor.execute(new Runnable() { @Override public void run() { SessionNegotiation.Status status = negotiation .start(new ConsoleProgressIndicator(System.out)); if (status == Status.OK) sessionManager.startSharingProjects(negotiation.getPeer()); <START> else if (status == Status.ERROR || status == Status.REMOTE_ERROR) log.error(negotiation.getErrorMessage()); <END> } }); }</code><technical_language>I do information is contained in getErrorMessage(). I hurt a better/unique log statement for ERROR,REMOTE_ERROR, LOCAL_CANCEL REMOTE_CANCEL</technical_language>

Target:
public void handleOutgoingSessionNegotiation( final OutgoingSessionNegotiation negotiation) { sessionExecutor.execute(new Runnable() { @Override public void run() { SessionNegotiation.Status status; if (ServerConfig.isInteractive()) { status = negotiation .start(new ConsoleProgressIndicator(System.out)); } else { status = negotiation .start(new NullProgressMonitor()); } switch (status) { case OK: sessionManager.startSharingProjects(negotiation.getPeer()); break; case ERROR: log.error("ERROR running session negotiation: "+negotiation.getErrorMessage()); break; case REMOTE_ERROR: log.error("REMOTE_ERROR running session negotiation: "+ negotiation.getErrorMessage()+" at remote: "+negotiation.getPeer().toString()); break; case CANCEL: log.info("Session negotiation was cancelled locally"); break; case REMOTE_CANCEL: log.info("Session negotiation was cancelled by remote: "+ negotiation.getPeer().toString()); break; } } }); }
Source:
<code>AsyncHttpMessageHandlerSpec(Expression uriExpression, AsyncRestTemplate asyncRestTemplate) { this.target = new AsyncHttpRequestExecutingMessageHandler(uriExpression, asyncRestTemplate); this.target.setUriVariableExpressions(this.uriVariableExpressions); <START> this.target.setHeaderMapper(this.headerMapper); <END> this.asyncRestTemplate = asyncRestTemplate; }</code><technical_language>M-m-m. I move assignments ctor of super class. in case need variables protected Sonar Qube angry</technical_language>

Target:
AsyncHttpMessageHandlerSpec(Expression uriExpression, AsyncRestTemplate asyncRestTemplate) { super(new AsyncHttpRequestExecutingMessageHandler(uriExpression, asyncRestTemplate)); this.asyncRestTemplate = asyncRestTemplate; }
Source:
<code>public <R> CtMethod<R> getOverriddenMethod() { CtTypeReference<T> lambdaTypeRef = getType(); if (lambdaTypeRef == null) { return null; } CtMethod<?> lambdaExecutableMethod = null; if (!(lambdaTypeRef instanceof CtIntersectionTypeReference)) { return getOverriddenAux(lambdaTypeRef); } else { <START> CtElement parent = lambdaTypeRef.getParent(); <END> CtTypeReference<?> parentTypeReference = null; if (parent != null && parent instanceof CtLocalVariable) { parentTypeReference = ((CtLocalVariable) parent).getType(); } else if (parent != null && parent instanceof CtAssignment) { parentTypeReference = ((CtAssignment) parent).getAssigned().getType(); } for (CtTypeReference<?> ctTypeReference : ((CtIntersectionTypeReference<?>) lambdaTypeRef).getBounds()) { CtMethod<?> tmp = getOverriddenAux(ctTypeReference); if (tmp != null && (lambdaExecutableMethod == null || ctTypeReference.equals(parentTypeReference))) { lambdaExecutableMethod = tmp; } } } if (lambdaExecutableMethod == null) { throw new SpoonException("The lambda can be based on interface, which has one method. But " + lambdaTypeRef.getQualifiedName() + " has no one"); } return (CtMethod<R>) lambdaExecutableMethod; }</code><technical_language>refactor else block in getOverriddenMethodForIntersectionType</technical_language>

Target:
public <R> CtMethod<R> getOverriddenMethod() { CtTypeReference<T> lambdaTypeRef = getType(); if (lambdaTypeRef == null) { return null; } if (!(lambdaTypeRef instanceof CtIntersectionTypeReference)) { return getOverriddenMethodForNormalType(lambdaTypeRef); } CtMethod<?> lambdaExecutableMethod = getOverriddenMethodForIntersectionType(lambdaTypeRef); if (lambdaExecutableMethod == null) { throw new SpoonException("The lambda can be based on interface, which has one method. But " + lambdaTypeRef.getQualifiedName() + " has no one"); } return (CtMethod<R>) lambdaExecutableMethod; }
Source:
<code>public void shouldCreateWarehouse() throws Exception { onRequest() .havingMethodEqualTo("POST") .havingPathEqualTo(Warehouses.URI) <START> .havingHeader(GoodData.GDC_HOST_HEADER) <END> .respond() .withBody(readFromResource(TASK_POLL)) .withStatus(202); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(pollingTask.getPollLink()) .havingHeader(GoodData.GDC_HOST_HEADER) .respond() .withStatus(202) .thenRespond() .withBody(readFromResource(TASK_DONE)) .withStatus(201); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(finishedTask.getWarehouseLink()) .havingHeader(GoodData.GDC_HOST_HEADER) .respond() .withBody(readFromResource(WAREHOUSE)) .withStatus(200); final Warehouse created = gd.getWarehouseService().createWarehouse(new Warehouse(TITLE, "{Token}", "Storage")).get(); assertThat(created, notNullValue()); assertThat(created.getTitle(), is(TITLE)); assertThat(created.getConnectionUrl(), is(CONNECTION_URL)); }</code><technical_language>Well, enough test presence of header in test (to other tests concise possible). other hand test for absence of header null is is missing</technical_language>

Target:
public void shouldCreateWarehouse() throws Exception { onRequest() .havingMethodEqualTo("POST") .havingPathEqualTo(Warehouses.URI) .respond() .withBody(readFromResource(TASK_POLL)) .withStatus(202); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(pollingTask.getPollLink()) .respond() .withStatus(202) .thenRespond() .withBody(readFromResource(TASK_DONE)) .withStatus(201); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(finishedTask.getWarehouseLink()) .respond() .withBody(readFromResource(WAREHOUSE)) .withStatus(200); final Warehouse created = gd.getWarehouseService().createWarehouse(new Warehouse(TITLE, "{Token}", "Storage")).get(); assertThat(created, notNullValue()); assertThat(created.getTitle(), is(TITLE)); assertThat(created.getConnectionUrl(), is(CONNECTION_URL)); }
Source:
<code>public boolean hasOperations(View view) { <START> return getOperations(view) != null; <END> }</code><technical_language>check viewOperations map</technical_language>

Target:
public boolean hasOperations(View view) { return viewOperations.containsKey(view.getName()); }
Source:
<code>public static @CheckForNull String getAccessIpAddress(@Nonnull Server server) throws IllegalArgumentException, NoSuchElementException { String fixedIPv4 = null; String fixedIPv6 = null; String floatingIPv6 = null; Collection<List<? extends Address>> addressMap = server.getAddresses().getAddresses().values(); for (List<? extends Address> addresses: addressMap) { for (Address addr: addresses) { String type = addr.getType(); int version = addr.getVersion(); String address = addr.getAddr(); if (version != 4 && version != 6) throw new IllegalArgumentException( "Unknown or unsupported IP protocol version: " + version ); if (Objects.equals(type, "floating")) { if (version == 4) { return address; } else { if (floatingIPv6 == null) { floatingIPv6 = address; } } <START> } else if (Objects.equals(type, "fixed") || type == null) { <END> if (version == 4) { if (fixedIPv4 == null) { fixedIPv4 = address; } } else { if (fixedIPv6 == null) { fixedIPv6 = address; } } } } } if (floatingIPv6 != null) return floatingIPv6; if (fixedIPv4 != null) return fixedIPv4; if (fixedIPv6 != null) return fixedIPv6; throw new NoSuchElementException("No access IP address found for " + server.getName() + ": " + addressMap); }</code><technical_language>I guess do need else if accept everything</technical_language>

Target:
public static @CheckForNull String getAccessIpAddress(@Nonnull Server server) throws IllegalArgumentException, NoSuchElementException { String fixedIPv4 = null; String fixedIPv6 = null; String floatingIPv6 = null; Collection<List<? extends Address>> addressMap = server.getAddresses().getAddresses().values(); for (List<? extends Address> addresses: addressMap) { for (Address addr: addresses) { String type = addr.getType(); int version = addr.getVersion(); String address = addr.getAddr(); if (version != 4 && version != 6) throw new IllegalArgumentException( "Unknown or unsupported IP protocol version: " + version ); if (Objects.equals(type, "floating")) { if (version == 4) { return address; } else { if (floatingIPv6 == null) { floatingIPv6 = address; } } } else { if (version == 4) { if (fixedIPv4 == null) { fixedIPv4 = address; } } else { if (fixedIPv6 == null) { fixedIPv6 = address; } } } } } if (floatingIPv6 != null) return floatingIPv6; if (fixedIPv4 != null) return fixedIPv4; if (fixedIPv6 != null) return fixedIPv6; throw new NoSuchElementException("No access IP address found for " + server.getName() + ": " + addressMap); }
Source:
<code>public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException { super.configurePipeline(pipelineConfigurer); parseConfiguration(config.compressor); try { Schema outputSchema = Schema.parseJson(config.schema); List<Field> outFields = outputSchema.getFields(); for (Field field : outFields) { outSchemaMap.put(field.getName(), field.getSchema().getType()); } pipelineConfigurer.getStageConfigurer().setOutputSchema(outputSchema); } catch (IOException e) { throw new IllegalArgumentException("Format of schema specified is invalid. Please check the format."); } Schema inputSchema = pipelineConfigurer.getStageConfigurer().getInputSchema(); if (inputSchema != null) { for (Schema.Field field : inputSchema.getFields()) { if (outSchemaMap.containsKey(field.getName()) && compMap.containsKey(field.getName()) && compMap.get(field.getName()) != CompressorType.NONE && !Schema.Type.BYTES.equals(field.getSchema().getType()) && !Schema.Type.STRING.equals(field.getSchema().getType())) { throw new IllegalArgumentException( <START> String.format("Input field %s should be of type BYTES to compress. It is currently of type %s", <END> field.getName(), field.getSchema().getType().toString())); } } } }</code><technical_language>of type bytes string</technical_language>

Target:
public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException { super.configurePipeline(pipelineConfigurer); parseConfiguration(config.compressor); try { Schema outputSchema = Schema.parseJson(config.schema); List<Field> outFields = outputSchema.getFields(); for (Field field : outFields) { outSchemaMap.put(field.getName(), field.getSchema().getType()); } pipelineConfigurer.getStageConfigurer().setOutputSchema(outputSchema); } catch (IOException e) { throw new IllegalArgumentException("Format of schema specified is invalid. Please check the format."); } Schema inputSchema = pipelineConfigurer.getStageConfigurer().getInputSchema(); if (inputSchema != null) { for (Schema.Field field : inputSchema.getFields()) { if (outSchemaMap.containsKey(field.getName()) && compMap.containsKey(field.getName()) && compMap.get(field.getName()) != CompressorType.NONE && !Schema.Type.BYTES.equals(field.getSchema().getType()) && !Schema.Type.STRING.equals(field.getSchema().getType())) { throw new IllegalArgumentException( String.format("Input field %s must be of type bytes or string. It is currently of type %s", field.getName(), field.getSchema().getType().toString())); } } } }
Source:
<code>public void damage(double amount, Entity source, EntityDamageEvent.DamageCause cause) { if (noDamageTicks > 0 || health <= 0 || !canTakeDamage(cause)) { return; } else { noDamageTicks = maxNoDamageTicks; } if (cause != null && hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { switch (cause) { case PROJECTILE: if (source == null || !(source instanceof Fireball)) { break; } case FIRE: case FIRE_TICK: case LAVA: return; } } EntityDamageEvent event; if (source == null) { event = new EntityDamageEvent(this, cause, amount); } else { event = new EntityDamageByEntityEvent(source, this, cause, amount); } EventFactory.callEvent(event); if (event.isCancelled()) { return; } if (source != null && source instanceof GlowPlayer) { ((GlowPlayer) source).addExhaustion(0.3f); } amount = event.getFinalDamage(); lastDamage = amount; setHealth(health - amount); playEffect(EntityEffect.HURT); <START> if (health > 0.0) { <END> Sound hurtSound = getHurtSound(); if (hurtSound != null) { world.playSound(location, hurtSound, 1.0f, 1.0f); } } }</code><technical_language>0 is needed</technical_language>

Target:
public void damage(double amount, Entity source, EntityDamageEvent.DamageCause cause) { if (noDamageTicks > 0 || health <= 0 || !canTakeDamage(cause)) { return; } else { noDamageTicks = maxNoDamageTicks; } if (cause != null && hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { switch (cause) { case PROJECTILE: if (source == null || !(source instanceof Fireball)) { break; } case FIRE: case FIRE_TICK: case LAVA: return; } } EntityDamageEvent event; if (source == null) { event = new EntityDamageEvent(this, cause, amount); } else { event = new EntityDamageByEntityEvent(source, this, cause, amount); } EventFactory.callEvent(event); if (event.isCancelled()) { return; } if (source != null && source instanceof GlowPlayer) { ((GlowPlayer) source).addExhaustion(0.3f); } amount = event.getFinalDamage(); lastDamage = amount; setHealth(health - amount); playEffect(EntityEffect.HURT); if (health > 0) { Sound hurtSound = getHurtSound(); if (hurtSound != null) { world.playSound(location, hurtSound, 1.0f, 1.0f); } } }
Source:
<code>public void testAddAndRemoveUsageListener() throws Exception { final RecordingUsageListener listener = new RecordingUsageListener(); mgmt.getUsageManager().addUsageListener(listener); app = TestApplication.Factory.newManagedInstanceForTests(mgmt); app.setCatalogItemId("testCatalogItem"); app.start(ImmutableList.<Location>of()); Asserts.succeedsEventually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getApplicationEvents(); assertEquals(events.size(), 2, "events="+events); String appId = (String) events.get(0).get(1); String appName = (String) events.get(0).get(2); String entityType = (String) events.get(0).get(3); String catalogItemId = (String) events.get(0).get(4); <START> System.out.println(catalogItemId); <END> Map<?,?> metadata = (Map<?, ?>) events.get(0).get(5); ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(6); assertEquals(appId, app.getId(), "events="+events); assertNotNull(appName, "events="+events); assertEquals(app.getCatalogItemId(), "testCatalogItem"); assertNotNull(entityType, "events="+events); assertNotNull(metadata, "events="+events); assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events); }}); listener.clearEvents(); mgmt.getUsageManager().removeUsageListener(listener); app.start(ImmutableList.<Location>of()); Asserts.succeedsContinually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getLocationEvents(); assertEquals(events.size(), 0, "events="+events); }}); }</code><technical_language>Delete System.out</technical_language>

Target:
public void testAddAndRemoveUsageListener() throws Exception { final RecordingUsageListener listener = new RecordingUsageListener(); mgmt.getUsageManager().addUsageListener(listener); app = TestApplication.Factory.newManagedInstanceForTests(mgmt); app.setCatalogItemId("testCatalogItem"); app.start(ImmutableList.<Location>of()); Asserts.succeedsEventually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getApplicationEvents(); assertEquals(events.size(), 2, "events="+events); String appId = (String) events.get(0).get(1); String appName = (String) events.get(0).get(2); String entityType = (String) events.get(0).get(3); String catalogItemId = (String) events.get(0).get(4); Map<?,?> metadata = (Map<?, ?>) events.get(0).get(5); ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(6); assertEquals(appId, app.getId(), "events="+events); assertNotNull(appName, "events="+events); assertEquals(catalogItemId, app.getCatalogItemId(), "events="+events); assertNotNull(entityType, "events="+events); assertNotNull(metadata, "events="+events); assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events); }}); listener.clearEvents(); mgmt.getUsageManager().removeUsageListener(listener); app.start(ImmutableList.<Location>of()); Asserts.succeedsContinually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getLocationEvents(); assertEquals(events.size(), 0, "events="+events); }}); }
Source:
<code>public String doctitle() { <START> return getString("doctitle"); <END> }</code><technical_language>add getDoctitle() mark doctitle() deprecated. for method takes arguments</technical_language>

Target:
public String doctitle() { return getDoctitle(); }
Source:
<code>void createBatchDefault() { ServiceBusMessageBatch batch = new ServiceBusMessageBatch(MAX_MESSAGE_LENGTH_BYTES, null, null, null); when(asyncSender.createBatch()).thenReturn(Mono.just(batch)); ServiceBusMessageBatch batchMessage = sender.createBatch(); Assertions.assertEquals(MAX_MESSAGE_LENGTH_BYTES, batchMessage.getMaxSizeInBytes()); Assertions.assertEquals(0, batchMessage.getCount()); verify(asyncSender, times(1)).createBatch(); <START> <END> }</code><technical_language>nit: uneeded line</technical_language>

Target:
void createBatchDefault() { ServiceBusMessageBatch batch = new ServiceBusMessageBatch(MAX_MESSAGE_LENGTH_BYTES, null, null, null); when(asyncSender.createBatch()).thenReturn(Mono.just(batch)); ServiceBusMessageBatch batchMessage = sender.createBatch(); Assertions.assertEquals(MAX_MESSAGE_LENGTH_BYTES, batchMessage.getMaxSizeInBytes()); Assertions.assertEquals(0, batchMessage.getCount()); verify(asyncSender).createBatch(); }
Source:
<code>protected Void doInBackground(Void... arg0) { try { <START> if (!Utils.isNetworkAvailable(context)) { <END> exception = new WebconnectionException(WebconnectionException.ERROR_NETWORK, "Network not available!"); return null; } String zipFileString = Utils.buildPathForTemplatesZip(templateData.getName()); ServerCalls.getInstance().downloadProject(zipFileUrl, zipFileString, null, null, 0); } catch (WebconnectionException | IOException webconnectionException) { Log.e(TAG, Log.getStackTraceString(webconnectionException)); message = webconnectionException.getMessage(); } return null; }</code><technical_language>this is similar code... a solution, code twice..</technical_language>

Target:
protected Boolean doInBackground(Void... arg0) { if (!Utils.isNetworkAvailable(context)) { return false; } String zipFileString = Utils.buildPathForTemplatesZip(templateData.getName()); try { ServerCalls.getInstance().downloadProject(zipFileUrl, zipFileString, null, null, 0); } catch (WebconnectionException | IOException webconnectionException) { Log.e(TAG, Log.getStackTraceString(webconnectionException)); message = webconnectionException.getMessage(); } return true; }
Source:
<code>private static void checkMapNativeMaxSizePolicy(MapConfig mapConfig) { MaxSizePolicy maxSizePolicy = mapConfig.getEvictionConfig().getMaxSizePolicy(); if (!MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES.contains(maxSizePolicy)) { <START> throw new IllegalArgumentException("Maximum size policy " + maxSizePolicy <END> + " cannot be used with NATIVE in memory format backed Map." + " Supported maximum size policies are: " + MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES); } }</code><technical_language>throw InvalidConfigurationException in this class instead</technical_language>

Target:
private static void checkMapNativeMaxSizePolicy(MapConfig mapConfig) { MaxSizePolicy maxSizePolicy = mapConfig.getEvictionConfig().getMaxSizePolicy(); if (!MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES.contains(maxSizePolicy)) { throw new InvalidConfigurationException("Maximum size policy " + maxSizePolicy + " cannot be used with NATIVE in memory format backed Map." + " Supported maximum size policies are: " + MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES); } }
Source:
<code>public Collection<MercurialTagAction> getActiveBranches(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { ArgumentListBuilder cmd = findHgExe(build, listener, false); <START> cmd.add("branches", "--active"); <END> ByteArrayOutputStream baos = new ByteArrayOutputStream(); joinWithPossibleTimeout( launch(launcher).cmds(cmd) .stdout(new ForkOutputStream(baos, listener.getLogger())) .pwd(workspace2Repo(build.getWorkspace())), true, listener); Collection<MercurialTagAction> branches = new ArrayList<MercurialTagAction>(); BufferedReader in = new BufferedReader(new InputStreamReader( new ByteArrayInputStream(baos.toByteArray()))); String line; while ((line = in.readLine()) != null) { String sha = line.substring(line.indexOf(':')+1); String name = line.substring(0, line.indexOf(" ")); branches.add(new MercurialTagAction(sha, name)); } return branches; }</code><technical_language>I recommend passing --debug get full SHA-1. some cleaner do this, hg log --template ..., require revsets a new Mercurial feature</technical_language>

Target:
public Collection<MercurialTagAction> getActiveBranches(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { ArgumentListBuilder cmd = findHgExe(build, listener, false); cmd.add("branches", "--active", "--debug"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); joinWithPossibleTimeout( launch(launcher).cmds(cmd) .stdout(new ForkOutputStream(baos, listener.getLogger())) .pwd(workspace2Repo(build.getWorkspace())), true, listener); Collection<MercurialTagAction> branches = new ArrayList<MercurialTagAction>(); BufferedReader in = new BufferedReader(new InputStreamReader( new ByteArrayInputStream(baos.toByteArray()))); String line; while ((line = in.readLine()) != null) { String sha = line.substring(line.indexOf(':')+1); String name = line.substring(0, line.indexOf(" ")); branches.add(new MercurialTagAction(sha, name)); } return branches; }
Source:
<code>public void testTextBuildWithPrivateUrl() { String content = builder.buildContentString(ics); <START> System.out.println(content); <END> assertTrue(content.matches(withPrivateUrlPattern)); assertTrue(content.matches(withoutDefaultUrlPattern)); }</code><technical_language>Avoid "System.out.println" replace a logger if needed</technical_language>

Target:
public void testTextBuildWithPrivateUrl() { String content = builder.buildContentString(ics); assertTrue(content.matches(withPrivateUrlPattern)); assertTrue(content.matches(withoutDefaultUrlPattern)); }
Source:
<code>public void testList() throws StripeException { <START> SKUCollection skus = SKU.list(null); <END> assertNotNull(skus); assertEquals(1, skus.getData().size()); verifyRequest( APIResource.RequestMethod.GET, "/v1/skus" ); }</code><technical_language>called resources</technical_language>

Target:
public void testList() throws StripeException { final Map<String, Object> params = new HashMap<String, Object>(); params.put("limit", 1); final SKUCollection skus = SKU.list(params); assertNotNull(skus); assertEquals(1, skus.getData().size()); verifyRequest( APIResource.RequestMethod.GET, "/v1/skus", params ); }
Source:
<code>public void cleanup() { executeStatement("delete old query status rows from " + escapeIdent(statusTableName) + " table", String.format(ENGLISH, "DELETE FROM %s WHERE query_id = ANY(" + <START> "SELECT query_id FROM %s WHERE completed_at < now() - interval '24' hours" + <END> ")", escapeIdent(statusTableName), escapeIdent(statusTableName)) ); }</code><technical_language>24 hours configurable</technical_language>

Target:
public void cleanup() { executeStatement("delete old query status rows from " + escapeIdent(statusTableName) + " table", String.format(ENGLISH, "DELETE FROM %s WHERE query_id = ANY(" + "SELECT query_id FROM %s WHERE completed_at < now() - interval '%d seconds'" + ")", escapeIdent(statusTableName), escapeIdent(statusTableName), cleanupDuration.getSeconds()) ); }
Source:
<code>BlobStoreCompactor(String dataDir, String storeId, StoreKeyFactory storeKeyFactory, StoreConfig config, StoreMetrics metrics, DiskIOScheduler diskIOScheduler, Log srcLog, MessageStoreRecovery recovery, Time time, UUID sessionId, UUID incarnationId) throws IOException, StoreException { this.dataDir = new File(dataDir); this.storeId = storeId; this.storeKeyFactory = storeKeyFactory; this.config = config; this.srcMetrics = metrics; tgtMetrics = new StoreMetrics(storeId + METRICS_SUFFIX, metrics.getRegistry()); this.srcLog = srcLog; this.diskIOScheduler = diskIOScheduler; this.recovery = recovery; this.time = time; this.sessionId = sessionId; this.incarnationId = incarnationId; fixStateIfRequired(); <START> logger.trace("Constructed BlobStoreCompactor"); <END> }</code><technical_language>append storeId information in log statements</technical_language>

Target:
BlobStoreCompactor(String dataDir, String storeId, StoreKeyFactory storeKeyFactory, StoreConfig config, StoreMetrics metrics, DiskIOScheduler diskIOScheduler, Log srcLog, MessageStoreRecovery recovery, Time time, UUID sessionId, UUID incarnationId) throws IOException, StoreException { this.dataDir = new File(dataDir); this.storeId = storeId; this.storeKeyFactory = storeKeyFactory; this.config = config; this.srcMetrics = metrics; tgtMetrics = new StoreMetrics(storeId + METRICS_SUFFIX, metrics.getRegistry()); this.srcLog = srcLog; this.diskIOScheduler = diskIOScheduler; this.recovery = recovery; this.time = time; this.sessionId = sessionId; this.incarnationId = incarnationId; fixStateIfRequired(); logger.trace("Constructed BlobStoreCompactor for {}", dataDir); }
Source:
<code>public static boolean hasPushPublishActionlet(final WorkflowAction action) { try { final List<WorkflowActionClass> actionlets = APILocator.getWorkflowAPI() .findActionClasses(action); for (WorkflowActionClass actionlet : actionlets) { <START> if (actionlet.getActionlet() != null && actionlet.getActionlet().getClass() <END> .getCanonicalName().equals(PushPublishActionlet.class.getCanonicalName())) { return true; } } } catch (DotDataException e) { Logger.error(ActionletUtil.class, String.format( "Can't determine weather or not action '%s' has PushPublishActionlet.", action.getName()), e); } return false; }</code><technical_language>this change for (final WorkflowActionClass actionClass : actionClasses) { final Actionlet actionlet = AnnotationUtils. getBeanAnnotation(ReflectionUtils.getClassFor(actionClass.getClazz()), Actionlet.class); if (null != actionlet && actionlet.pushPublish()) { return true; }</technical_language>

Target:
public static boolean hasPushPublishActionlet(final WorkflowAction action) { try { final List<WorkflowActionClass> actionlets = APILocator.getWorkflowAPI().findActionClasses(action); for (final WorkflowActionClass actionletClass : actionlets) { final Actionlet actionlet = AnnotationUtils. getBeanAnnotation(ReflectionUtils.getClassFor(actionletClass.getClazz()), Actionlet.class); if (null != actionlet && actionlet.pushPublish()) { return true; } } } catch (DotDataException e) { Logger.error(ActionletUtil.class, String.format( "Can't determine if action '%s' has PushPublishActionlet.", action.getName()), e); } return false; }
Source:
<code>private void refetchTaskInformation(Task task) throws FacilityNotExistsException, InternalErrorException, PrivilegeException, ServiceNotExistsException { log.debug("Rereading facility and exec service for task {}", task.getId()); <START> Facility dbFacility = perun.getFacilitiesManager().getFacilityById(perunSession, task.getFacilityId()); <END> if(dbFacility == null) { throw new FacilityNotExistsException("No facility with id " + task.getFacilityId()); } Boolean taskModified = false; if(!dbFacility.equals(task.getFacility())) { task.setFacility(dbFacility); taskModified = true; } ExecService dbExecService = generalServiceManager.getExecService(perunSession, task.getExecServiceId()); if(dbExecService == null) { throw new ServiceNotExistsException("No exec service with id " + task.getExecServiceId()); } if(!dbExecService.equals(task.getExecService())) { task.setExecService(dbExecService); taskModified = true; } if(taskModified) { log.debug("Task components have changed, updating task {}", task.getId()); schedulingPool.setTaskStatus(task, task.getStatus()); } }</code><technical_language>perun.getFacilitiesManagerBl() avoid creating unnecessary new transaction, this deal PrivilegeException</technical_language>

Target:
private void refetchTaskInformation(Task task) throws FacilityNotExistsException, InternalErrorException, PrivilegeException, ServiceNotExistsException { log.debug("Rereading facility and exec service for task {}", task.getId()); Facility dbFacility = perun.getFacilitiesManagerBl().getFacilityById(perunSession, task.getFacilityId()); if(dbFacility == null) { throw new FacilityNotExistsException("No facility with id " + task.getFacilityId()); } Boolean taskModified = false; if(!dbFacility.equals(task.getFacility())) { task.setFacility(dbFacility); taskModified = true; } ExecService dbExecService = generalServiceManager.getExecService(perunSession, task.getExecServiceId()); if(dbExecService == null) { throw new ServiceNotExistsException("No exec service with id " + task.getExecServiceId()); } if(!dbExecService.equals(task.getExecService())) { task.setExecService(dbExecService); taskModified = true; } if(taskModified) { log.debug("Task components have changed, updating task {}", task.getId()); schedulingPool.setTaskStatus(task, task.getStatus()); } }
Source:
<code>public String getParentId() { <START> if (parentId == UNDEFINED) { <END> parentId = (String) state.get(KEY_PARENT_ID); } return parentId; }</code><technical_language>Related field instantiation, test parentId = UNDEFINED_PARENT_ID</technical_language>

Target:
public String getParentId() { if (parentId == UNDEFINED_PARENT_ID) { parentId = (String) state.get(KEY_PARENT_ID); } return parentId; }
Source:
<code>protected void checkAuthorization(HttpServletRequest request) { final String authorization = request.getHeader("Authorization"); <START> if (authorization != null && authorization.toLowerCase().startsWith("basic")) { <END> String base64Credentials = authorization.substring("Basic".length()).trim(); byte[] decodedCredentials = java.util.Base64.getDecoder().decode(base64Credentials); String credentials = new String(decodedCredentials, java.nio.charset.StandardCharsets.UTF_8); final String[] values = credentials.split(":"); if (values.length == 2) { clientId = values[0]; clientSecret = values[1]; } } }</code><technical_language>a constant for Basic bellow</technical_language>

Target:
protected void checkAuthorization(HttpServletRequest request) { final String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.toLowerCase().startsWith(BASIC_AUTHENTICATION_HEADER_PREFIX)) { String base64Credentials = authorization.substring(BASIC_AUTHENTICATION_HEADER_PREFIX.length()).trim(); byte[] decodedCredentials = java.util.Base64.getDecoder().decode(base64Credentials); String credentials = new String(decodedCredentials, java.nio.charset.StandardCharsets.UTF_8); String[] values = credentials.split(":", 2); if (values.length == 2) { clientId = values[0]; clientSecret = values[1]; } } }