auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static Schema getSchema(RuntimeContainer container, SalesforceProvideConnectionProperties properties, String module) throws IOException { <START> SalesforceSourceOrSink ss = new SalesforceSourceOrSink(); <END> ss.initialize(null, (ComponentProperties) properties); PartnerConnection connection = null; try { connection = ss.connect(container).connection; } catch (IOException ex) { throw new ComponentException(SalesforceRuntimeCommon.exceptionToValidationResult(ex)); } return ss.getSchema(connection, module); }</code><technical_language>I this kind modification remove modification in Talend/components/pull/259 I this caused issue again. explain this part of code revert back</technical_language>

Target:
public static Schema getSchema(RuntimeContainer container, SalesforceProvideConnectionProperties properties, String module) throws IOException { ClassLoader classLoader = SalesforceSourceOrSink.class.getClassLoader(); RuntimeInfo runtimeInfo = SalesforceDefinition.getCommonRuntimeInfo(SalesforceSourceOrSink.class.getCanonicalName()); try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClassWithCurrentJVMProperties(runtimeInfo, classLoader)) { SalesforceSourceOrSink ss = (SalesforceSourceOrSink) sandboxedInstance.getInstance(); ss.initialize(null, (ComponentProperties) properties); PartnerConnection connection = null; try { connection = ss.connect(container).connection; } catch (IOException ex) { throw new ComponentException(SalesforceRuntimeCommon.exceptionToValidationResult(ex)); } return ss.getSchema(connection, module); } }
Source:
<code>public String toString() { return toStringHelper(this) .add("queryId", queryId) .add("transactionId", transactionId) .add("user", getUser()) .add("principal", getIdentity().getPrincipal().orElse(null)) .add("source", source.orElse(null)) .add("catalog", catalog.orElse(null)) .add("schema", schema.orElse(null)) .add("timeZoneKey", timeZoneKey) .add("locale", locale) .add("remoteUserAddress", remoteUserAddress.orElse(null)) .add("userAgent", userAgent.orElse(null)) .add("clientInfo", clientInfo.orElse(null)) <START> .add("tags", Joiner.on(',').join(tags)) <END> .add("startTime", startTime) .omitNullValues() .toString(); }</code><technical_language>default formatting for sets</technical_language>

Target:
public String toString() { return toStringHelper(this) .add("queryId", queryId) .add("transactionId", transactionId) .add("user", getUser()) .add("principal", getIdentity().getPrincipal().orElse(null)) .add("source", source.orElse(null)) .add("catalog", catalog.orElse(null)) .add("schema", schema.orElse(null)) .add("timeZoneKey", timeZoneKey) .add("locale", locale) .add("remoteUserAddress", remoteUserAddress.orElse(null)) .add("userAgent", userAgent.orElse(null)) .add("clientInfo", clientInfo.orElse(null)) .add("clientTags", clientTags) .add("startTime", startTime) .omitNullValues() .toString(); }
Source:
<code>protected void run() throws Exception { walk = createWalk(); for (final RevSort s : sorting) walk.sort(s, true); if (pathFilter instanceof FollowFilter) walk.setTreeFilter(pathFilter); else if (pathFilter != TreeFilter.ALL) walk.setTreeFilter(AndTreeFilter.create(pathFilter, TreeFilter.ANY_DIFF)); if (revLimiter.size() == 1) walk.setRevFilter(revLimiter.get(0)); else if (revLimiter.size() > 1) walk.setRevFilter(AndRevFilter.create(revLimiter)); if (all) for (Ref a : db.getAllRefs().values()) { <START> ObjectId oid = a.getPeeledObjectId(); <END> commits.add(walk.parseCommit((oid == null) ? a.getObjectId() : oid)); } if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { final RevCommit real = argWalk == walk ? c : walk.parseCommit(c); if (c.has(RevFlag.UNINTERESTING)) walk.markUninteresting(real); else walk.markStart(real); } final long start = System.currentTimeMillis(); final int n = walkLoop(); if (count) { final long end = System.currentTimeMillis(); System.err.print(n); System.err.print(' '); System.err.println(MessageFormat.format( CLIText.get().timeInMilliSeconds, end - start)); } }</code><technical_language>I prefer say: if (oid == null) oid = a.getObjectId(); ?: operator below</technical_language>

Target:
protected void run() throws Exception { walk = createWalk(); for (final RevSort s : sorting) walk.sort(s, true); if (pathFilter instanceof FollowFilter) walk.setTreeFilter(pathFilter); else if (pathFilter != TreeFilter.ALL) walk.setTreeFilter(AndTreeFilter.create(pathFilter, TreeFilter.ANY_DIFF)); if (revLimiter.size() == 1) walk.setRevFilter(revLimiter.get(0)); else if (revLimiter.size() > 1) walk.setRevFilter(AndRevFilter.create(revLimiter)); if (all) for (Ref a : db.getAllRefs().values()) { ObjectId oid = a.getPeeledObjectId(); if (oid == null) oid = a.getObjectId(); try { commits.add(walk.parseCommit(oid)); } catch (IncorrectObjectTypeException e) { } } if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { final RevCommit real = argWalk == walk ? c : walk.parseCommit(c); if (c.has(RevFlag.UNINTERESTING)) walk.markUninteresting(real); else walk.markStart(real); } final long start = System.currentTimeMillis(); final int n = walkLoop(); if (count) { final long end = System.currentTimeMillis(); System.err.print(n); System.err.print(' '); System.err.println(MessageFormat.format( CLIText.get().timeInMilliSeconds, end - start)); } }
Source:
<code>public String getUrlName() { <START> return "webhook"; <END> }</code><technical_language>I easy do this, nice if URL configurable. if want install multiple plugins accessible a URL? other plugins responding /webhook</technical_language>

