auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public Optional<String> getPrimaryTypeName() { return getStorage() .map(Storage::getFileName) .map(filename -> filename.replace(".java", "")) .map(filename -> filename.replace(".jav", "")); }

Target:
public Optional<String> getPrimaryTypeName() { return getStorage() .map(Storage::getFileName) .map(Utils::removeFileExtension); }
Source:
public JacksonTraverseCallback(JsonGenerator generator) { this(generator, false); }

Target:
protected JacksonTraverseCallback(JsonGenerator generator) { this(generator, false); }
Source:
public Response listNotifiers(@Context UriInfo uriInfo) { List<CatalogService.QueryParam> queryParams = new ArrayList<CatalogService.QueryParam>(); try { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); Collection<NotifierInfo> notifierInfos; if (params.isEmpty()) { notifierInfos = catalogService.listNotifierInfos(); } else { for (String param : params.keySet()) { queryParams.add(new CatalogService.QueryParam(param, params.getFirst(param))); } notifierInfos = catalogService.listNotifierInfos(queryParams); } if(notifierInfos != null && ! notifierInfos.isEmpty()) { return WSUtils.respond(OK, SUCCESS, notifierInfos); } } catch (Exception ex) { return WSUtils.respond(INTERNAL_SERVER_ERROR, EXCEPTION, ex.getMessage()); } return WSUtils.respond(NOT_FOUND, ENTITY_NOT_FOUND_FOR_FILTER, queryParams.toString()); }

Target:
public Response listNotifiers(@Context UriInfo uriInfo) { List<CatalogService.QueryParam> queryParams = new ArrayList<CatalogService.QueryParam>(); try { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); Collection<NotifierInfo> notifierInfos; if (params.isEmpty()) { notifierInfos = catalogService.listNotifierInfos(); } else { for (String param : params.keySet()) { queryParams.add(new CatalogService.QueryParam(param, params.getFirst(param))); } notifierInfos = catalogService.listNotifierInfos(queryParams); } if(notifierInfos != null && ! notifierInfos.isEmpty()) { return WSUtils.respond(OK, SUCCESS, notifierInfos); } } catch (Exception ex) { LOG.error("Got exception", ex); return WSUtils.respond(INTERNAL_SERVER_ERROR, EXCEPTION, ex.getMessage()); } return WSUtils.respond(NOT_FOUND, ENTITY_NOT_FOUND_FOR_FILTER, queryParams.toString()); }
Source:
public Coordinator(CachedDatastreamReader datastreamCache, CoordinatorConfig config) throws DatastreamException { _datastreamCache = datastreamCache; _config = config; _clusterName = _config.getCluster(); _heartbeatPeriod = Duration.ofMillis(config.getHeartbeatPeriodMs()); _adapter = new ZkAdapter(_config.getZkAddress(), _clusterName, _config.getDefaultTransportProviderName(), _config.getZkSessionTimeout(), _config.getZkConnectionTimeout(), this); _eventQueue = new CoordinatorEventBlockingQueue(); _eventThread = new CoordinatorEventProcessor(); _eventThread.setDaemon(true); _dynamicMetricsManager = DynamicMetricsManager.getInstance(); _dynamicMetricsManager.registerGauge(MODULE, NUM_PAUSED_DATASTREAMS_GROUPS, PAUSED_DATASTREAMS_GROUPS::get); _dynamicMetricsManager.registerGauge(MODULE, IS_LEADER, () -> getIsLeader().getAsBoolean() ? 1 : 0); _dynamicMetricsManager.registerGauge(MODULE, MAX_PARTITION_COUNT_IN_TASK, MAX_PARTITION_COUNT::get); VerifiableProperties coordinatorProperties = new VerifiableProperties(_config.getConfigProperties()); _eventProducerConfig = coordinatorProperties.getDomainProperties(EVENT_PRODUCER_CONFIG_DOMAIN); _cpProvider = new ZookeeperCheckpointProvider(_adapter); Optional.ofNullable(_cpProvider.getMetricInfos()).ifPresent(_metrics::addAll); _metrics.addAll(EventProducer.getMetricInfos()); _shutdown = false; }

Target:
public Coordinator(CachedDatastreamReader datastreamCache, CoordinatorConfig config) throws DatastreamException { _datastreamCache = datastreamCache; _config = config; _clusterName = _config.getCluster(); _heartbeatPeriod = Duration.ofMillis(config.getHeartbeatPeriodMs()); _adapter = new ZkAdapter(_config.getZkAddress(), _clusterName, _config.getDefaultTransportProviderName(), _config.getZkSessionTimeout(), _config.getZkConnectionTimeout(), this); _eventQueue = new CoordinatorEventBlockingQueue(); _eventThread = new CoordinatorEventProcessor(); _eventThread.setDaemon(true); _dynamicMetricsManager = DynamicMetricsManager.getInstance(); _dynamicMetricsManager.registerGauge(MODULE, NUM_PAUSED_DATASTREAMS_GROUPS, PAUSED_DATASTREAMS_GROUPS::get); _dynamicMetricsManager.registerGauge(MODULE, IS_LEADER, () -> getIsLeader().getAsBoolean() ? 1 : 0); _dynamicMetricsManager.registerGauge(MODULE, MAX_PARTITION_COUNT_IN_TASK, MAX_PARTITION_COUNT::get); VerifiableProperties coordinatorProperties = new VerifiableProperties(_config.getConfigProperties()); _eventProducerConfig = coordinatorProperties.getDomainProperties(EVENT_PRODUCER_CONFIG_DOMAIN); _cpProvider = new ZookeeperCheckpointProvider(_adapter); Optional.ofNullable(_cpProvider.getMetricInfos()).ifPresent(_metrics::addAll); _metrics.addAll(EventProducer.getMetricInfos()); }
Source:
protected List<Tree> getClauses(IfStatementTree ifStatement) { Preconditions.checkArgument(ifStatement.is(Kind.IF_STATEMENT)); List<Tree> clauses = new ArrayList<>(); clauses.add(ifStatement); clauses.addAll(ifStatement.elseifClauses()); if (ifStatement.elseClause() != null) { ElseClauseTree currentElseClause = ifStatement.elseClause(); while (currentElseClause != null) { StatementTree statement = currentElseClause.statements().get(0); if (statement.is(Kind.IF_STATEMENT)) { IfStatementTree nestedIfStatement = (IfStatementTree) statement; clauses.add(nestedIfStatement); checkedIfStatements.add(nestedIfStatement); currentElseClause = nestedIfStatement.elseClause(); } else { clauses.add(currentElseClause); currentElseClause = null; } } } return clauses; }

