auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or canceled.", LogUtils.truncateMessageLines(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLines(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLines(request)), e); } } } mRequestObserver.onNext(request); }

Target:
public void send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or cancelled.", LogUtils.truncateMessageLineLength(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLineLength(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLineLength(request)), e); } } } mRequestObserver.onNext(request); }
Source:
public String apply(ProjectResource rsrc, Input input) throws AuthException, ResourceNotFoundException, BadRequestException, UnprocessableEntityException, IOException { if (!rsrc.getControl().isOwner()) { throw new AuthException("restricted to project owner"); } if (input == null || Strings.isNullOrEmpty(input.ref)) { throw new BadRequestException("ref required"); } String ref = input.ref; if (!ref.startsWith(Constants.R_REFS)) { ref = Constants.R_HEADS + ref; } Repository repo = null; try { repo = repoManager.openRepository(rsrc.getNameKey()); if (repo.getRef(ref) == null) { throw new UnprocessableEntityException(String.format( "Ref Not Found: %s", input.ref)); } if (!repo.getRef(Constants.HEAD).getTarget().getName().equals(ref)) { final RefUpdate u = repo.updateRef(Constants.HEAD, true); u.disableRefLog(); RefUpdate.Result res = u.link(ref); switch(res) { case NO_CHANGE: case RENAMED: case FORCED: break; default: throw new IOException("Setting HEAD failed with " + res); } } return ref; } catch (RepositoryNotFoundException e) { throw new ResourceNotFoundException(rsrc.getName()); } finally { if (repo != null) { repo.close(); } } }

Target:
public String apply(ProjectResource rsrc, Input input) throws AuthException, ResourceNotFoundException, BadRequestException, UnprocessableEntityException, IOException { if (!rsrc.getControl().isOwner()) { throw new AuthException("restricted to project owner"); } if (input == null || Strings.isNullOrEmpty(input.ref)) { throw new BadRequestException("ref required"); } String ref = input.ref; if (!ref.startsWith(Constants.R_REFS)) { ref = Constants.R_HEADS + ref; } Repository repo = null; try { repo = repoManager.openRepository(rsrc.getNameKey()); if (repo.getRef(ref) == null) { throw new UnprocessableEntityException(String.format( "Ref Not Found: %s", ref)); } if (!repo.getRef(Constants.HEAD).getTarget().getName().equals(ref)) { final RefUpdate u = repo.updateRef(Constants.HEAD, true); u.setRefLogIdent(identifiedUser.newRefLogIdent()); RefUpdate.Result res = u.link(ref); switch(res) { case NO_CHANGE: case RENAMED: case FORCED: case NEW: break; default: throw new IOException("Setting HEAD failed with " + res); } } return ref; } catch (RepositoryNotFoundException e) { throw new ResourceNotFoundException(rsrc.getName()); } finally { if (repo != null) { repo.close(); } } }
Source:
public FContext addEphemeralProperties(Map<Object, Object> properties) { for (Map.Entry<Object, Object> pair : properties.entrySet()) { ephemeralProperties.putAll(properties); } return this; }