Target:
public String getUrlName() { String url = globalConfig.getSlackOutgoingWebhookURL(); if (url == null || url.equals("")) return null; return "/"+url; }
Source:
<code>private String getEncodingCharsetName(byte[] codedCharacterSet){ String codedCharacterSetString = new String(codedCharacterSet); try { if (Charset.isSupported(codedCharacterSetString)) { return codedCharacterSetString; } }catch (IllegalCharsetNameException e){ }catch (IllegalArgumentException e){ } byte[] codedCharacterSetNormalized = new byte[codedCharacterSet.length]; int j=0; <START> for(int i=0; i< codedCharacterSet.length; i++){ <END> if(codedCharacterSet[i] != ' ') { codedCharacterSetNormalized[j++] = codedCharacterSet[i]; } } for(CharsetEscapeSequence escapeSeq : CharsetEscapeSequence.getSupportedEscapeSeqList()){ if(j != escapeSeq.escapeSequence.length) continue; boolean match = true; for(int i=0; i < j; i++ ){ if(codedCharacterSetNormalized[i] != escapeSeq.escapeSequence[i]){ match = false; break; } } if(match){ return escapeSeq.charsetName; } } return "ISO-8859-1"; }</code><technical_language>implemented enhanced for-loop syntax</technical_language>

Target:
private String getEncodingCharsetName(byte[] codedCharacterSet){ final Character WHITESPACE = ' '; String codedCharacterSetString = new String(codedCharacterSet); try { if (Charset.isSupported(codedCharacterSetString)) { return codedCharacterSetString; } }catch (IllegalCharsetNameException e){ }catch (IllegalArgumentException e){ } byte[] utf8EscSeq = new byte[]{'\u001B','%','G'}; int j=0; boolean match = true; for(byte character : codedCharacterSet){ if(!WHITESPACE.equals(character) && utf8EscSeq[j++] != character) { match = false; } } if(match){ return UTF_8; } return DEFAULT_ENCODING; }
Source:
<code>public PagingStore getPageStore(final SimpleString storeName) throws Exception { if (managementAddress != null && storeName.startsWith(managementAddress)) { return null; } try { return stores.computeIfAbsent(storeName, (s) -> { try { return newStore(s); } catch (Exception e) { <START> throw new RuntimeException(e); <END> } }); } catch (RuntimeException e) { throw (Exception) e.getCause(); } }</code><technical_language>I stores.get is in fast path before: chm:.get is completly lock-free, while chm::computeIfAbsent lock segment level fallback chm::computeIfAbsent if chm::get return null</technical_language>

