auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static Object convertStringToInternalValue(String valStr, DataType type) { if (valStr == null) { return null; } LogicalTypeRoot typeRoot = type.getLogicalType().getTypeRoot(); switch (typeRoot) { case CHAR: case VARCHAR: return StringData.fromString(valStr); case BOOLEAN: return Boolean.parseBoolean(valStr); case TINYINT: return Byte.parseByte(valStr); case SMALLINT: return Short.parseShort(valStr); case INTEGER: return Integer.parseInt(valStr); case BIGINT: return Long.parseLong(valStr); case FLOAT: return Float.parseFloat(valStr); case DOUBLE: return Double.parseDouble(valStr); case DATE: <START> LocalDate date = ISO_LOCAL_DATE.parse(valStr).query(TemporalQueries.localDate()); <END> return (int) date.toEpochDay(); case TIMESTAMP_WITHOUT_TIME_ZONE: return TimestampData.fromLocalDateTime(LocalDateTime.parse(valStr)); default: throw new RuntimeException(String.format( "Can not convert %s to type %s for partition value", valStr, type)); } }</code><technical_language>LocalDate.parse</technical_language>

Target:
public static Object convertStringToInternalValue(String valStr, DataType type) { if (valStr == null) { return null; } LogicalTypeRoot typeRoot = type.getLogicalType().getTypeRoot(); switch (typeRoot) { case CHAR: case VARCHAR: return StringData.fromString(valStr); case BOOLEAN: return Boolean.parseBoolean(valStr); case TINYINT: return Byte.parseByte(valStr); case SMALLINT: return Short.parseShort(valStr); case INTEGER: return Integer.parseInt(valStr); case BIGINT: return Long.parseLong(valStr); case FLOAT: return Float.parseFloat(valStr); case DOUBLE: return Double.parseDouble(valStr); case DATE: return (int) LocalDate.parse(valStr).toEpochDay(); case TIMESTAMP_WITHOUT_TIME_ZONE: return TimestampData.fromLocalDateTime(LocalDateTime.parse(valStr)); default: throw new RuntimeException(String.format( "Can not convert %s to type %s for partition value", valStr, type)); } }
Source:
<code>public void testIdentityColumn() throws Exception { <START> if (TestUtil.haveMinimumServerVersion(conn, ServerVersion.v10)) { <END> assumePreparedStatementMetadataSupported(); PreparedStatement pstmt = conn.prepareStatement("SELECT id FROM identitytest"); ResultSet rs = pstmt.executeQuery(); ResultSetMetaData rsmd = pstmt.getMetaData(); Assert.assertTrue(rsmd.isAutoIncrement(1)); } }</code><technical_language>"assume..." for that</technical_language>

Target:
public void testIdentityColumn() throws Exception { assumeMinimumServerVersion(ServerVersion.v10); assumePreparedStatementMetadataSupported(); PreparedStatement pstmt = conn.prepareStatement("SELECT id FROM identitytest"); ResultSet rs = pstmt.executeQuery(); ResultSetMetaData rsmd = pstmt.getMetaData(); Assert.assertTrue(rsmd.isAutoIncrement(1)); }
Source:
<code>private void populateStatus(final List<GlusterGeoRepSessionDetails> details) { final VolumeGeoRepSessionDetailsModel windowModel = new VolumeGeoRepSessionDetailsModel(); windowModel.setHelpTag(HelpTag.geo_replication_status_detail); windowModel.setHashName("geo_replication_status_detail"); final UIConstants constants = ConstantsManager.getInstance().getConstants(); windowModel.setTitle(constants.geoReplicationSessionDetailsTitle()); UICommand okCommand = new UICommand("closeWindow", this); okCommand.setIsCancel(true); okCommand.setTitle(constants.ok()); windowModel.getCommands().add(okCommand); setWindow(windowModel); List<VdcQueryParametersBase> <START> queryParamsList = <END> new ArrayList<VdcQueryParametersBase>(); for(GlusterGeoRepSessionDetails detail : details) { queryParamsList.add(new IdQueryParameters(detail.getMasterBrickId())); } final List<EntityModel<GlusterGeoRepSessionDetails>> detailRows = new ArrayList<>(); for (GlusterGeoRepSessionDetails detail : details) { detailRows.add(new EntityModel<GlusterGeoRepSessionDetails>(detail)); } windowModel.getGeoRepSessionSummary().setItems(detailRows, detailRows.get(0)); }</code><technical_language>variable</technical_language>

Target:
private void populateStatus(final List<GlusterGeoRepSessionDetails> details) { final VolumeGeoRepSessionDetailsModel windowModel = new VolumeGeoRepSessionDetailsModel(); windowModel.setHelpTag(HelpTag.geo_replication_status_detail); windowModel.setHashName("geo_replication_status_detail"); final UIConstants constants = ConstantsManager.getInstance().getConstants(); windowModel.setTitle(constants.geoReplicationSessionDetailsTitle()); UICommand okCommand = new UICommand("closeWindow", this); okCommand.setIsCancel(true); okCommand.setTitle(constants.ok()); windowModel.getCommands().add(okCommand); setWindow(windowModel); final List<EntityModel<GlusterGeoRepSessionDetails>> detailRows = new ArrayList<>(); for (GlusterGeoRepSessionDetails detail : details) { detailRows.add(new EntityModel<GlusterGeoRepSessionDetails>(detail)); } windowModel.getGeoRepSessionSummary().setItems(detailRows, detailRows.get(0)); }
Source:
<code><START> public synchronized boolean containsValuesOfType(Category.Type type) { <END> return values.keySet().stream().anyMatch(e -> e.getType().equals(type)); }</code><technical_language>I this called concurrently called HtmlReporter. I mind if leave in</technical_language>

Target:
public boolean containsValuesOfType(Category.Type type) { return values.keySet().stream().anyMatch(e -> e.getType().equals(type)); }
Source:
<code>public TimestampSpec( @JsonProperty("column") String timestampColumn, @JsonProperty("format") String format ) { this.timestampColumn = (timestampColumn == null) ? defaultColumn : timestampColumn.toLowerCase(); this.timestampFormat = format == null ? defaultFormat : format; <START> try { <END> this.timestampConverter = ParserUtils.createTimestampParser(timestampFormat); } catch (ParseException e) { throw Throwables.propagate(e); } }</code><technical_language>I ParseException wrapping is right here, is creating a parser, parsing</technical_language>