Target:
protected List<Tree> getClauses(IfStatementTree ifStatement) { Preconditions.checkArgument(ifStatement.is(Kind.IF_STATEMENT)); List<Tree> clauses = new ArrayList<>(); clauses.add(ifStatement); clauses.addAll(ifStatement.elseifClauses()); ElseClauseTree currentElseClause = ifStatement.elseClause(); while (currentElseClause != null) { StatementTree statement = currentElseClause.statements().get(0); if (statement.is(Kind.IF_STATEMENT)) { IfStatementTree nestedIfStatement = (IfStatementTree) statement; clauses.add(nestedIfStatement); checkedIfStatements.add(nestedIfStatement); currentElseClause = nestedIfStatement.elseClause(); } else { clauses.add(currentElseClause); currentElseClause = null; } } return clauses; }
Source:
public static Configuration newMetastoreConf() { Configuration conf = new Configuration(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = MetastoreConf.class.getClassLoader(); } hiveDefaultURL = classLoader.getResource("hive-default.xml"); hiveSiteURL = findConfigFile(classLoader, "hive-site.xml"); if (hiveSiteURL != null) conf.addResource(hiveSiteURL); URL hivemetastoreSiteUrl = findConfigFile(classLoader, "hivemetastore-site.xml"); if (hivemetastoreSiteUrl != null) conf.addResource(hivemetastoreSiteUrl); URL metastoreSiteURL = findConfigFile(classLoader, "metastore-site.xml"); if (metastoreSiteURL != null) conf.addResource(metastoreSiteURL); for (ConfVars var : ConfVars.values()) { if (System.getProperty(var.varname) != null) { LOG.debug("Setting conf value " + var.varname + " using value " + System.getProperty(var.varname)); conf.set(var.varname, System.getProperty(var.varname)); } else if (System.getProperty(var.hiveName) != null) { conf.set(var.hiveName, System.getProperty(var.hiveName)); } } if (getBoolVar(conf, ConfVars.SCHEMA_VERIFICATION)) { setBoolVar(conf, ConfVars.AUTO_CREATE_ALL, false); } return conf; }