Target:
public PagingStore getPageStore(final SimpleString storeName) throws Exception { if (managementAddress != null && storeName.startsWith(managementAddress)) { return null; } PagingStore store = stores.get(storeName); if (store != null) { return store; } try { return stores.computeIfAbsent(storeName, (s) -> { try { return newStore(s); } catch (Exception e) { throw new RuntimeException(e); } }); } catch (RuntimeException e) { throw (Exception) e.getCause(); } }
Source:
<code>public void removeAllGroupResourceAttributes(PerunSession sess, Resource resource) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException { List<Group> groups = this.perunBl.getResourcesManagerBl().getAssignedGroups(sess, resource); List<Attribute> attrs = new ArrayList<>(); for(Group group: groups){ <START> attrs =this.getAttributes(sess, resource, group); <END> for(Attribute attr : attrs) { attr.setValue(null); try { this.checkAttributesValue(sess, resource, group, attrs); } catch(WrongAttributeAssignmentException ex) { throw new ConsistencyErrorException(ex); } } } this.attributesManagerImpl.removeAllGroupResourceAttributes(sess, resource); log.info("All non-virtual group-resource attributes removed for all groups and {}", resource); }</code><technical_language>Coding style :(</technical_language>

Target:
public void removeAllGroupResourceAttributes(PerunSession sess, Resource resource) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException { List<Group> groups = this.perunBl.getResourcesManagerBl().getAssignedGroups(sess, resource); List<Attribute> attrs = new ArrayList<>(); for (Group group : groups) { this.getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, resource, group); } this.attributesManagerImpl.removeAllGroupResourceAttributes(sess, resource); log.info("All non-virtual group-resource attributes removed for all groups and {}", resource); }
Source:
<code>public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { try { <START> return client.get(sessionProperties.createHeaderFromSession(session)).listTables(new PrestoThriftNullableSchemaName(schemaNameOrNull)).stream() <END> .map(PrestoThriftSchemaTableName::toSchemaTableName) .collect(toImmutableList()); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }</code><technical_language>Put .listTables() next line</technical_language>

Target:
public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { try { return client.get(sessionProperties.toHeader(session)) .listTables(new PrestoThriftNullableSchemaName(schemaNameOrNull)).stream() .map(PrestoThriftSchemaTableName::toSchemaTableName) .collect(toImmutableList()); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }
Source:
<code>private void addAccount(String data) throws JSONException { JSONObject auth = new JSONObject(data); OAuth2AuthzSession session = new OAuth2AuthzSession(); session.setAccountId(AuthData.NAME); <START> session.setAccessToken(auth.getString("key") + ":" + auth.getString("secret")); <END> sessionStore.save(session); }</code><technical_language>Is this supposed used? Secret Store's tokens OAuth Tokens</technical_language>

Target:
private void addAccount(String data) throws JSONException { JSONObject auth = new JSONObject(data); Session session = new Session(); session.setAccountId(AuthData.NAME); session.setKey(auth.getString(AuthData.Credentials.KEY)); session.setSecret(auth.getString(AuthData.Credentials.SECRET)); if (auth.has(AuthData.Credentials.EXPIRES_ON)) { session.setExpires_on(Long.parseLong(auth.getString(AuthData.Credentials.EXPIRES_ON))); } else { session.setExpires_on(0); } sessionStore.save(session); }
Source:
<code>public void hashCodeForCompositeConvertersChangesWithDifferentTransformationChain() { Converter byteArrayToObjectConverter = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter = new ByteArrayToInputStream(); Converter byteArrayToObjectConverter2 = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter2 = new ByteArrayToInputStream(); Converter byteArrayToSerializableConverter = new ByteArrayToSerializable(); int hashCodeConverterA = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAClone = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAFakeClone = new CompositeConverter(byteArrayToObjectConverter2, byteArrayToInputStreamConverter2).hashCode(); int hashCodeConverterReverseClone = new CompositeConverter(byteArrayToInputStreamConverter, byteArrayToObjectConverter).hashCode(); int hashCodeConverterNotAClone = new CompositeConverter(byteArrayToInputStreamConverter, byteArrayToSerializableConverter).hashCode(); assertThat(Arrays.asList(hashCodeConverterAClone), everyItem(equalTo(hashCodeConverterA))); <START> assertThat(Arrays.asList(hashCodeConverterReverseClone, hashCodeConverterNotAClone, hashCodeConverterAFakeClone), <END> everyItem(not(equalTo(hashCodeConverterA)))); }</code><technical_language>beware, hashCodes for equals object, is necessarily true</technical_language>

Target:
public void hashCodeForCompositeConvertersChangesWithDifferentTransformationChain() { Converter byteArrayToObjectConverter = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter = new ByteArrayToInputStream(); Converter byteArrayToObjectConverter2 = new ByteArrayToObject(); Converter byteArrayToInputStreamConverter2 = new ByteArrayToInputStream(); int hashCodeConverterA = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAClone = new CompositeConverter(byteArrayToObjectConverter, byteArrayToInputStreamConverter).hashCode(); int hashCodeConverterAnotherClone = new CompositeConverter(byteArrayToObjectConverter2, byteArrayToInputStreamConverter2).hashCode(); assertThat(Arrays.asList(hashCodeConverterAClone, hashCodeConverterAnotherClone), everyItem(equalTo(hashCodeConverterA))); }
Source:
<code>@Override public String toString() { <START> return createdSince == null ? "" : "created:>=" + ISO_8601_DATE.print(createdSince); <END> }</code><technical_language>While kind of cool return null toString, returning null omit query parameter URL altogether</technical_language>

Target:
@Override public String toString() { return createdSince == null ? null : "created:>=" + ISO_8601_DATE.print(createdSince); }
Source:
<code>protected void configure() { bind(TestAuthServiceClient.class).to(KeycloakTestAuthServiceClient.class); bind(TestMachineServiceClient.class).to(CheTestMachineServiceClient.class); <START> bind(TestWorkspaceServiceClient.class).to(CheTestWorkspaceServiceClient.class); <END> bind(DefaultTestUserProvider.class).to(MultiUserCheDefaultTestUserProvider.class); bind(TestUser.class).toProvider(TestUserProvider.class); bind(TestUserProvider.class).to(MultiUserCheTestUserProvider.class); bind(AdminTestUser.class).toProvider(AdminTestUserProvider.class); bind(AdminTestUserProvider.class).to(MultiUserCheAdminTestUserProvider.class); bind(TestOrganizationServiceClient.class).to(CheTestDefaultOrganizationServiceClient.class); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<AdminTestUser>>() {}.getType()))); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<TestUserImpl>>() {}.getType()))); install(new FactoryModuleBuilder().build(TestOrganizationServiceClientFactory.class)); }</code><technical_language>omit binding TestWorkspaceServiceClient done in CheSeleniumSuiteModule.java</technical_language>

Target:
protected void configure() { bind(TestAuthServiceClient.class).to(KeycloakTestAuthServiceClient.class); bind(TestMachineServiceClient.class).to(CheTestMachineServiceClient.class); bind(DefaultTestUserProvider.class).to(MultiUserCheDefaultTestUserProvider.class); bind(TestUser.class).toProvider(TestUserProvider.class); bind(TestUserProvider.class).to(MultiUserCheTestUserProvider.class); bind(AdminTestUser.class).toProvider(AdminTestUserProvider.class); bind(AdminTestUserProvider.class).to(MultiUserCheAdminTestUserProvider.class); bind(TestOrganizationServiceClient.class).to(CheTestDefaultOrganizationServiceClient.class); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<AdminTestUser>>() {}.getType()))); install( new FactoryModuleBuilder() .build(Key.get(new TypeLiteral<TestUserFactory<TestUserImpl>>() {}.getType()))); install(new FactoryModuleBuilder().build(TestOrganizationServiceClientFactory.class)); }
Source:
<code>public Map<K, V> getEntries() { Set<Node> nodes = new HashSet<>(this.group.getMembership().getMembers()); try (Batch batch = this.batcher.createBatch()) { Map<K, V> map = new HashMap<>(); for (Map.Entry<K, V> kvEntry : this.cache.getAdvancedCache().getAll(nodes).values()) { <START> if (map.put(kvEntry.getKey(), kvEntry.getValue()) != null) { <END> throw new IllegalStateException("Duplicate key"); } } return map; } }</code><technical_language>Remove conditional + exception. Uniqueness is guaranteed here</technical_language>

Target:
public Map<K, V> getEntries() { Set<Node> nodes = new HashSet<>(this.group.getMembership().getMembers()); try (Batch batch = this.batcher.createBatch()) { Map<K, V> map = new HashMap<>(); for (Map.Entry<K, V> entry : this.cache.getAdvancedCache().getAll(nodes).values()) { map.put(entry.getKey(), entry.getValue()); } return map; } }
Source:
<code>public void setupHttpService() { service = NettyHttpService.builder() .setHost("localhost") .setPort(7777) .addHttpHandlers(ImmutableList.of(new PingHandler())) .build(); service.startAndWait(); <START> UrlFetchRealtimeSourceConfig config = new UrlFetchRealtimeSourceConfig( <END> String.format("http://%s:%s/ping", service.getBindAddress().getHostName(), service.getBindAddress().getPort()), 1L ); }</code><technical_language>this</technical_language>