Target:
public TimestampSpec( @JsonProperty("column") String timestampColumn, @JsonProperty("format") String format ) { this.timestampColumn = (timestampColumn == null) ? defaultColumn : timestampColumn.toLowerCase(); this.timestampFormat = format == null ? defaultFormat : format; this.timestampConverter = ParserUtils.createTimestampParser(timestampFormat); }
Source:
<code>public List<Integer> getIntersectingChildren(long time) { List<Integer> <START> intersectingChildren = <END> new LinkedList<>(); for (int i = 0; i < nbChildren; i++) { if (time >= childStart[i] && time <= childEnd[i]) { intersectingChildren.add(children[i]); } } return intersectingChildren; }</code><technical_language>This array list. Faster iteration, such</technical_language>

Target:
public List<Integer> getIntersectingChildren(long time) { List<Integer> intersectingChildren = new ArrayList<>(); for (int i = 0; i < nbChildren; i++) { if (time >= childStart[i] && time <= childEnd[i]) { intersectingChildren.add(children[i]); } } return intersectingChildren; }
Source:
<code>private void _add(String fieldName, IonValueLite child) { <START> if(!hasNullFieldName && fieldName == null) hasNullFieldName = true; <END> int size = get_child_count(); add(size, child); if (_field_map != null) { add_field(fieldName, child._elementid()); } }</code><technical_language>Is benefit checking !hasNullFieldName here? If true, harmful set true</technical_language>

Target:
private void _add(String fieldName, IonValueLite child) { hasNullFieldName |= fieldName == null; int size = get_child_count(); add(size, child); if (_field_map != null) { add_field(fieldName, child._elementid()); } }
Source:
<code>public void setField(final CheckboxMultipleField field) { this.field = field; if (this.field.isShowLabel()) { TextView label = findViewById(R.id.liferay_ddm_label); label.setText(field.getLabel()); label.setVisibility(VISIBLE); if (this.field.isRequired()) { label.append(ThemeUtil.getRequiredSpannable(getContext())); } } if (this.field.isInline()) { linearLayout.setOrientation(HORIZONTAL); } LayoutParams layoutParams = calculateLayoutParams(this.field.isInline(), this.field.showAsSwitcher()); List<Option> availableOptions = field.getAvailableOptions(); <START> if (field.showAsSwitcher()) { <END> for (Option opt : availableOptions) { Switch switchView = createSwitchView(opt, layoutParams); addView(field, switchView); } } else { for (Option opt : availableOptions) { CheckBox checkBoxView = createCheckBoxView(opt, layoutParams); addView(field, checkBoxView); } } refresh(); }</code><technical_language>if loop, right</technical_language>

Target:
public void setField(final CheckboxMultipleField field) { this.field = field; if (field.isShowLabel()) { TextView label = findViewById(R.id.liferay_ddm_label); label.setText(field.getLabel()); label.setVisibility(VISIBLE); if (field.isRequired()) { label.append(ThemeUtil.getRequiredSpannable(getContext())); } } if (field.isInline()) { linearLayout.setOrientation(HORIZONTAL); } LayoutParams layoutParams = calculateLayoutParams(field.isInline(), field.showAsSwitcher()); List<Option> availableOptions = field.getAvailableOptions(); for (Option opt : availableOptions) { if (field.showAsSwitcher()) { Switch switchView = createSwitchView(opt, layoutParams); addView(field, switchView); } else { CheckBox checkBoxView = createCheckBoxView(opt, layoutParams); addView(field, checkBoxView); } } refresh(); }
Source:
<code>public void synchToTime(final TmfTimeSynchSignal signal) { if (signal.getSource() == this || fTrace == null) { return; } final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); final int selectionValue = getSelectionValue(time); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (fTimeGraphCombo.isDisposed()) { return; } fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true); startZoomThread(fTimeGraphCombo.getTimeGraphViewer().getTime0(), fTimeGraphCombo.getTimeGraphViewer().getTime1()); <START> selectEntry(selectionValue); <END> } }); }</code><technical_language>Instead of computing obscure 'selection value', do work in method in subclass, for example synchToTime(long time) called in asyncExec</technical_language>

Target:
public void synchToTime(final TmfTimeSynchSignal signal) { if (signal.getSource() == this || fTrace == null) { return; } final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (fTimeGraphCombo.isDisposed()) { return; } fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true); startZoomThread(fTimeGraphCombo.getTimeGraphViewer().getTime0(), fTimeGraphCombo.getTimeGraphViewer().getTime1()); synchingToTime(time); } }); }
Source:
<code>private void addPutEntriesForDelete(long indexSegmentStartOffset, List<IndexEntry> indexEntries) throws StoreException { Set<StoreKey> seenPuts = new HashSet<>(); List<IndexEntry> newEntries = new ArrayList<>(); for (IndexEntry entry : indexEntries) { IndexValue value = entry.getValue(); if (value.isFlagSet(IndexValue.Flags.Delete_Index)) { if (value.getOriginalMessageOffset() != IndexValue.UNKNOWN_ORIGINAL_MESSAGE_OFFSET && value.getOriginalMessageOffset() != value.getOffset().getOffset() <START> && value.getOriginalMessageOffset() >= indexSegmentStartOffset && !seenPuts.contains(entry.getKey())) { <END> IndexValue originalPutValue = getPutRecordForDeletedKey(entry.getKey(), value); newEntries.add(new IndexEntry(entry.getKey(), originalPutValue)); } } else if (!entry.getValue().isFlagSet(IndexValue.Flags.Ttl_Update_Index)) { seenPuts.add(entry.getKey()); } } indexEntries.addAll(newEntries); indexEntries.sort(KEY_OFFSET_COMPARATOR); }</code><technical_language>Based description in java doc: "put entry (if exists) occur a delete entry", is good value.getOriginalMessageOffset() < value.getOffset().getOffset() in stead of value.getOriginalMessageOffset() != value.getOffset().getOffset()</technical_language>