Target:
public FContext addEphemeralProperties(Map<Object, Object> properties) { ephemeralProperties.putAll(properties); return this; }
Source:
public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { lifter.liftEmbargo(context, item); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item "+item.getHandle()); itemService.update(context, item); }

Target:
public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item "+item.getHandle()); itemService.update(context, item); }
Source:
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { BigDecimal finalResult = BigDecimal.ZERO; for(int i=0;i<children.size();i++) { if (!children.get(i).evaluate(tuple, ptr)) { return false; } if (ptr.getLength() == 0) { return true; } BigDecimal value; PDataType type = children.get(i).getDataType(); ColumnModifier columnModifier = children.get(i).getColumnModifier(); if(type == PDataType.TIMESTAMP) { Timestamp timestamp = (Timestamp)PDataType.TIMESTAMP.toObject(ptr, columnModifier); long millisPart = timestamp.getTime(); BigDecimal nanosPart = BigDecimal.valueOf((timestamp.getNanos() % QueryConstants.MILLIS_TO_NANOS_CONVERTOR)/QueryConstants.MILLIS_TO_NANOS_CONVERTOR); value = BigDecimal.valueOf(millisPart).add(nanosPart); } else if (type.isCoercibleTo(PDataType.DECIMAL)) { value = (((BigDecimal)PDataType.DECIMAL.toObject(ptr, columnModifier)).multiply(BD_MILLIS_IN_DAY)).setScale(6, RoundingMode.HALF_UP); } else if (type.isCoercibleTo(PDataType.DOUBLE)) { value = ((BigDecimal.valueOf(type.getCodec().decodeDouble(ptr, columnModifier))).multiply(BD_MILLIS_IN_DAY)).setScale(6, RoundingMode.HALF_UP); } else { value = BigDecimal.valueOf(type.getCodec().decodeLong(ptr, columnModifier)); } if (i == 0) { finalResult = value; } else { finalResult = finalResult.subtract(value); } } Timestamp ts = DateUtil.getTimestamp(finalResult.longValue(), ((finalResult.remainder(BigDecimal.ONE).multiply(BigDecimal.valueOf(QueryConstants.MILLIS_TO_NANOS_CONVERTOR))).intValue())); byte[] resultPtr = new byte[getDataType().getByteSize()]; PDataType.TIMESTAMP.toBytes(ts, resultPtr, 0); ptr.set(resultPtr); return true; }

Target:
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { BigDecimal finalResult = BigDecimal.ZERO; for(int i=0; i<children.size(); i++) { if (!children.get(i).evaluate(tuple, ptr)) { return false; } if (ptr.getLength() == 0) { return true; } BigDecimal value; PDataType type = children.get(i).getDataType(); ColumnModifier columnModifier = children.get(i).getColumnModifier(); if(type == PDataType.TIMESTAMP) { value = (BigDecimal)(PDataType.DECIMAL.toObject(ptr, PDataType.TIMESTAMP, columnModifier)); } else if (type.isCoercibleTo(PDataType.DECIMAL)) { value = (((BigDecimal)PDataType.DECIMAL.toObject(ptr, columnModifier)).multiply(BD_MILLIS_IN_DAY)).setScale(6, RoundingMode.HALF_UP); } else if (type.isCoercibleTo(PDataType.DOUBLE)) { value = ((BigDecimal.valueOf(type.getCodec().decodeDouble(ptr, columnModifier))).multiply(BD_MILLIS_IN_DAY)).setScale(6, RoundingMode.HALF_UP); } else { value = BigDecimal.valueOf(type.getCodec().decodeLong(ptr, columnModifier)); } if (i == 0) { finalResult = value; } else { finalResult = finalResult.subtract(value); } } Timestamp ts = DateUtil.getTimestamp(finalResult); byte[] resultPtr = new byte[getDataType().getByteSize()]; PDataType.TIMESTAMP.toBytes(ts, resultPtr, 0); ptr.set(resultPtr); return true; }
Source:
private static void handleExecStartConnectionReset(RuntimeException exception) { Throwable rootCause = Throwables.getRootCause(exception.getCause()); if (rootCause instanceof IOException && rootCause.getMessage().equals("Connection reset by peer")) { log.warn("Failed to read the output of exec start", exception); } else { throw exception; } }

Target:
private static void handleExecStartConnectionReset(RuntimeException exception) { Throwable rootCause = Throwables.getRootCause(exception); if (rootCause instanceof IOException && "Connection reset by peer".equals(rootCause.getMessage())) { log.warn("Failed to read the output of exec start", exception); } else { throw exception; } }
Source:
private AccountInfo adaptAccountInfo(CommitInfo commitInfo, IProgressMonitor monitor) throws GerritException { String accountId = commitInfo.getAuthor().getEmail(); for (int retries = 0;; retries++) { try { return retrieveAccountInfo(accountId, monitor); } catch (GerritException e) { if (retries < 3) { accountId = commitInfo.getAuthor().getName(); continue; } } } }

Target:
private AccountInfo adaptAccountInfo(CommitInfo commitInfo, IProgressMonitor monitor) throws GerritException { String accountId = commitInfo.getAuthor().getEmail(); for (int retries = 0;; retries++) { try { return retrieveAccountInfo(accountId, monitor); } catch (GerritException e) { if (retries < 3) { accountId = commitInfo.getAuthor().getName(); continue; } else { throw e; } } } }
Source:
public boolean isCompatibleWith(DockerImageName other) { final boolean thisRegistrySame = other.registry.equals(this.registry); final boolean thisRepoSame = other.repo.equals(this.repo); final boolean thisVersioningNotSpecifiedOrSame = other.versioning == null || other.versioning.equals(Versioning.TagVersioning.LATEST) || other.versioning.equals(this.versioning); if (thisRegistrySame && thisRepoSame && thisVersioningNotSpecifiedOrSame) { return true; } if (this.compatibleSubstituteFor == null) { return false; } return this.compatibleSubstituteFor.isCompatibleWith(other); }

Target:
public boolean isCompatibleWith(DockerImageName other) { if (other.equals(this)) { return true; } if (this.compatibleSubstituteFor == null) { return false; } return this.compatibleSubstituteFor.isCompatibleWith(other); }
Source:
public List<DetectedObject> getPredictedObjects(INDArray networkOutput, double threshold){ if(networkOutput.rank() != 4){ throw new IllegalStateException("Invalid network output activations array: should be rank 4. Got array " + "with shape " + Arrays.toString(networkOutput.shape())); } if(threshold < 0.0 || threshold > 1.0){ throw new IllegalStateException("Invalid threshold: must be in range [0,1]. Got: " + threshold); } int mb = networkOutput.size(0); int h = networkOutput.size(2); int w = networkOutput.size(3); int b = layerConf().getBoundingBoxes().size(0); int c = (networkOutput.size(1)/b)-5; INDArray output5 = networkOutput.dup('c').reshape(mb, b, 5+c, h, w); INDArray predictedConfidence = output5.get(all(), all(), point(4), all(), all()); INDArray softmax = output5.get(all(), all(), interval(5, 5+c), all(), all()); List<DetectedObject> out = new ArrayList<>(); for( int i=0; i<mb; i++ ){ for( int x=0; x<w; x++ ){ for( int y=0; y<h; y++ ){ for( int box=0; box<b; box++ ){ double conf = predictedConfidence.getDouble(i, box, y, x); if(conf < threshold){ continue; } double px = output5.getDouble(i, box, 0, y, x); double py = output5.getDouble(i, box, 1, y, x); double pw = output5.getDouble(i, box, 2, y, x); double ph = output5.getDouble(i, box, 3, y, x); px += x; py += y; INDArray sm; try (MemoryWorkspace wsO = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) { sm = softmax.get(point(i), point(box), all(), point(x), point(y)).dup(); } out.add(new DetectedObject(i, px, py, pw, ph, sm, conf)); } } } } return out; }

Target:
public List<DetectedObject> getPredictedObjects(INDArray networkOutput, double threshold){ if(networkOutput.rank() != 4){ throw new IllegalStateException("Invalid network output activations array: should be rank 4. Got array " + "with shape " + Arrays.toString(networkOutput.shape())); } if(threshold < 0.0 || threshold > 1.0){ throw new IllegalStateException("Invalid threshold: must be in range [0,1]. Got: " + threshold); } int mb = networkOutput.size(0); int h = networkOutput.size(2); int w = networkOutput.size(3); int b = layerConf().getBoundingBoxes().size(0); int c = (networkOutput.size(1)/b)-5; INDArray output5 = networkOutput.dup('c').reshape(mb, b, 5+c, h, w); INDArray predictedConfidence = output5.get(all(), all(), point(4), all(), all()); INDArray softmax = output5.get(all(), all(), interval(5, 5+c), all(), all()); List<DetectedObject> out = new ArrayList<>(); for( int i=0; i<mb; i++ ){ for( int x=0; x<w; x++ ){ for( int y=0; y<h; y++ ){ for( int box=0; box<b; box++ ){ double conf = predictedConfidence.getDouble(i, box, y, x); if(conf < threshold){ continue; } double px = output5.getDouble(i, box, 0, y, x); double py = output5.getDouble(i, box, 1, y, x); double pw = output5.getDouble(i, box, 2, y, x); double ph = output5.getDouble(i, box, 3, y, x); px += x; py += y; INDArray sm; try (MemoryWorkspace wsO = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) { sm = softmax.get(point(i), point(box), all(), point(y), point(x)).dup(); } out.add(new DetectedObject(i, px, py, pw, ph, sm, conf)); } } } } return out; }
Source:
private void displayParents(final List<PatchSetInfo.ParentInfo> parents) { if (parents.size() == 0) { infoTable.setWidget(R_PARENTS, 1, new InlineLabel(Util.C.initialCommit())); return; } final Grid parentsTable = new Grid(parents.size(), 2); parentsTable.setStyleName(Gerrit.RESOURCES.css().parentsTable()); parentsTable.addStyleName(Gerrit.RESOURCES.css().noborder()); final CellFormatter ptfmt = parentsTable.getCellFormatter(); int row = 0; for (PatchSetInfo.ParentInfo parent : parents) { parentsTable.setWidget(row, 0, new InlineLabel(parent.id.get())); ptfmt.addStyleName(row, 0, Gerrit.RESOURCES.css().noborder()); ptfmt.addStyleName(row, 0, Gerrit.RESOURCES.css().monospace()); String parentMsg = parent.shortMessage; if (parentMsg.length() > 80) { parentMsg = parentMsg.substring(0, 80) + "..."; } parentsTable.setWidget(row, 1, new InlineLabel(parentMsg)); ptfmt.addStyleName(row, 1, Gerrit.RESOURCES.css().noborder()); row++; } infoTable.setWidget(R_PARENTS, 1, parentsTable); }

Target:
private void displayParents(final List<PatchSetInfo.ParentInfo> parents) { if (parents.size() == 0) { infoTable.setWidget(R_PARENTS, 1, new InlineLabel(Util.C.initialCommit())); return; } final Grid parentsTable = new Grid(parents.size(), 2); parentsTable.setStyleName(Gerrit.RESOURCES.css().parentsTable()); parentsTable.addStyleName(Gerrit.RESOURCES.css().noborder()); final CellFormatter ptfmt = parentsTable.getCellFormatter(); int row = 0; for (PatchSetInfo.ParentInfo parent : parents) { parentsTable.setWidget(row, 0, new InlineLabel(parent.id.get())); ptfmt.addStyleName(row, 0, Gerrit.RESOURCES.css().noborder()); ptfmt.addStyleName(row, 0, Gerrit.RESOURCES.css().monospace()); String parentMsg = parent.shortMessage; if (parentMsg.length() > 80) { parentMsg = parentMsg.substring(0, 77) + "..."; } parentsTable.setWidget(row, 1, new InlineLabel(parentMsg)); ptfmt.addStyleName(row, 1, Gerrit.RESOURCES.css().noborder()); row++; } infoTable.setWidget(R_PARENTS, 1, parentsTable); }
Source:
private void validate() { if (shortIndex.equals(longIndex)) { throw new IllegalArgumentException("Interpolation requires two different indices"); } }

Target:
private void validate() { if (!shortIndex.getCurrency().equals(longIndex.getCurrency())) { throw new IllegalArgumentException("Interpolation requires two indices in the same currency"); } if (shortIndex.equals(longIndex)) { throw new IllegalArgumentException("Interpolation requires two different indices"); } if (fixingDate.plus(shortIndex.getTenor()).isAfter(fixingDate.plus(longIndex.getTenor()))) { throw new IllegalArgumentException( Messages.format("Interpolation indices passed in wrong order: {}", shortIndex, longIndex)); } }
Source:
private void includeSingleTag(PostDiscoveryFilter filter) { assertTrue(filter.apply(classWithTag1).included()); assertTrue(filter.apply(classWithTag1AndSurroundingWhitespace).included()); assertTrue(filter.apply(classWithBothTags).included()); assertThat(filter.apply(classWithTag1).getReason().get()).contains( "Test included Because it contains tags: [tag1]"); assertThat(filter.apply(classWithTag1AndSurroundingWhitespace).getReason().get()).contains( "Test included Because it contains tags: [tag1]"); assertThat(filter.apply(classWithBothTags).getReason().get()).contains( "Test included Because it contains tags: [tag1,tag2]"); assertTrue(filter.apply(classWithTag2).excluded()); assertTrue(filter.apply(classWithDifferentTags).excluded()); assertTrue(filter.apply(classWithNoTags).excluded()); assertThat(filter.apply(classWithTag2).getReason().get()).contains( "Test excluded Because it contains tags: [tag2]"); assertThat(filter.apply(classWithDifferentTags).getReason().get()).contains( "Test excluded Because it contains tags: [foo,bar]"); assertThat(filter.apply(classWithNoTags).getReason().get()).contains( "Test excluded Because it contains tags: []"); }

Target:
private void includeSingleTag(PostDiscoveryFilter filter) { assertTrue(filter.apply(classWithTag1).included()); assertTrue(filter.apply(classWithTag1AndSurroundingWhitespace).included()); assertTrue(filter.apply(classWithBothTags).included()); assertReason(filter.apply(classWithTag1), "included because tags match expression(s): [tag1]"); assertReason(filter.apply(classWithTag1AndSurroundingWhitespace), "included because tags match expression(s): [tag1]"); assertReason(filter.apply(classWithBothTags), "included because tags match expression(s): [tag1]"); assertTrue(filter.apply(classWithTag2).excluded()); assertTrue(filter.apply(classWithDifferentTags).excluded()); assertTrue(filter.apply(classWithNoTags).excluded()); assertReason(filter.apply(classWithTag2), "excluded because tags do not match tag expression(s): [tag1]"); assertReason(filter.apply(classWithDifferentTags), "excluded because tags do not match tag expression(s): [tag1]"); assertReason(filter.apply(classWithNoTags), "excluded because tags do not match tag expression(s): [tag1]"); }
Source:
public void changeDiscoveryMode(){ validationProvider = new QualifierValidationProviderCDI11(); prepareBeanXml("all", true); }

Target:
public void changeDiscoveryMode(){ validationProvider = new QualifierValidationProvider("JSR-365"); prepareBeanXml("all", true); }
Source:
public void testRemoveProject() throws ProjectManagerException { System.out.println("projectManagerTest: testRemoveProject"); ProjectManager manager = createProjectManager(); String projectName = "myTestRemoveProject"; String projectDescription = "This is to test removing a project"; User user = new User("testUser"); Project project = createProjectUtil(manager, projectName, projectDescription, user); manager.removeProject(project, user); Project fetchedProject = manager.getProject(project.getId()); Assert.assertFalse(fetchedProject.isActive()); System.out.println("Removed project successfully"); }

Target:
public void testRemoveProject() throws Exception { System.out.println("TestRemoveProject"); Project project = manager.createProject(PROJECT_NAME, PROJECT_DESCRIPTION, user); manager.removeProject(project, user); verify(loader).removeProject(project, user.getUserId()); verify(loader).postEvent(project, ProjectLogEvent.EventType.DELETED, user.getUserId(), null); Project fetchedProject = manager.getProject(project.getId()); verify(loader).fetchProjectById(project.getId()); verify(loader).fetchAllProjectFlows(project); Assert.assertFalse(fetchedProject.isActive()); }
Source:
public void testRequestorUid() { final NetworkCapabilities nc = new NetworkCapabilities(); assertEquals(Process.INVALID_UID, new NetworkRequest.Builder() .setCapabilities(nc).build().getRequestorUid()); nc.setRequestorUid(1314); final NetworkRequest nr = new NetworkRequest.Builder().setCapabilities(nc).build(); assertNotEquals(2628, nr.getRequestorUid()); assertEquals(1314, nr.getRequestorUid()); }

Target:
public void testRequestorUid() { final NetworkCapabilities nc = new NetworkCapabilities(); assertEquals(Process.INVALID_UID, new NetworkRequest.Builder() .setCapabilities(nc).build().getRequestorUid()); nc.setRequestorUid(1314); final NetworkRequest nr = new NetworkRequest.Builder().setCapabilities(nc).build(); assertEquals(1314, nr.getRequestorUid()); assertEquals(Process.INVALID_UID, new NetworkRequest.Builder() .clearCapabilities().build().getRequestorUid()); }
Source:
@Test void testSignFunc() { tester.setFor( SqlStdOperatorTable.SIGN); tester.checkType("sign(1)", "INTEGER NOT NULL"); tester.checkType("sign(cast(1 as float))", "FLOAT NOT NULL"); tester.checkType( "sign(case when false then 1 else null end)", "INTEGER"); strictTester.checkFails( "^sign('abc')^", "Cannot apply 'SIGN' to arguments of type 'SIGN\\(<CHAR\\(3\\)>\\)'\\. Supported form\\(s\\): 'SIGN\\(<NUMERIC>\\)'", false); tester.checkType("sign('abc')", "DECIMAL(19, 0) NOT NULL"); tester.checkScalar( "sign(1)", 1, "INTEGER NOT NULL"); tester.checkScalar( "sign(cast(-1 as decimal(1, 0)))", BigDecimal.valueOf(-1), "DECIMAL(1, 0) NOT NULL"); tester.checkScalar( "sign(cast(0 as float))", 0d, "FLOAT NOT NULL"); tester.checkNull("sign(cast(null as integer))"); tester.checkNull("sign(cast(null as double))"); tester.checkType("sign(cast(.1 as decimal))", "DECIMAL(19, 0) NOT NULL"); }

Target:
@Test void testSignFunc() { tester.setFor( SqlStdOperatorTable.SIGN); tester.checkType("sign(1)", "INTEGER NOT NULL"); tester.checkType("sign(cast(1 as float))", "FLOAT NOT NULL"); tester.checkType( "sign(case when false then 1 else null end)", "INTEGER"); strictTester.checkFails( "^sign('abc')^", "Cannot apply 'SIGN' to arguments of type 'SIGN\\(<CHAR\\(3\\)>\\)'\\. Supported form\\(s\\): 'SIGN\\(<NUMERIC>\\)'", false); tester.checkType("sign('abc')", "DECIMAL(19, 0) NOT NULL"); tester.checkScalar( "sign(1)", 1, "INTEGER NOT NULL"); tester.checkScalar( "sign(cast(-1 as decimal(1, 0)))", BigDecimal.valueOf(-1), "DECIMAL(1, 0) NOT NULL"); tester.checkScalar( "sign(cast(0 as float))", 0d, "FLOAT NOT NULL"); tester.checkNull("sign(cast(null as integer))"); tester.checkNull("sign(cast(null as double))"); tester.checkType("sign(cast(0.1 as float))", "FLOAT NOT NULL"); tester.checkType("sign(cast(.1 as decimal))", "DECIMAL(19, 0) NOT NULL"); tester.checkScalar( "sign(0.1)", 1, "DECIMAL(2, 0) NOT NULL"); tester.checkScalar( "sign(cast(-0.1 as decimal(2, 0)))", BigDecimal.valueOf(-1), "DECIMAL(2, 0) NOT NULL"); tester.checkScalar( "sign(cast(-.1 as decimal(1, 0)))", BigDecimal.valueOf(-1), "DECIMAL(1, 0) NOT NULL"); tester.checkScalar( "sign(cast(0.1 as float))", 1d, "FLOAT NOT NULL"); }
Source:
public MessageKey(long sequenceId, long producerTimestamp, int producerPid) { this.sequenceId = sequenceId; this.producerId = producerId(producerTimestamp, producerPid); this.routingHash = this.hashCode(); }

Target:
public MessageKey(long sequenceId, long producerTimestamp, int producerPid) { this.sequenceId = sequenceId; this.producerTimestamp = producerTimestamp; this.producerId = producerId(producerTimestamp, producerPid); this.routingHash = this.hashCode(); }
Source:
public void testIgniteSsl() throws Exception { System.setProperty("zookeeper.clientCnxnSocket", "org.apache.zookeeper.ClientCnxnSocketNetty"); IgniteEx ignite = startGrids(2); assertEquals(2, ignite.cluster().topologyVersion()); }

Target:
public void testIgniteSsl() throws Exception { IgniteEx ignite = startGrids(2); assertEquals(2, ignite.cluster().topologyVersion()); }
Source:
public void onScrollChanged(int oldScrollY, int scrollY, boolean isHumanScroll) { if (getVisibility() == View.GONE) { return; } int contentHeight = (int)(webView.getContentHeight() * DimenUtil.getDensityScalar()); int bottomOffset = contentHeight - scrollY - webView.getHeight(); int bottomHeight = getHeight(); if (bottomOffset > bottomHeight) { setTranslationY(bottomHeight); if (getVisibility() != View.INVISIBLE) { setVisibility(View.INVISIBLE); } } else { setTranslationY(bottomOffset); this.postDelayed(() -> { if (getVisibility() != View.VISIBLE) { setVisibility(View.VISIBLE); } }, HALF_SEC_DELAY); if (!firstTimeShown && readMoreItems != null) { firstTimeShown = true; funnel.logSuggestionsShown(page.getTitle(), readMoreItems.getResults()); } } }

Target:
public void onScrollChanged(int oldScrollY, int scrollY, boolean isHumanScroll) { if (getVisibility() == View.GONE) { return; } int contentHeight = (int)(webView.getContentHeight() * DimenUtil.getDensityScalar()); int bottomOffset = contentHeight - scrollY - webView.getHeight(); int bottomHeight = getHeight(); if (bottomOffset > bottomHeight) { setTranslationY(bottomHeight); if (getVisibility() != View.INVISIBLE) { setVisibility(View.INVISIBLE); } } else { setTranslationY(bottomOffset); this.postDelayed(() -> { if (getVisibility() != View.VISIBLE) { setVisibility(View.VISIBLE); } }, QUARTER_SEC_DELAY); if (!firstTimeShown && readMoreItems != null) { firstTimeShown = true; funnel.logSuggestionsShown(page.getTitle(), readMoreItems.getResults()); } } }
Source:
public String newProject() { this.myProjekt = new Project(); this.myProjekt.setClient(serviceManager.getUserService().getSessionClientOfAuthenticatedUser()); return projectEditPath; }

Target:
public String newProject() { this.project = new Project(); this.project.setClient(serviceManager.getUserService().getSessionClientOfAuthenticatedUser()); return projectEditPath; }
Source:
private static Geometry createBufferedCircleFromPoint( Measure<Double, Length> distance, CoordinateReferenceSystem origCRS, Geometry point) { Geometry pointGeo = point; MathTransform toTransform, fromTransform = null; Unit<Length> unit = distance.getUnit(); if (!(origCRS instanceof ProjectedCRS)) { double x = point.getCoordinate().x; double y = point.getCoordinate().y; String crsCode = "AUTO:42001," + x + "," + y; CoordinateReferenceSystem utmCrs; try { utmCrs = CRS.decode(crsCode); toTransform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, utmCrs); fromTransform = CRS.findMathTransform(utmCrs, DefaultGeographicCRS.WGS84); pointGeo = JTS.transform(point, toTransform); return JTS.transform(pointGeo.buffer(distance.doubleValue(SI.METER)), fromTransform); } catch (MismatchedDimensionException | TransformException | FactoryException e) { LOGGER.debug("Unable to transform original CRS to UTM.", e); } } else { unit = (Unit<Length>) origCRS.getCoordinateSystem().getAxis(0).getUnit(); } return pointGeo.buffer(distance.doubleValue(unit)); }