Target:
public void setupHttpService() { service = NettyHttpService.builder() .setHost("localhost") .setPort(7777) .addHttpHandlers(ImmutableList.of(new PingHandler())) .build(); service.startAndWait(); }
Source:
<code>private Query fieldQuery(IndexPredicate<ChangeData> p) throws QueryParseException { <START> if (p instanceof RegexFilePredicate) { <END> return regexQuery(p); } else if (p.getType() == FieldType.INTEGER) { return intQuery(p); } else if (p.getType() == FieldType.EXACT) { return exactQuery(p); } else { throw badFieldType(p.getType()); } }</code><technical_language>I this handled TimestampRangePredicate. a RegexPredicate extend IndexPredicate RegexFilePredicate extend RegexPredicate. RegexPredicate of EXACT field type handle regex</technical_language>

Target:
private Query fieldQuery(IndexPredicate<ChangeData> p) throws QueryParseException { if (p.getType() == FieldType.INTEGER) { return intQuery(p); } else if (p.getType() == FieldType.TIMESTAMP) { return timestampQuery(p); } else if (p.getType() == FieldType.EXACT) { return exactQuery(p); } else { throw badFieldType(p.getType()); } }
Source:
<code>public static void main(String[] arg) { <START> if (arg.length > 0 && arg[0].startsWith("testCloseConsumerOnConnectionReset")) { <END> try { AmqpClient client = new AmqpClient(new URI("tcp://127.0.0.1:5672?transport.soLinger=0"), null, null); AmqpConnection connection = client.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(QUEUE_NAME); receiver.flow(10); System.exit(OK); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } } else { System.err.println("Test " + arg[0] + " unkown"); System.exit(-2); } }</code><technical_language>argument queue name? dont need a constant, side benefits test isolation if wonky read logs immediately test output etc</technical_language>

Target:
public static void main(String[] arg) { if (arg.length == 2 && arg[0].startsWith("testCloseConsumerOnConnectionReset")) { try { String queueName = arg[1]; AmqpClient client = new AmqpClient(new URI("tcp://127.0.0.1:5672?transport.soLinger=0"), null, null); AmqpConnection connection = client.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(queueName); receiver.flow(10); System.exit(OK); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); } } else { System.err.println("Test " + arg[0] + " unkown"); System.exit(-2); } }
Source:
<code>public void markAsDispatchedToDeliver(UUID channelID) { ChannelInformation channelInformation = channelDeliveryInfo.get(channelID); channelInformation.addChannelStatus(ChannelMessageStatus.DISPATCHED); if (!this.isBeyondLastRollbackedMessage) { int i = channelInformation.incrementDeliveryCount(); MessageTracer.trace(getMessageID(), getDestination(), "Message within rollback id. " <START> + "Increased count " + i); <END> } else { MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK); MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK + " current count = " + channelInformation.getDeliveryCount()); } }</code><technical_language>I suppose increased count is a bit misleading. term current count in else block</technical_language>

