auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> private void initHttpClient(String hostUrlString) { <END> try { hostUrl = new URL(hostUrlString); if (hostUrl.getProtocol().equalsIgnoreCase(HTTPS_PROTOCOL)) { URL trustStorePath = new URL(FILE_URL_PREFIX + EngineLocalConfig.getInstance().getPKIExternalTrustStore()); String trustStorePassword = EngineLocalConfig.getInstance().getPKIExternalTrustStorePassword(); boolean enableSniExtension = EngineLocalConfig.getInstance().isEnableSniExtension(); System.setProperty("jsse.enableSNIExtension", String.valueOf(enableSniExtension)); int hostPort = hostUrl.getPort(); if (hostPort == -1) { hostPort = DEFAULT_SECURED_PORT; } Protocol httpsProtocol = new Protocol("https", new AuthSSLProtocolSocketFactory(null, null, trustStorePath, trustStorePassword), hostPort); httpClient.getHostConfiguration().setHost(hostUrl.getHost(), hostPort, httpsProtocol); this.isSecured = true; } else { int hostPort = hostUrl.getPort(); if (hostPort == -1) { hostPort = DEFAULT_PORT; } httpClient.getHostConfiguration().setHost(hostUrl.getHost(), hostPort); } objectMapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); Credentials hostProviderCredentials = new UsernamePasswordCredentials(hostProvider.getUsername(), hostProvider.getPassword()); httpClient.getState().setCredentials(AuthScope.ANY, hostProviderCredentials); httpClient.getState().setAuthenticationPreemptive(true); } catch (MalformedURLException e) { throw new VdcBLLException(VdcBllErrors.PROVIDER_FAILURE, e.getMessage()); } }</code><technical_language>implementation is in base class</technical_language>

Target:
private void initHttpClient(String hostUrlString) { try { URL hostUrl = getUrl(); if (isSecured()) { URL trustStorePath = ExternalTrustStoreInitializer.getTrustStoreUrl(); String trustStorePassword = ExternalTrustStoreInitializer.getTrustStorePassword(); int hostPort = hostUrl.getPort() == -1 ? HttpsURL.DEFAULT_PORT : hostUrl.getPort(); Protocol httpsProtocol = new Protocol(String.valueOf(HttpsURL.DEFAULT_SCHEME), (ProtocolSocketFactory) new AuthSSLProtocolSocketFactory(null, null, trustStorePath, trustStorePassword), hostPort); httpClient.getHostConfiguration().setHost(hostUrl.getHost(), hostPort, httpsProtocol); } else { int hostPort = hostUrl.getPort() == -1 ? HttpURL.DEFAULT_PORT : hostUrl.getPort(); httpClient.getHostConfiguration().setHost(hostUrl.getHost(), hostPort); } objectMapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); Credentials hostProviderCredentials = new UsernamePasswordCredentials(hostProvider.getUsername(), hostProvider.getPassword()); httpClient.getState().setCredentials(AuthScope.ANY, hostProviderCredentials); httpClient.getState().setAuthenticationPreemptive(true); } catch (MalformedURLException e) { throw new VdcBLLException(VdcBllErrors.PROVIDER_FAILURE, e.getMessage()); } }
Source:
<code>public IStatus getProfileDefinitionStatus() { String profilePath = getProfileURI(); if (profilePath == null || profilePath.equalsIgnoreCase("")) { return Status.OK_STATUS; } URI profileURI = URI.createURI(profilePath); ResourceSet resourceSet = Util.createTemporaryResourceSet(); Resource resource = null; try { resource = resourceSet.getResource(profileURI, true); } catch (WrappedException ex) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_UnavailableResource, ex); } finally { <START> EMFHelper.unload(resourceSet); <END> } if (resource == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NullResource); } if (resource.getContents().isEmpty()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_EmptyResource); } EObject eObject = resource.getContents().get(0); if (!(eObject instanceof Profile)) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NotAProfile); } Profile profile = (Profile) eObject; if (!profile.isDefined()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_ProfileNotDefined); } return Status.OK_STATUS; }</code><technical_language>finally wrap entire method ("Always unload returning") Otherwise, if everything's fine, this will: - Load resource - Finally => Unload resource set - Check contents of Resource -> unloaded empty</technical_language>

Target:
public IStatus getProfileDefinitionStatus() { String profilePath = getProfileURI(); URI profileURI = URI.createURI(profilePath); ResourceSet resourceSet = Util.createTemporaryResourceSet(); try { if (profilePath == null || profilePath.equalsIgnoreCase("")) { return Status.OK_STATUS; } Resource resource = null; resource = resourceSet.getResource(profileURI, true); if (resource == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NullResource); } if (resource.getContents().isEmpty()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_EmptyResource); } EObject eObject = resource.getContents().get(0); if (!(eObject instanceof Profile)) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_NotAProfile); } Profile profile = (Profile) eObject; if (!profile.isDefined()) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_ProfileNotDefined); } return Status.OK_STATUS; } catch (WrappedException ex) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ProfileChooserComposite_ProfileStatus_UnavailableResource, ex); } finally { EMFHelper.unload(resourceSet); } }
Source:
<code>public CompletableFuture<Integer> readIntoArray(byte[] res, int offset, int length) { try { System.arraycopy(data, index, res, offset, length); } catch (ArrayIndexOutOfBoundsException e) { <START> System.out.println(); <END> } index += length; return CompletableFuture.completedFuture(length); }</code><technical_language>debug artefact</technical_language>

Target:
public CompletableFuture<Integer> readIntoArray(byte[] res, int offset, int length) { System.arraycopy(data, index, res, offset, length); index += length; return CompletableFuture.completedFuture(length); }
Source:
<code>private CsvReader(Path inputPath) throws IOException { mCloser = Closer.create(); Configuration conf = ReadWriterUtils.readNoCacheConf(); <START> mFs = inputPath.getFileSystem(conf); <END> mCloser.register(mFs); CSVProperties props = new CSVProperties.Builder() .hasHeader() .build(); Schema schema; try (InputStream inputStream = open(mFs, inputPath)) { String schemaName = inputPath.getName(); if (schemaName.contains(".")) { schemaName = schemaName.substring(0, schemaName.indexOf(".")); } schema = AvroCSV.inferSchema(schemaName, inputStream, props); mSchema = new CsvSchema(schema); } mReader = new AvroCSVReader<>(open(mFs, inputPath), props, schema, Record.class, false); mCloser.register(mReader); }</code><technical_language>do mFs = mCloser.register(inputPath.getFileSystem(conf)) (applies mReader too)</technical_language>