Target:
public static Configuration newMetastoreConf() { Configuration conf = new Configuration(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = MetastoreConf.class.getClassLoader(); } hiveDefaultURL = classLoader.getResource("hive-default.xml"); hiveSiteURL = findConfigFile(classLoader, "hive-site.xml"); if (hiveSiteURL != null) conf.addResource(hiveSiteURL); hiveMetastoreSiteURL = findConfigFile(classLoader, "hivemetastore-site.xml"); if (hiveMetastoreSiteURL != null) conf.addResource(hiveMetastoreSiteURL); metastoreSiteURL = findConfigFile(classLoader, "metastore-site.xml"); if (metastoreSiteURL != null) conf.addResource(metastoreSiteURL); for (ConfVars var : ConfVars.values()) { if (System.getProperty(var.varname) != null) { LOG.debug("Setting conf value " + var.varname + " using value " + System.getProperty(var.varname)); conf.set(var.varname, System.getProperty(var.varname)); } else if (System.getProperty(var.hiveName) != null) { conf.set(var.hiveName, System.getProperty(var.hiveName)); } } if (getBoolVar(conf, ConfVars.SCHEMA_VERIFICATION)) { setBoolVar(conf, ConfVars.AUTO_CREATE_ALL, false); } return conf; }
Source:
private void registerStatistic(Object context, String name, String observerName, String tag, String propertyKey, ValueStatistic<Number> source) { Set<String> tags = new HashSet<>(Arrays.asList(tag, "tier")); Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", tag); properties.put(propertyKey, name); StatisticsManager.createPassThroughStatistic(context, observerName, tags, properties, source); }

Target:
private void registerStatistic(Object context, String name, String observerName, String tag, String propertyKey, ValueStatistic<Number> source) { Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", tag); properties.put(propertyKey, name); StatisticsManager.createPassThroughStatistic(context, observerName, tags(tag, "tier"), properties, source); }
Source:
public void changeMinimumTime(long change) { synchronized (scoreBoardModel) { setMinimumTime(minimumTime + change); } }

Target:
public void changeMinimumTime(long change) { synchronized (coreLock) { setMinimumTime(minimumTime + change); } }
Source:
public void writeToFile( String jaifPath, AnnotationsInContexts annosToIgnore, OutputFormat outputFormat, BaseTypeChecker checker) { assert jaifPath.endsWith(".jaif"); AScene scene = theScene.clone(); removeAnnosFromScene(scene, annosToIgnore); scene.prune(); String filepath; switch (outputFormat) { case JAIF: filepath = jaifPath; break; case STUB: String astubWithChecker = "-" + checker.getClass().getCanonicalName() + ".astub"; filepath = jaifPath.replace(".jaif", astubWithChecker); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } new File(filepath).delete(); if (!scene.isEmpty()) { try { switch (outputFormat) { case STUB: SceneToStubWriter.write(this, filepath, checker); break; case JAIF: for (Map.Entry<String, AClass> classEntry : scene.classes.entrySet()) { AClass aClass = classEntry.getValue(); for (Map.Entry<String, AMethod> methodEntry : aClass.getMethods().entrySet()) { AMethod aMethod = methodEntry.getValue(); List<AnnotationMirror> contractAnnotationMirrors = checker.getTypeFactory().getContractAnnotations(aMethod); List<Annotation> contractAnnotations = mapList( AnnotationConverter::annotationMirrorToAnnotation, contractAnnotationMirrors); aMethod.contracts = contractAnnotations; } } IndexFileWriter.write(scene, new FileWriter(filepath)); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } } catch (IOException e) { throw new UserError("Problem while writing %s: %s", filepath, e.getMessage()); } catch (DefException e) { throw new BugInCF(e); } } }

Target:
public void writeToFile( String jaifPath, AnnotationsInContexts annosToIgnore, OutputFormat outputFormat, BaseTypeChecker checker) { assert jaifPath.endsWith(".jaif"); AScene scene = theScene.clone(); removeAnnosFromScene(scene, annosToIgnore); scene.prune(); String filepath; switch (outputFormat) { case JAIF: filepath = jaifPath; break; case STUB: String astubWithChecker = "-" + checker.getClass().getCanonicalName() + ".astub"; filepath = jaifPath.replace(".jaif", astubWithChecker); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } new File(filepath).delete(); if (!scene.isEmpty()) { try { switch (outputFormat) { case STUB: SceneToStubWriter.write(this, filepath, checker); break; case JAIF: for (Map.Entry<String, AClass> classEntry : scene.classes.entrySet()) { AClass aClass = classEntry.getValue(); for (Map.Entry<String, AMethod> methodEntry : aClass.getMethods().entrySet()) { AMethod aMethod = methodEntry.getValue(); List<AnnotationMirror> contractAnnotationMirrors = checker.getTypeFactory().getContractAnnotations(aMethod); List<Annotation> contractAnnotations = CollectionsPlume.mapList( AnnotationConverter::annotationMirrorToAnnotation, contractAnnotationMirrors); aMethod.contracts = contractAnnotations; } } IndexFileWriter.write(scene, new FileWriter(filepath)); break; default: throw new BugInCF("Unhandled outputFormat " + outputFormat); } } catch (IOException e) { throw new UserError("Problem while writing %s: %s", filepath, e.getMessage()); } catch (DefException e) { throw new BugInCF(e); } } }
Source:
public LibraryContextSwitchEvent( EventType eventType, String uri ) { this.eventType = eventType; this.uri = uri; }

Target:
public LibraryContextSwitchEvent( EventType eventType, String uri ) { checkNotNull( "eventType", eventType ); checkNotNull( "uri", uri ); this.eventType = eventType; this.uri = uri; }
Source:
public GridData.Range onSelectHeaderCell(final int headerRowIndex, final int headerColumnIndex) { selectHeaderMerged(headerRowIndex, headerColumnIndex); return new GridData.Range(headerRowIndex); }

Target:
public GridData.Range onSelectHeaderCell(final int headerRowIndex, final int headerColumnIndex) { return selectHeaderCell(headerRowIndex, headerColumnIndex); }
Source:
public void indexerTest() throws Exception { sparqlIndexer.update(uri, createDefaultModel().read( new StringReader(fooRDF), "", "N3")); waitForTriples(3); assertEquals("Triples should be present!", 3, countDescribeTriples(uri)); final String sparqlQuery = "PREFIX fcrepo: <<LINK_0>> \n" + "SELECT ?p \n" + "WHERE \n" + "{ ?p fcrepo:hasParent ?c }"; assertEquals("Triple should return from search!", 3, countQueryTriples(sparqlQuery)); sparqlIndexer.remove(uri); waitForTriples(0); assertTrue("Triples should not be present!", countDescribeTriples(uri) == 0); }

Target:
public void indexerTest() throws Exception { sparqlIndexer.update(uri, createDefaultModel().read( new StringReader(fooRDF), "", "N3")); waitForTriples(3); assertEquals("Triples should be present!", 3, countDescribeTriples(uri)); final String sparqlQuery = "PREFIX fcrepo: <<LINK_0>> \n" + "SELECT ?p \n" + "WHERE \n" + "{ ?p fcrepo:hasParent ?c }"; assertTrue("Triple should return from search!", countQueryTriples(sparqlQuery) > 0 ); sparqlIndexer.remove(uri); waitForTriples(0); assertTrue("Triples should not be present!", countDescribeTriples(uri) == 0); }
Source:
public void canRetrieveOwnNumber() throws Exception { final Repo repo = this.repo(); final RtEvent event = new RtEvent(new FakeRequest(), repo, 2); MatcherAssert.assertThat( event.number(), Matchers.sameInstance(2) ); }

Target:
public void canRetrieveOwnNumber() throws Exception { final Repo repo = this.repo(); final RtEvent event = new RtEvent(new FakeRequest(), repo, 2); MatcherAssert.assertThat( event.number(), Matchers.equalTo(2) ); }
Source:
private RollingUpdateOp rollingUpdateMarkUndeployed(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { try { final Node node = client.getNode( Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName())); final int version = node.getStat().getVersion(); final List<String> hostsToUndeploy = Json.read(node.getBytes(), STRING_LIST_TYPE); if (!hostsToUndeploy.removeAll(ImmutableList.of(host))) { return opFactory.nextTask(); } return opFactory.nextTask(ImmutableList.of( check(Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName()), version), set(Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName()), Json.asBytes(hostsToUndeploy)))); } catch (KeeperException | IOException e) { log.error("unable to mark host undeployed after removal from deployment group: " + "deployment-group={}, host={}", deploymentGroup.getName(), host, e); return opFactory.nextTask(); } }

Target:
private RollingUpdateOp rollingUpdateMarkUndeployed(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { try { final Node node = client.getNode( Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName())); final int version = node.getStat().getVersion(); final List<String> hostsToUndeploy = Json.read(node.getBytes(), STRING_LIST_TYPE); if (!hostsToUndeploy.removeAll(ImmutableList.of(host))) { return opFactory.nextTask(); } return opFactory.nextTask(ImmutableList.of( check(Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName()), version), set(Paths.statusDeploymentGroupRemovedHosts(deploymentGroup.getName()), Json.asBytes(hostsToUndeploy)))); } catch (KeeperException | IOException e) { return opFactory.error("unable to mark host undeployed after removal from deployment group", host, RollingUpdateError.UNABLE_TO_MARK_HOST_UNDEPLOYED); } }
Source:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TaskModel taskModel = (TaskModel) o; if (!changelogPartition.equals(taskModel.changelogPartition)) { return false; } if (!systemStreamPartitions.equals(taskModel.systemStreamPartitions)) { return false; } if (!taskName.equals(taskModel.taskName)) { return false; } return true; }

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TaskModel taskModel = (TaskModel) o; if (!changelogPartition.equals(taskModel.changelogPartition)) { return false; } if (!systemStreamPartitions.equals(taskModel.systemStreamPartitions)) { return false; } if (!taskName.equals(taskModel.taskName)) { return false; } if (!taskMode.equals(taskModel.taskMode)) { return false; } return true; }
Source:
private HashSet<String> determineStatusTags(IndexDocumentBean idb) throws IndexingException { HashSet<String> statusTags = new HashSet<String>(); List<String> contentStatus = idb.getContentStatus(); List<String> accessStatus = idb.getStatus(); if (contentStatus.contains(FacetConstants.UNPUBLISHED)) { statusTags.add(FacetConstants.UNPUBLISHED); } if (contentStatus.contains(FacetConstants.CONTENT_DESCRIBED)) { statusTags.add(FacetConstants.CONTENT_DESCRIBED); } else { statusTags.add(FacetConstants.CONTENT_NOT_DESCRIBED); } if (contentStatus.contains(FacetConstants.IS_PRIMARY_OBJECT)) { statusTags.add(FacetConstants.IS_PRIMARY_OBJECT); } if (accessStatus.contains(FacetConstants.EMBARGOED)) { statusTags.add(FacetConstants.EMBARGOED); } if (accessStatus.contains(FacetConstants.EMBARGOED_PARENT)) { statusTags.add(FacetConstants.EMBARGOED_PARENT); } return statusTags; }