Target:
public void markAsDispatchedToDeliver(UUID channelID) { ChannelInformation channelInformation = channelDeliveryInfo.get(channelID); channelInformation.addChannelStatus(ChannelMessageStatus.DISPATCHED); if (!this.isBeyondLastRollbackedMessage) { int i = channelInformation.incrementDeliveryCount(); MessageTracer.trace(getMessageID(), getDestination(), "Message within rollback id. " + "Current count " + i); } else { MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK); MessageTracer.trace(getMessageID(), getDestination(), MessageTracer.MESSAGE_BEYOND_LAST_ROLLBACK + " current count = " + channelInformation.getDeliveryCount()); } }
Source:
<code>public Optional<Course> getCurrentCourse(Path path) { <START> String[] folders = path.toString().split("\\" + File.separator); <END> for (String folder : folders) { if (courseStubs.containsKey(folder)) { return Optional.of(courseStubs.get(folder)); } } return Optional.absent(); }</code><technical_language>[java.nio.Path#iterator()](<LINK_0> here</technical_language>

Target:
public Optional<Course> getCurrentCourse(Path path) { Iterator<Path> it = path.iterator(); while (it.hasNext()) { String folder = it.next().toString(); if (courseStubs.containsKey(folder)) { return Optional.of(courseStubs.get(folder)); } } return Optional.absent(); }
Source:
<code>public final void testGetSourceDateFrom() { <START> Calendar one = Calendar.getInstance(); <END> Calendar other = Calendar.getInstance(); one.set(2009, 01, 01, 0, 0, 0); one.set(Calendar.MILLISECOND, 0); other.set(2009, 03, 31, 0, 0, 0); other.set(Calendar.MILLISECOND, 0); assertEquals(one.getTime(), testManager.getSourceDateFrom()); assertNotSame(other.getTime(), testManager.getSourceDateFrom()); }</code><technical_language>calenderOne calenderTwo. other meaningful</technical_language>

Target:
public final void testGetSourceDateFrom() { Calendar calendarOne = Calendar.getInstance(); Calendar calendarTwo = Calendar.getInstance(); calendarOne.set(2009, 01, 01, 0, 0, 0); calendarOne.set(Calendar.MILLISECOND, 0); calendarTwo.set(2009, 03, 31, 0, 0, 0); calendarTwo.set(Calendar.MILLISECOND, 0); assertEquals(calendarOne.getTime(), testManager.getSourceDateFrom()); assertNotSame(calendarTwo.getTime(), testManager.getSourceDateFrom()); }
Source:
<code>public ImmutableBitmap union(Iterable<ImmutableBitmap> b) throws ClassCastException { <START> if (b instanceof List) { <END> final List<ImmutableBitmap> bitmapList = (List<ImmutableBitmap>) b; if (bitmapList.isEmpty()) { return makeEmptyImmutableBitmap(); } else if (bitmapList.size() == 1) { return Iterables.getOnlyElement(b); } } return new WrappedImmutableConciseBitmap(ImmutableConciseSet.union(unwrap(b))); }</code><technical_language>check for Collection</technical_language>

Target:
public ImmutableBitmap union(Iterable<ImmutableBitmap> b) throws ClassCastException { if (b instanceof Collection) { final Collection<ImmutableBitmap> bitmapList = (Collection<ImmutableBitmap>) b; final int size = bitmapList.size(); if (size == 0) { return makeEmptyImmutableBitmap(); } else if (size == 1) { return Iterables.getOnlyElement(b); } } return new WrappedImmutableConciseBitmap(ImmutableConciseSet.union(unwrap(b))); }
Source:
<code>protected ClientConfig createClientConfig() { <START> ClientConfig cc = new ClientConfig(m_username, m_password); <END> cc.setProcedureCallTimeout(10 * 60 * 1000); return cc; }</code><technical_language>I cleaner add a createClientConfig(Stirng username, String password) method this current call empty strings</technical_language>

Target:
protected ClientConfig createClientConfig() { return createClientConfig("", ""); }
Source:
<code>public void run() { try { if (carbonMessage instanceof TextCarbonMessage) { String event = ((TextCarbonMessage) carbonMessage).getText(); sourceEventListener.onEvent(event); } else if (carbonMessage instanceof MapCarbonMessage) { Map<String, String> event = new HashMap<>(); <START> Enumeration<String> mapNames = ((MapCarbonMessage) carbonMessage).getMapNames(); <END> while (mapNames.hasMoreElements()) { String key = mapNames.nextElement(); event.put(key, ((MapCarbonMessage) carbonMessage).getValue(key)); } sourceEventListener.onEvent(event); } else { throw new JMSInputAdaptorRuntimeException("The message type of the JMS message is not supported!"); } if (carbonCallback != null) { carbonCallback.done(carbonMessage); } } catch (RuntimeException e) { throw new JMSInputAdaptorRuntimeException("Failed to process JMS message.", e); } }</code><technical_language>cast in multiple places. Compiler optimize. do sure</technical_language>

Target:
public void run() { try { if (carbonMessage.getClass() == TextCarbonMessage.class) { String event = ((TextCarbonMessage) carbonMessage).getText(); sourceEventListener.onEvent(event); } else if (carbonMessage.getClass() == MapCarbonMessage.class) { Map<String, String> event = new HashMap<>(); MapCarbonMessage mapCarbonMessage = (MapCarbonMessage) carbonMessage; Enumeration<String> mapNames = mapCarbonMessage.getMapNames(); while (mapNames.hasMoreElements()) { String key = mapNames.nextElement(); event.put(key, mapCarbonMessage.getValue(key)); } sourceEventListener.onEvent(event); } else { throw new JMSInputAdaptorRuntimeException("The message type of the JMS message" + carbonMessage.getClass() + " is not supported!"); } if (carbonCallback != null) { carbonCallback.done(carbonMessage); } } catch (RuntimeException e) { throw new JMSInputAdaptorRuntimeException("Failed to process JMS message.", e); } }
Source:
<code><START> public FixedBitIntReaderWriterV2(PinotDataBuffer dataBuffer, int numValues, int numBitsPerValue) { <END> Preconditions .checkState(dataBuffer.size() == (int) (((long) numValues * numBitsPerValue + Byte.SIZE - 1) / Byte.SIZE)); _dataBitSet = PinotDataBitSetV2.createBitSet(dataBuffer, numBitsPerValue); _numBitsPerValue = numBitsPerValue; }</code><technical_language>Consider writing a header for backward/forward compatibility</technical_language>

Target:
public FixedBitIntReaderWriterV2(PinotDataBuffer dataBuffer, int numValues, int numBitsPerValue) { Preconditions .checkState(dataBuffer.size() == (int) (((long) numValues * numBitsPerValue + Byte.SIZE - 1) / Byte.SIZE)); _dataBitSet = PinotDataBitSetV2.createBitSet(dataBuffer, numBitsPerValue); }
Source:
<code>boolean areAllContainersRunning(Pod pod) { PodStatus podStatus = pod.getStatus(); if (podStatus == null) { return false; } List<ContainerStatus> containerStatuses = pod.getStatus().getContainerStatuses(); if (containerStatuses.isEmpty()) { return false; } for (ContainerStatus containerStatus : containerStatuses) { if (containerStatus != null) { ContainerStateWaiting waitingState = containerStatus.getState().getWaiting(); if (waitingState != null) { String waitingStateMsg = waitingState.getMessage(); if (waitingStateMsg != null && waitingStateMsg.contains("Back-off pulling image")) { runListener.error("Unable to pull Docker image \""+containerStatus.getImage()+"\". Check if image name is spelled correctly"); <START> Jenkins jenkins = Jenkins.getInstanceOrNull(); <END> if (jenkins != null) { Queue q = jenkins.getQueue(); for (Queue.Item item : q.getItems()) { Label itemLabel = item.getAssignedLabel(); if (itemLabel != null && isCorrespondingLabels(itemLabel.getDisplayName(), pod.getMetadata().getName())) { String itemTaskName = item.task.getFullDisplayName(); String jobName = getJobName(itemTaskName); if (jobName.equals("")) { LOGGER.log(Level.WARNING, "Unknown / Invalid job format name"); break; } q.cancel(item); break; } } } } return false; } if (containerStatus.getState().getTerminated() != null) { return false; } if (!containerStatus.getReady()) { return false; } } } return true; }</code><technical_language>Jenkins.get() simplify code</technical_language>

Target:
boolean areAllContainersRunning(Pod pod) { PodStatus podStatus = pod.getStatus(); if (podStatus == null) { return false; } List<ContainerStatus> containerStatuses = pod.getStatus().getContainerStatuses(); if (containerStatuses.isEmpty()) { return false; } for (ContainerStatus containerStatus : containerStatuses) { if (containerStatus != null) { ContainerStateWaiting waitingState = containerStatus.getState().getWaiting(); if (waitingState != null) { String waitingStateMsg = waitingState.getMessage(); if (waitingStateMsg != null && waitingStateMsg.contains("Back-off pulling image")) { String errorMsg = "Unable to pull Docker image \""+containerStatus.getImage()+"\". Check if image tag name is spelled correctly."; runListener.error(errorMsg); throw new InvalidDockerImageException(errorMsg); } return false; } if (containerStatus.getState().getTerminated() != null) { return false; } if (!containerStatus.getReady()) { return false; } } } return true; }
Source:
<code>public LedgerMetadata parseConfig(byte[] bytes, Optional<Long> metadataStoreCtime) throws IOException { if (log.isDebugEnabled()) { log.debug("Deserializing {}", Base64.getEncoder().encodeToString(bytes)); } try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) { int metadataFormatVersion = readHeader(is); if (log.isDebugEnabled()) { log.debug("Format version detected", metadataFormatVersion); } switch (metadataFormatVersion) { <START> case 3: <END> return parseVersion3Config(is); case 2: return parseVersion2Config(is, metadataStoreCtime); case 1: return parseVersion1Config(is); default: throw new IOException( String.format("Metadata version not compatible. Expected between %d and %d, but got %d", LOWEST_COMPAT_METADATA_FORMAT_VERSION, CURRENT_METADATA_FORMAT_VERSION, metadataFormatVersion)); } } }</code><technical_language>constants</technical_language>