Target:
private void addPutEntriesForDelete(long indexSegmentStartOffset, List<IndexEntry> indexEntries) throws StoreException { Set<StoreKey> seenPuts = new HashSet<>(); List<IndexEntry> newEntries = new ArrayList<>(); for (IndexEntry entry : indexEntries) { IndexValue value = entry.getValue(); if (value.isFlagSet(IndexValue.Flags.Delete_Index)) { if (value.getOriginalMessageOffset() != IndexValue.UNKNOWN_ORIGINAL_MESSAGE_OFFSET && value.getOriginalMessageOffset() < value.getOffset().getOffset() && value.getOriginalMessageOffset() >= indexSegmentStartOffset && !seenPuts.contains(entry.getKey())) { IndexValue originalPutValue = getPutRecordForDeletedKey(entry.getKey(), value); newEntries.add(new IndexEntry(entry.getKey(), originalPutValue)); } } else if (!entry.getValue().isFlagSet(IndexValue.Flags.Ttl_Update_Index)) { seenPuts.add(entry.getKey()); } } indexEntries.addAll(newEntries); }
Source:
<code>public boolean equals(Object o) { if (!(o instanceof ViolationMessage)) { return false; } ViolationMessage message; message = (ViolationMessage)o; <START> return this.filePath == message.filePath <END> && this.lineNumber == message.lineNumber && this.columnNumber == message.columnNumber && this.classification == message.classification && this.violationMessage == message.violationMessage; }</code><technical_language>Need .equals() compare strings, commit a fix (will compare primitives objects for performance)</technical_language>

Target:
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ViolationMessage)) return false; ViolationMessage candidateObject = (ViolationMessage) o; return (this.lineNumber == candidateObject.lineNumber) && (this.columnNumber == candidateObject.columnNumber) && (this.filePath.equals(candidateObject.filePath)) && (this.classification.equals(candidateObject.classification)) && (this.violationMessage.equals(candidateObject.violationMessage)); }
Source:
<code>public static ItemStack getFilledBucket(@Nonnull UniversalBucket item, FluidStack fluidStack) { Fluid fluid = fluidStack.getFluid(); if (fluidStack.tag == null || fluidStack.tag.hasNoTags()) { if (fluid == net.minecraftforge.fluids.FluidRegistry.WATER) { <START> return new ItemStack(Items.WATER_BUCKET); <END> } else if (fluid == net.minecraftforge.fluids.FluidRegistry.LAVA) { return new ItemStack(Items.LAVA_BUCKET); } else if (fluid.getName().equals("milk")) { return new ItemStack(Items.MILK_BUCKET); } } if (net.minecraftforge.fluids.FluidRegistry.getBucketFluids().contains(fluid)) { ItemStack bucket = new ItemStack(item); NBTTagCompound tag = new NBTTagCompound(); FluidStack fluidContents = new FluidStack(fluid, item.getCapacity()); fluidContents.writeToNBT(tag); bucket.setTagCompound(tag); return bucket; } return ItemStack.EMPTY; }</code><technical_language>this is right? I so</technical_language>

Target:
public static ItemStack getFilledBucket(@Nonnull UniversalBucket item, FluidStack fluidStack) { if (net.minecraftforge.fluids.FluidRegistry.getBucketFluids().contains(fluidStack.getFluid())) { ItemStack bucket = new ItemStack(item); NBTTagCompound tag = new NBTTagCompound(); FluidStack fluidContents = new FluidStack(fluidStack.getFluid(), item.getCapacity()); fluidContents.writeToNBT(tag); bucket.setTagCompound(tag); return bucket; } return ItemStack.EMPTY; }
Source:
<code>private GHRepository create() throws IOException, InterruptedException { GHRepository repo = gitHub.createRepository(repoName).create(); for (int attempts = 0; attempts < 5; attempts++) { try { repo = gitHub.getRepository(repo.getFullName()); break; } catch (Exception e) { LOG.info("Waiting for to be created", repo.getFullName()); <START> Thread.sleep(TimeUnit.SECONDS.toMillis(1)); <END> } } LOG.info("GitHub repo has been created", repo.getHtmlUrl()); return repo; }</code><technical_language>WaitUtils.sleepQuietly()? instead of Thread.sleep()</technical_language>

Target:
private GHRepository create() throws IOException, InterruptedException { GHRepository repo = gitHub.createRepository(repoName).create(); ensureRepositoryCreated(repo); LOG.info("GitHub repo has been created", repo.getHtmlUrl()); return repo; }
Source:
<code>public boolean hasPreview(String xpath) { String srcMT = getMimeType(xpath); if (!Framework.getService(ConfigurationService.class).isBooleanPropertyTrue(ALLOW_ZIP_PREVIEW) <START> && "application/zip".equals(srcMT)) { <END> return false; } MimeTypePreviewer mtPreviewer = getPreviewManager().getPreviewer(srcMT); return mtPreviewer != null || getConversionService().getConverterName(srcMT, "text/html") != null; }</code><technical_language>Put "application/zip".equals(srcMT) && cheaper evaluate</technical_language>

Target:
public boolean hasPreview(String xpath) { String srcMT = getMimeType(xpath); if ("application/zip".equals(srcMT) && !Framework.getService(ConfigurationService.class).isBooleanPropertyTrue(ALLOW_ZIP_PREVIEW)) { return false; } MimeTypePreviewer mtPreviewer = getPreviewManager().getPreviewer(srcMT); return mtPreviewer != null || getConversionService().getConverterName(srcMT, "text/html") != null; }
Source:
<code>public TestGerritTaskEditorPage() { <START> super(getMockEditor()); <END> model = mock(TaskDataModel.class); TaskRepository repository = new TaskRepository(GerritConnector.CONNECTOR_KIND, "mock"); TaskData taskData = new TaskData(new TaskAttributeMapper(repository), GerritConnector.CONNECTOR_KIND, "mock", "mock"); taskData.getRoot().createAttribute(GerritQueryResultSchema.getDefault().BRANCH.getKey()); taskData.getRoot().createAttribute(GerritQueryResultSchema.getDefault().PROJECT.getKey()); taskData.getRoot().createAttribute(GerritQueryResultSchema.getDefault().STATUS.getKey()); when(model.getTaskData()).thenReturn(taskData); when(model.getTaskRepository()).thenReturn(repository); IEditorSite editorSite = mock(IEditorSite.class); IHandlerService service = mock(IHandlerService.class); when(editorSite.getService(IHandlerService.class)).thenReturn(service); TaskEditorInput taskEditorInput = new TaskEditorInput(repository, linkedTask); when(getTaskEditor().getTaskEditorInput()).thenReturn(taskEditorInput); when(taskEditorInput.getTask()).thenReturn(linkedTask); init(editorSite, taskEditorInput); }</code><technical_language>pass mock(TaskEditor.class) set mocking page.getEditor aftewards</technical_language>