Target:
private HashSet<String> determineStatusTags(IndexDocumentBean idb) throws IndexingException { HashSet<String> statusTags = new HashSet<>(); List<String> contentStatus = idb.getContentStatus(); List<String> accessStatus = idb.getStatus(); if (contentStatus.contains(FacetConstants.UNPUBLISHED)) { statusTags.add(FacetConstants.UNPUBLISHED); } if (contentStatus.contains(FacetConstants.CONTENT_DESCRIBED)) { statusTags.add(FacetConstants.CONTENT_DESCRIBED); } else { statusTags.add(FacetConstants.CONTENT_NOT_DESCRIBED); } if (contentStatus.contains(FacetConstants.IS_PRIMARY_OBJECT)) { statusTags.add(FacetConstants.IS_PRIMARY_OBJECT); } if (accessStatus.contains(FacetConstants.EMBARGOED)) { statusTags.add(FacetConstants.EMBARGOED); } return statusTags; }
Source:
public SpongeFlyingData() { return new SpongeFlyingData(false); }

Target:
public SpongeFlyingData() { this(false); }
Source:
private void createGroup() { if ( createGroupeIfNotExist ) { Assert.hasText( consumerGroupName, "'consumerGroupName' must be set" ); Assert.hasText( consumerName, "'consumerName' must be set" ); try { template.execute( (RedisCallback<Object>) connection -> connection.execute( "XGROUP", "CREATE".getBytes(), streamName.getBytes(), consumerGroupName.getBytes(), ReadOffset.latest().getOffset().getBytes(), "MKSTREAM".getBytes() ) ); } catch ( Exception e ) { e.printStackTrace(); } } }

Target:
private void createGroup() { if ( createGroupIfNotExist ) { Assert.notNull( template, "'template' should not be null" ); Assert.hasText( consumerGroupName, "'consumerGroupName' must be set" ); Assert.hasText( consumerName, "'consumerName' must be set" ); try { this.template.execute( ( RedisCallback<Object> ) connection -> connection.execute( "XGROUP", "CREATE".getBytes(), streamKey.getBytes(), consumerGroupName.getBytes(), ReadOffset.latest().getOffset().getBytes(), "MKSTREAM".getBytes() ) ); } catch ( Exception e ) { e.printStackTrace(); } } }
Source:
protected VmDevice createVmDevice() { return new VmDevice(new VmDeviceId(disk.getId(), getVmId()), VmDeviceType.DISK.getName(), VmDeviceType.DISK.getName(), "", 0, null, true, getParameters().isPlugUnPlug(), false, "", null); }

Target:
protected VmDevice createVmDevice() { return new VmDevice(new VmDeviceId(disk.getId(), getVmId()), VmDeviceGeneralType.DISK, VmDeviceType.DISK.getName(), "", 0, null, true, getParameters().isPlugUnPlug(), false, "", null); }
Source:
public Response taskPost( final Task task, @Context final HttpServletRequest req ) { final String dataSource = task.getDataSource(); final ResourceAction resourceAction = new ResourceAction( new Resource(dataSource, ResourceType.DATASOURCE), Action.WRITE ); Access authResult = AuthorizationUtils.authorizeResourceAction( req, resourceAction, authorizerMapper ); if (!authResult.isAllowed()) { return Response.status(Response.Status.FORBIDDEN) .header("Access-Check-Result", authResult) .entity(ImmutableMap.of("error", "Not authorized.")) .build(); } return asLeaderWith( taskMaster.getTaskQueue(), new Function<TaskQueue, Response>() { @Override public Response apply(TaskQueue taskQueue) { try { taskQueue.add(task); return Response.ok(ImmutableMap.of("task", task.getId())).build(); } catch (EntryExistsException e) { return Response.status(Response.Status.BAD_REQUEST) .entity(ImmutableMap.of("error", StringUtils.format("Task[%s] already exists!", task.getId()))) .build(); } } } ); }

Target:
public Response taskPost( final Task task, @Context final HttpServletRequest req ) { final String dataSource = task.getDataSource(); final ResourceAction resourceAction = new ResourceAction( new Resource(dataSource, ResourceType.DATASOURCE), Action.WRITE ); Access authResult = AuthorizationUtils.authorizeResourceAction( req, resourceAction, authorizerMapper ); if (!authResult.isAllowed()) { throw new ForbiddenException(authResult.toString()); } return asLeaderWith( taskMaster.getTaskQueue(), new Function<TaskQueue, Response>() { @Override public Response apply(TaskQueue taskQueue) { try { taskQueue.add(task); return Response.ok(ImmutableMap.of("task", task.getId())).build(); } catch (EntryExistsException e) { return Response.status(Response.Status.BAD_REQUEST) .entity(ImmutableMap.of("error", StringUtils.format("Task[%s] already exists!", task.getId()))) .build(); } } } ); }
Source:
private long checkInternal(MesosComputer c) { if (c.getNode() == null) { return 1; } if ((System.currentTimeMillis() - c.getConnectTime()) < MINUTES.toMillis(idleTerminationMinutes)) { return 1; } if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > MINUTES.toMillis(idleTerminationMinutes)) { LOGGER.info("Disconnecting idle computer " + c.getName()); c.getNode().setPendingDelete(true); if (!c.isOffline()) { c.setTemporarilyOffline(true, OfflineCause.create(Messages._DeletedCause())); } } } return 1; }