Target:
public LedgerMetadata parseConfig(byte[] bytes, Optional<Long> metadataStoreCtime) throws IOException { if (log.isDebugEnabled()) { log.debug("Deserializing {}", Base64.getEncoder().encodeToString(bytes)); } try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) { int metadataFormatVersion = readHeader(is); if (log.isDebugEnabled()) { String contentStr = ""; if (metadataFormatVersion <= METADATA_FORMAT_VERSION_2) { contentStr = ", content: " + new String(bytes, UTF_8); } log.debug("Format version detected{}", metadataFormatVersion, contentStr); } switch (metadataFormatVersion) { case METADATA_FORMAT_VERSION_3: return parseVersion3Config(is); case METADATA_FORMAT_VERSION_2: return parseVersion2Config(is, metadataStoreCtime); case METADATA_FORMAT_VERSION_1: return parseVersion1Config(is); default: throw new IOException( String.format("Metadata version not compatible. Expected between %d and %d, but got %d", LOWEST_COMPAT_METADATA_FORMAT_VERSION, CURRENT_METADATA_FORMAT_VERSION, metadataFormatVersion)); } } }
Source:
<code>private static Map<String, String> parsePreparedStatementsHeaders(HttpServletRequest servletRequest) { ImmutableMap.Builder<String, String> preparedStatements = ImmutableMap.builder(); for (String header : splitSessionHeader(servletRequest.getHeaders(PRESTO_PREPARED_STATEMENT))) { List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header); assertRequest(nameValue.size() == 2, "Invalid %s header", PRESTO_PREPARED_STATEMENT); String statementName; String sqlString; try { statementName = urlDecode(nameValue.get(0)); sqlString = urlDecode(nameValue.get(1)); } catch (IllegalArgumentException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } SqlParser sqlParser = new SqlParser(); try { <START> sqlParser.createStatement(sqlString, new ParsingOptions(true )); <END> } catch (ParsingException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } preparedStatements.put(statementName, sqlString); } return preparedStatements.build(); }</code><technical_language>"anything" mean? BTW, this wrong. match setting prepared statement created</technical_language>

Target:
private static Map<String, String> parsePreparedStatementsHeaders(HttpServletRequest servletRequest) { ImmutableMap.Builder<String, String> preparedStatements = ImmutableMap.builder(); for (String header : splitSessionHeader(servletRequest.getHeaders(PRESTO_PREPARED_STATEMENT))) { List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header); assertRequest(nameValue.size() == 2, "Invalid %s header", PRESTO_PREPARED_STATEMENT); String statementName; String sqlString; try { statementName = urlDecode(nameValue.get(0)); sqlString = urlDecode(nameValue.get(1)); } catch (IllegalArgumentException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } SqlParser sqlParser = new SqlParser(); try { sqlParser.createStatement(sqlString, new ParsingOptions(AS_DOUBLE )); } catch (ParsingException e) { throw badRequest(format("Invalid %s header: %s", PRESTO_PREPARED_STATEMENT, e.getMessage())); } preparedStatements.put(statementName, sqlString); } return preparedStatements.build(); }
Source:
<code>private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { if (a.hashes.get(ai) != b.hashes.get(bi)) return false; int as = a.lines.get(ai); int bs = b.lines.get(bi); int ae = a.lines.get(ai + 1); int be = b.lines.get(bi + 1); as = trimLeadingWhitespace(a.content, as, ae); bs = trimLeadingWhitespace(b.content, bs, be); ae = trimTrailingWhitespace(a.content, as, ae); be = trimTrailingWhitespace(b.content, bs, be); while (as < ae && bs < be) { byte ac = a.content[as]; byte bc = b.content[bs]; <START> while (as < ae - 1 && isWhitespace(ac)) { <END> as++; ac = a.content[as]; } while (bs < be - 1 && isWhitespace(bc)) { bs++; bc = b.content[bs]; } if (ac != bc) return false; as++; bs++; } return ae - as == be - bs; }</code><technical_language>trimmed whitespace loop, this is redundant. I remove trimLeadingWhitespace of 84/85 loops main loop handle that</technical_language>