Target:
public TestGerritTaskEditorPage() { super(getMockEditor()); model = mock(TaskDataModel.class); TaskData taskData = new TaskData(new TaskAttributeMapper(repository), GerritConnector.CONNECTOR_KIND, "mock", "mock"); taskData.getRoot().createAttribute(GerritQueryResultSchema.getDefault().BRANCH.getKey()); taskData.getRoot().createAttribute(GerritQueryResultSchema.getDefault().PROJECT.getKey()); taskData.getRoot().createAttribute(GerritQueryResultSchema.getDefault().STATUS.getKey()); when(model.getTaskData()).thenReturn(taskData); when(model.getTaskRepository()).thenReturn(repository); IEditorSite editorSite = mock(IEditorSite.class); IHandlerService service = mock(IHandlerService.class); when(editorSite.getService(IHandlerService.class)).thenReturn(service); when(getTaskEditor().getTaskEditorInput()).thenReturn(taskEditorInput); init(editorSite, taskEditorInput); }
Source:
<code>AllocatedEvaluator allocateContainer(String id, int cpu, int mem) { EvaluatorRequest evaluatorRequest = createEvaluatorRequest(cpu, mem); LOG.log(Level.INFO, "Requesting container for executor, id: {0}, mem: {1}, cpu: {2}", new Object[]{id, mem, cpu}); requestor.submit(evaluatorRequest); try { AllocatedEvaluator evaluator = allocatedContainerQ.take(); LOG.log(Level.INFO, "Container {0} is allocated for executor, id: {1}", new Object[]{evaluator.getId(), id}); return evaluator; } catch (InterruptedException e) { LOG.log(Level.WARNING, "Interrupted while waiting for container allocation", e); <START> return null; <END> } }</code><technical_language>this exceptional case. throw exception instead of returning null</technical_language>

Target:
AllocatedEvaluator allocateContainer(String id, int cpu, int mem) throws InterruptedException { EvaluatorRequest evaluatorRequest = createEvaluatorRequest(cpu, mem); LOG.log(Level.INFO, "Requesting container for executor, id: {0}, mem: {1}, cpu: {2}", new Object[]{id, mem, cpu}); requestor.submit(evaluatorRequest); AllocatedEvaluator evaluator = allocatedContainerQ.take(); LOG.log(Level.INFO, "Container {0} is allocated for executor, id: {1}", new Object[]{evaluator.getId(), id}); return evaluator; }
Source:
<code>public CompressionOutputStream createOutputStream(OutputStream out) throws IOException { <START> throw new RuntimeException("Not supported"); <END> }</code><technical_language>UnsupportedOperationException (same others)</technical_language>

Target:
public CompressionOutputStream createOutputStream(OutputStream out) throws IOException { throw new UnsupportedOperationException("Not supported"); }
Source:
<code>public StaticProfileUtil(Profile profile) { Stereotype ePkg = profile.getAppliedStereotype(EPackage_QNAME); definition = EcoreFactory.eINSTANCE.createEPackage(); if (ePkg != null) { basePackage = (String) profile.getValue(ePkg, EPKG_BASE_PACKAGE); packageName = (String) profile.getValue(ePkg, EPKG_PACKAGE_NAME); definition.setNsPrefix((String) profile.getValue(ePkg, EPKG_NS_PREFIX)); } else { basePackage = null; packageName = null; definition.setNsPrefix(""); } if (profile.getURI() != null) { definition.setNsURI(profile.getURI()); } else if (ePkg != null) { definition.setNsURI((String) <START> profile.getValue(ePkg, <END> EPKG_NS_URI)); } else { definition.setNsURI(""); } }</code><technical_language>This null empty string, of is a valid NS URI</technical_language>

Target:
public StaticProfileUtil(Profile profile) { Stereotype ePkg = profile.getAppliedStereotype(EPackage_QNAME); definition = EcoreFactory.eINSTANCE.createEPackage(); if (ePkg != null) { basePackage = (String) profile.getValue(ePkg, EPKG_BASE_PACKAGE); packageName = (String) profile.getValue(ePkg, EPKG_PACKAGE_NAME); definition.setNsPrefix((String) profile.getValue(ePkg, EPKG_NS_PREFIX)); } else { basePackage = null; packageName = null; definition.setNsPrefix(""); } String nsURI = null; if (ePkg != null) { nsURI = (String) profile.getValue(ePkg, EPKG_NS_URI); } if (nsURI == null || nsURI.isEmpty()) { nsURI = profile.getURI(); } if (nsURI == null) { nsURI = ""; } definition.setNsURI(nsURI); }
Source:
<code>private List<Column> getChartColumns() { List<Column> chartColumns = new ArrayList<>(metricBucket.size()); for (MetricAvailabilityBucket metricBucket : this.metricBucket) { MetricAvailability metricAvailability = null; if (metricBucket.getValue().equals("NaN")) { metricAvailability = MetricAvailability.from("unknown"); <START> } else if (Float.parseFloat(metricBucket.getValue()) >= .5) { <END> metricAvailability = MetricAvailability.from("up"); } else { metricAvailability = MetricAvailability.from("down"); } float columnValue = getColumnValue(metricAvailability); int columnColor = getColumnColor(metricAvailability); chartColumns.add(new Column(Collections.singletonList(new SubcolumnValue(columnValue, columnColor)))); } return chartColumns; }</code><technical_language>is hawkular-services 0.0.5 a "admin" available. test this section 0.0.5</technical_language>