Target:
private CsvReader(Path inputPath) throws IOException { mCloser = Closer.create(); try { Configuration conf = ReadWriterUtils.readNoCacheConf(); mFs = mCloser.register(inputPath.getFileSystem(conf)); CSVProperties props = new CSVProperties.Builder() .hasHeader() .build(); Schema schema; try (InputStream inputStream = open(mFs, inputPath)) { String schemaName = inputPath.getName(); if (schemaName.contains(".")) { schemaName = schemaName.substring(0, schemaName.indexOf(".")); } schema = AvroCSV.inferSchema(schemaName, inputStream, props); mSchema = new CsvSchema(schema); } mReader = mCloser.register( new AvroCSVReader<>(open(mFs, inputPath), props, schema, Record.class, false)); } catch (IOException e) { try { mCloser.close(); } catch (IOException ioe) { e.addSuppressed(ioe); } throw e; } }
Source:
<code>public List<Metric> transformScanner(List<MetricScanner> scanners) { <START> if (scanners == null) { <END> throw new MissingDataException("The metric scanners list cannot be null or empty while performing transforms."); } if (scanners.size() != 1) { throw new UnsupportedOperationException("Anomaly DetectionTransform can only be used with one metric."); } MetricScanner scanner = scanners.get(0); if (!scanner.hasNextDP()) { throw new MissingDataException("Metric scanner must contain data points to perform transforms."); } Map<Long, Double> datapoints = fitParametersScanner(scanner); Metric predictions = predictAnomalies(datapoints); Metric predictionsNormalized = normalizePredictions(predictions); List<Metric> resultMetrics = new ArrayList<>(); resultMetrics.add(predictionsNormalized); return resultMetrics; }</code><technical_language>For these, is a method System.assert(condition, message, exceptionType) constructing a new exception if/else</technical_language>

Target:
public List<Metric> transformScanner(List<MetricScanner> scanners) { SystemAssert.requireArgument(scanners != null, "The metric scanners list cannot be null or empty while performing transforms."); SystemAssert.requireArgument(scanners.size() == 1, "Anomaly DetectionTransform can only be used with one metric."); MetricScanner scanner = scanners.get(0); SystemAssert.requireArgument(scanner.hasNextDP(), "Metric scanner must contain data points to perform transforms."); Map<Long, Double> datapoints = fitParametersScanner(scanner); Metric predictions = predictAnomalies(datapoints); Metric predictionsNormalized = normalizePredictions(predictions); List<Metric> resultMetrics = new ArrayList<>(); resultMetrics.add(predictionsNormalized); return resultMetrics; }
Source:
<code>public void testJobWithMaxRowsFilter() throws Exception { FilterComponentBuilder<MaxRowsFilter, Category> filter = analysisJobBuilder.addFilter(MaxRowsFilter.class); <START> filter.addInputColumn(analysisJobBuilder.getSourceColumnByName("email")); <END> filter.getComponentInstance().setMaxRows(5); emailTransformerBuilder.setRequirement(filter, Category.VALID); PreviewTransformedDataActionListener action = new PreviewTransformedDataActionListener(null, emailTransformerBuilder); TableModel tableModel = action.call(); assertEquals(5, tableModel.getRowCount()); }</code><technical_language>some finals there</technical_language>

Target:
public void testJobWithMaxRowsFilter() throws Exception { final FilterComponentBuilder<MaxRowsFilter, Category> filter = analysisJobBuilder .addFilter(MaxRowsFilter.class); filter.addInputColumn(analysisJobBuilder.getSourceColumnByName("email")); filter.getComponentInstance().setMaxRows(5); emailTransformerBuilder.setRequirement(filter, Category.VALID); final PreviewTransformedDataActionListener action = new PreviewTransformedDataActionListener(null, emailTransformerBuilder); final TableModel tableModel = action.call(); assertEquals(5, tableModel.getRowCount()); }
Source:
<code>public void postInitialise(Context rootContext) { metrics.initialise(); <START> InjectionHelper.inject(this, rootContext); <END> if (config.getTelemetryConfig().isEnableTelemetry()) { Unstructured systemContextMetric = metrics.getSystemContextMetric().getMetric(); TelemetryUtils.trackMetric(emitter,NAMESPACE_TRACKER,systemContextMetric); } }</code><technical_language>InjectionHelper a bit heavy for this. grab config (only injected field) root context instead</technical_language>

Target:
public void postInitialise(Context rootContext) { metrics.initialise(rootContext); addTelemetryLogstashAppender(rootContext); }
Source:
<code>private static ArtifactProxy createProxy(final String artGuid, final String artifactName, final long branchGuid, final String branchName) { return new ArtifactProxy() { @Override public IOseeBranch getBranch() { return TokenFactory.createBranch(branchGuid, branchName); } @Override public String getName() { return artifactName; } @Override public String getGuid() { return artGuid; } @Override public ArtifactType getArtifactType() { return null; } @Override public boolean isAttributeTypeValid(IAttributeType attributeType) { return false; } @Override public Collection<RelationType> getValidRelationTypes() { return null; } @Override public Collection<ArtifactProxy> getHierarchy() { return null; } @Override public IBasicArtifact<?> getObject() { return null; } @Override public Long getUuid() { <START> return new Long(0); <END> } }; }</code><technical_language>'L'</technical_language>