Target:
private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { if (a.hashes.get(ai) != b.hashes.get(bi)) return false; int as = a.lines.get(ai); int bs = b.lines.get(bi); int ae = a.lines.get(ai + 1); int be = b.lines.get(bi + 1); ae = trimTrailingWhitespace(a.content, as, ae); be = trimTrailingWhitespace(b.content, bs, be); while (as < ae && bs < be) { byte ac = a.content[as]; byte bc = b.content[bs]; while (as < ae - 1 && isWhitespace(ac)) { as++; ac = a.content[as]; } while (bs < be - 1 && isWhitespace(bc)) { bs++; bc = b.content[bs]; } if (ac != bc) return false; as++; bs++; } return as == ae && bs == be; }
Source:
<code>public void testList() throws StripeException { final Transfer transfer = Transfer.retrieve(TRANSFER_ID); <START> final TransferReversalCollection reversals = transfer.getReversals().list(null); <END> assertNotNull(reversals); assertEquals(1, reversals.getData().size()); verifyRequest( APIResource.RequestMethod.GET, String.format("/v1/transfers/%s/reversals", transfer.getId()) ); }</code><technical_language>called resources</technical_language>

Target:
public void testList() throws StripeException { final Transfer transfer = getTransferFixture(); final Map<String, Object> params = new HashMap<String, Object>(); params.put("limit", 1); final TransferReversalCollection reversals = transfer.getReversals().list(params); assertNotNull(reversals); verifyRequest( APIResource.RequestMethod.GET, String.format("/v1/transfers/%s/reversals", transfer.getId()), params ); }
Source:
<code>public static void runFinalization() { <START> if (runGC) { Runtime.getRuntime().gc(); runGC = false; } <END> Runtime.getRuntime().runFinalization(); }</code><technical_language>this cover some people a legit reason. some do "gc/runFinalization/gc"</technical_language>

Target:
public static void runFinalization() { boolean shouldRunGC; synchronized(lock) { shouldRunGC = runGC; runGC = false; } if (shouldRunGC) { Runtime.getRuntime().gc(); } Runtime.getRuntime().runFinalization(); justRanFinalization = true; }
Source:
<code>public static void setUp() { IKernelTrace trace = new TmfXmlKernelTraceStub(); IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE); IStatus status = trace.validate(null, filePath.toOSString()); if (!status.isOK()) { fail(status.getException().getMessage()); } try { trace.initTrace(null, filePath.toOSString(), TmfEvent.class); } catch (TmfTraceException e) { fail(e.getMessage()); } deleteSuppFiles(trace); ((TmfTrace) trace).traceOpened(new <START> TmfTraceOpenedSignal(null, trace, <END> null)); IAnalysisModule module = null; for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) { module = mod; } assertNotNull(module); module.schedule(); module.waitForCompletion(); fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID); assertNotNull(fModule); fTrace = trace; }</code><technical_language>"this" instead of null</technical_language>

Target:
public void setUp() { IKernelTrace trace = new TmfXmlKernelTraceStub(); IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE); IStatus status = trace.validate(null, filePath.toOSString()); if (!status.isOK()) { fail(status.getException().getMessage()); } try { trace.initTrace(null, filePath.toOSString(), TmfEvent.class); } catch (TmfTraceException e) { fail(e.getMessage()); } deleteSuppFiles(trace); ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null)); IAnalysisModule module = null; for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) { module = mod; } assertNotNull(module); module.schedule(); module.waitForCompletion(); fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID); assertNotNull(fModule); fTrace = trace; }
Source:
<code>public String toString() { <START> return NLS.bind("{0} Succeeded, {1} Unstable, {2} Failed", END> new Object[] { numSuccess, numUnstable, numFailed }); }</code><technical_language>Strings displayed in UI marked NON-NLS</technical_language>

Target:
public String toString() { return NLS.bind(Messages.BuildsView_BuildStatusSummary, new Object[] { numSuccess, numUnstable, numFailed }); }
Source:
<code>private State parseRGBState(final String value) { if(!value.startsWith("RGB") || value.length() != 12) return null; try { final int red = Integer.valueOf(value.substring(3, 6)); final int green = Integer.valueOf(value.substring(6, 9)); final int blue = Integer.valueOf(value.substring(9, 12)); return new HSBType(new Color(red, green, blue)); } catch (NumberFormatException e) { <START> logger.warn("cannot parse color from " + value, e); <END> } return null; }</code><technical_language>parameterized logging instead of string concatenation</technical_language>

Target:
private State parseRGBState(final String value) { if (!value.startsWith("RGB") || value.length() != 12) return null; try { final int red = Integer.valueOf(value.substring(3, 6)); final int green = Integer.valueOf(value.substring(6, 9)); final int blue = Integer.valueOf(value.substring(9, 12)); return new HSBType(new Color(red, green, blue)); } catch (NumberFormatException e) { logger.warn("cannot parse color from {}", value, e); } return null; }
Source:
<code>private void checkArray(final Field field) throws Violation { if (field.isAnnotationPresent(Immutable.Array.class)) { try { this.check(field.getType().getComponentType()); } catch (final ImmutabilityChecker.Violation ex) { throw new ImmutabilityChecker.Violation( String.format( "Field array component type '%s' is mutable", field.getType().getComponentType().getName() ), ex ); } } else { throw new ImmutabilityChecker.Violation( String.format( <START> "Field '%s' is an array, which is mutable", <END> field.getName() ) ); } }</code><technical_language>great mention @Immutable.Array in this message. hard time figure out do array</technical_language>