Target:
private long checkInternal(MesosComputer c) { if (c.getNode() == null) { return 1; } if ((DateTimeUtils.currentTimeMillis() - c.getConnectTime()) < MINUTES.toMillis(idleTerminationMinutes < 1 ? 1 : idleTerminationMinutes)) { return 1; } if (isTerminable() && c.isIdle()) { final long idleMilliseconds = DateTimeUtils.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > MINUTES.toMillis(idleTerminationMinutes)) { LOGGER.info("Disconnecting idle computer " + c.getName()); c.getNode().setPendingDelete(true); if (!c.isOffline()) { c.setTemporarilyOffline(true, OfflineCause.create(Messages._DeletedCause())); } } } return 1; }
Source:
private SampleNumberPerProject createSampleNumberPerProject(Project project, User user) { SampleNumberPerProject sampleNumberPerProject; sampleNumberPerProject = new SampleNumberPerProjectImpl(); sampleNumberPerProject.setProject(project); sampleNumberPerProject.setHighestSampleNumber(0); sampleNumberPerProject.setPadding(DEFAULT_PADDING); sampleNumberPerProject.setCreatedBy(user); sampleNumberPerProject.setUpdatedBy(user); sampleNumberPerProject.setLastUpdated(new Date()); sampleNumberPerProject.setCreationDate(new Date()); addSampleNumberPerProject(sampleNumberPerProject); return sampleNumberPerProject; }

Target:
private SampleNumberPerProject createSampleNumberPerProject(Project project, User user) { SampleNumberPerProject sampleNumberPerProject; sampleNumberPerProject = new SampleNumberPerProjectImpl(); sampleNumberPerProject.setProject(project); sampleNumberPerProject.setHighestSampleNumber(0); sampleNumberPerProject.setPadding(DEFAULT_PADDING); sampleNumberPerProject.setCreatedBy(user); sampleNumberPerProject.setUpdatedBy(user); addSampleNumberPerProject(sampleNumberPerProject); return sampleNumberPerProject; }
Source:
void connect(final Socket s, final String host, final int port) throws IOException { try { s.connect(new InetSocketAddress(host, port)); final DataOutputStream writer = new DataOutputStream(s.getOutputStream()); final BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream())); writer.writeBytes("HELO\n"); writer.flush(); final String line = reader.readLine(); if (line.startsWith("HELO")) { log.info("Connected to helios-solo watchdog"); } else { throw new IOException("We didn't get back the HELO we sent to the watchdog process."); } } catch (IOException e) { log.debug("Failed to connect to helios-solo watchdog"); throw e; } }

Target:
void connect(final Socket s, final String host, final int port) throws IOException { s.connect(new InetSocketAddress(host, port)); final DataOutputStream writer = new DataOutputStream(s.getOutputStream()); final BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream())); writer.writeBytes("HELO\n"); writer.flush(); final String line = reader.readLine(); if (line.startsWith("HELO")) { log.info("Connected to helios-solo watchdog"); } else { throw new IOException("We didn't get back the HELO we sent to the watchdog process."); } }
Source:
private LinkedList<MaxwellAbstractRowsEvent> getTransactionEvents() throws Exception { BinlogEventV4 v4Event; MaxwellAbstractRowsEvent event; LinkedList<MaxwellAbstractRowsEvent> list = new LinkedList<>(); while ( true ) { v4Event = queue.poll(100, TimeUnit.MILLISECONDS); if (v4Event == null) continue; switch(v4Event.getHeader().getEventType()) { case MySQLConstants.WRITE_ROWS_EVENT: case MySQLConstants.WRITE_ROWS_EVENT_V2: case MySQLConstants.UPDATE_ROWS_EVENT: case MySQLConstants.UPDATE_ROWS_EVENT_V2: case MySQLConstants.DELETE_ROWS_EVENT: case MySQLConstants.DELETE_ROWS_EVENT_V2: rowEventsProcessed++; event = processRowsEvent((AbstractRowEvent) v4Event); if ( event.matchesFilter() ) list.add(event); break; case MySQLConstants.TABLE_MAP_EVENT: tableCache.processEvent(this.schema, (TableMapEvent) v4Event); break; case MySQLConstants.QUERY_EVENT: QueryEvent qe = (QueryEvent) v4Event; throw new RuntimeException("Unhandled QueryEvent: " + qe); case MySQLConstants.XID_EVENT: XidEvent xe = (XidEvent) v4Event; for ( MaxwellAbstractRowsEvent e : list ) e.setXid(xe.getXid()); if ( !list.isEmpty() ) list.getLast().setCommit(true); return list; } } }

Target:
private LinkedList<MaxwellAbstractRowsEvent> getTransactionEvents() throws Exception { BinlogEventV4 v4Event; MaxwellAbstractRowsEvent event; LinkedList<MaxwellAbstractRowsEvent> list = new LinkedList<>(); while ( true ) { v4Event = queue.poll(100, TimeUnit.MILLISECONDS); if (v4Event == null) continue; switch(v4Event.getHeader().getEventType()) { case MySQLConstants.WRITE_ROWS_EVENT: case MySQLConstants.WRITE_ROWS_EVENT_V2: case MySQLConstants.UPDATE_ROWS_EVENT: case MySQLConstants.UPDATE_ROWS_EVENT_V2: case MySQLConstants.DELETE_ROWS_EVENT: case MySQLConstants.DELETE_ROWS_EVENT_V2: rowEventsProcessed++; event = processRowsEvent((AbstractRowEvent) v4Event); if ( event.matchesFilter() ) list.add(event); break; case MySQLConstants.TABLE_MAP_EVENT: tableCache.processEvent(this.schema, (TableMapEvent) v4Event); break; case MySQLConstants.QUERY_EVENT: QueryEvent qe = (QueryEvent) v4Event; throw new RuntimeException("Unhandled QueryEvent: " + qe); case MySQLConstants.XID_EVENT: XidEvent xe = (XidEvent) v4Event; for ( MaxwellAbstractRowsEvent e : list ) e.setXid(xe.getXid()); if ( !list.isEmpty() ) list.getLast().setTXCommit(); return list; } } }
Source:
public void testGetStorageQuotas() throws ExecutionException, InterruptedException { VolumeQuota volumeQuota = quotaApi.getByTenant("non"); assertNotNull(volumeQuota.getGigabytes()); assertNotNull(volumeQuota.getVolumes()); assertNotNull(volumeQuota.getSnapshots()); }

