auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public BatchingRegistryImpl() { notificationSources.switchMap( new Func1<Observable<ChangeNotification<T>>, Observable<Boolean>>() { @Override public Observable<Boolean> call(Observable<ChangeNotification<T>> notifications) { return notifications.map(new Func1<ChangeNotification<T>, Boolean>() { @Override public Boolean call(ChangeNotification<T> notification) { if (notification instanceof StreamStateNotification) { StreamStateNotification<T> stateNotification = (StreamStateNotification<T>) notification; interestsBufferingState.put(stateNotification.getInterest(), stateNotification.getBufferingState()); return true; } return null; } }).filter(new Func1<Boolean, Boolean>() { @Override public Boolean call(Boolean value) { return value != null; } <START> }).materialize().flatMap(new Func1<Notification<Boolean>, Observable<Boolean>>() { <END> @Override public Observable<Boolean> call(Notification<Boolean> materialized) { switch (materialized.getKind()) { case OnNext: return Observable.just(materialized.getValue()); case OnError: if (logger.isDebugEnabled()) { logger.debug("Swallowed observable error", materialized.getThrowable()); } } for(Interest<T> i: interestsBufferingState.keySet()) { interestsBufferingState.put(i, BufferingState.FinishBuffering); } return Observable.just(false); } }).doOnCompleted(new Action0() { @Override public void call() { interestsBufferingState.clear(); } }); } } ).subscribe(updatesSubject); }</code><technical_language>map flatmap</technical_language>

Target:
public BatchingRegistryImpl() { notificationSources.switchMap( new Func1<Observable<ChangeNotification<T>>, Observable<Boolean>>() { @Override public Observable<Boolean> call(Observable<ChangeNotification<T>> notifications) { return notifications .filter(ChangeNotifications.streamStateFilter()) .map(new Func1<ChangeNotification<T>, Boolean>() { @Override public Boolean call(ChangeNotification<T> notification) { StreamStateNotification<T> stateNotification = (StreamStateNotification<T>) notification; interestsBufferingState.put(stateNotification.getInterest(), stateNotification.getBufferState()); return true; } }).materialize().map(new Func1<Notification<Boolean>, Boolean>() { @Override public Boolean call(Notification<Boolean> materialized) { switch (materialized.getKind()) { case OnNext: return materialized.getValue(); case OnCompleted: break; case OnError: if (logger.isDebugEnabled()) { logger.debug("Swallowed observable error", materialized.getThrowable()); } break; } for (Interest<T> i : interestsBufferingState.keySet()) { interestsBufferingState.put(i, BufferState.BufferEnd); } return false; } }).doOnTerminate(new Action0() { @Override public void call() { interestsBufferingState.clear(); } }); } } ).subscribe(updatesSubject); }
Source:
<code>public static ClusterBasedJobCoordinator createFromMetadataStore(Config metadataStoreConfig) { MetricsRegistryMap metrics = new MetricsRegistryMap(); CoordinatorStreamStore coordinatorStreamStore = new CoordinatorStreamStore(metadataStoreConfig, metrics); <START> coordinatorStreamStore.init(); <END> Config config = CoordinatorStreamUtil.readConfigFromCoordinatorStream(coordinatorStreamStore); return new ClusterBasedJobCoordinator(metrics, coordinatorStreamStore, config); }</code><technical_language>call init in shared constructor. Please call once</technical_language>

Target:
static ClusterBasedJobCoordinator createFromMetadataStore(Config metadataStoreConfig) { MetricsRegistryMap metrics = new MetricsRegistryMap(); CoordinatorStreamStore coordinatorStreamStore = new CoordinatorStreamStore(metadataStoreConfig, metrics); coordinatorStreamStore.init(); Config config = CoordinatorStreamUtil.readConfigFromCoordinatorStream(coordinatorStreamStore); return new ClusterBasedJobCoordinator(metrics, coordinatorStreamStore, config); }
Source:
<code>public Object setValue(Object value) { this.value = value; <START> return oldValue; <END> }</code><technical_language>if I agree this change. if a case setValue() is invoked multiple times, I return "prev" "oldValue"</technical_language>

Target:
public Object setValue(Object value) { Object prev = this.value; this.value = value; return prev; }
Source:
<code>private void initConfigurationResolver() { if (!requiresConfig.get()) { configurationResolver = (event, stopping) -> empty(); return; } findConfigurationProvider().ifPresent(configurationProvider::set); Optional<ConfigurationInstance> staticConfiguration = getStaticConfiguration(); if (staticConfiguration.isPresent()) { configurationResolver = (event, stopping) -> staticConfiguration; return; } if (isConfigurationSpecified()) { configurationResolver = (event, stopping) -> { if (stopping) { <START> return configurationProvider.get().getIfPresent(event); <END> } else { ConfigurationInstance instance = configurationProvider.get().get(event); if (instance == null) { throw new IllegalModelDefinitionException(format( "Root component '%s' contains a reference to config '%s' but it doesn't exists", getLocation().getRootContainerName(), configurationProvider)); } return of(instance); } }; } else { configurationResolver = (event, stopping) -> extensionManager.getConfiguration(extensionModel, componentModel, event); } }</code><technical_language>This a matter of populating cache. If context is stopping, dynamic config spawned all</technical_language>

Target:
private void initConfigurationResolver() { if (!requiresConfig.get()) { configurationResolver = event -> empty(); return; } findConfigurationProvider().ifPresent(configurationProvider::set); Optional<ConfigurationInstance> staticConfiguration = getStaticConfiguration(); if (staticConfiguration.isPresent()) { configurationResolver = event -> staticConfiguration; return; } if (isConfigurationSpecified()) { configurationResolver = event -> { ConfigurationInstance instance = configurationProvider.get().get(event); if (instance == null) { throw new IllegalModelDefinitionException(format( "Root component '%s' contains a reference to config '%s' but it doesn't exists", getLocation().getRootContainerName(), configurationProvider)); } return of(instance); }; } else { configurationResolver = event -> extensionManager.getConfiguration(extensionModel, componentModel, event); } }
Source:
<code>public static boolean <START> isBound(UseCase <END> useCase) { checkInitialized(); Collection<UseCaseGroupLifecycleController> controllers = sCameraX.mUseCaseGroupRepository.getUseCaseGroups(); for (UseCaseGroupLifecycleController controller : controllers) { UseCaseGroup useCaseGroup = controller.getUseCaseGroup(); if (useCaseGroup.contains(useCase)) { return true; } } return false; }</code><technical_language>related this CL, is a reason this method enforced main thread? is accessing data structures bindToLifecycle() unbind() thread</technical_language>