Target:
private void checkArray(final Field field) throws Violation { if (field.isAnnotationPresent(Immutable.Array.class)) { try { this.check(field.getType().getComponentType()); } catch (final ImmutabilityChecker.Violation ex) { throw new ImmutabilityChecker.Violation( String.format( "Field array component type '%s' is mutable", field.getType().getComponentType().getName() ), ex ); } } else { throw new ImmutabilityChecker.Violation( String.format( "Field '%s' is an array and is not annotated with @Immutable.Array", field.getName() ) ); } }
Source:
<code>public AutoRecoveryMain(ServerConfiguration conf, StatsLogger statsLogger) throws IOException, InterruptedException, KeeperException, UnavailableException, CompatibilityException { this.conf = conf; this.bkc = Auditor.createBookKeeperClient(conf); MetadataClientDriver metadataClientDriver = bkc.getMetadataClientDriver(); <START> metadataClientDriver.setConnectionExpiredListener(() -> { <END> LOG.error("Client connection to the Metadata server has expired, so shutting down AutoRecoveryMain!"); shutdown(ExitCode.ZK_EXPIRED); }); auditorElector = new AuditorElector( Bookie.getBookieAddress(conf).toString(), conf, bkc, statsLogger.scope(AUDITOR_SCOPE), false); replicationWorker = new ReplicationWorker( conf, bkc, false, statsLogger.scope(REPLICATION_WORKER_SCOPE)); deathWatcher = new AutoRecoveryDeathWatcher(this); }</code><technical_language>@sijie thank for pointing this out. yes, I session expires is implementation specific behavior, I incorporate proposal #1701 this change is merged</technical_language>

Target:
public AutoRecoveryMain(ServerConfiguration conf, StatsLogger statsLogger) throws IOException, InterruptedException, KeeperException, UnavailableException, CompatibilityException { this.conf = conf; this.bkc = Auditor.createBookKeeperClient(conf); MetadataClientDriver metadataClientDriver = bkc.getMetadataClientDriver(); metadataClientDriver.setSessionStateListener(() -> { LOG.error("Client connection to the Metadata server has expired, so shutting down AutoRecoveryMain!"); shutdown(ExitCode.ZK_EXPIRED); }); auditorElector = new AuditorElector( Bookie.getBookieAddress(conf).toString(), conf, bkc, statsLogger.scope(AUDITOR_SCOPE), false); replicationWorker = new ReplicationWorker( conf, bkc, false, statsLogger.scope(REPLICATION_WORKER_SCOPE)); deathWatcher = new AutoRecoveryDeathWatcher(this); }
Source:
<code>protected void activate(ComponentContext ctxt) { try { if (log.isDebugEnabled()) { log.debug("User Profile Mgt bundle is activated "); } <START> } catch (Exception e) { <END> log.error("Failed to activate ProfileMgt bundle ", e); } }</code><technical_language>catch throwable in activate method</technical_language>

Target:
protected void activate(ComponentContext ctxt) { try { if (log.isDebugEnabled()) { log.debug("User Profile Mgt bundle is activated "); } } catch (Throwable e) { log.error("Failed to activate ProfileMgt bundle ", e); } }
Source:
<code>public void shouldUnRetireAnEncounterType() throws Exception { EncounterType encounterType = service.getEncounterTypeByUuid(getUuid()); encounterType.setRetired(true); <START> encounterType.setRetiredBy(Context.getAuthenticatedUser()); <END> encounterType.setDateRetired(new Date()); encounterType.setRetireReason("random reason"); encounterType = service.saveEncounterType(encounterType); assertTrue(encounterType.isRetired()); String json = "{\"deleted\": \"false\"}"; SimpleObject response = deserialize(handle(newPostRequest(getURI() + "/" + getUuid(), json))); encounterType = service.getEncounterTypeByUuid(getUuid()); assertFalse(encounterType.isRetired()); assertEquals("false", PropertyUtils.getProperty(response, "retired").toString()); }</code><technical_language>I guess do need set retiredBy, retireReason, dateRetired</technical_language>

Target:
public void shouldUnRetireAnEncounterType() throws Exception { EncounterType encounterType = service.getEncounterTypeByUuid(getUuid()); encounterType.setRetired(true); encounterType.setRetireReason("random reason"); service.saveEncounterType(encounterType); encounterType = service.getEncounterTypeByUuid(getUuid()); assertTrue(encounterType.isRetired()); String json = "{\"deleted\": \"false\"}"; SimpleObject response = deserialize(handle(newPostRequest(getURI() + "/" + getUuid(), json))); encounterType = service.getEncounterTypeByUuid(getUuid()); assertFalse(encounterType.isRetired()); assertEquals("false", PropertyUtils.getProperty(response, "retired").toString()); }
Source:
<code>public void lookupImportEmlFileToMailboxShouldReturnEnumValue() { <START> assertThat(CmdType.lookup("importemlfiletomailbox")).isEqualTo(CmdType.IMPORTEMLFILETOMAILBOX); <END> }</code><technical_language>Add breakline isEqualTo</technical_language>

Target:
public void lookupImportEmlFileToMailboxShouldReturnEnumValue() { assertThat(CmdType.lookup("ImportEml")) .isEqualTo(CmdType.IMPORTEML); }
Source:
<code>public void init() { setLabel("Plugin"); addAttribute(ID, ROLE_ID).setLabel("Identifier"); addAttribute(LABEL, ROLE_LABEL, ROLE_LOOKUP).setNillable(false).setUnique(true).setLabel("Label"); <START> addAttribute(DESCRIPTION, ROLE_LOOKUP).setLabel("Description").setDataType(HTML); <END> }</code><technical_language>TEXT datatype more appropriate</technical_language>

Target:
public void init() { setLabel("Plugin"); addAttribute(ID, ROLE_ID).setLabel("Identifier"); addAttribute(LABEL, ROLE_LABEL, ROLE_LOOKUP).setNillable(false).setUnique(true).setLabel("Label"); addAttribute(DESCRIPTION, ROLE_LOOKUP).setLabel("Description"); }