Target:
private static ArtifactProxy createProxy(final String artGuid, final String artifactName, final long branchGuid, final String branchName) { return new ArtifactProxy() { @Override public IOseeBranch getBranch() { return TokenFactory.createBranch(branchGuid, branchName); } @Override public String getName() { return artifactName; } @Override public String getGuid() { return artGuid; } @Override public ArtifactType getArtifactType() { return null; } @Override public boolean isAttributeTypeValid(IAttributeType attributeType) { return false; } @Override public Collection<RelationType> getValidRelationTypes() { return null; } @Override public Collection<ArtifactProxy> getHierarchy() { return null; } @Override public IBasicArtifact<?> getObject() { return null; } @Override public Long getUuid() { return 0L; } }; }
Source:
<code><START> public int hashCode() <END> { return abstractBlockHashCode(); }</code><technical_language>implementing hashCode abstract level is specific here</technical_language>

Target:
public int hashCode() { return super.hashCode(); }
Source:
<code>protected Message decodeDelivery(Delivery delivery) { final int messageSize = delivery.pending(); final byte[] buffer = new byte[messageSize]; final int read = receiver.recv(buffer, 0, messageSize); receiver.advance(); final Message message = Proton.message(); message.decode(buffer, 0, read); ExtendedAmqpMessage extendedAmqpMessage = null; if (receiver.getSenderSettleMode() == SenderSettleMode.SETTLED) { delivery.disposition(Accepted.getInstance()); delivery.settle(); extendedAmqpMessage = new ExtendedAmqpMessage(message, null); } else { extendedAmqpMessage = new ExtendedAmqpMessage(message, ByteBuffer.wrap(delivery.getTag())); } <START> return extendedAmqpMessage; <END> }</code><technical_language>Do need maintaining type information return this method? Currently, this method returns lose concrete type caller need check object type if want access extended message properties</technical_language>

Target:
protected Message decodeDelivery(Delivery delivery) { final int messageSize = delivery.pending(); final byte[] buffer = new byte[messageSize]; final int read = receiver.recv(buffer, 0, messageSize); receiver.advance(); final Message message = Proton.message(); message.decode(buffer, 0, read); delivery.settle(); return message; }
Source:
<code>private List<String> getPubMedIdsFromQuery(String query) throws FetcherException { boolean fetchIDs = false; boolean firstOccurrenceOfCount = false; List<String> idList = new ArrayList<>(); try { URL ncbi = createSearchUrl(query); XMLInputFactory inputFactory = XMLInputFactory.newFactory(); XMLStreamReader streamReader = inputFactory.createXMLStreamReader(ncbi.openStream()); <START> System.out.println("parsing xml"); <END> fetchLoop: while (streamReader.hasNext()) { int event = streamReader.getEventType(); switch (event) { case XMLStreamConstants.START_ELEMENT: if (streamReader.getName().toString().equals("Count")) { firstOccurrenceOfCount = true; } if (streamReader.getName().toString().equals("IdList")) { fetchIDs = true; } break; case XMLStreamConstants.CHARACTERS: if (firstOccurrenceOfCount) { numberOfResultsFound = Integer.parseInt(streamReader.getText()); firstOccurrenceOfCount = false; } if (fetchIDs) { idList.add(streamReader.getText()); } break; case XMLStreamConstants.END_ELEMENT: if (streamReader.getName().toString().equals("IdList")) { break fetchLoop; } } streamReader.next(); } streamReader.close(); return idList; } catch (IOException | URISyntaxException e) { throw new FetcherException("Unable to get PubMed IDs", Localization.lang("Unable to get PubMed IDs"), e); } catch (XMLStreamException e) { throw new FetcherException("Error while parsing ID list", Localization.lang("Error while parsing ID list"), e); } }</code><technical_language>logging infrastructure set log level accordingly? Include in log4j2.xml: <Logger name="org.jabref.logic.importer.fetcher" level="DEBUG"> <AppenderRef ref="CONSOLE"/> </Logger></technical_language>

Target:
private List<String> getPubMedIdsFromQuery(String query) throws FetcherException { boolean fetchIDs = false; boolean firstOccurrenceOfCount = false; List<String> idList = new ArrayList<>(); try { URL ncbi = createSearchUrl(query); XMLInputFactory inputFactory = XMLInputFactory.newFactory(); XMLStreamReader streamReader = inputFactory.createXMLStreamReader(ncbi.openStream()); fetchLoop: while (streamReader.hasNext()) { int event = streamReader.getEventType(); switch (event) { case XMLStreamConstants.START_ELEMENT: if (streamReader.getName().toString().equals("Count")) { firstOccurrenceOfCount = true; } if (streamReader.getName().toString().equals("IdList")) { fetchIDs = true; } break; case XMLStreamConstants.CHARACTERS: if (firstOccurrenceOfCount) { numberOfResultsFound = Integer.parseInt(streamReader.getText()); firstOccurrenceOfCount = false; } if (fetchIDs) { idList.add(streamReader.getText()); } break; case XMLStreamConstants.END_ELEMENT: if (streamReader.getName().toString().equals("IdList")) { break fetchLoop; } } streamReader.next(); } streamReader.close(); return idList; } catch (IOException | URISyntaxException e) { throw new FetcherException("Unable to get PubMed IDs", Localization.lang("Unable to get PubMed IDs"), e); } catch (XMLStreamException e) { throw new FetcherException("Error while parsing ID list", Localization.lang("Error while parsing ID list"), e); } }
Source:
<code>public URL getResource(String name) { if (name != null) { String resourceName = name; if (name.startsWith("/")) { resourceName = name.substring(1); <START> } <END> return bundle.getResource(resourceName); } return null; }</code><technical_language>need check in case, assignment time instead of assign sometimes: java String resourceName; if (name.startsWith("/")) { resourceName = name.substring(1); } else { resourceName = name; }</technical_language>

Target:
public URL getResource(String name) { if (name != null) { String resourceName; if (name.startsWith("/")) { resourceName = name.substring(1); } else { resourceName = name; } return bundle.getResource(resourceName); } return null; }
Source:
<code>private static Class<?> getNumericClass(int total, int decimal) { if (decimal <= 0) { if (total > 18 || total == 0) { return BigInteger.class; <START> } else if (total > 9 || total == 0) { <END> return Long.class; } else if (total > 4) { return Integer.class; } else if (total > 2) { return Short.class; } else if (total > 0) { return Byte.class; } else { return Boolean.class; } } else { return BigDecimal.class; } }</code><technical_language>Total 0 once. Is this intended</technical_language>