Target:
public void testGetStorageQuotas() throws ExecutionException, InterruptedException { VolumeQuota volumeQuota = quotaApi.getByTenant("demo"); assertTrue(volumeQuota.getGigabytes() >= 0); assertTrue(volumeQuota.getVolumes() >= 0); assertTrue(volumeQuota.getSnapshots() >= 0); }
Source:
protected boolean doProcess(Record record) { Timer.Context timerContext = elapsedTime.time(); try { XContentBuilder documentBuilder = jsonBuilder().startObject(); Map<String, Collection<Object>> map = record.getFields().asMap(); for (Map.Entry<String, Collection<Object>> entry : map.entrySet()) { String key = entry.getKey(); Iterator<Object> iterator = entry.getValue().iterator(); while (iterator.hasNext()) { documentBuilder.field(key, iterator.next()); } } documentBuilder.endObject(); loader.addDocument(documentBuilder.bytes(), indexName, indexType, ttl); } catch (Exception e) { LOGGER.warn(null); throw new MorphlineRuntimeException(e); } finally { timerContext.stop(); } return super.doProcess(record); }

Target:
protected boolean doProcess(Record record) { Timer.Context timerContext = elapsedTime.time(); try { XContentBuilder documentBuilder = jsonBuilder().startObject(); Map<String, Collection<Object>> map = record.getFields().asMap(); for (Map.Entry<String, Collection<Object>> entry : map.entrySet()) { String key = entry.getKey(); Iterator<Object> iterator = entry.getValue().iterator(); while (iterator.hasNext()) { documentBuilder.field(key, iterator.next()); } } documentBuilder.endObject(); loader.addDocument(documentBuilder.bytes(), indexName, indexType, ttl); } catch (Exception e) { throw new MorphlineRuntimeException(e); } finally { timerContext.stop(); } return super.doProcess(record); }
Source:
public void testJoinerTransactionSurvives() throws Exception { Cache<Object, Object> c0 = manager(0).getCache(); Cache<Object, Object> c1 = manager(1).getCache(); TransactionTable tt0 = TestingUtil.extractComponent(c0, TransactionTable.class); LocalTopologyManager ltm0 = TestingUtil.extractGlobalComponent(manager(0), LocalTopologyManager.class); ltm0.setRebalancingEnabled(false); addClusterEnabledCacheManager(configurationBuilder); Cache<Object, Object> c2 = manager(2).getCache(); tm(2).begin(); c2.put("key1", "value1"); assertEquals(1, tt0.getRemoteGlobalTransaction().size()); Transaction tx2 = tm(2).suspend(); tm(1).begin(); c1.put("key2", "value2"); assertEquals(2, tt0.getRemoteGlobalTransaction().size()); Transaction tx1 = tm(1).suspend(); manager(1).stop(); TestingUtil.blockUntilViewsReceived(60000, false, c0, c2); TestingUtil.waitForRehashToComplete(c0); assertEquals(Arrays.asList(address(0)), c0.getAdvancedCache().getDistributionManager().getConsistentHash().getMembers()); assertEquals(1, tt0.getRemoteGlobalTransaction().size()); tm(2).resume(tx2); tm(2).commit(); }

Target:
public void testJoinerTransactionSurvives() throws Exception { Cache<Object, Object> c0 = manager(0).getCache(); Cache<Object, Object> c1 = manager(1).getCache(); final TransactionTable tt0 = TestingUtil.extractComponent(c0, TransactionTable.class); LocalTopologyManager ltm0 = TestingUtil.extractGlobalComponent(manager(0), LocalTopologyManager.class); ltm0.setRebalancingEnabled(false); addClusterEnabledCacheManager(configurationBuilder); Cache<Object, Object> c2 = manager(2).getCache(); tm(2).begin(); c2.put("key1", "value1"); assertEquals(1, tt0.getRemoteGlobalTransaction().size()); Transaction tx2 = tm(2).suspend(); tm(1).begin(); c1.put("key2", "value2"); assertEquals(2, tt0.getRemoteGlobalTransaction().size()); Transaction tx1 = tm(1).suspend(); manager(1).stop(); TestingUtil.blockUntilViewsReceived(60000, false, c0, c2); TestingUtil.waitForRehashToComplete(c0); assertEquals(Arrays.asList(address(0)), c0.getAdvancedCache().getDistributionManager().getConsistentHash().getMembers()); eventually(new Condition() { @Override public boolean isSatisfied() throws Exception { return tt0.getRemoteTransactions().size() == 1; } }); tm(2).resume(tx2); tm(2).commit(); }
Source:
public Release latest() throws IOException { Release latestRelease = null; final Iterator<Release> itRelease = this.iterate().iterator(); while (itRelease.hasNext()) { final Release release = itRelease.next(); if (latestRelease == null) { latestRelease = release; } else if (this.createLatest(latestRelease, release)) { latestRelease = release; } } return latestRelease; }

Target:
public Release latest() throws IOException { Release latest = null; for (final Release release: this.iterate()) { if (latest == null) { latest = release; } else if (this.isNewer(latest, release)) { latest = release; } } return latest; }
Source:
public void of(RecordCursor base, SqlExecutionContext executionContext) { this.base = base; this.baseRecord = base.getRecord(); final Record placeHolderRecord = base.getRecordB(); chain.clear(); while (base.hasNext()) { executionContext.getSqlExecutionInterruptor().checkInterrupted(); chain.put( baseRecord, base, placeHolderRecord, comparator ); } chainCursor.toTop(); }

Target:
public void of(RecordCursor base, SqlExecutionContext executionContext) { this.base = base; this.baseRecord = base.getRecord(); final Record placeHolderRecord = base.getRecordB(); SqlExecutionInterruptor interruptor = executionContext.getSqlExecutionInterruptor(); chain.clear(); while (base.hasNext()) { interruptor.checkInterrupted(); chain.put( baseRecord, base, placeHolderRecord, comparator ); } chainCursor.toTop(); }
Source:
public void _init() { final boolean isSc = model.getServerType() == WizardModel.ServerType.SONARCLOUD; final String sqOrSc = isSc ? "SonarCloud" : "SonarQube"; notificationsCheckBox.setText("Receive notifications from " + sqOrSc); notificationsCheckBox.setVisible(model.isNotificationsSupported()); notificationsCheckBox.setEnabled(model.isNotificationsSupported()); notificationsCheckBox.setSelected(!model.isNotificationsDisabled()); final String docUrl = isSc ? "<LINK_1>" : "<LINK_0>"; notificationsDetails.setText("You will receive <a href=\"" + docUrl + "\">notifications</a> from " + sqOrSc + " in situations like:\n" + "<ul>" + "<li>the Quality Gate status of a bound project changes</li>" + "<li>the latest analysis of a bound project on " + sqOrSc + " raises new issues assigned to you</li>" + "</ul>"); notificationsDetails.addHyperlinkListener(new BrowserHyperlinkListener()); notificationsDetails.setVisible(model.isNotificationsSupported()); }