Target:
public static boolean isBound(UseCase useCase) { CameraX cameraX = checkInitialized(); Collection<UseCaseGroupLifecycleController> controllers = cameraX.mUseCaseGroupRepository.getUseCaseGroups(); for (UseCaseGroupLifecycleController controller : controllers) { UseCaseGroup useCaseGroup = controller.getUseCaseGroup(); if (useCaseGroup.contains(useCase)) { return true; } } return false; }
Source:
<code>public static String getRefDescription(Ref ref) { String name = ref.getName(); if (name.equals(Constants.HEAD)) { if (ref.isSymbolic()) return UIText.GitLabelProvider_RefDescriptionHeadSymbolic; else return UIText.GitLabelProvider_RefDescriptionHead; } else if (name.equals(Constants.ORIG_HEAD)) return UIText.GitLabelProvider_RefDescriptionOrigHead; else if (name.equals(Constants.FETCH_HEAD)) { <START> return UIText.GitLabelProvider_RefDescriptionFetchHead; <END> } else return ""; }</code><technical_language>[optional] add "refs/stash"</technical_language>

Target:
public static String getRefDescription(Ref ref) { String name = ref.getName(); if (name.equals(Constants.HEAD)) { if (ref.isSymbolic()) return UIText.GitLabelProvider_RefDescriptionHeadSymbolic; else return UIText.GitLabelProvider_RefDescriptionHead; } else if (name.equals(Constants.ORIG_HEAD)) return UIText.GitLabelProvider_RefDescriptionOrigHead; else if (name.equals(Constants.FETCH_HEAD)) return UIText.GitLabelProvider_RefDescriptionFetchHead; else if (name.equals(Constants.R_STASH)) return UIText.GitLabelProvider_RefDescriptionStash; else return null; }
Source:
<code>public static Comparator<Row> createComparator(InputColumn<?> column, final int columnIndex) { final Class<?> dataType = column.getDataType(); final boolean isNumber = dataType != null && ReflectionUtils.isNumber(dataType); final boolean isDate = dataType != null && ReflectionUtils.isDate(dataType); return new Comparator<Row>() { @Override public int compare(Row row1, Row row2) { final Comparable<?> value1 = getComparableValue(row1, columnIndex, isNumber, isDate); final Comparable<?> value2 = getComparableValue(row2, columnIndex, isNumber, isDate); int comparableResult = CompareUtils.compareUnbound(value1, value2); if (comparableResult != 0) { return comparableResult; } else { int numberOfSelectItems = row1.getSelectItems().length; for (int i = 0; i < numberOfSelectItems; i++) { final String rowValue1 = (String) row1.getValue(i); final String rowValue2 = (String) row2.getValue(i); final String rowValue1LowerCased = rowValue1.toLowerCase(); final String rowValue2LowerCased = rowValue2.toLowerCase(); <START> if (CompareUtils.compare(rowValue1LowerCased, rowValue2LowerCased) == 0) { <END> continue; } else { return CompareUtils.compare(rowValue1LowerCased, rowValue2LowerCased); } } } return comparableResult; } }; }</code><technical_language>If there, Strings, String.compareToIgnoreCase() instead of lowercasing them</technical_language>

Target:
public static Comparator<Row> createComparator(InputColumn<?> column, final int columnIndex) { final Class<?> dataType = column.getDataType(); final boolean isNumber = dataType != null && ReflectionUtils.isNumber(dataType); final boolean isDate = dataType != null && ReflectionUtils.isDate(dataType); return new Comparator<Row>() { @Override public int compare(Row row1, Row row2) { final Comparable<?> value1 = getComparableValue(row1, columnIndex, isNumber, isDate); final Comparable<?> value2 = getComparableValue(row2, columnIndex, isNumber, isDate); int comparableResult = CompareUtils.compareUnbound(value1, value2); if (comparableResult != 0) { return comparableResult; } else { int numberOfSelectItems = row1.getSelectItems().length; for (int i = 0; i < numberOfSelectItems; i++) { final String rowValue1 = (String) row1.getValue(i); final String rowValue2 = (String) row2.getValue(i); final int compareResult = rowValue1.compareToIgnoreCase(rowValue2); if (compareResult == 0) { continue; } else { return compareResult; } } } return comparableResult; } }; }
Source:
<code>private ImageioClient getImageioClient() { if (imageioClient == null) { imageioClient = new ImageioClient(getImageioUnixSocketPath().toString()); } <START> return imageioClient; <END> }</code><technical_language>client provide reliable persistent connection, I instance in command create a new client for request instead. Adding more state command avoid need create client lazily</technical_language>

Target:
private ImageioClient getImageioClient() { if (imageioClient == null) { imageioClient = new ImageioClient(getImageioUnixSocketPath().toString()); } return new ImageioClient(getImageioUnixSocketPath().toString()); }
Source:
<code>public HttpClientConnector(URI uri) { super(HostAndPort.fromParts(uri.getHost(), uri.getPort())); if (uri.getScheme().compareTo("http") != 0 && <START> uri.getScheme().compareTo("https") != 0) { <END> throw new IllegalArgumentException("HTTP connector only connects to HTTP/HTTPS URIs"); } this.endpointUri = uri; }</code><technical_language>this more readable if a precondition? Also, is a NPE in wings uri == null</technical_language>