Target:
private static Class<?> getNumericClass(int total, int decimal) { if (decimal <= 0) { if (total > 18 || total == 0) { return BigInteger.class; } else if (total > 9) { return Long.class; } else if (total > 4) { return Integer.class; } else if (total > 2) { return Short.class; } else { return Byte.class; } } else { return BigDecimal.class; } }
Source:
<code>public org.apache.activemq.artemis.api.core.Message putByteProperty(SimpleString key, byte value) { org.apache.activemq.artemis.api.core.Message message = putByteProperty(key.toString(), value); <START> messageChanged(); <END> return message; }</code><technical_language>this isnt needed delegated method added messageChanged() already, for a number of methods</technical_language>

Target:
public org.apache.activemq.artemis.api.core.Message putByteProperty(SimpleString key, byte value) { return putByteProperty(key.toString(), value); }
Source:
<code>public IImage getIcon() { return ECoreImage.METADATA_TABLE_ICON; <START> } <END></code><technical_language>METADATA_VIEW_ICON</technical_language>

Target:
public IImage getIcon() { return ECoreImage.METADATA_VIEW_ICON; }
Source:
<code>public RowFilter adapt(FilterAdapterContext context, ColumnPaginationFilter filter) throws IOException { if (filter.getColumnOffset() != null) { byte[] family = context.getScan().getFamilies()[0]; ByteString startQualifier = ByteString.copyFrom(filter.getColumnOffset()); return createChain( filter, <START> F.qualifier().range(Bytes.toString(family)) <END> .startClosed(startQualifier)); } else if (filter.getOffset() > 0) { return createChain( filter, F.offset().cellsPerRow(filter.getOffset())); } else { return createChain(filter, null); } }</code><technical_language>I I LGTM'ed this, usage guess decision. feel amending to: F.qualifier().exactFamilyMatch("family").startClosed(...).endOpen(...) else, range(family) is misleading</technical_language>

Target:
public RowFilter adapt(FilterAdapterContext context, ColumnPaginationFilter filter) throws IOException { if (filter.getColumnOffset() != null) { byte[] family = context.getScan().getFamilies()[0]; ByteString startQualifier = ByteString.copyFrom(filter.getColumnOffset()); return createChain( filter, F.qualifier().rangeWithinFamily(Bytes.toString(family)) .startClosed(startQualifier)); } else if (filter.getOffset() > 0) { return createChain( filter, F.offset().cellsPerRow(filter.getOffset())); } else { return createChain(filter, null); } }
Source:
<code>public void copyTo(SequentialFile dstFile) throws IOException { <START> ActiveMQJournalLogger.LOGGER.debug("Copying " + this + " as " + dstFile); <END> if (isOpen()) { throw new IllegalStateException("File opened!"); } if (dstFile.isOpen()) { throw new IllegalArgumentException("dstFile must be closed too"); } try (RandomAccessFile src = new RandomAccessFile(getFile(), "rw"); FileChannel srcChannel = src.getChannel(); FileLock srcLock = srcChannel.lock()) { final long readableBytes = srcChannel.size(); if (readableBytes > 0) { try (RandomAccessFile dst = new RandomAccessFile(dstFile.getJavaFile(), "rw"); FileChannel dstChannel = dst.getChannel(); FileLock dstLock = dstChannel.lock()) { final long oldLength = dst.length(); final long newLength = oldLength + readableBytes; dst.setLength(newLength); final long transferred = dstChannel.transferFrom(srcChannel, oldLength, readableBytes); if (transferred != readableBytes) { dstChannel.truncate(oldLength); throw new IOException("copied less then expected"); } } } } }</code><technical_language>If a change it: if (logger.isDebugEnabled()) { logger.debug(.....); }</technical_language>

Target:
public void copyTo(SequentialFile dstFile) throws IOException { if (ActiveMQJournalLogger.LOGGER.isDebugEnabled()) { ActiveMQJournalLogger.LOGGER.debug("Copying " + this + " as " + dstFile); } if (isOpen()) { throw new IllegalStateException("File opened!"); } if (dstFile.isOpen()) { throw new IllegalArgumentException("dstFile must be closed too"); } try (RandomAccessFile src = new RandomAccessFile(getFile(), "rw"); FileChannel srcChannel = src.getChannel(); FileLock srcLock = srcChannel.lock()) { final long readableBytes = srcChannel.size(); if (readableBytes > 0) { try (RandomAccessFile dst = new RandomAccessFile(dstFile.getJavaFile(), "rw"); FileChannel dstChannel = dst.getChannel(); FileLock dstLock = dstChannel.lock()) { final long oldLength = dst.length(); final long newLength = oldLength + readableBytes; dst.setLength(newLength); final long transferred = dstChannel.transferFrom(srcChannel, oldLength, readableBytes); if (transferred != readableBytes) { dstChannel.truncate(oldLength); throw new IOException("copied less then expected"); } } } } }
Source:
<code>private DfsBlockCache(DfsBlockCacheConfig cfg) { tableSize = tableSize(cfg); if (tableSize < 1) throw new IllegalArgumentException(JGitText.get().tSizeMustBeGreaterOrEqual1); table = new AtomicReferenceArray<>(tableSize); loadLocks = new ReentrantLock[cfg.getConcurrencyLevel()]; for (int i = 0; i < loadLocks.length; i++) loadLocks[i] = new ReentrantLock(true ); refLocks = new ReentrantLock[cfg.getConcurrencyLevel()]; <START> for (int i = 0; i < refLocks.length; i++) <END> refLocks[i] = new ReentrantLock(true ); maxBytes = cfg.getBlockLimit(); maxStreamThroughCache = (long) (maxBytes * cfg.getStreamRatio()); blockSize = cfg.getBlockSize(); blockSizeShift = Integer.numberOfTrailingZeros(blockSize); clockLock = new ReentrantLock(true ); String none = ""; clockHand = new Ref<>( DfsStreamKey.of(new DfsRepositoryDescription(none), none, null), -1, 0, null); clockHand.next = clockHand; statHit = new AtomicReference<>(newCounters()); statMiss = new AtomicReference<>(newCounters()); statEvict = new AtomicReference<>(newCounters()); liveBytes = new AtomicReference<>(newCounters()); refLockWaitTime = cfg.getRefLockWaitTimeConsumer(); }</code><technical_language>style nit: missing braces</technical_language>