Target:
public void _init() { final boolean isSc = model.getServerType() == WizardModel.ServerType.SONARCLOUD; final String sqOrSc = isSc ? "SonarCloud" : "SonarQube"; notificationsCheckBox.setText("Receive notifications from " + sqOrSc); notificationsCheckBox.setSelected(!model.isNotificationsDisabled()); final String docUrl = isSc ? "<LINK_1>" : "<LINK_0>"; notificationsDetails.setText("You will receive <a href=\"" + docUrl + "\">notifications</a> from " + sqOrSc + " in situations like:\n" + "<ul>" + "<li>the Quality Gate status of a bound project changes</li>" + "<li>the latest analysis of a bound project on " + sqOrSc + " raises new issues assigned to you</li>" + "</ul>"); notificationsDetails.addHyperlinkListener(new BrowserHyperlinkListener()); }
Source:
public void setStatus(String status) { this.status = GlusterHookStatus.valueOf(status); }

Target:
public void setStatus(String status) { if (status != null) { this.status = GlusterHookStatus.valueOf(status); } else { this.status = null; } }
Source:
public boolean visit(final DhcpEntryRules dhcp) throws ResourceUnavailableException { final VirtualRouter router = dhcp.getRouter(); final Commands commands = new Commands(Command.OnError.Stop); final NicVO nicVo = dhcp.getNicVo(); final UserVmVO userVM = dhcp.getUserVM(); final DeployDestination destination = dhcp.getDestination(); final boolean remove = dhcp.isRemove(); if (destination != null && router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) { _commandSetupHelper.createDhcpEntryCommand(router, userVM, nicVo, remove, commands); return _networkGeneralHelper.sendCommandsToRouter(router, commands); } return true; }

Target:
public boolean visit(final DhcpEntryRules dhcp) throws ResourceUnavailableException { final VirtualRouter router = dhcp.getRouter(); final Commands commands = new Commands(Command.OnError.Stop); final NicVO nicVo = dhcp.getNicVo(); final UserVmVO userVM = dhcp.getUserVM(); final DeployDestination destination = dhcp.getDestination(); final boolean remove = dhcp.isRemove(); if (router != null && (remove || (destination != null && destination.getPod() != null && router.getPodIdToDeployIn() != null && router.getPodIdToDeployIn().longValue() == destination.getPod().getId()))) { _commandSetupHelper.createDhcpEntryCommand(router, userVM, nicVo, remove, commands); return _networkGeneralHelper.sendCommandsToRouter(router, commands); } return true; }
Source:
private synchronized void saveAccounts() { if (accountFile == null) return; if (!accountFile.exists()) { try { accountFile.createNewFile(); } catch (IOException e) { LOG.error( "could not create file: " + accountFile.getAbsolutePath() + " to store account data"); return; } } ByteArrayOutputStream out = new ByteArrayOutputStream(); XStream xStream = createXStream(); FileOutputStream dataOut = null; try { dataOut = new FileOutputStream(accountFile); xStream.toXML(new ImmutablePair(activeAccount, accounts), out); byte[] encryptedAccountData = Crypto.encrypt(out.toByteArray(), secretKey); dataOut.write(encryptedAccountData); dataOut.flush(); } catch (RuntimeException e) { LOG.error("internal error while storing account data", e); return; } catch (Exception e) { LOG.error("could not store account data", e); return; } finally { IOUtils.closeQuietly(dataOut); } LOG.debug("saved " + accounts.size() + " account(s)"); }

Target:
private synchronized void saveAccounts() { if (accountFile == null) return; if (!accountFile.exists()) { try { accountFile.createNewFile(); } catch (IOException e) { LOG.error( "could not create file: " + accountFile.getAbsolutePath() + " to store account data"); return; } } ByteArrayOutputStream out = new ByteArrayOutputStream(); XStream xStream = createXStream(); FileOutputStream dataOut = null; try { dataOut = new FileOutputStream(accountFile); ArrayList<XMPPAccount> accountsToSave = new ArrayList<>(accounts); int activeAccountIndex = accountsToSave.indexOf(activeAccount); xStream.toXML(new AccountStoreInformation(activeAccountIndex, accountsToSave), out); byte[] encryptedAccountData = Crypto.encrypt(out.toByteArray(), secretKey); dataOut.write(encryptedAccountData); dataOut.flush(); } catch (RuntimeException e) { LOG.error("internal error while storing account data", e); return; } catch (Exception e) { LOG.error("could not store account data", e); return; } finally { IOUtils.closeQuietly(dataOut); } LOG.debug("saved " + accounts.size() + " account(s)"); }
Source:
public Command getCommand(Request request) { if (understandsRequest(request)) { EditPart editPart = getHost(); ResetOriginChangeModelOperation operation = null; if (editPart instanceof DiagramEditPart) { operation = new ResetOriginChangeModelOperation((DiagramEditPart) editPart); } else if (editPart instanceof AbstractDiagramContainerEditPart) { AbstractDiagramContainerEditPart adcp = (AbstractDiagramContainerEditPart) editPart; if (adcp.isRegionContainer()) { operation = new ResetOriginChangeModelOperation((AbstractDiagramContainerEditPart) editPart); } } if (operation != null) { ICommand command = CommandFactory.createICommand(((IGraphicalEditPart) editPart).getEditingDomain(), operation); return new ICommandProxy(command); } } return super.getCommand(request); }