Target:
public HttpClientConnector(URI uri) { super(HostAndPort.fromParts(checkNotNull(uri).getHost(), checkNotNull(uri).getPort())); checkArgument(uri.isAbsolute() && !uri.isOpaque(), "HttpClientConnector requires an absolute URI with a path"); checkArgument(uri.getScheme().compareTo("http") != 0 && uri.getScheme().compareTo("https") != 0, "HttpClientConnector only connects to HTTP/HTTPS URIs"); this.endpointUri = uri; }
Source:
<code>public List<ResponseInfo> sendAndPoll(List<RequestInfo> requestInfos) { List<ResponseInfo> responseInfoList = new ArrayList<ResponseInfo>(); for (RequestInfo requestInfo : requestInfos) { pendingRequests.add(new RequestMetadata(time.milliseconds(), requestInfo, null)); } List<NetworkSend> sends = prepareSends(responseInfoList); try { selector.poll(POLL_TIMEOUT_MS, sends); handleSelectorEvents(responseInfoList); } catch (IOException e) { <START> logger.error("Received exception while polling the selector", e); <END> } return responseInfoList; }</code><technical_language>log, update metric move next iteration</technical_language>

Target:
public List<ResponseInfo> sendAndPoll(List<RequestInfo> requestInfos) throws IOException { if (closed) { throw new IllegalStateException("The NetworkClient is closed."); } List<ResponseInfo> responseInfoList = new ArrayList<ResponseInfo>(); for (RequestInfo requestInfo : requestInfos) { pendingRequests.add(new RequestMetadata(time.milliseconds(), requestInfo)); } List<NetworkSend> sends = prepareSends(responseInfoList); selector.poll(POLL_TIMEOUT_MS, sends); handleSelectorEvents(responseInfoList); return responseInfoList; }
Source:
<code>protected List<DiskImage> getVmDisksFromDb() { VM vmFromConfiguration = getVmFromConfiguration(); if (vmFromConfiguration == null) { <START> return Collections.emptyList(); <END> } List<DiskImage> disksFromDb = DisksFilter.filterImageDisks(vmFromConfiguration.getDiskMap().values(), ONLY_SNAPABLE, ONLY_ACTIVE); disksFromDb.addAll(DisksFilter.filterCinderDisks(getVm().getDiskMap().values(), ONLY_PLUGGED)); return disksFromDb; }</code><technical_language>worth a debug log</technical_language>

Target:
protected List<DiskImage> getVmDisksFromDb() { VM vmFromConfiguration = getVmFromConfiguration(); if (vmFromConfiguration == null) { log.debug("No VM configuration found for snapshot id '{}'", getParameters().getSnapshotId()); return Collections.emptyList(); } List<DiskImage> disksFromDb = DisksFilter.filterImageDisks(vmFromConfiguration.getDiskMap().values(), ONLY_SNAPABLE, ONLY_ACTIVE); disksFromDb.addAll(DisksFilter.filterCinderDisks(getVm().getDiskMap().values(), ONLY_PLUGGED)); return disksFromDb; }
Source:
<code>public SimpleVersionedSerializer<List<MockSourceSplit>> getEnumeratorCheckpointSerializer() { return new SimpleVersionedSerializer<List<MockSourceSplit>>() { @Override public int getVersion() { return 0; } @Override public byte[] serialize(List<MockSourceSplit> obj) throws IOException { return InstantiationUtil.serializeObject(obj.toArray()); } @Override public List<MockSourceSplit> deserialize(int version, byte[] serialized) throws IOException { MockSourceSplit[] splitArray; try { splitArray = InstantiationUtil.deserializeObject(serialized, getClass().getClassLoader()); } catch (ClassNotFoundException e) { <START> throw new RuntimeException("Failed to deserialize the source split."); <END> } return new ArrayList<>(Arrays.asList(splitArray)); } }; }</code><technical_language>throwing IOException here? Other parts of code typically do that. checked IOException is supposed failed deserialization (for reason), sense throw that</technical_language>

Target:
public SimpleVersionedSerializer<List<MockSourceSplit>> getEnumeratorCheckpointSerializer() { return new SimpleVersionedSerializer<List<MockSourceSplit>>() { @Override public int getVersion() { return 0; } @Override public byte[] serialize(List<MockSourceSplit> obj) throws IOException { return InstantiationUtil.serializeObject(obj.toArray()); } @Override public List<MockSourceSplit> deserialize(int version, byte[] serialized) throws IOException { MockSourceSplit[] splitArray; try { splitArray = InstantiationUtil.deserializeObject(serialized, getClass().getClassLoader()); } catch (ClassNotFoundException e) { throw new IOException("Failed to deserialize the source split."); } return new ArrayList<>(Arrays.asList(splitArray)); } }; }
Source:
<code><START> private static Method getMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... types) throws NoSuchMethodException { <END> Method res = null; try { res = clazz.getDeclaredMethod(methodName, types); } catch (NoSuchMethodException e) { Class superclass = clazz.getSuperclass(); if (superclass != null) { res = getMethod(superclass, methodName, types); } } catch (SecurityException e) { throw new AssertionError(e); } if (res == null) { throw new NoSuchMethodException("Method " + methodName + " not found in " + clazz.getName()); } return res; }</code><technical_language>return null if exception superclass is null. method marked CheckForNull</technical_language>

Target:
private static Method getMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... types) { Method res = null; try { res = clazz.getDeclaredMethod(methodName, types); if (res != null && (Modifier.isPrivate(res.getModifiers()) || Modifier.isFinal(res.getModifiers()) || Modifier.isStatic(res.getModifiers()))) { res = null; } } catch (NoSuchMethodException e) { Class superclass = clazz.getSuperclass(); if (superclass != null) { res = getMethod(superclass, methodName, types); } } catch (SecurityException e) { throw new AssertionError(e); } if (res == null) { throw new IllegalArgumentException( String.format("Method %s not found in %s (or it is private, final or static)", methodName, clazz.getName())); } return res; }
Source:
<code>public void testRoundTrip() throws IOException, StructureException { Structure structure = StructureIO.getStructure("4CUP"); AdapterToStructureData writerToEncoder = new AdapterToStructureData(); new MmtfStructureWriter(structure, writerToEncoder); MmtfStructureReader mmtfStructureReader = new MmtfStructureReader(); new StructureDataToAdapter(writerToEncoder, mmtfStructureReader); <START> mmtfStructureReader.getStructure(); <END> }</code><technical_language>good assert a roundtripped structure check thing. testing elsewhere</technical_language>