Target:
private static Geometry createBufferedCircleFromPoint( Measure<Double, Length> distance, CoordinateReferenceSystem origCRS, Geometry point) { Geometry pointGeo = point; Unit<Length> unit = distance.getUnit(); if (!(origCRS instanceof ProjectedCRS)) { double x = point.getCoordinate().x; double y = point.getCoordinate().y; String crsCode = "AUTO:42001," + x + "," + y; try { CoordinateReferenceSystem utmCrs = CRS.decode(crsCode); MathTransform toTransform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, utmCrs); MathTransform fromTransform = CRS.findMathTransform(utmCrs, DefaultGeographicCRS.WGS84); pointGeo = JTS.transform(point, toTransform); return JTS.transform(pointGeo.buffer(distance.doubleValue(SI.METER)), fromTransform); } catch (MismatchedDimensionException | TransformException | FactoryException e) { LOGGER.debug("Unable to create buffered circle from point.", e); } } else { unit = (Unit<Length>) origCRS.getCoordinateSystem().getAxis(0).getUnit(); } return pointGeo.buffer(distance.doubleValue(unit)); }
Source:
public void onStatusUpdate(QpidStatus oldStatus, QpidStatus newStatus) { if (newStatus.equals(oldStatus)) { log.debug("Status has not changed."); return; } log.debug("EventSource was notified of a QpidStatus change: {}", newStatus); for (EventReceiver receiver : this.eventReceivers) { if (!receiver.requiresQpid()) { continue; } if (QpidStatus.FLOW_STOPPED.equals(newStatus) || QpidStatus.DOWN.equals(newStatus)) { log.debug("Stopping session for EventReciever."); receiver.stopSession(); } else if (QpidStatus.CONNECTED.equals(newStatus)) { log.debug("Starting session for EventReciever."); receiver.startSession(); } } }