Target:
private List<Column> getChartColumns() { List<Column> chartColumns = new ArrayList<>(metricBucket.size()); for (MetricBucket metricBucket : this.metricBucket) { MetricAvailability metricAvailability = null; if (metricBucket.getValue().equals("NaN")) { metricAvailability = MetricAvailability.from("unknown"); } else if (Float.parseFloat(metricBucket.getValue()) >= .5) { metricAvailability = MetricAvailability.from("up"); } else { metricAvailability = MetricAvailability.from("down"); } float columnValue = getColumnValue(metricAvailability); int columnColor = getColumnColor(metricAvailability); chartColumns.add(new Column(Collections.singletonList(new SubcolumnValue(columnValue, columnColor)))); } return chartColumns; }
Source:
<code>protected void registerGetters() { <START> registerFieldGetter(Keys.AGE, ImmutableSpongeAgeableData.this::getAge); <END> registerKeyValue(Keys.AGE, ImmutableSpongeAgeableData.this::age); registerFieldGetter(Keys.BABY, ImmutableSpongeAgeableData.this::isBaby); registerKeyValue(Keys.BABY, ImmutableSpongeAgeableData.this::baby); registerFieldGetter(Keys.ADULT, ImmutableSpongeAgeableData.this::isAdult); registerKeyValue(Keys.ADULT, ImmutableSpongeAgeableData.this::adult); }</code><technical_language>lambdas getAge</technical_language>

Target:
protected void registerGetters() { registerFieldGetter(Keys.AGE, ImmutableSpongeAgeableData.this::getAge); registerKeyValue(Keys.AGE, ImmutableSpongeAgeableData.this::age); registerFieldGetter(Keys.IS_ADULT, ImmutableSpongeAgeableData.this::isAdult); registerKeyValue(Keys.IS_ADULT, ImmutableSpongeAgeableData.this::adult); }
Source:
<code>public void testSameSID() throws Exception { QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[2], peerTmpdir[2], peerClientPort[2], 3, 2, 2000, 2, 2); QuorumCnxManager cnxManager = new QuorumCnxManager(peer); QuorumCnxManager.Listener listener = cnxManager.listener; if (listener != null) { Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread th, Throwable ex) { if (ex instanceof RuntimeException) { String msg = ex.getMessage(); LOG.error(msg); Assert.assertEquals("org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException:" + " Appearing duplicate SID: 2", msg); } } }; listener.setUncaughtExceptionHandler(handler); listener.start(); } else { LOG.error("Null listener when initializing cnx manager"); } try (Socket sock = new Socket()) { InetSocketAddress electionAddr = peers.get(peer.getId()).electionAddr; LOG.info("Creating socket connection, host: {}, port: {}", electionAddr.getHostString(), electionAddr.getPort()); <START> sock.connect(electionAddr, 30000); <END> try (DataOutputStream dout = new DataOutputStream(sock.getOutputStream())) { dout.writeLong(peer.getId()); dout.flush(); cnxManager.receiveConnection(sock); } } }</code><technical_language>timeout is big (30000 ms) relation other tests (5000 ms). is necessary this big</technical_language>

Target:
public void testSameSID() throws Exception { QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[2], peerTmpdir[2], peerClientPort[2], 3, 2, 2000, 2, 2); QuorumCnxManager cnxManager = new QuorumCnxManager(peer); QuorumCnxManager.Listener listener = cnxManager.listener; if (listener != null) { Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread th, Throwable ex) { if (ex instanceof RuntimeException) { String msg = ex.getMessage(); LOG.error(msg); Assert.assertEquals("org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException:" + " Duplicate SID 2 found", msg); } } }; listener.setUncaughtExceptionHandler(handler); listener.start(); } else { LOG.error("Null listener when initializing cnx manager"); } try (Socket sock = new Socket()) { InetSocketAddress electionAddr = peers.get(peer.getId()).electionAddr; LOG.info("Creating socket connection, host: {}, port: {}", electionAddr.getHostString(), electionAddr.getPort()); sock.connect(electionAddr, 5000); try (DataOutputStream dout = new DataOutputStream(sock.getOutputStream())) { dout.writeLong(peer.getId()); dout.flush(); cnxManager.receiveConnection(sock); } } }
Source:
<code>protected void doStart() throws Exception { super.doStart(); if (this.taskExecutor == null) { this.taskExecutor = new SimpleAsyncTaskExecutor((getBeanName() == null ? "container" : getBeanName()) + "-"); } this.taskExecutor.execute(new Runnable() { boolean initialized = false; @Override public void run() { while (!initialized) { try { for (int i = 0; i < consumersPerQueue; i++) { for (String queue : getQueueNames()) { Connection connection = getConnectionFactory().createConnection(); Channel channel = connection.createChannel(false); channel.basicQos(prefetch); RabbitUtils.setPhysicalCloseRequired(true); SimpleConsumer consumer = new SimpleConsumer(channel, queue); consumers.add(consumer); <START> channel.basicConsume(queue, consumer); <END> } } } catch (Exception e) { logger.error("Error creating consumer", e); doShutdown(); try { Thread.sleep(5000); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } continue; } initialized = true; } } }); }</code><technical_language>I try understand if need separate Thread initiate basicConsume(). this.taskExecutor schedule this while task. do doStart() Thread</technical_language>

Target:
protected void doStart() throws Exception { super.doStart(); if (this.taskExecutor == null) { this.taskExecutor = new SimpleAsyncTaskExecutor((getBeanName() == null ? "container" : getBeanName()) + "-"); } this.taskExecutor.execute(new Runnable() { boolean initialized = false; @Override public void run() { while (!initialized) { try { for (int i = 0; i < SimpleDirectMessageListenerContainer.this.consumersPerQueue; i++) { for (String queue : getQueueNames()) { Connection connection = getConnectionFactory().createConnection(); Channel channel = connection.createChannel(false); channel.basicQos(SimpleDirectMessageListenerContainer.this.prefetch); RabbitUtils.setPhysicalCloseRequired(true); SimpleConsumer consumer = new SimpleConsumer(channel, queue); SimpleDirectMessageListenerContainer.this.consumers.add(consumer); channel.basicConsume(queue, consumer); } } } catch (Exception e) { logger.error("Error creating consumer", e); doShutdown(); try { Thread.sleep(5000); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } continue; } initialized = true; } } }); }
Source:
<code>protected boolean amendDiskRequested() { if (getNewDisk().getDiskStorageType() == DiskStorageType.IMAGE && <START> !(getNewDisk().isDiskSnapshot() && ((DiskImage) getNewDisk()).getImage().getVolumeFormat() == VolumeFormat.RAW)) { <END> QcowCompat qcowCompat = ((DiskImage) getNewDisk()).getQcowCompat(); return getDiskImages(getOldDisk().getId()).stream().anyMatch(disk -> disk.isQcowFormat() && disk.getQcowCompat() != qcowCompat); } return false; }</code><technical_language>unreadable, please extract a boolean a meaningful name</technical_language>