Target:
public void testRoundTrip() throws IOException, StructureException { Structure structure = StructureIO.getStructure("4CUP"); AdapterToStructureData writerToEncoder = new AdapterToStructureData(); new MmtfStructureWriter(structure, writerToEncoder); MmtfStructureReader mmtfStructureReader = new MmtfStructureReader(); new StructureDataToAdapter(writerToEncoder, mmtfStructureReader); assertTrue(checkIfAtomsSame(structure,mmtfStructureReader.getStructure())); }
Source:
<code><START> private synchronized void ackImpl(long uso, Exception ackCallStack) { <END> if (uso == Long.MIN_VALUE && m_onDrain != null) { if (!m_isInContinueingGeneration) m_drained = true; m_drainTraceForDebug = new Exception("Acking USO " + uso, ackCallStack); m_onDrain.run(); return; } if (uso > 0) { try { releaseExportBytes(uso); } catch (IOException e) { VoltDB.crashLocalVoltDB("Error attempting to release export bytes", true, e); return; } } }</code><technical_language>Is necessary synchronize this</technical_language>

Target:
private synchronized void ackImpl(long uso, Exception ackCallStack) { if (uso == Long.MIN_VALUE && m_onDrain != null) { m_drained = true; m_drainTraceForDebug = new Exception("Acking USO " + uso, ackCallStack); m_onDrain.run(); return; } if (uso > 0) { try { releaseExportBytes(uso); } catch (IOException e) { VoltDB.crashLocalVoltDB("Error attempting to release export bytes", true, e); return; } } }
Source:
<code>protected void initExecutorService () { BlockingQueue bqueue; if (sessions == maxSessions) bqueue = new SynchronousQueue(); else bqueue = new LinkedBlockingQueue(); <START> es = new ThreadPoolExecutor(maxSessions, Integer.MAX_VALUE, sessionIdle <END> ,TimeUnit.SECONDS, bqueue, new TMThreadFactory(getName(),getLog())); es.allowCoreThreadTimeOut(true); }</code><technical_language>@demsey this instead be: s = new ThreadPoolExecutor(sessions, maxSessions, sessionIdle</technical_language>

Target:
protected void initExecutorService () { BlockingQueue bqueue; String strategy = cfg.get("queuing-strategy", "unbound"); if (strategy.equals("direct-hand-off")) bqueue = new SynchronousQueue(); else bqueue = new LinkedBlockingQueue(); es = new ThreadPoolExecutor(maxSessions, Integer.MAX_VALUE, sessionIdle ,TimeUnit.SECONDS, bqueue, new TMThreadFactory(getName(),getLog())); es.allowCoreThreadTimeOut(true); }
Source:
<code>public KafkaManager(final LoggerContext loggerContext, final String name, final String topic, final boolean syncSend, final Property[] properties, final String key) { super(loggerContext, name); this.topic = Objects.requireNonNull(topic, "topic"); this.syncSend = syncSend; config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); config.setProperty("batch.size", "0"); for (final Property property : properties) { config.setProperty(property.getName(), property.getValue()); } <START> this.key = (key != null ) ? key.getBytes() : null ; <END> this.timeoutMillis = Integer.parseInt(config.getProperty("timeout.ms", DEFAULT_TIMEOUT_MILLIS)); }</code><technical_language>key.getBytes() some platform default charset. good rely that, charset explicitly</technical_language>

Target:
public KafkaManager(final LoggerContext loggerContext, final String name, final String topic, final boolean syncSend, final Property[] properties, final String key) { super(loggerContext, name); this.topic = Objects.requireNonNull(topic, "topic"); this.syncSend = syncSend; config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); config.setProperty("batch.size", "0"); for (final Property property : properties) { config.setProperty(property.getName(), property.getValue()); } this.key = (key != null ) ? key.getBytes(StandardCharsets.UTF_8) : null ; this.timeoutMillis = Integer.parseInt(config.getProperty("timeout.ms", DEFAULT_TIMEOUT_MILLIS)); }
Source:
<code>public LocalDate randomDate() { <START> return LocalDate.ofEpochDay( nextLong( (-999_999_999L - 1970) * 365, (999_999_999L - 1970) * 365) ); <END> }</code><technical_language>calculations require explanations, possibly breaking out methods constants, depending explanations. Is this complete span of random dates uniformly distributed? I aim, aligned general expectations here</technical_language>

Target:
public LocalDate randomDate() { return LocalDate.ofEpochDay( nextLong( LocalDate.MIN.toEpochDay(), LocalDate.MAX.toEpochDay() ) ); }
Source:
<code><START> public void setCredentialsProvider(CredentialsProvider credentialsProvider) { <END> this.credentialsProvider = credentialsProvider; }</code><technical_language>return 'this' other setters</technical_language>

Target:
public PullCommand setCredentialsProvider( CredentialsProvider credentialsProvider) { checkCallable(); this.credentialsProvider = credentialsProvider; return this; }
Source:
<code>private Registration getAndSetRegistration(final HttpServletRequest request) { final Registration registration = FenixFramework.getDomainObject(request.getParameter("registrationOID")); <START> if (!getUserView(request).getPerson().getStudent().getAllRegistrations().contains(registration)) { <END> return null; } request.setAttribute("registration", registration); request.setAttribute("registrationOID", registration.getExternalId().toString()); return registration; }</code><technical_language>Avoid calling getAllRegistrations() method. poor performance</technical_language>