Target:
private DfsBlockCache(DfsBlockCacheConfig cfg) { tableSize = tableSize(cfg); if (tableSize < 1) { throw new IllegalArgumentException(JGitText.get().tSizeMustBeGreaterOrEqual1); } table = new AtomicReferenceArray<>(tableSize); loadLocks = new ReentrantLock[cfg.getConcurrencyLevel()]; for (int i = 0; i < loadLocks.length; i++) { loadLocks[i] = new ReentrantLock(true ); } refLocks = new ReentrantLock[cfg.getConcurrencyLevel()]; for (int i = 0; i < refLocks.length; i++) { refLocks[i] = new ReentrantLock(true ); } maxBytes = cfg.getBlockLimit(); maxStreamThroughCache = (long) (maxBytes * cfg.getStreamRatio()); blockSize = cfg.getBlockSize(); blockSizeShift = Integer.numberOfTrailingZeros(blockSize); clockLock = new ReentrantLock(true ); String none = ""; clockHand = new Ref<>( DfsStreamKey.of(new DfsRepositoryDescription(none), none, null), -1, 0, null); clockHand.next = clockHand; statHit = new AtomicReference<>(newCounters()); statMiss = new AtomicReference<>(newCounters()); statEvict = new AtomicReference<>(newCounters()); liveBytes = new AtomicReference<>(newCounters()); refLockWaitTime = cfg.getRefLockWaitTimeConsumer(); }
Source:
<code>public InputStream deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonElement aa = ((JsonObject) json.getAsJsonObject().get("attachments")).get(taskData.getValue()); <START> JsonPrimitive xxxx = aa.getAsJsonObject().get("data").getAsJsonPrimitive(); <END> InputStream is = new ByteArrayInputStream(xxxx.getAsString().getBytes()); return new Base64InputStream(is); }</code><technical_language>this NPE</technical_language>

Target:
public InputStream deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonElement attachments = ((JsonObject) json.getAsJsonObject().get("attachments")) .get(taskAttribute.getValue()); JsonPrimitive attachment = attachments.getAsJsonObject().get("data").getAsJsonPrimitive(); if (attachment == null) { throw com.google.common.base.Throwables.propagate(new CoreException( new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, "Can not get Attachment Data"))); } InputStream is = new ByteArrayInputStream(attachment.getAsString().getBytes()); return new Base64InputStream(is); }
Source:
<code>public void showError(String error) { <START> <END> }</code><technical_language>do this empty method? user informed error, in some way</technical_language>

Target:
public void showError(String error) { Toaster.show(rootView, error); }
Source:
<code>public Destination getDestination(Destination defaultDestination) { <START> return Destination.from(getOrDefault(DESTINATION,defaultDestination.toString())); <END> }</code><technical_language>nit: space missing</technical_language>

Target:
public Destination getDestination(Destination defaultDestination) { return Destination.valueOf(getOrDefault(DESTINATION, defaultDestination.toString())); }
Source:
<code><START> static synchronized void addToList(TerminalInfoView view) { <END> views.add(view); }</code><technical_language>Visibility missing. Synchronized static</technical_language>

Target:
private static synchronized void addToList(TerminalInfoView view) { views.add(view); }
Source:
<code>public void openFilePage(String fileName) { <START> getUrl(Global.DOMAIN + URLsContent.wikiDir + URLsContent.fileNS + fileName); <END> waitForElementByElement(tabList.get(0)); PageObjectLogging.log("Open file page", "file page opened", true); }</code><technical_language>getUrl method nicer if parameter consist variable e.g. getUrl(URLsContent.filePage + fileName);</technical_language>

Target:
public void openFilePage(String fileName) { getUrl(URLsContent.filePage + fileName); waitForElementByElement(tabList.get(0)); PageObjectLogging.log("Open file page", "file page opened", true); }
Source:
<code>public void processOptionsNone() throws IOException { LinkedList<String> options = new LinkedList<String>(); Ls ls = new Ls(); ls.processOptions(options); assertFalse(ls.isPathOnly()); assertTrue(ls.isDirRecurse()); assertFalse(ls.isHumanReadable()); assertFalse(ls.isRecursive()); assertFalse(ls.isOrderReverse()); assertFalse(ls.isOrderSize()); assertFalse(ls.isOrderTime()); assertFalse(ls.isUseAtime()); <START> assertFalse(ls.isDisplayECPolicy()); <END> }</code><technical_language>This is EC policy patch again. I abfs needs all</technical_language>

Target:
public void processOptionsNone() throws IOException { LinkedList<String> options = new LinkedList<String>(); Ls ls = new Ls(); ls.processOptions(options); assertFalse(ls.isPathOnly()); assertTrue(ls.isDirRecurse()); assertFalse(ls.isHumanReadable()); assertFalse(ls.isRecursive()); assertFalse(ls.isOrderReverse()); assertFalse(ls.isOrderSize()); assertFalse(ls.isOrderTime()); assertFalse(ls.isUseAtime()); }
Source:
<code><START> public void initialize(Map<String, Object> config) { <END> initializeRuleRuntimeProvider(); initializeRuleRuntimes(config); buildStreamToRulesRuntime(); }</code><technical_language>merge initialize() step constructor</technical_language>

Target:
public void initialize(Map<String, Object> config) { initializeRuleRuntimes(config); buildStreamToRulesRuntime(); this.processAll = this.rulesProcessor.getProcessAll(); }
Source:
<code>public void onComplete(Task task) { try { cleanup(); } catch (Exception e) { <START> onErrorInternal(task, e, false); <END> } if (_nextTaskListener != null) { _nextTaskListener.onComplete(task); } }</code><technical_language>I return here</technical_language>