Target:
protected boolean amendDiskRequested() { boolean isBaseSnapshotDisk = getNewDisk().isDiskSnapshot() && ((DiskImage) getNewDisk()).getImage().getVolumeFormat() == VolumeFormat.RAW; if (getNewDisk().getDiskStorageType() == DiskStorageType.IMAGE && !isBaseSnapshotDisk) { QcowCompat qcowCompat = ((DiskImage) getNewDisk()).getQcowCompat(); return getDiskImages(getOldDisk().getId()).stream().anyMatch(disk -> disk.isQcowFormat() && disk.getQcowCompat() != qcowCompat); } return false; }
Source:
<code>public static Trackable searchTrackable(final String geocode) { Log.d("GeokretyConnector.searchTrackable: gkid=" + getId(geocode)); try { final String response = Network.getResponseData(Network.getRequest("<LINK_0>" + getId(geocode))); final InputSource is = new InputSource(); is.setEncoding("UTF-8"); <START> is.setCharacterStream(new StringReader(response)); <END> return GeokretyParser.parse(is).get(0); } catch (Exception e) { Log.w("GeokretyConnector.searchTrackable", e); return null; } }</code><technical_language>Network.getResponseStream() get stream a HTTP response</technical_language>

Target:
public static Trackable searchTrackable(final String geocode) { Log.d("GeokretyConnector.searchTrackable: gkid=" + getId(geocode)); try { final InputStream response = Network.getResponseStream(Network.getRequest("<LINK_0>" + getId(geocode))); final InputSource is = new InputSource(response); return GeokretyParser.parse(is).get(0); } catch (Exception e) { Log.w("GeokretyConnector.searchTrackable", e); return null; } }
Source:
<code>public static IPath getLocationForElement(IJavaElement next) { IResource resource = next.getResource(); if (resource != null) { return resource.getLocation() == null ? <START> new Path("") : <END> resource.getLocation(); } return next.getPath(); }</code><technical_language>Path.EMPTY</technical_language>

Target:
public static IPath getLocationForElement(IJavaElement next) { IResource resource = next.getResource(); if (resource != null) { return resource.getLocation() == null ? Path.EMPTY : resource.getLocation(); } return next.getPath(); }
Source:
<code>private void setRedirectCookies(HttpMethod method) { ArrayList<HttpCookie> cookiesToSet = new ArrayList<>(); <START> Header[] setCookieHeaders = method.getResponseHeaders("Set-Cookie"); <END> for (Header setCookieHeader : setCookieHeaders) { try { cookiesToSet.addAll(HttpCookie.parse(setCookieHeader.getValue())); } catch (Exception e) { if (LOG.isDebugEnabled()) LOG.debug("Set-Cookie header: \" " + setCookieHeader.getValue() + " \" is malformed "); } } if (cookiesToSet.isEmpty()) return; redirectCookies.addAll(cookiesToSet); ArrayList<String> cookieNames = new ArrayList<>(); for (HttpCookie cookie : cookiesToSet) { cookieNames.add(cookie.getName()); } Header cookieHeader = method.getRequestHeader("Cookie"); if (cookieHeader != null) { HeaderElement[] cookieElements = cookieHeader.getElements(); for (HeaderElement cookieElement : cookieElements) { String cookieName = cookieElement.getName(); if (!cookieNames.contains(cookieName)) cookiesToSet.add(new HttpCookie(cookieName, cookieElement.getValue())); } } String cookieHeaderValue = ""; for (HttpCookie cookie : cookiesToSet) { cookieHeaderValue += cookie.toString() + "; "; } if (cookieHeaderValue.length() > 2) { cookieHeaderValue = cookieHeaderValue.substring(0, cookieHeaderValue.length() - 2); method.setRequestHeader("Cookie", cookieHeaderValue); } }</code><technical_language>This a constant, defined in HttpHeader</technical_language>

Target:
private void setRedirectCookies(HttpMethod method) { ArrayList<HttpCookie> cookiesToSet = new ArrayList<>(); Header[] setCookieHeaders = method.getResponseHeaders(HttpHeader.SET_COOKIE); for (Header setCookieHeader : setCookieHeaders) { try { cookiesToSet.addAll(HttpCookie.parse(setCookieHeader.getValue())); } catch (Exception e) { if (LOG.isDebugEnabled()) LOG.debug("Set-Cookie header: \" " + setCookieHeader.getValue() + " \" is malformed "); } } if (cookiesToSet.isEmpty()) return; redirectCookies.addAll(cookiesToSet); ArrayList<String> cookieNames = new ArrayList<>(); for (HttpCookie cookie : cookiesToSet) { cookieNames.add(cookie.getName()); } Header cookieHeader = method.getRequestHeader(HttpHeader.COOKIE); if (cookieHeader != null) { HeaderElement[] cookieElements = cookieHeader.getElements(); for (HeaderElement cookieElement : cookieElements) { String cookieName = cookieElement.getName(); if (!cookieNames.contains(cookieName)) cookiesToSet.add(new HttpCookie(cookieName, cookieElement.getValue())); } } String cookieHeaderValue = ""; for (HttpCookie cookie : cookiesToSet) { cookieHeaderValue += cookie.toString() + "; "; } if (cookieHeaderValue.length() > 2) { cookieHeaderValue = cookieHeaderValue.substring(0, cookieHeaderValue.length() - 2); method.setRequestHeader(HttpHeader.COOKIE, cookieHeaderValue); } }
Source:
<code>public void testTocProvider() { JavaDocTocProvider provider = new JavaDocTocProvider(); ITocContribution[] contributions = provider .getTocContributions("en_US"); assertTrue(contributions.length > 0); <START> assertTrue(contributions.length == 1); <END> ITocContribution con = contributions[0]; assertEquals(con.getId(), "org.eclipse.linuxtools.javadocs.toc"); assertTrue(con.isPrimary()); assertEquals(con.getCategoryId(), null); assertEquals(con.getLocale(), "en_US"); String[] docs = con.getExtraDocuments(); assertEquals(docs.length, 0); assertTrue(con.getLinkTo().equals("org.eclipse.linuxtools.javadocs/")); assertEquals(con.getContributorId(), "org.eclipse.linuxtools.javadocs"); }</code><technical_language>This condition implies previous</technical_language>