Target:
private Registration getAndSetRegistration(final HttpServletRequest request) { final Registration registration = FenixFramework.getDomainObject(request.getParameter("registrationOID")); if (!getUserView(request).getPerson().getStudent().getRegistrationStream().anyMatch(r -> r.equals(registration))) { return null; } request.setAttribute("registration", registration); request.setAttribute("registrationOID", registration.getExternalId().toString()); return registration; }
Source:
<code>public DlmsConnectionHolder getConnection(final DlmsDevice device, final DlmsMessageListener dlmsMessageListener) throws TechnicalException { DlmsConnector connector; if (device.isHls5Active()) { connector = this.hls5ConnectorProvider.get(); } else if (device.isLls1Active()) { connector = this.lls1ConnectorProvider.get(); } else if (device.communicateUnencrypted()) { connector = this.publicConnectorProvider.get(); } else { throw new UnsupportedOperationException( <START> "Only HLS 5, LLS 1 and public (LLS 0) connections are currently supported"); <END> } final DlmsConnectionHolder holder = new DlmsConnectionHolder(connector, device, dlmsMessageListener); holder.connect(); return holder; }</code><technical_language>If public connections officially called LLS0, nice if code reflected that. a class called Lls0Connector, DlmsConnector now, DlmsConnector interface</technical_language>

Target:
public DlmsConnectionHolder getConnection(final DlmsDevice device, final DlmsMessageListener dlmsMessageListener) throws TechnicalException { DlmsConnector connector; if (device.isHls5Active()) { connector = this.hls5ConnectorProvider.get(); } else if (device.isLls1Active()) { connector = this.lls1ConnectorProvider.get(); } else if (device.communicateUnencrypted()) { connector = this.lls0ConnectorProvider.get(); } else { throw new UnsupportedOperationException( "Only HLS 5, LLS 1 and public (LLS 0) connections are currently supported"); } final DlmsConnectionHolder holder = new DlmsConnectionHolder(connector, device, dlmsMessageListener); holder.connect(); return holder; }
Source:
<code>public ActivityStarterHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.activity_chooser_item, parent, false); <START> int marginsInPx = (int) TypedValue.applyDimension( <END> TypedValue.COMPLEX_UNIT_DIP, 8, parent.getResources().getDisplayMetrics()); RelativeLayout.LayoutParams text1Params = (RelativeLayout.LayoutParams) itemView.findViewById(android.R.id.text1) .getLayoutParams(); RelativeLayout.LayoutParams text2Params = (RelativeLayout.LayoutParams) itemView.findViewById(android.R.id.text2) .getLayoutParams(); text1Params.topMargin = marginsInPx; text2Params.bottomMargin = marginsInPx; return new ActivityStarterHolder(itemView); }</code><technical_language>in this custom margin code do in XML</technical_language>

Target:
public ActivityStarterHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ActivityStarterHolder( LayoutInflater.from(parent.getContext()) .inflate(R.layout.activity_chooser_item, parent, false)); }
Source:
<code>protected void initVNumaNodes() { unassignedVNodeModelList = new ArrayList<VNodeModel>(); p2vNumaNodesMap = new HashMap<Integer, List<VNodeModel>>(); final Set<Integer> hostIndizes = new HashSet<>(); for (VdsNumaNode numaNode : numaNodeList){ hostIndizes.add(numaNode.getIndex()); } for (final VM vm : getVmsWithvNumaNodeList()) { if (vm.getvNumaNodeList() != null) { for (VmNumaNode vmNumaNode : vm.getvNumaNodeList()) { VNodeModel vNodeModel = new VNodeModel(this, vm, vmNumaNode, false); if (vmNumaNode.getVdsNumaNodeList() != null && !vmNumaNode.getVdsNumaNodeList().isEmpty()) { for (Pair<Guid, Pair<Boolean, Integer>> pair : vmNumaNode.getVdsNumaNodeList()) { Integer hostIndex = pair.getSecond().getSecond(); <START> if (pair.getSecond().getFirst()) { <END> if (!hostIndizes.contains(hostIndex)) { vNodeModel.setPinned(false); break; } else { vNodeModel.setPinned(true); assignVNumaToPhysicalNuma(vNodeModel, hostIndex); break; } } } } if (!vNodeModel.isPinned()){ unassignedVNodeModelList.add(vNodeModel); if (vmNumaNode.getVdsNumaNodeList() != null) { vmNumaNode.getVdsNumaNodeList().clear(); } } } } } }</code><technical_language>pair.getSecond().getFirst() stands for? extract a variable is more readable</technical_language>

Target:
protected void initVNumaNodes() { unassignedVNodeModelList = new ArrayList<VNodeModel>(); p2vNumaNodesMap = new HashMap<Integer, List<VNodeModel>>(); final Set<Integer> hostIndices = new HashSet<>(); for (VdsNumaNode numaNode : numaNodeList){ hostIndices.add(numaNode.getIndex()); } for (final VM vm : getVmsWithvNumaNodeList()) { if (vm.getvNumaNodeList() != null) { for (VmNumaNode vmNumaNode : vm.getvNumaNodeList()) { VNodeModel vNodeModel = new VNodeModel(this, vm, vmNumaNode, false); if (vmNumaNode.getVdsNumaNodeList() != null && !vmNumaNode.getVdsNumaNodeList().isEmpty()) { for (Pair<Guid, Pair<Boolean, Integer>> pair : vmNumaNode.getVdsNumaNodeList()) { Integer hostIndex = pair.getSecond().getSecond(); boolean pinned = pair.getSecond().getFirst(); if (pinned) { if (!hostIndices.contains(hostIndex)) { vNodeModel.setPinned(false); } else { vNodeModel.setPinned(true); assignVNumaToPhysicalNuma(vNodeModel, hostIndex); } break; } } } if (!vNodeModel.isPinned()){ unassignedVNodeModelList.add(vNodeModel); if (vmNumaNode.getVdsNumaNodeList() != null) { vmNumaNode.getVdsNumaNodeList().clear(); } } } } } }
Source:
<code>public DirectoryProposalAutoCompleteField(Control control, IControlContentAdapter controlContentAdapter) { proposalProvider = new FileNameSubstringMatchContentProposalProvider(); KeyStroke triggeringKeyStroke = safeKeyStroke("Ctrl+Space"); char[] autoactivationChars = <START> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\b\u007F" END> .toCharArray(); adapter = new ReopenableContentProposalAdapter(control, controlContentAdapter, proposalProvider, triggeringKeyStroke, autoactivationChars); adapter.setPropagateKeys(true); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); }</code><technical_language>these. pls. explain? "magic numbers" me</technical_language>

Target:
public DirectoryProposalAutoCompleteField(Control control, IControlContentAdapter controlContentAdapter) { proposalProvider = new FileNameSubstringMatchContentProposalProvider(); KeyStroke triggeringKeyStroke = safeKeyStroke("Ctrl+Space"); String backspace = "\b"; String delete = "\u007F"; char[] autoactivationChars = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + backspace + delete).toCharArray(); adapter = new ReopenableContentProposalAdapter(control, controlContentAdapter, proposalProvider, triggeringKeyStroke, autoactivationChars); adapter.setPropagateKeys(true); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); }
Source:
<code>public ResponseEntity<?> listSubscriptions( @Nullable @RequestParam(value = "owning_application", required = false) final String owningApplication, @Nullable @RequestParam(value = "event_type", required = false) final Set<String> eventTypes, @RequestParam(value = "show_status", required = false, defaultValue = "false") final boolean showStatus, @RequestParam(value = "limit", required = false, defaultValue = "20") final int limit, @RequestParam(value = "offset", required = false, defaultValue = "0") final int offset, <START> final NativeWebRequest request) { <END> return status(OK) .body(subscriptionService .listSubscriptions(owningApplication, eventTypes, showStatus, limit, offset)); }</code><technical_language>declare throws please</technical_language>