Target:
public void onStatusUpdate(QpidStatus oldStatus, QpidStatus newStatus) { if (newStatus.equals(oldStatus)) { log.debug("Status has not changed."); return; } log.debug("EventSource was notified of a QpidStatus change: {}", newStatus); for (MessageReceiver receiver : this.messageReceivers) { if (!receiver.requiresQpid()) { continue; } if (QpidStatus.FLOW_STOPPED.equals(newStatus) || QpidStatus.DOWN.equals(newStatus)) { log.debug("Stopping session for EventReciever."); receiver.stopSession(); } else if (QpidStatus.CONNECTED.equals(newStatus)) { log.debug("Starting session for EventReciever."); receiver.startSession(); } } }
Source:
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { if (getServletConfig() != null) { request.setAttribute(APPLICATION_TYPE, getServletConfig().getServletContext().getInitParameter(APPLICATION_TYPE)); } request.setAttribute(LOCALE_KEYS, LocaleFilter.getLocaleKeys()); String oVirtVersion = backend.RunPublicQuery(VdcQueryType.GetConfigurationValue, new GetConfigurationValueParameters(ConfigurationValues.ProductRPMVersion, ConfigCommon.defaultConfigurationVersion)).getReturnValue(); request.setAttribute(VERSION, oVirtVersion != null ? oVirtVersion : "myVersion"); request.setAttribute(SECTIONS, brandingManager .getWelcomeSections((Locale) request.getAttribute(LocaleFilter.LOCALE))); RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/ovirt-engine.jsp"); response.setContentType("text/html;charset=UTF-8"); if (dispatcher != null) { dispatcher.include(request, response); } }

Target:
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { request.setAttribute(LOCALE_KEYS, LocaleFilter.getLocaleKeys()); String oVirtVersion = backend.RunPublicQuery(VdcQueryType.GetConfigurationValue, new GetConfigurationValueParameters(ConfigurationValues.ProductRPMVersion, ConfigCommon.defaultConfigurationVersion)).getReturnValue(); request.setAttribute(VERSION, oVirtVersion != null ? oVirtVersion : "myVersion"); request.setAttribute(SECTIONS, brandingManager .getWelcomeSections((Locale) request.getAttribute(LocaleFilter.LOCALE))); RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/ovirt-engine.jsp"); response.setContentType("text/html;charset=UTF-8"); if (dispatcher != null) { dispatcher.include(request, response); } }
Source:
public void shouldArrayWithStreamReturnNotNull() { assertThat(array(charSeq('1', '2', '3').toJavaList().stream())).isNotNull(); }

Target:
public void shouldArrayWithStreamReturnNotNull() { assertThat(Array(Stream.of('1', '2', '3'))).isNotNull(); }
Source:
private void initiateCenterCreation(CenterPayload centerPayload) { if (isCenterNameValid()) { mCreateNewCenterPresenter.createCenter(centerPayload); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder .setMessage("Would you like to create another center?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { et_centerName.setText(""); cb_centerActiveStatus.setChecked(false); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { getFragmentManager().popBackStack(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }

Target:
private void initiateCenterCreation(CenterPayload centerPayload) { if (isCenterNameValid()) { mCreateNewCenterPresenter.createCenter(centerPayload); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity(), R.style.MaterialAlertDialogStyle); alertDialogBuilder .setMessage(getString(R.string.create_center_dialog)) .setPositiveButton(getString(R.string.action_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { etCenterName.setText(""); cbCenterActiveStatus.setChecked(false); } }) .setNegativeButton(getString(R.string.action_no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { getFragmentManager().popBackStack(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }
Source:
public static boolean isStaleStore( File storeDir, String offsetFileName, long storeDeleteRetentionInMs, long currentTimeMs) { boolean isStaleStore = false; String storePath = storeDir.toPath().toString(); if (storeDir.exists()) { File offsetFileRef = new File(storeDir, offsetFileName); long offsetFileLastModifiedTime = offsetFileRef.lastModified(); if ((currentTimeMs - offsetFileLastModifiedTime) >= storeDeleteRetentionInMs) { LOG.info( String.format("Store: %s is stale since lastModifiedTime of offset file: %d, is older than store deleteRetentionMs: %d.", storePath, offsetFileLastModifiedTime, storeDeleteRetentionInMs)); isStaleStore = true; } } else { LOG.info("Storage partition directory: does not exist.", storePath); LOG.info("{}", storePath, storePath); } return isStaleStore; }

Target:
public static boolean isStaleStore( File storeDir, String offsetFileName, long storeDeleteRetentionInMs, long currentTimeMs) { boolean isStaleStore = false; String storePath = storeDir.toPath().toString(); if (storeDir.exists()) { File offsetFileRef = new File(storeDir, offsetFileName); long offsetFileLastModifiedTime = offsetFileRef.lastModified(); if ((currentTimeMs - offsetFileLastModifiedTime) >= storeDeleteRetentionInMs) { LOG.info( String.format("Store: %s is stale since lastModifiedTime of offset file: %d, is older than store deleteRetentionMs: %d.", storePath, offsetFileLastModifiedTime, storeDeleteRetentionInMs)); isStaleStore = true; } } else { LOG.info("Storage partition directory: does not exist.", storePath); } return isStaleStore; }
Source:
public void close() { if (restClient != null) { try { LOGGER.info("Closing Rest Client"); restClient.close(); } catch (IOException e) { LOGGER.error("Could not close ElasticSearch Rest Client", e); } restClient = null; } }

Target:
public void close() { if (restClient != null) { try { LOGGER.info("Closing ElasticSearch connection"); restClient.close(); } catch (IOException e) { LOGGER.error("Could not close ElasticSearch connection", e); } restClient = null; } }
Source:
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { if (obj instanceof Number) { Number num = (Number) obj; double value = num.doubleValue() * fFactor; if (Double.isInfinite(value) || Double.isNaN(value)) { return toAppendTo.append(FORMAT.format(value)); } double abs = Math.abs(value); if (abs >= 1) { if (abs >= PETA) { return toAppendTo.append(FORMAT.format(value / PETA)).append(' ').append(PETA_PREFIX); } if (abs >= TERA) { return toAppendTo.append(FORMAT.format(value / TERA)).append(' ').append(TERA_PREFIX); } if (abs >= GIGA) { return toAppendTo.append(FORMAT.format(value / GIGA)).append(' ').append(GIGA_PREFIX); } if (abs >= MEGA) { return toAppendTo.append(FORMAT.format(value / MEGA)).append(' ').append(MEGA_PREFIX); } if (abs >= KILO) { return toAppendTo.append(FORMAT.format(value / KILO)).append(' ').append(KILO_PREFIX); } return toAppendTo.append(FORMAT.format(value)); } if (abs < PICO) { return toAppendTo.append(FORMAT.format(value)); } if (abs < NANO) { return toAppendTo.append(FORMAT.format(value * TERA)).append(' ').append(PICO_PREFIX); } if (abs < MICRO) { return toAppendTo.append(FORMAT.format(value * GIGA)).append(' ').append(NANO_PREFIX); } if (abs < MILLI) { return toAppendTo.append(FORMAT.format(value * MEGA)).append(' ').append(MICRO_PREFIX); } return toAppendTo.append(FORMAT.format(value * KILO)).append(' ').append(MILLI_PREFIX); } throw new IllegalArgumentException("Cannot format given Object as a Number: " + obj); }

Target:
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { if (obj instanceof Number) { Number num = (Number) obj; double value = num.doubleValue() * fFactor; double abs = Math.abs(value); if (Double.isInfinite(value) || Double.isNaN(value) || abs < PICO) { return toAppendTo.append(FORMAT.format(value)); } if (abs >= 1) { if (abs >= PETA) { return toAppendTo.append(FORMAT.format(value / PETA)).append(' ').append(PETA_PREFIX); } if (abs >= TERA) { return toAppendTo.append(FORMAT.format(value / TERA)).append(' ').append(TERA_PREFIX); } if (abs >= GIGA) { return toAppendTo.append(FORMAT.format(value / GIGA)).append(' ').append(GIGA_PREFIX); } if (abs >= MEGA) { return toAppendTo.append(FORMAT.format(value / MEGA)).append(' ').append(MEGA_PREFIX); } if (abs >= KILO) { return toAppendTo.append(FORMAT.format(value / KILO)).append(' ').append(KILO_PREFIX); } return toAppendTo.append(FORMAT.format(value)); } if (abs < NANO) { return toAppendTo.append(FORMAT.format(value * TERA)).append(' ').append(PICO_PREFIX); } if (abs < MICRO) { return toAppendTo.append(FORMAT.format(value * GIGA)).append(' ').append(NANO_PREFIX); } if (abs < MILLI) { return toAppendTo.append(FORMAT.format(value * MEGA)).append(' ').append(MICRO_PREFIX); } return toAppendTo.append(FORMAT.format(value * KILO)).append(' ').append(MILLI_PREFIX); } throw new IllegalArgumentException("Cannot format given Object as a Number: " + obj); }
Source:
public static DocVector createDocVector(String content, int ngram) { LuceneTokenizer tokenizer; if(ngram > 1){ LOG.info("Using Ngram Cosine Model, user specified ngram value : {}", ngram); tokenizer = new LuceneTokenizer(content, TokenizerType.STANDARD, StemFilterType.PORTERSTEM_FILTER, ngram); } else if(stopWords!=null) { tokenizer = new LuceneTokenizer(content, TokenizerType.STANDARD, stopWords, true, StemFilterType.PORTERSTEM_FILTER); } else { tokenizer = new LuceneTokenizer(content, TokenizerType.STANDARD, true, StemFilterType.PORTERSTEM_FILTER); } TokenStream tStream = tokenizer.getTokenStream(); HashMap<String, Integer> termVector = new HashMap<>(); try { CharTermAttribute charTermAttribute = tStream.addAttribute(CharTermAttribute.class); tStream.reset(); while(tStream.incrementToken()) { String term = charTermAttribute.toString(); LOG.info(term); if(termVector.containsKey(term)) { int count = termVector.get(term); count++; termVector.put(term, count); } else { termVector.put(term, 1); } } DocVector docVector = new DocVector(); docVector.setTermFreqVector(termVector); return docVector; } catch (IOException e) { LOG.error("Error creating DocVector : {}",StringUtils.stringifyException(e)); } return null; }

Target:
public static DocVector createDocVector(String content, int ngram) { LuceneTokenizer tokenizer; if(ngram > 1){ LOG.info("Using Ngram Cosine Model, user specified ngram value : {}", ngram); tokenizer = new LuceneTokenizer(content, TokenizerType.STANDARD, StemFilterType.PORTERSTEM_FILTER, ngram); } else if(stopWords!=null) { tokenizer = new LuceneTokenizer(content, TokenizerType.STANDARD, stopWords, true, StemFilterType.PORTERSTEM_FILTER); } else { tokenizer = new LuceneTokenizer(content, TokenizerType.STANDARD, true, StemFilterType.PORTERSTEM_FILTER); } TokenStream tStream = tokenizer.getTokenStream(); HashMap<String, Integer> termVector = new HashMap<>(); try { CharTermAttribute charTermAttribute = tStream.addAttribute(CharTermAttribute.class); tStream.reset(); while(tStream.incrementToken()) { String term = charTermAttribute.toString(); LOG.debug(term); if(termVector.containsKey(term)) { int count = termVector.get(term); count++; termVector.put(term, count); } else { termVector.put(term, 1); } } DocVector docVector = new DocVector(); docVector.setTermFreqVector(termVector); return docVector; } catch (IOException e) { LOG.error("Error creating DocVector : {}",StringUtils.stringifyException(e)); } return null; }
Source:
public void handle(ChannelHandlerContext ctx, FullHttpRequest request) { Tracker.getInstance().track(request); if ( !mediaTypeChecker.isAcceptValid(request.headers()) ) { DefaultHandler.sendResponse(ctx, request, String.format("Unsupported media type for Content-Type: %s", request.headers().get(HttpHeaders.Names.CONTENT_TYPE)), HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE ); return; } final String tenantId = request.headers().get("tenantId"); HttpResponseStatus status = HttpResponseStatus.OK; ObjectMapper objectMapper = new ObjectMapper(); String responseBody = null; final Timer.Context httpEventsFetchTimerContext = httpEventsFetchTimer.time(); try { HttpRequestWithDecodedQueryParams requestWithParams = (HttpRequestWithDecodedQueryParams) request; Map<String, List<String>> params = requestWithParams.getQueryParams(); if (params == null || params.size() == 0) { throw new InvalidDataException("Query should contain at least one query parameter"); } parseDateFieldInQuery(params, "from"); parseDateFieldInQuery(params, "until"); List<Map<String, Object>> searchResult = searchIO.search(tenantId, params); responseBody = objectMapper.writeValueAsString(searchResult); } catch (InvalidDataException e) { log.error(String.format("Exception %s", e.toString())); responseBody = String.format("Error: %s", e.getMessage()); status = HttpResponseStatus.BAD_REQUEST; } catch (Exception e) { log.error(String.format("Exception %s", e.toString())); responseBody = String.format("Error: %s", e.getMessage()); status = HttpResponseStatus.INTERNAL_SERVER_ERROR; } finally { DefaultHandler.sendResponse(ctx, request, responseBody, status, null); httpEventsFetchTimerContext.stop(); } }

Target:
public void handle(ChannelHandlerContext ctx, FullHttpRequest request) { Tracker.getInstance().track(request); final String tenantId = request.headers().get("tenantId"); HttpResponseStatus status = HttpResponseStatus.OK; ObjectMapper objectMapper = new ObjectMapper(); String responseBody = null; final Timer.Context httpEventsFetchTimerContext = httpEventsFetchTimer.time(); try { HttpRequestWithDecodedQueryParams requestWithParams = (HttpRequestWithDecodedQueryParams) request; Map<String, List<String>> params = requestWithParams.getQueryParams(); if (params == null || params.size() == 0) { throw new InvalidDataException("Query should contain at least one query parameter"); } parseDateFieldInQuery(params, "from"); parseDateFieldInQuery(params, "until"); List<Map<String, Object>> searchResult = searchIO.search(tenantId, params); responseBody = objectMapper.writeValueAsString(searchResult); } catch (InvalidDataException e) { log.error(String.format("Exception %s", e.toString())); responseBody = String.format("Error: %s", e.getMessage()); status = HttpResponseStatus.BAD_REQUEST; } catch (Exception e) { log.error(String.format("Exception %s", e.toString())); responseBody = String.format("Error: %s", e.getMessage()); status = HttpResponseStatus.INTERNAL_SERVER_ERROR; } finally { DefaultHandler.sendResponse(ctx, request, responseBody, status, null); httpEventsFetchTimerContext.stop(); } }
Source:
public void testSingleChildOfSpanWithOtherFollowsFromRefs() { TestTraceReporter reporter = new TestTraceReporter(); Tracer tracer = new APMTracer(reporter); Span refdSpan1 = tracer.buildSpan("ref1") .start(); refdSpan1.finish(); Span refdSpan2 = tracer.buildSpan("ref2") .start(); refdSpan2.finish(); Span parentSpan = tracer.buildSpan("parentSpan") .start(); Span span = tracer.buildSpan("SingleChildOfSpan") .addReference(References.FOLLOWS_FROM, refdSpan1.context()) .asChildOf(parentSpan) .addReference(References.FOLLOWS_FROM, refdSpan2.context()) .start(); span.finish(); parentSpan.finish(); assertEquals(3, reporter.getTraces().size()); Trace trace1 = reporter.getTraces().get(0); Trace trace2 = reporter.getTraces().get(1); Trace trace3 = reporter.getTraces().get(2); assertEquals(1, trace3.getNodes().size()); assertEquals(Component.class, trace3.getNodes().get(0).getClass()); Component parentComponent = (Component) trace3.getNodes().get(0); assertEquals(1, parentComponent.getNodes().size()); assertEquals(Component.class, parentComponent.getNodes().get(0).getClass()); Component childComponent = (Component) parentComponent.getNodes().get(0); assertTrue(childComponent.getCorrelationIds().contains( new CorrelationIdentifier(Scope.CausedBy, trace1.getFragmentId() + ":0"))); assertTrue(childComponent.getCorrelationIds().contains( new CorrelationIdentifier(Scope.CausedBy, trace2.getFragmentId() + ":0"))); assertEquals(0, childComponent.getNodes().size()); }

Target:
public void testSingleChildOfSpanWithOtherFollowsFromRefs() { TestTraceReporter reporter = new TestTraceReporter(); Tracer tracer = new APMTracer(reporter); Span rootSpan = tracer.buildSpan("root") .start(); Span childSpan1 = tracer.buildSpan("child1") .asChildOf(rootSpan) .start(); childSpan1.finish(); Span childSpan2 = tracer.buildSpan("child2") .asChildOf(rootSpan) .start(); Span referencingSpan = tracer.buildSpan("referencingSpan") .addReference(References.FOLLOWS_FROM, childSpan1.context()) .asChildOf(childSpan2) .start(); childSpan2.finish(); rootSpan.finish(); referencingSpan.finish(); assertEquals(1, reporter.getTraces().size()); Trace trace = reporter.getTraces().get(0); assertEquals(1, trace.getNodes().size()); assertEquals(Component.class, trace.getNodes().get(0).getClass()); Component rootComponent = (Component) trace.getNodes().get(0); assertEquals(2, rootComponent.getNodes().size()); assertEquals(Component.class, rootComponent.getNodes().get(0).getClass()); assertEquals(Component.class, rootComponent.getNodes().get(1).getClass()); Component child1Component = (Component) rootComponent.getNodes().get(0); Component child2Component = (Component) rootComponent.getNodes().get(1); assertEquals(0, child1Component.getNodes().size()); assertEquals(1, child2Component.getNodes().size()); assertEquals(Component.class, child2Component.getNodes().get(0).getClass()); Component referencingComponent = (Component) child2Component.getNodes().get(0); assertTrue(referencingComponent.getCorrelationIds().contains( new CorrelationIdentifier(Scope.CausedBy, trace.getFragmentId() + ":0:0"))); }
Source:
final void removeFirst() { Node head = get(); Node next = head.get(); size--; Node newHead = new Node(null); Node newNext = next.get(); newHead.set(newNext); setFirst(newHead); if (newNext == null) { tail = newHead; } }

Target:
final void removeFirst() { Node head = get(); Node next = head.get(); size--; setFirst(next); }
Source:
public ItemStack getResultForClick() { if(!getWorld().isRemote) { ItemStack result = getOutput(true); if (result.isEmpty()) { result = getOutput(false); } if (result.isEmpty()) { return ItemStack.EMPTY; } result.setCount(inv.addCompressed(result, false)); if (result.getCount() > 0) { return result; } return ItemStack.EMPTY; } return ItemStack.EMPTY; }

Target:
public ItemStack getResultForClick() { if(MainProxy.isServer(getWorld())) { ItemStack result = getOutput(true); if (result.isEmpty()) { result = getOutput(false); } if (result.isEmpty()) { return ItemStack.EMPTY; } result.setCount(inv.addCompressed(result, false)); if (result.getCount() > 0) { return result; } return ItemStack.EMPTY; } return ItemStack.EMPTY; }