Target:
public void testTocProvider() { JavaDocTocProvider provider = new JavaDocTocProvider(); ITocContribution[] contributions = provider .getTocContributions("en_US"); assertTrue(contributions.length == 1); ITocContribution con = contributions[0]; assertEquals(con.getId(), "org.eclipse.linuxtools.javadocs.toc"); assertTrue(con.isPrimary()); assertEquals(con.getCategoryId(), null); assertEquals(con.getLocale(), "en_US"); String[] docs = con.getExtraDocuments(); assertEquals(docs.length, 0); assertTrue(con.getLinkTo().equals("org.eclipse.linuxtools.javadocs/")); assertEquals(con.getContributorId(), "org.eclipse.linuxtools.javadocs"); }
Source:
<code>void completePlayerSetup(boolean asked) { if (asked) { skinLayout = (OoyalaSkinLayout) findViewById(R.id.ooyalaSkin); PlayerDomain playerDomain = new PlayerDomain(domain); Options.Builder optionBuilder = new Options.Builder().setShowNativeLearnMoreButton(false).setShowPromoImage(false).setUseExoPlayer(true); <START> if(!selectedFormat.equalsIgnoreCase("default")) <END> optionBuilder.setPlayerInfo(new CustomPlayerInfo(selectedFormat)); if(hevcMode.equalsIgnoreCase("HEVCPreferred")) optionBuilder.enableHevc(true); else if(hevcMode.equalsIgnoreCase("HEVCNotPreferred")) optionBuilder.enableHevc(false); Options options = optionBuilder.build(); player = new OoyalaPlayer(pcode, playerDomain, options); if(isStaging) { Log.i(TAG, "Environment Set to Staging:"); OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING, Environment.PROTOCOL_HTTPS); } SkinOptions skinOptions = new SkinOptions.Builder().build(); playerLayoutController = new OoyalaSkinLayoutController(getApplication(), skinLayout, player, skinOptions); playerLayoutController.addObserver(this); player.addObserver(this); @SuppressWarnings("unused") OoyalaFreewheelManager fwManager = new OoyalaFreewheelManager(this, skinLayout.getAdView(), player); if (player.setEmbedCode(embedCode)) { if(autoPlay) player.play(); } } }</code><technical_language>add curly braces</technical_language>

Target:
void completePlayerSetup(boolean asked) { if (asked) { skinLayout = (OoyalaSkinLayout) findViewById(R.id.ooyalaSkin); PlayerDomain playerDomain = new PlayerDomain(domain); player = new OoyalaPlayer(pcode, playerDomain, getOptions()); if(isStaging) { Log.i(TAG, "Environment Set to Staging:"); OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING, Environment.PROTOCOL_HTTPS); } else { OoyalaPlayer.setEnvironment(Environment.EnvironmentType.PRODUCTION, Environment.PROTOCOL_HTTPS); } SkinOptions skinOptions = new SkinOptions.Builder().build(); playerLayoutController = new OoyalaSkinLayoutController(getApplication(), skinLayout, player, skinOptions); playerLayoutController.addObserver(this); player.addObserver(this); @SuppressWarnings("unused") OoyalaFreewheelManager fwManager = new OoyalaFreewheelManager(this, skinLayout.getAdView(), player); if (player.setEmbedCode(embedCode)) { if(autoPlay) { player.play(); } } } }
Source:
<code>protected void onDraw(Canvas canvas) { if (mBounds == null) { return; } int width = mBounds.width(); int height = mBounds.height(); if (width == 0 || height == 0) { return; } if (!mCacheValid || width != mCachedWidth || height != mCachedHeight) { if (width == mCachedWidth && height == mCachedHeight) { mCacheBitmap.eraseColor(0); } else { mCacheBitmap.recycle(); mCacheBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); mCachedWidth = width; mCachedHeight = height; } Canvas cacheCanvas = new Canvas(mCacheBitmap); if (mMaskDrawable != null) { int sc = cacheCanvas.save(); mMaskDrawable.draw(cacheCanvas); mMaskedPaint.setColorFilter((mDesaturateOnPress && isPressed()) ? mDesaturateColorFilter : null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cacheCanvas.saveLayer(mBoundsF, mMaskedPaint); } else { <START> cacheCanvas.saveLayer(mBoundsF, mMaskedPaint, Canvas.ALL_SAVE_FLAG); <END> } super.onDraw(cacheCanvas); cacheCanvas.restoreToCount(sc); } else if (mDesaturateOnPress && isPressed()) { int sc = cacheCanvas.save(); cacheCanvas.drawRect(0, 0, mCachedWidth, mCachedHeight, mBlackPaint); mMaskedPaint.setColorFilter(mDesaturateColorFilter); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cacheCanvas.saveLayer(mBoundsF, mMaskedPaint); } else { cacheCanvas.saveLayer(mBoundsF, mMaskedPaint, Canvas.ALL_SAVE_FLAG); } super.onDraw(cacheCanvas); cacheCanvas.restoreToCount(sc); } else { super.onDraw(cacheCanvas); } if (mBorderDrawable != null) { mBorderDrawable.draw(cacheCanvas); } } canvas.drawBitmap(mCacheBitmap, mBounds.left, mBounds.top, null); }</code><technical_language>right side of expression present</technical_language>

Target:
protected void onDraw(Canvas canvas) { if (mBounds == null) { return; } int width = mBounds.width(); int height = mBounds.height(); if (width == 0 || height == 0) { return; } if (!mCacheValid || width != mCachedWidth || height != mCachedHeight) { if (width == mCachedWidth && height == mCachedHeight) { mCacheBitmap.eraseColor(0); } else { mCacheBitmap.recycle(); mCacheBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); mCachedWidth = width; mCachedHeight = height; } Canvas cacheCanvas = new Canvas(mCacheBitmap); if (mMaskDrawable != null) { int sc = cacheCanvas.save(); mMaskDrawable.draw(cacheCanvas); mMaskedPaint.setColorFilter((mDesaturateOnPress && isPressed()) ? mDesaturateColorFilter : null); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { saveLayer(cacheCanvas); } else { saveLayerCompat(cacheCanvas); } super.onDraw(cacheCanvas); cacheCanvas.restoreToCount(sc); } else if (mDesaturateOnPress && isPressed()) { int sc = cacheCanvas.save(); cacheCanvas.drawRect(0, 0, mCachedWidth, mCachedHeight, mBlackPaint); mMaskedPaint.setColorFilter(mDesaturateColorFilter); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { saveLayer(cacheCanvas); } else { saveLayerCompat(cacheCanvas); } super.onDraw(cacheCanvas); cacheCanvas.restoreToCount(sc); } else { super.onDraw(cacheCanvas); } if (mBorderDrawable != null) { mBorderDrawable.draw(cacheCanvas); } } canvas.drawBitmap(mCacheBitmap, mBounds.left, mBounds.top, null); }
Source:
<code>protected String getSubsystemXsdPath() throws Exception { <START> return "schema/jboss-as-wise_1_0.xsd"; <END> }</code><technical_language>schema named wildfly-wise-...</technical_language>