Target:
public ResponseEntity<?> listSubscriptions( @Nullable @RequestParam(value = "owning_application", required = false) final String owningApplication, @Nullable @RequestParam(value = "event_type", required = false) final Set<String> eventTypes, @RequestParam(value = "show_status", required = false, defaultValue = "false") final boolean showStatus, @RequestParam(value = "limit", required = false, defaultValue = "20") final int limit, @RequestParam(value = "offset", required = false, defaultValue = "0") final int offset, final NativeWebRequest request) throws InvalidLimitException, ServiceTemporarilyUnavailableException { return status(OK) .body(subscriptionService .listSubscriptions(owningApplication, eventTypes, showStatus, limit, offset)); }
Source:
<code><START> void registerReceiverIfRequired() { <END> if (!receiverRegistered) { networkBroadcastReceiver = new NetworkBroadcastReceiver(); IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); context.registerReceiver(networkBroadcastReceiver, filter); receiverRegistered = true; LogUtil.log(TAG, "Registered network broadcast receiver {}" + this); } }</code><technical_language>Do need receiverRegistered more? based nullability of networkBroadcastReceiver</technical_language>

Target:
void registerReceiverIfRequired() { if (null == networkBroadcastReceiver) { networkBroadcastReceiver = new NetworkBroadcastReceiver(); IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); context.registerReceiver(networkBroadcastReceiver, filter); LogUtil.log(TAG, "Registered network broadcast receiver {}" + this); } }
Source:
<code>public void exampleShouldBeTheStored() { String csv = "name,lastname,age\n" + "alejo,abdala,25\n" + "pablo,cabrera,27\n"; DefaultCSVMetaDataBuilder builder = new DefaultCSVMetaDataBuilder(); CSVMetaDataModel model = builder.setDelimiter(",").setExample(csv).addField("name", DataType.STRING).addField("lastname", DataType.STRING).addField("age", DataType.DECIMAL).build(); Assert.assertThat(model, CoreMatchers.notNullValue()); Assert.assertThat(model.getDelimiter(), CoreMatchers.is(",")); <START> Assert.assertThat(model.getFields().size(), CoreMatchers.is(3)); <END> Assert.assertThat(model.getExample(), CoreMatchers.is(csv)); }</code><technical_language>hasSize</technical_language>

Target:
public void exampleShouldBeTheStored() { String csv = "name,lastname,age\n" + "alejo,abdala,25\n" + "pablo,cabrera,27\n"; DefaultCSVMetaDataBuilder builder = new DefaultCSVMetaDataBuilder(); CSVMetaDataModel model = builder.setDelimiter(COMMA_DELIMITER).setExample(csv).addField(FIELD_NAME, DataType.STRING).addField(FIELD_LAST_NAME, DataType.STRING).addField(FIELD_AGE, DataType.DECIMAL).build(); assertThat(model, notNullValue()); assertThat(model.getDelimiter(), is(COMMA_DELIMITER)); assertThat(model.getFields(), hasSize(3)); assertThat(model.getExample(), is(csv)); }
Source:
<code>void checkUsages() { for (Map.Entry<Symbol.TypeSymbol, Multiset<Symbol>> usageByInnerClassEntry : usagesByInnerClass.entrySet()) { <START> final Multiset<Symbol> innerClassUsages = usageByInnerClassEntry.getValue(); <END> for (Symbol methodUsed : innerClassUsages.elementSet()) { final boolean matchArity = unknownInvocations.get(methodUsed.name()) .stream() .anyMatch(mit -> hasSameArity((Symbol.MethodSymbol) methodUsed, mit)); if (!matchArity && methodUsed.usages().size() == innerClassUsages.count(methodUsed)) { reportIssueOnMethod((MethodTree) methodUsed.declaration(), usageByInnerClassEntry.getKey()); } } } }</code><technical_language>do need final modifier variables</technical_language>