Target:
public Command getCommand(Request request) { if (understandsRequest(request)) { EditPart editPart = getHost(); ResetOriginChangeModelOperation operation = null; if (editPart instanceof DiagramEditPart) { operation = new ResetOriginChangeModelOperation((DiagramEditPart) editPart); } else if (editPart instanceof AbstractDiagramContainerEditPart) { AbstractDiagramContainerEditPart adcp = (AbstractDiagramContainerEditPart) editPart; if (!adcp.isRegionContainer()) { operation = new ResetOriginChangeModelOperation((AbstractDiagramContainerEditPart) editPart); } } if (operation != null) { ICommand command = CommandFactory.createICommand(((IGraphicalEditPart) editPart).getEditingDomain(), operation); return new ICommandProxy(command); } } return super.getCommand(request); }
Source:
private String getJMSSubResourcePath(String subscriptionID, String topicName) { String resourcePath = this.topicStoragePath; topicName = topicName.replaceAll("\\.", "/"); if (!topicName.startsWith("/")) { resourcePath = resourcePath + "/"; } if (topicName.contains("*")) { topicName = topicName.substring(0, topicName.indexOf("*")); } else if (topicName.contains("#")) { topicName = topicName.substring(0, topicName.indexOf("#")); } resourcePath = resourcePath + topicName; if (!resourcePath.endsWith("/")) { resourcePath = resourcePath + "/"; } resourcePath = resourcePath + (EventBrokerConstants.EB_CONF_JMS_SUBSCRIPTION_COLLECTION_NAME + "/" + subscriptionID); return resourcePath; }

Target:
private String getJMSSubResourcePath(String subscriptionID, String topicName) { String resourcePath = this.topicStoragePath; topicName = topicName.replaceAll("\\.", RegistryConstants.PATH_SEPARATOR); if (!topicName.startsWith(RegistryConstants.PATH_SEPARATOR)) { resourcePath = resourcePath + RegistryConstants.PATH_SEPARATOR; } if (topicName.indexOf(STAR_WILDCARD) > -1) { topicName = topicName.substring(0, topicName.indexOf(STAR_WILDCARD)); } else if (topicName.indexOf(HASH_WILDCARD) > -1) { topicName = topicName.substring(0, topicName.indexOf(HASH_WILDCARD)); } resourcePath = resourcePath + topicName; if (!resourcePath.endsWith(RegistryConstants.PATH_SEPARATOR)) { resourcePath = resourcePath + RegistryConstants.PATH_SEPARATOR; } resourcePath = resourcePath + (EventBrokerConstants.EB_CONF_JMS_SUBSCRIPTION_COLLECTION_NAME + RegistryConstants.PATH_SEPARATOR + subscriptionID); return resourcePath; }
Source:
public void testGetBytes() { if (!StringUnsafe.canUse()) { return; } StringUnsafe stringUnsafe = StringUnsafe.getInstance(); assertThat(ByteBuffer.wrap(stringUnsafe.getByteArray("hello"))) .isEqualTo(StandardCharsets.ISO_8859_1.encode("hello")); if (System.getProperty("os.arch").equals("s390x")) assertThat(ByteBuffer.wrap(stringUnsafe.getByteArray("lambda λ"))) .isEqualTo(StandardCharsets.UTF_16BE.encode("lambda λ")); else assertThat(ByteBuffer.wrap(stringUnsafe.getByteArray("lambda λ"))) .isEqualTo(StandardCharsets.UTF_16LE.encode("lambda λ")); }

Target:
public void testGetBytes() { if (!StringUnsafe.canUse()) { return; } StringUnsafe stringUnsafe = StringUnsafe.getInstance(); assertThat(ByteBuffer.wrap(stringUnsafe.getByteArray("hello"))) .isEqualTo(StandardCharsets.ISO_8859_1.encode("hello")); if (ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN)) { assertThat(ByteBuffer.wrap(stringUnsafe.getByteArray("lambda λ"))) .isEqualTo(StandardCharsets.UTF_16BE.encode("lambda λ")); } else { assertThat(ByteBuffer.wrap(stringUnsafe.getByteArray("lambda λ"))) .isEqualTo(StandardCharsets.UTF_16LE.encode("lambda λ")); } }
Source:
private static void loadProperties() { if (errorStrings != null) { return; } try (InputStream fileInputStream = KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { errorStrings = new Properties(); errorStrings.load(fileInputStream); } catch (IOException ex) { ex.printStackTrace(); } }

Target:
private static synchronized void loadProperties() { if (errorStrings == null) { try (InputStream fileInputStream = KeyVaultErrorCodeStrings.class.getClassLoader().getResource((ERROR_STRINGS_FILE_NAME)).openStream()) { errorStrings = new Properties(); errorStrings.load(fileInputStream); } catch (IOException ex) { ex.printStackTrace(); } } }
Source:
public Optional<List<LockWatchEvent>> getFromVersion(long version) { long lastWrittenSequence = nextSequence - 1; if (versionInTheFuture(version, lastWrittenSequence) || versionTooOld(version, lastWrittenSequence)) { return Optional.empty(); } int startIndex = LongMath.mod(version + 1, maxSize); int windowSize = Ints.saturatedCast(lastWrittenSequence - version); List<LockWatchEvent> events = new ArrayList<>(windowSize); for (int i = startIndex; events.size() < windowSize; i = (i + 1) % maxSize) { events.add(buffer[i]); } return validateConsistencyOrReturnEmpty(version, events); }

Target:
public Optional<List<LockWatchEvent>> getFromVersion(long version) { long lastWrittenSequence = nextSequence - 1; if (versionInTheFuture(version, lastWrittenSequence) || versionTooOld(version, lastWrittenSequence)) { return Optional.empty(); } int startIndex = LongMath.mod(version + 1, maxSize); int windowSize = Ints.saturatedCast(lastWrittenSequence - version); List<LockWatchEvent> events = new ArrayList<>(windowSize); for (int i = startIndex; events.size() < windowSize; i = incrementAndMod(i)) { events.add(buffer[i]); } return validateConsistencyOrReturnEmpty(version, events); }
Source:
public boolean addAll(Jar to, Jar sub, Instruction filter, String destination) { boolean dupl = false; for (String name : sub.getResources() .keySet()) { if ("META-INF/MANIFEST.MF".equals(name)) continue; String parts[] = name.split("/"); if (doNotCopy(parts[parts.length - 1])) continue; if (filter == null || filter.matches(name) ^ filter.isNegated()) dupl |= to.putResource(Processor.appendPath(destination, name), sub.getResource(name), true); } return dupl; }

Target:
public boolean addAll(Jar to, Jar sub, Instruction filter, String destination) { boolean dupl = false; for (String name : sub.getResources() .keySet()) { if ("META-INF/MANIFEST.MF".equals(name)) continue; if (doNotCopy(Strings.getLastSegment(name, '/'))) continue; if (filter == null || filter.matches(name) ^ filter.isNegated()) dupl |= to.putResource(Processor.appendPath(destination, name), sub.getResource(name), true); } return dupl; }