Target:
protected String getSubsystemXsdPath() throws Exception { return "schema/wildfly-wise_1_0.xsd"; }
Source:
<code>public static Map<Integer, ? extends Collection<Tile>> readLaneTiles(final File illuminaRunDirectory, final ReadStructure readStructure, final ValidationStringency validationStringency, final boolean isNovaSeq) { final Collection<Tile> tiles; try { List<File> tileMetricsOutFiles = TileMetricsUtil.findTileMetricsFiles(illuminaRunDirectory, readStructure.totalCycles, isNovaSeq); if (isNovaSeq) { tiles = TileMetricsUtil.parseClusterRecordsFromTileMetricsV3( tileMetricsOutFiles, TileMetricsUtil.renderPhasingMetricsFilesFromBasecallingDirectory(illuminaRunDirectory), readStructure ); } else { <START> tiles = TileMetricsUtil.parseTileMetrics(tileMetricsOutFiles.get(0), <END> readStructure, validationStringency ); } } catch (final FileNotFoundException e) { throw new PicardException("Unable to open laneMetrics file.", e); } return tiles.stream().filter(tile -> tile.getLaneNumber() > 0).collect(Collectors.groupingBy(Tile::getLaneNumber)); }</code><technical_language>Nitpick: push tileMetricsOutFiles.get(0) next line, match formatting of call in if branch</technical_language>

Target:
public static Map<Integer, ? extends Collection<Tile>> readLaneTiles(final File illuminaRunDirectory, final ReadStructure readStructure, final ValidationStringency validationStringency, final boolean isNovaSeq) { final Collection<Tile> tiles; try { final List<File> tileMetricsOutFiles = TileMetricsUtil.findTileMetricsFiles(illuminaRunDirectory, readStructure.totalCycles, isNovaSeq); if (isNovaSeq) { tiles = TileMetricsUtil.parseClusterRecordsFromTileMetricsV3( tileMetricsOutFiles, TileMetricsUtil.renderPhasingMetricsFilesFromBasecallingDirectory(illuminaRunDirectory), readStructure ); } else { tiles = TileMetricsUtil.parseTileMetrics( tileMetricsOutFiles.get(0), readStructure, validationStringency ); } } catch (final FileNotFoundException e) { throw new PicardException("Unable to open laneMetrics file.", e); } return tiles.stream().filter(tile -> tile.getLaneNumber() > 0).collect(Collectors.groupingBy(Tile::getLaneNumber)); }
Source:
<code>void updateRenderEntireFile() { for (CodeMirror cm : getCms()) { <START> cm.removeKeyMap(RENDER_ENTIRE_FILE_KEYMAP); cm.removeKeyMap(RENDER_ENTIRE_FILE_KEYMAP); <END> if (prefs.renderEntireFile()) { cm.addKeyMap(RENDER_ENTIRE_FILE_KEYMAP); } cm.setOption("viewportMargin", prefs.renderEntireFile() ? POSITIVE_INFINITY : 10); } }</code><technical_language>code was: void updateRenderEntireFile() { cmA.removeKeyMap(RENDER_ENTIRE_FILE_KEYMAP); cmB.removeKeyMap(RENDER_ENTIRE_FILE_KEYMAP); Now, iterating A B in a loop, removeKeyMap enough</technical_language>

Target:
void updateRenderEntireFile() { boolean entireFile = renderEntireFile(); for (CodeMirror cm : getCms()) { cm.removeKeyMap(RENDER_ENTIRE_FILE_KEYMAP); if (entireFile) { cm.addKeyMap(RENDER_ENTIRE_FILE_KEYMAP); } cm.setOption("viewportMargin", entireFile ? POSITIVE_INFINITY : 10); } }
Source:
<code>static void containsSubset(@NonNull JSONObject subject, @NonNull JSONObject contains) throws JSONException { Iterator<String> iterator = contains.keys(); while (iterator.hasNext()) { String key = iterator.next(); if (contains.get(key) instanceof JSONObject && subject.get(key) instanceof JSONObject) <START> equals((JSONObject) contains.get(key), (JSONObject) subject.get(key)); <END> else assertEquals( normalizeType(contains.get(key)), normalizeType(subject.get(key)) ); } }</code><technical_language>getJSONObject instead of get remove type cast here</technical_language>

Target:
static void containsSubset(@NonNull JSONObject subject, @NonNull JSONObject contains) throws JSONException { Iterator<String> iterator = contains.keys(); while (iterator.hasNext()) { String key = iterator.next(); if (contains.get(key) instanceof JSONObject && subject.get(key) instanceof JSONObject) equals(contains.getJSONObject(key), subject.getJSONObject(key)); else assertEquals( normalizeType(contains.get(key)), normalizeType(subject.get(key)) ); } }
Source:
<code>private String getValidity(X509Certificate certificate) { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); return new StringBuilder() <START> .append("Issued On: ").append(dateFormat.format(certificate.getNotBefore())).append('\n') <END> .append(EXPIRES_ON_PREFIX).append(dateFormat.format(certificate.getNotAfter())) .toString(); }</code><technical_language>move "Issued On: " a constant for sake of consistency (with EXPIRES_ON_PREFIX)</technical_language>

Target:
private String getValidity(X509Certificate certificate) { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); return new StringBuilder() .append(ISSUED_ON_PREFIX).append(dateFormat.format(certificate.getNotBefore())).append('\n') .append(EXPIRES_ON_PREFIX).append(dateFormat.format(certificate.getNotAfter())) .toString(); }