Target:
void checkUsages() { for (Map.Entry<Symbol.TypeSymbol, Multiset<Symbol>> usageByInnerClassEntry : usagesByInnerClass.entrySet()) { Multiset<Symbol> innerClassUsages = usageByInnerClassEntry.getValue(); for (Symbol methodUsed : innerClassUsages.elementSet()) { boolean matchArity = unknownInvocations.get(methodUsed.name()) .stream() .anyMatch(mit -> hasSameArity((Symbol.MethodSymbol) methodUsed, mit)); if (!matchArity && methodUsed.usages().size() == innerClassUsages.count(methodUsed)) { reportIssueOnMethod((MethodTree) methodUsed.declaration(), usageByInnerClassEntry.getKey()); } } } }
Source:
<code>public void testEnumConverter() throws Exception { NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName()); FieldDesc fieldDesc = typeDesc.getField("acctType"); AvroConverter<Enum<AccountType>, String> converter1 = (AvroConverter<Enum<AccountType>, String>) transducer.getValueConverter(fieldDesc); assertEquals(AvroUtils._string(), converter1.getSchema()); assertEquals(AccountType.class, converter1.getDatumClass()); Assert.assertEquals(AccountType.ACCOUNTS_PAYABLE.value(), converter1.convertToAvro(AccountType.ACCOUNTS_PAYABLE)); <START> Assert.assertEquals(AccountType.ACCOUNTS_PAYABLE, <END> converter1.convertToDatum(AccountType.ACCOUNTS_PAYABLE.value())); Assert.assertEquals(AccountType.ACCOUNTS_PAYABLE, converter1.convertToDatum(AccountType.ACCOUNTS_PAYABLE.name())); fieldDesc = typeDesc.getField("generalRate"); assertNotNull(fieldDesc); AvroConverter<Enum<ConsolidatedRate>, String> converter2 = (AvroConverter<Enum<ConsolidatedRate>, String>) transducer.getValueConverter(fieldDesc); Assert.assertEquals(ConsolidatedRate.HISTORICAL.value(), converter2.convertToAvro(ConsolidatedRate.HISTORICAL)); Assert.assertEquals(ConsolidatedRate.HISTORICAL, converter2.convertToDatum(ConsolidatedRate.HISTORICAL.value())); }</code><technical_language>Seems, this is deprecated Deprecated. assertArrayEquals</technical_language>

Target:
public void testEnumConverter() throws Exception { NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName()); FieldDesc fieldDesc = typeDesc.getField("acctType"); AvroConverter<Enum<AccountType>, String> converter1 = (AvroConverter<Enum<AccountType>, String>) transducer.getValueConverter(fieldDesc); assertEquals(AvroUtils._string(), converter1.getSchema()); assertEquals(AccountType.class, converter1.getDatumClass()); assertEquals(AccountType.ACCOUNTS_PAYABLE.value(), converter1.convertToAvro(AccountType.ACCOUNTS_PAYABLE)); assertEquals(AccountType.ACCOUNTS_PAYABLE, converter1.convertToDatum(AccountType.ACCOUNTS_PAYABLE.value())); assertEquals(AccountType.ACCOUNTS_PAYABLE, converter1.convertToDatum(AccountType.ACCOUNTS_PAYABLE.name())); fieldDesc = typeDesc.getField("generalRate"); assertNotNull(fieldDesc); AvroConverter<Enum<ConsolidatedRate>, String> converter2 = (AvroConverter<Enum<ConsolidatedRate>, String>) transducer.getValueConverter(fieldDesc); assertEquals(ConsolidatedRate.HISTORICAL.value(), converter2.convertToAvro(ConsolidatedRate.HISTORICAL)); assertEquals(ConsolidatedRate.HISTORICAL, converter2.convertToDatum(ConsolidatedRate.HISTORICAL.value())); }
Source:
<code>private void startGeoRepSession() { GlusterGeoRepSession selectedSession = (GlusterGeoRepSession) getSelectedItem(); if (selectedSession == null) { return; } GlusterVolumeGeoRepActionConfirmationModel cModel = new GlusterVolumeGeoRepActionConfirmationModel(); cModel.setTitle(constants.geoReplicationStartTitle()); cModel.setHelpTag(HelpTag.volume_geo_rep_start_confirmation); cModel.setHashName("volume_geo_rep_start_confirmation"); cModel.setMessage(constants.geoRepStartConfirmation()); cModel.setForceLabel(constants.geoRepStartForce()); <START> cModel.getMasterVolume().setEntity(selectedSession.getMasterVolumeName() == null ? constants.notAvailableLabel() : selectedSession.getMasterVolumeName()); <END> cModel.getSlaveVolume().setEntity(selectedSession.getSlaveVolumeName()); cModel.getSlaveHost().setEntity(selectedSession.getSlaveHostName()); UICommand okCommand = new UICommand("onStartGeoRepSession", this); okCommand.setTitle(constants.ok()); okCommand.setIsDefault(true); cModel.getCommands().add(okCommand); UICommand cancelCommand = new UICommand("closeWindow", this); cancelCommand.setTitle(constants.cancel()); cancelCommand.setIsCancel(true); cModel.getCommands().add(cancelCommand); setWindow(cModel); }</code><technical_language>this null</technical_language>

Target:
private void startGeoRepSession() { GlusterGeoRepSession selectedSession = (GlusterGeoRepSession) getSelectedItem(); if (selectedSession == null) { return; } GlusterVolumeGeoRepActionConfirmationModel cModel = new GlusterVolumeGeoRepActionConfirmationModel(); cModel.setTitle(constants.geoReplicationStartTitle()); cModel.setHelpTag(HelpTag.volume_geo_rep_start_confirmation); cModel.setHashName("volume_geo_rep_start_confirmation"); setWindow(cModel); cModel.initWindow(selectedSession); cModel.setForceHelp(constants.geoRepForceStartHelp()); cModel.setForceLabel(constants.geoRepStartForce()); UICommand okCommand = new UICommand("onStartGeoRepSession", this); okCommand.setTitle(constants.ok()); okCommand.setIsDefault(true); cModel.getCommands().add(okCommand); UICommand cancelCommand = new UICommand("closeWindow", this); cancelCommand.setTitle(constants.cancel()); cancelCommand.setIsCancel(true); cModel.getCommands().add(cancelCommand); }
Source:
<code>private void launchModuleWithDependencies(String module, String[] args, String[] includes, String[] excludes) { try { Resource[] libraries = this.moduleResolver.resolve( <START> new Coordinates[]{toCoordinates(module, DEFAULT_MODULE_CLASSIFIER)}, <END> toCoordinateArray(includes), excludes); List<Archive> archives = new ArrayList<>(); for (Resource library : libraries) { archives.add(new JarFileArchive(library.getFile())); } MultiArchiveLauncher jarLauncher = new MultiArchiveLauncher(archives); jarLauncher.launch(args); } catch (IOException e) { throw new RuntimeException("failed to launch module: " + module, e); } }</code><technical_language>this -exec classifier, default, correct</technical_language>