Target:
public void onComplete(Task task) { try { cleanup(); } catch (Exception e) { onErrorInternal(task, e, false); return; } if (_nextTaskListener != null) { _nextTaskListener.onComplete(task); } }
Source:
<code><START> public boolean run() throws IOException, CompileException{ <END> ObjectId rulesId; rulesId = git.resolve(GitRepositoryManager.REF_CONFIG + ":rules.pl"); if (rulesId == null) { System.err.println("error: no rules.pl in " + git.getDirectory()); return false; } if (cacheDir == null) { System.err.println("error: caching not enabled on server"); return false; } File ruleDir = new File(cacheDir.getPath() + "/rules"); ruleDir.mkdir(); File tempDir = File.createTempFile("GerritCodeReview_", ".rulec"); if (!tempDir.delete() || !tempDir.mkdir()) throw new IOException("Cannot create temporary directory " + tempDir); try { compileProlog(rulesId, tempDir); compileJava(tempDir); File jarFile = new File(ruleDir.getPath() + "/rules-" + rulesId.getName() + ".jar"); List<String> tempFiles = getRelativePaths(tempDir, ".class"); createJarArchive(jarFile, tempFiles, tempDir); return true; } finally { deleteAllFiles(tempDir); } }</code><technical_language>Style-nit: Space {</technical_language>

Target:
public void run() throws IOException, CompileException { ObjectId rulesId; rulesId = git.resolve(GitRepositoryManager.REF_CONFIG + ":rules.pl"); if (rulesId == null) { throw new CompileException("error: no rules.pl in " + git.getDirectory()); } if (cacheDir == null) { throw new CompileException("error: caching not enabled on server"); } File ruleDir = new File(cacheDir, "rules"); ruleDir.mkdir(); File tempDir = File.createTempFile("GerritCodeReview_", ".rulec"); if (!tempDir.delete() || !tempDir.mkdir()) throw new IOException("Cannot create temporary directory " + tempDir); try { compileProlog(rulesId, tempDir); compileJava(tempDir); File jarFile = new File(ruleDir, "rules-" + rulesId.getName() + ".jar"); List<String> tempFiles = getRelativePaths(tempDir, ".class"); createJarArchive(jarFile, tempFiles, tempDir); } finally { deleteAllFiles(tempDir); } }
Source:
<code>public boolean removeInterceptor(ChannelInterceptor interceptor) { boolean removed = super.removeInterceptor(interceptor) && interceptor instanceof ExecutorChannelInterceptor && this.executorInterceptors.remove(interceptor); if (removed) { this.executorInterceptorsSize--; return true; } else { <START> return false; <END> } }</code><technical_language>true if exec. inter. super.remove() successful</technical_language>

Target:
public boolean removeInterceptor(ChannelInterceptor interceptor) { boolean removed = super.removeInterceptor(interceptor); if (removed && interceptor instanceof ExecutorChannelInterceptor) { this.executorInterceptorsSize--; } return removed; }
Source:
<code>public int compare(IPowerNode o1, IPowerNode o2){ TileEntity te1 = (TileEntity)o1; TileEntity te2 = (TileEntity)o2; BlockPos tePos1 = te1.getPos(); BlockPos tePos2 = te2.getPos(); <START> if (tePos1.getX() == tePos2.getX() && tePos1.getZ() == tePos2.getZ() && tePos1.getY() == tePos2.getY()) <END> return 0; if (tePos1.getX() > tePos2.getX()){ return 1; }else{ if (tePos1.getZ() > tePos2.getZ()){ return 1; }else{ if (tePos1.getY() > tePos2.getY()){ return 1; }else{ return -1; } } } }</code><technical_language>te1.getPos().equals(te2.getPos())</technical_language>

Target:
public int compare(IPowerNode o1, IPowerNode o2){ TileEntity te1 = (TileEntity)o1; TileEntity te2 = (TileEntity)o2; BlockPos tePos1 = te1.getPos(); BlockPos tePos2 = te2.getPos(); if (te1.getPos().equals(te2.getPos())) return 0; if (tePos1.getX() > tePos2.getX()){ return 1; }else{ if (tePos1.getZ() > tePos2.getZ()){ return 1; }else{ if (tePos1.getY() > tePos2.getY()){ return 1; }else{ return -1; } } } }
Source:
<code>public final void replaceInt(final int destColumn, final int destRow, final int value) { <START> getColumn(destColumn, destRow).replaceInt(value, destRow); <END> }</code><technical_language>confused this (here below): getColumn(destColumn, destRow).replaceInt(value, destRow % TupleBatch.BATCH_SIZE);</technical_language>

Target:
public final void replaceInt(final int destColumn, final int destRow, final int value) { getColumn(destColumn, destRow).replaceInt(value, destRow % TupleBatch.BATCH_SIZE); }
Source:
<code>public void download(final URI uri, final File outputFile, final HttpContext clientContext) throws Exception { final HttpGet httpGet = new HttpGet(uri); httpClient.execute(httpGet, new ResponseHandler<Void>() { @Override public Void handleResponse(final HttpResponse response) throws IOException { final HttpEntity entity = response.getEntity(); if (entity != null) { if (log != null) { log.info(String.format( "%s: %s", "Downloading", uri)); } final long totalLength = entity.getContentLength(); final char unit = totalLength >= KBYTE ? K_UNIT : B_UNIT; long completed = 0L; byte[] tmp = new byte[8 * (int) KBYTE]; try (InputStream in = entity.getContent(); FileOutputStream out = new FileOutputStream(outputFile)) { int bytesRead; while ((bytesRead = in.read(tmp)) != -1) { out.write(tmp, 0, bytesRead); if (log != null) { completed += bytesRead; final String totalInUnits; final long completedInUnits; if (unit == K_UNIT) { totalInUnits = totalLength == -1 ? "?" : Long.toString(totalLength / KBYTE) + unit; completedInUnits = completed / KBYTE; } else { totalInUnits = totalLength == -1 ? "?" : Long.toString(totalLength); completedInUnits = completed; } log.info(String.format("%d/%s", completedInUnits, totalInUnits)); } } out.flush(); if (log != null) { log.info(String.format("%s %s", "downloaded", unit == K_UNIT ? Long.toString(completed / KBYTE) + unit : Long.toString(completed))); } } catch (IOException ex) { if (log != null) { <START> log.error(ex); <END> } throw ex; } } return null; } }, clientContext); }</code><technical_language>@ok2c bot want suppress IO errors in non-interactive mode</technical_language>

Target:
public void download(final URI uri, final File outputFile, final HttpContext clientContext) throws Exception { final HttpGet httpGet = new HttpGet(uri); httpClient.execute(httpGet, new ResponseHandler<Void>() { @Override public Void handleResponse(final HttpResponse response) throws IOException { final HttpEntity entity = response.getEntity(); if (entity != null) { progressReport.initiate(uri, entity.getContentLength()); byte[] tmp = new byte[8 * 11024]; try (InputStream in = entity.getContent(); OutputStream out = new FileOutputStream(outputFile)) { int bytesRead; while ((bytesRead = in.read(tmp)) != -1) { out.write(tmp, 0, bytesRead); progressReport.update(bytesRead); } out.flush(); progressReport.completed(); } catch (IOException ex) { progressReport.error(ex); throw ex; } } return null; } }, clientContext); }
Source:
<code>ProgramState resetFieldValues(ConstraintManager constraintManager, boolean resetOnlyStaticFields) { final List<Symbol> fields = new ArrayList<>(); values.forEach((symbol, symbolicValue) -> { if (isField(symbol) && !symbol.isFinal() && (symbol.isStatic() || !resetOnlyStaticFields) ) { fields.add(symbol); } }); if (fields.isEmpty()) { return this; } PMap<Symbol, SymbolicValue> newValues = values; PMap<SymbolicValue, Integer> newReferences = references; for (Symbol field : fields) { SymbolicValue oldValue = newValues.get(field); <START> if (field != null) { <END> newReferences = decreaseReference(newReferences, oldValue); } Tree declarationOrFirstUsage = declarationOrFirstUsage(field); SymbolicValue newValue = constraintManager.createSymbolicValue(declarationOrFirstUsage); newValues = newValues.put(field, newValue); newReferences = increaseReference(newReferences, newValue); } return new ProgramState(newValues, newReferences, constraints, visitedPoints, stack, exitSymbolicValue); }</code><technical_language>this test testing oldValue , this means condition is covered tests (field is null here). I suggest replace calling ProgramState.put(field, newValue) instead, reusing logic is there</technical_language>

Target:
ProgramState resetFieldValues(ConstraintManager constraintManager, boolean resetOnlyStaticFields) { List<Symbol> fields = new ArrayList<>(); values.forEach((symbol, symbolicValue) -> { if (isField(symbol) && !symbol.isFinal() && (symbol.isStatic() || !resetOnlyStaticFields) ) { fields.add(symbol); } }); ProgramState newProgramState = this; for (Symbol field : fields) { newProgramState = newProgramState.put(field, constraintManager.createDefaultSymbolicValue()); } return newProgramState; }
Source:
<code>private void renderChangeInfo(ChangeInfo info) { changeInfo = info; lastDisplayedUpdate = info.updated(); statusText.setInnerText(Util.toLongString(info.status())); boolean current = info.status().isOpen() && revision.equals(info.current_revision()); boolean canSubmit = labels.set(info, current); renderOwner(info); renderReviewers(info); renderActionTextDate(info); renderRevisions(info); renderHistory(info); actions.display(info, revision); star.setValue(info.starred()); permalink.setHref(ChangeLink.permalink(changeId)); changeIdText.setInnerText(String.valueOf(info.legacy_id())); projectText.setInnerText(info.project()); branchText.setInnerText(info.branch()); idText.setText("Change-Id: " + info.change_id()); idText.setPreviewText(info.change_id()); reload.set(info); topic.set(info); commit.set(commentLinkProcessor, info, revision); related.set(info, revision); quickApprove.set(info, revision); <START> if (Gerrit.isSignedIn()) { <END> replyAction = new ReplyAction(info, revision, style, reply); if (topic.canEdit()) { keysAction.add(new KeyCommand(0, 't', Util.C.keyEditTopic()) { @Override public void onKeyPress(KeyPressEvent event) { topic.onEdit(); } }); } } if (current) { loadMergeable(info.status(), canSubmit); } StringBuilder sb = new StringBuilder(); sb.append(Util.M.changeScreenTitleId(info.id_abbreviated())); if (info.subject() != null) { sb.append(": "); sb.append(info.subject()); } setWindowTitle(sb.toString()); initEditCommitMessageAction(); }</code><technical_language>initEditMessageAction logic belongs here</technical_language>

Target:
private void renderChangeInfo(ChangeInfo info) { changeInfo = info; lastDisplayedUpdate = info.updated(); statusText.setInnerText(Util.toLongString(info.status())); boolean current = info.status().isOpen() && revision.equals(info.current_revision()); boolean canSubmit = labels.set(info, current); renderOwner(info); renderReviewers(info); renderActionTextDate(info); renderRevisions(info); renderHistory(info); actions.display(info, revision); star.setValue(info.starred()); permalink.setHref(ChangeLink.permalink(changeId)); changeIdText.setInnerText(String.valueOf(info.legacy_id())); projectText.setInnerText(info.project()); branchText.setInnerText(info.branch()); idText.setText("Change-Id: " + info.change_id()); idText.setPreviewText(info.change_id()); reload.set(info); topic.set(info); commit.set(commentLinkProcessor, info, revision); related.set(info, revision); quickApprove.set(info, revision); if (Gerrit.isSignedIn()) { initEditMessageAction(); replyAction = new ReplyAction(info, revision, style, reply); if (topic.canEdit()) { keysAction.add(new KeyCommand(0, 't', Util.C.keyEditTopic()) { @Override public void onKeyPress(KeyPressEvent event) { topic.onEdit(); } }); } } if (current) { loadMergeable(info.status(), canSubmit); } StringBuilder sb = new StringBuilder(); sb.append(Util.M.changeScreenTitleId(info.id_abbreviated())); if (info.subject() != null) { sb.append(": "); sb.append(info.subject()); } setWindowTitle(sb.toString()); }
Source:
<code>public SmbConnectionBuilder(String type, ConnectionOptions options, AddressPortMapper mapper) { CifsConnectionType cifsConnectionType = options.getEnum(CONNECTION_TYPE, CifsConnectionType.class); switch (cifsConnectionType) { case TELNET: <START> connection = new SmbTelnetConnection(type, options, mapper); <END> break; case WINRM_INTERNAL: connection = new SmbWinRmConnection(type, options, mapper); break; case WINRM_NATIVE: connection = new SmbWinrsConnection(type, options, mapper); break; default: throw new IllegalArgumentException("Unknown CIFS connection type " + cifsConnectionType); } }</code><technical_language>1 SmbConnection takes a ProcessConnection</technical_language>

Target:
public SmbConnectionBuilder(String type, ConnectionOptions options, AddressPortMapper mapper) { connection = new SmbProcessConnection(type, options, mapper); }
Source:
<code>protected ScanResult dbScanWithThroughputBackOff(ScanRequest scanRequest) { Long currentBackOff = minBackOff.get(); while(true) { try { return dbClient.scan(scanRequest); } catch (ProvisionedThroughputExceededException e) { currentBackOff = Math.min(currentBackOff * 2, maxBackOff.get()); <START> log.info("Failed to poll Dynamo due to ProvisionedThroughputExceededException. Backing off."); <END> try { Thread.sleep(currentBackOff); } catch (InterruptedException ex) { } } } }</code><technical_language>this is infinite loop I a WARN if ERROR is justified here</technical_language>

Target:
protected ScanResult dbScanWithThroughputBackOff(ScanRequest scanRequest) { Long currentBackOffMs = minBackOffMs.get(); Long retryCount = 0L; while (true) { try { return dbClient.scan(scanRequest); } catch (ProvisionedThroughputExceededException e) { currentBackOffMs = Math.min(currentBackOffMs * 2, maxBackOffMs.get()); log.error(String.format("Failed to poll Dynamo due to ProvisionedThroughputExceededException. Backing off for %d ms.", currentBackOffMs)); if (retryCount > maxRetryCount.get()) { throw e; } retryCount++; try { Thread.sleep(currentBackOffMs); } catch (InterruptedException ex) { } } } }
Source:
<code>public static void writeACNVModeledSegmentFileAsAllelicCapSegFile(final File outFile, <START> final List<ACNVModeledSegment> acnvModeledSegments, <END> final Genome genome) { Utils.nonNull(genome, "The genome cannot be null."); final double divisor = 2.0; final List<ACSModeledSegment> acsModeledSegments = convertACNVSegmentsToACSSegments(acnvModeledSegments, divisor, genome); try (final TableWriter<ACSModeledSegment> writer = TableUtils.writer(outFile, new TableColumnCollection(ACSTableColumns.COLUMN_NAME_ARRAY), (segment, dataLine) -> { dataLine.append(segment.getContig()).append(segment.getStart()).append(segment.getEnd()) .append(segment.getTargetCount()) .append(segment.getEnd() - segment.getStart()) .append(segment.getHetCount()) .append(segment.getF()) .append(segment.getTau()).append(segment.getSigmaTau()) .append(segment.getMuMinor()).append(segment.getSigmaMinor()) .append(segment.getMuMajor()).append(segment.getSigmaMajor()) .append(segment.getSegLabelCNLOH()); } )) { for (final ACSModeledSegment segment : acsModeledSegments) { writer.writeRecord(Utils.nonNull(segment, "List of segments contains a null.")); } } catch (final IOException e) { throw new UserException.CouldNotCreateOutputFile(outFile, e); } }</code><technical_language>If writeSegmentFile in SegmentUtils public, this code reduced a one-liner (as in methods calling public readSegmentFile method above)</technical_language>

Target:
public static void writeACNVModeledSegmentFileAsAllelicCapSegFile(final File outFile, final List<ACNVModeledSegment> acnvModeledSegments, final Genome genome) { Utils.nonNull(genome, "The genome cannot be null."); Utils.nonNull(acnvModeledSegments, "ACNV modeled segments cannot be null."); final List<ACSModeledSegment> acsModeledSegments = convertACNVSegmentsToACSSegments(acnvModeledSegments, DIVISOR, genome); try (final TableWriter<ACSModeledSegment> writer = TableUtils.writer(outFile, new TableColumnCollection(ACSTableColumns.COLUMN_NAME_ARRAY), (segment, dataLine) -> { dataLine.append(segment.getContig()).append(segment.getStart()).append(segment.getEnd()) .append(segment.getTargetCount()) .append(segment.getEnd() - segment.getStart()) .append(segment.getHetCount()) .append(segment.getF()) .append(segment.getTau()).append(segment.getSigmaTau()) .append(segment.getMuMinor()).append(segment.getSigmaMinor()) .append(segment.getMuMajor()).append(segment.getSigmaMajor()) .append(segment.getSegLabelCNLOH()); } )) { for (final ACSModeledSegment segment : acsModeledSegments) { writer.writeRecord(Utils.nonNull(segment, "List of segments contains a null.")); } } catch (final IOException e) { throw new UserException.CouldNotCreateOutputFile(outFile, e); } }
Source:
<code>public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException { try { return OffsetDateTime.parse(defaultStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[.SSS]x")); } catch (NumberFormatException e) { throw SqlExceptionUtil.create("Problems with field " + fieldType + <START> " parsing default LocalDateTime value: " + defaultStr, e); <END> } }</code><technical_language>This "OffsetDateTime"</technical_language>

Target:
public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException { try { return OffsetDateTime.parse(defaultStr, new DateTimeFormatterBuilder() .appendPattern("yyyy-MM-dd HH:mm:ss") .appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true) .appendPattern("x") .toFormatter()); } catch (NumberFormatException e) { throw SqlExceptionUtil.create("Problems with field " + fieldType + " parsing default OffsetDateTime value: " + defaultStr, e); } }