Target:
private void launchModuleWithDependencies(String module, String[] args, String[] includes, String[] excludes) { try { Resource[] libraries = this.moduleResolver.resolve(toCoordinates(module, DEFAULT_MODULE_CLASSIFIER), toCoordinateArray(includes), excludes); List<Archive> archives = new ArrayList<>(); for (Resource library : libraries) { archives.add(new JarFileArchive(library.getFile())); } MultiArchiveLauncher jarLauncher = new MultiArchiveLauncher(archives); jarLauncher.launch(args); } catch (IOException e) { throw new RuntimeException("failed to launch module: " + module, e); } }
Source:
<code>public ProviderSqlSource(Configuration configuration, Object provider, Class<?> mapperType, Method mapperMethod) { <START> this(configuration, provider, mapperType, mapperMethod, new XMLLanguageDriver()); <END> }</code><technical_language>I Configuration#getDefaultScriptingLanguageInstance() instead of new XMLLanguageDriver()</technical_language>

Target:
public ProviderSqlSource(Configuration configuration, Object provider, Class<?> mapperType, Method mapperMethod) { this(configuration, provider, mapperType, mapperMethod, configuration.getDefaultScriptingLanguageInstance()); }
Source:
<code>private ValidationResult hostStatusValid() { VDSStatus hostStatus = getVds().getStatus(); if (hostStatus != VDSStatus.Maintenance && hostStatus != VDSStatus.Up) { <START> addCanDoActionMessage(VdcBllMessages.VAR__HOST_STATUS__UP_OR_MAINTENANCE); <END> return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL); } return ValidationResult.VALID; }</code><technical_language>addCanDoActionMessage for this, a ValidationResult constructor receives a list replacements (ellipsis wrap in a list anything). is in places</technical_language>

Target:
private ValidationResult hostStatusValid() { VDSStatus hostStatus = getVds().getStatus(); if (hostStatus != VDSStatus.Maintenance && hostStatus != VDSStatus.Up) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL, VdcBllMessages.VAR__HOST_STATUS__UP_OR_MAINTENANCE.name()); } return ValidationResult.VALID; }
Source:
<code>public static AtsConfigurations getConfigurations() { AtsConfigurations configs = null; String appServer = OseeClientProperties.getApplicationServerAddress(); <START> URI serverUri = URI.create(appServer); <END> URI uri = UriBuilder.fromUri(serverUri).path("ats/config").build(); WebResource resource = WebClientProviderService.getProvider().createResource(uri); try { String jsonStr = resource.accept(MediaType.APPLICATION_JSON).get(String.class); configs = gson.fromJson(jsonStr, AtsConfigurations.class); } catch (UniformInterfaceException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } return configs; }</code><technical_language>need create this URI, URIBuilder API supports strings parameter</technical_language>

Target:
public static AtsConfigurations getConfigurations() { AtsConfigurations configs = null; String appServer = OseeClientProperties.getApplicationServerAddress(); URI uri = UriBuilder.fromUri(appServer).path("ats").path("config").build(); WebResource resource = WebClientProviderService.getProvider().createResource(uri); try { String jsonStr = resource.accept(MediaType.APPLICATION_JSON).get(String.class); configs = gson.fromJson(jsonStr, AtsConfigurations.class); } catch (UniformInterfaceException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } return configs; }
Source:
<code>public SSHConnector(int port, StandardUsernameCredentials credentials, String username, String password, String privatekey, String jvmOptions, String javaPath, JDKInstaller jdkInstaller, String prefixStartSlaveCmd, String suffixStartSlaveCmd, Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime) { this.jvmOptions = jvmOptions; this.port = port == 0 ? 22 : port; this.credentials = credentials; this.credentialsId = credentials == null ? null : this.credentials.getId(); this.username = username; this.password = Secret.fromString(fixEmpty(password)); this.privatekey = privatekey; this.javaPath = javaPath; this.jdkInstaller = jdkInstaller; this.prefixStartSlaveCmd = fixEmpty(prefixStartSlaveCmd); this.suffixStartSlaveCmd = fixEmpty(suffixStartSlaveCmd); this.launchTimeoutSeconds = launchTimeoutSeconds == null || launchTimeoutSeconds <= 0 ? null : launchTimeoutSeconds; final Integer zero = 0; this.maxNumRetries = maxNumRetries == null || maxNumRetries <= 0 ? zero : maxNumRetries; <START> this.retryWaitTime = retryWaitTime == null || retryWaitTime <= 0 ? zero : retryWaitTime; <END> }</code><technical_language>I retryWaitTime == null ? 0 : Math.max(0, retryWaitTime) Math.max(0, retryWaitTime == null? 0 : retryWaitTime) retryWaitTime == null || retryWaitTime <= 0 ? 0 : (int)retryWaitTime adding a local constant insane stop complaints covariant returns elvis operator</technical_language>

Target:
public SSHConnector(int port, StandardUsernameCredentials credentials, String username, String password, String privatekey, String jvmOptions, String javaPath, JDKInstaller jdkInstaller, String prefixStartSlaveCmd, String suffixStartSlaveCmd, Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime) { this.jvmOptions = jvmOptions; this.port = port == 0 ? 22 : port; this.credentials = credentials; this.credentialsId = credentials == null ? null : this.credentials.getId(); this.username = username; this.password = Secret.fromString(fixEmpty(password)); this.privatekey = privatekey; this.javaPath = javaPath; this.jdkInstaller = jdkInstaller; this.prefixStartSlaveCmd = fixEmpty(prefixStartSlaveCmd); this.suffixStartSlaveCmd = fixEmpty(suffixStartSlaveCmd); this.launchTimeoutSeconds = launchTimeoutSeconds == null || launchTimeoutSeconds <= 0 ? null : launchTimeoutSeconds; this.maxNumRetries = maxNumRetries != null && maxNumRetries > 0 ? maxNumRetries : 0; this.retryWaitTime = retryWaitTime != null && retryWaitTime > 0 ? retryWaitTime : 0; }