auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void loadFromUrl(URL url, boolean force, ProcessContext processContext) { try { Watch watch = Watch.start(); if (loadFromUrl(url, force)) { processContext.addTiming(NLS.get("VirtualFile.fileDownloaded"), watch.elapsedMillis()); } else { processContext.addTiming(NLS.get("VirtualFile.fileDownloadSkipped"), watch.elapsedMillis()); } } catch (IOException e) { processContext.log(ProcessLog.error() .withNLSKey("#<N XXCS XM") .withContext("url", url.toString())); } }

Target:
public void loadFromUrl(URL url, boolean force, ProcessContext processContext) { try { Watch watch = Watch.start(); if (loadFromUrl(url, force)) { processContext.addTiming(NLS.get("VirtualFile.fileDownloaded"), watch.elapsedMillis()); } else { processContext.addTiming(NLS.get("VirtualFile.fileDownloadSkipped"), watch.elapsedMillis()); } } catch (IOException e) { processContext.log(ProcessLog.error() .withNLSKey("VirtualFile.downloadFailed") .withContext("url", url.toString())); } }
Source:
private static String getTemplateFromQuery(String template, String templateType) { SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient(); SrampClientQuery query = createQuery(client, template, templateType); QueryResultSet resultSet = null; try { resultSet = query.query(); } catch (SrampClientException e) { logger.error( Messages.i18n.format("NotificationResourceUtil.query.client.error", query.toString()), e); } catch (SrampAtomException e) { logger.error(Messages.i18n.format("NotificationResourceUtil.query.atom.error", query.toString()), e); } if (resultSet != null && resultSet.size() == 1) { ArtifactSummary artifactSummary = resultSet.get(0); InputStream is = null; try { is = client.getArtifactContent(artifactSummary); } catch (SrampClientException e) { logger.error(Messages.i18n.format( "NotificationResourceUtil.query.client.getArtifactContent.error", artifactSummary), e); } catch (SrampAtomException e) { logger.error(Messages.i18n.format( "NotificationResourceUtil.query.atom.getArtifactContent.error", artifactSummary), e); } if (is != null) { try { return IOUtils.toString(is); } catch (IOException e) { logger.error(Messages.i18n.format("NotificationResourceUtil.query.ioutils.to.string"), e); } } } else { logger.error(Messages.i18n.format("NotificationResourceUtil.query.no.result", template, templateType)); } return null; }

Target:
private static String getTemplateFromQuery(String template, String templateType) { SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient(); SrampClientQuery query = client.buildQuery("/s-ramp/ext/DtgovEmailTemplate[@template = ? and @template-type = ?]") .parameter(template).parameter(templateType); QueryResultSet resultSet = null; try { resultSet = query.query(); } catch (SrampClientException e) { logger.warn( Messages.i18n.format("NotificationResourceUtil.query.client.error", query.toString()), e); } catch (SrampAtomException e) { logger.warn(Messages.i18n.format("NotificationResourceUtil.query.atom.error", query.toString()), e); } if (resultSet != null && resultSet.size() == 1) { ArtifactSummary artifactSummary = resultSet.get(0); InputStream is = null; try { is = client.getArtifactContent(artifactSummary); } catch (SrampClientException e) { logger.warn(Messages.i18n.format( "NotificationResourceUtil.query.client.getArtifactContent.error", artifactSummary), e); } catch (SrampAtomException e) { logger.warn(Messages.i18n.format( "NotificationResourceUtil.query.atom.getArtifactContent.error", artifactSummary), e); } if (is != null) { try { return IOUtils.toString(is); } catch (IOException e) { logger.warn(Messages.i18n.format("NotificationResourceUtil.query.ioutils.to.string"), e); } } } else { logger.warn(Messages.i18n.format("NotificationResourceUtil.query.no.result", template, templateType)); } return null; }
Source:
public void exitQuery(@NotNull final se.tre.freki.query.SelectParser.QueryContext ctx) { super.exitQuery(ctx); try { predicateBuilder.metric(metric.get()); } catch (ExecutionException e) { throw new QueryException("Error while fetching metric", e); } catch (InterruptedException e) { throw new QueryException("Interrupted while waiting for metric", e); } List<TimeSeriesIdPredicate> predicateList; try { predicateList = allAsList(futurePredicateList).get(); } catch (InterruptedException e) { throw new QueryException("Interrupted while waiting for tags", e); } catch (ExecutionException e) { throw new QueryException("Error while fetching tags", e); } for (int i = 0; i < predicateList.size() / 2; i++) { final TimeSeriesIdPredicate key = predicateList.get(i * 2); final TimeSeriesIdPredicate value = predicateList.get(i * 2 + 1); if (operatorList.get(i)) { predicateBuilder.addTagPredicate(TimeSeriesTagPredicate.eq(key, value)); } else { predicateBuilder.addTagPredicate(TimeSeriesTagPredicate.neq(key, value)); } } final TimeSeriesQueryPredicate predicate = predicateBuilder.build(); query = queryBuilder.predicate(predicate).build(); }

Target:
public void exitQuery(@NotNull final se.tre.freki.query.SelectParser.QueryContext ctx) { super.exitQuery(ctx); try { predicateBuilder.metric(metric.get()); } catch (ExecutionException e) { throw new QueryException("Error while fetching metric", e); } catch (InterruptedException e) { throw new QueryException("Interrupted while waiting for metric", e); } List<TimeSeriesIdPredicate> predicateList; try { predicateList = allAsList(futurePredicateList).get(); } catch (InterruptedException e) { throw new QueryException("Interrupted while waiting for tags", e); } catch (ExecutionException e) { throw new QueryException("Error while fetching tags", e); } final Iterator<TimeSeriesIdPredicate> predicateIterator = predicateList.iterator(); final Iterator<Boolean> operatorIterator = operatorList.iterator(); while (predicateIterator.hasNext()) { final TimeSeriesIdPredicate key = predicateIterator.next(); final TimeSeriesIdPredicate value = predicateIterator.next(); final boolean operator = operatorIterator.next(); if (operator) { predicateBuilder.addTagPredicate(TimeSeriesTagPredicate.eq(key, value)); } else { predicateBuilder.addTagPredicate(TimeSeriesTagPredicate.neq(key, value)); } } final TimeSeriesQueryPredicate predicate = predicateBuilder.build(); query = queryBuilder.predicate(predicate).build(); }
Source:
protected Object receive(String queue, boolean expectNull) throws Exception { RedisTemplate<String, Object> template = createTemplate(); byte[] bytes = (byte[]) template.boundListOps("queue." + queue).rightPop(); if (bytes == null) { return null; } ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); int headerCount = byteBuffer.get(); for (int i = 0; i < headerCount; i++) { int len = byteBuffer.get(); byteBuffer.position(byteBuffer.position() + len); len = byteBuffer.get(); byteBuffer.position(byteBuffer.position() + len); } return new String(bytes, byteBuffer.position(), byteBuffer.remaining(), "UTF-8"); }

Target:
protected Object receive(String queue, boolean expectNull) throws Exception { RedisTemplate<String, Object> template = createTemplate(); byte[] bytes = (byte[]) template.boundListOps("queue." + queue).rightPop(50, TimeUnit.MILLISECONDS); if (bytes == null) { return null; } ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); int headerCount = byteBuffer.get(); for (int i = 0; i < headerCount; i++) { int len = byteBuffer.get(); byteBuffer.position(byteBuffer.position() + len); len = byteBuffer.get(); byteBuffer.position(byteBuffer.position() + len); } return new String(bytes, byteBuffer.position(), byteBuffer.remaining(), "UTF-8"); }
Source:
public final byte[] getCompressedMessage() { return compressedMessage; }

Target:
public final byte[] getCompressedMessage() { return compressedMessage.clone(); }
Source:
public ExternalImage(String id, IModel<Serializable> srcModel) { this(id, srcModel, (IModel<List<Serializable>>)null); }

Target:
public ExternalImage(String id, IModel<Serializable> srcModel) { this(id, srcModel, Model.ofList(Collections.<Serializable> emptyList())); }
Source:
private void setEmptyValidMongoOnlyWithIntentResult(){ jsonConfig = "{\"mongo\":{}"; fakeActivityResult(); }

Target:
private void setEmptyValidMongoOnlyWithIntentResult(){ jsonConfig = "{'mongo':{}}"; fakeActivityResult(); }
Source:
public void initialContentShouldEndUpInSecondBackupFileAfterTwoBackupRuns() throws IOException { String contentOne = "Test One."; final int kNumberOfBackups = 2; Process process = new Process(); process.setId(2); process.setProcessBaseUri(URI.create("2")); URI resolve = fileService.createResource(processService.getProcessDataDirectory(process), BACKUP_FILE_NAME); writeFile(resolve, contentOne); runBackup(kNumberOfBackups, process); assertFileHasContent(processService.getProcessDataDirectory(process) + "/" + BACKUP_FILE_NAME + ".1", contentOne); fileService.createResource(processService.getProcessDataDirectory(process), BACKUP_FILE_NAME); runBackup(kNumberOfBackups, process); assertFileHasContent(processService.getProcessDataDirectory(process) + "/" + BACKUP_FILE_NAME + ".2", contentOne); }

Target:
public void initialContentShouldEndUpInSecondBackupFileAfterTwoBackupRuns() throws IOException { String contentOne = "Test One."; final int numberOfBackups = 2; Process process = new Process(); process.setId(2); process.setProcessBaseUri(URI.create("2")); URI resolve = fileService.createResource(processService.getProcessDataDirectory(process), BACKUP_FILE_NAME); writeFile(resolve, contentOne); runBackup(numberOfBackups, process); assertFileHasContent(processService.getProcessDataDirectory(process) + "/" + BACKUP_FILE_NAME + ".1", contentOne); fileService.createResource(processService.getProcessDataDirectory(process), BACKUP_FILE_NAME); runBackup(numberOfBackups, process); assertFileHasContent(processService.getProcessDataDirectory(process) + "/" + BACKUP_FILE_NAME + ".2", contentOne); }
Source:
public int hashCode() { int h = 0; h = h * 31 + aId.hashCode(); h = h * 31 + bId.hashCode(); h = h * 31 + ignoreWhitespace.hashCode(); return h; }

Target:
public int hashCode() { int h = 0; h = h * 31 + aId.hashCode(); h = h * 31 + bId.hashCode(); h = h * 31 + (ignoreWhitespace ? 1 : 0); return h; }
Source:
private LogicalPlan tryApplyRules(LogicalPlan plan) { LogicalPlan node = plan; boolean done = false; while (!done) { done = true; for (Rule rule : rules) { Match match = rule.pattern().accept(node, Captures.empty()); if (match.isPresent()) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Rule '" + rule.getClass().getName() + "' matched"); } @SuppressWarnings("unchecked") LogicalPlan transformedPlan = rule.apply(match.value(), match.captures()); if (transformedPlan != null) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Rule '" + rule.getClass().getName() + "' transformed the logical plan"); } node = transformedPlan; done = false; } } } } return node; }

Target:
private LogicalPlan tryApplyRules(LogicalPlan plan) { final boolean isTraceEnabled = LOGGER.isTraceEnabled(); LogicalPlan node = plan; boolean done = false; while (!done) { done = true; for (Rule rule : rules) { Match match = rule.pattern().accept(node, Captures.empty()); if (match.isPresent()) { if (isTraceEnabled) { LOGGER.trace("Rule '" + rule.getClass().getName() + "' matched"); } @SuppressWarnings("unchecked") LogicalPlan transformedPlan = rule.apply(match.value(), match.captures()); if (transformedPlan != null) { if (isTraceEnabled) { LOGGER.trace("Rule '" + rule.getClass().getName() + "' transformed the logical plan"); } node = transformedPlan; done = false; } } } } return node; }
Source:
protected boolean processNonDuplicateVendorDetail(PaymentWorksVendor paymentWorksVendor, StringBuffer documentNumbers, VendorDetail oldVendor, VendorDetail newVendor) { boolean isRouted; VendorDetail vendorDetail = new PaymentWorksVendorUpdateConversionUtil().createVendorDetailForEdit(newVendor, oldVendor, paymentWorksVendor); try { MaintenanceDocument vendorMaintDoc = buildVendorMaintenanceDocument(paymentWorksVendor, oldVendor, vendorDetail); boolean isVendorLocked = checkForLockingDocument(vendorMaintDoc); if (!isVendorLocked) { isRouted = processUnlockedVendorMaintenanceDocument(documentNumbers, vendorMaintDoc); } else { LOG.error("Failed to route Vendor Edit document due to lock"); GlobalVariables.getMessageMap().putError("vendorDetail", KFSKeyConstants.ERROR_CUSTOM, "Failed to route Vendor Edit document due to lock"); isRouted = false; } } catch (Exception e) { LOG.error("Failed to route Vendor document due to error(s): " + e.getMessage()); isRouted = false; } return isRouted; }

Target:
protected boolean processNonDuplicateVendorDetail(PaymentWorksVendor paymentWorksVendor, StringBuffer documentNumbers, VendorDetail oldVendor, VendorDetail newVendor) { boolean routed = false; VendorDetail vendorDetail = new PaymentWorksVendorUpdateConversionUtil().createVendorDetailForEdit(newVendor, oldVendor, paymentWorksVendor); try { MaintenanceDocument vendorMaintDoc = buildVendorMaintenanceDocument(paymentWorksVendor, oldVendor, vendorDetail); if (!checkForLockingDocument(vendorMaintDoc)) { routed = processUnlockedVendorMaintenanceDocument(documentNumbers, vendorMaintDoc); } else { LOG.error("Failed to route Vendor Edit document due to lock"); GlobalVariables.getMessageMap().putError("vendorDetail", KFSKeyConstants.ERROR_CUSTOM, "Failed to route Vendor Edit document due to lock"); } } catch (Exception e) { LOG.error("Failed to route Vendor document due to error(s): " + e.getMessage()); } return routed; }
Source:
public ActiveResourceManager( ResourceManagerDriver<WorkerType> resourceManagerDriver, Configuration flinkConfig, RpcService rpcService, ResourceID resourceId, HighAvailabilityServices highAvailabilityServices, HeartbeatServices heartbeatServices, SlotManager slotManager, ResourceManagerPartitionTrackerFactory clusterPartitionTrackerFactory, JobLeaderIdService jobLeaderIdService, ClusterInformation clusterInformation, FatalErrorHandler fatalErrorHandler, ResourceManagerMetricGroup resourceManagerMetricGroup) { super( rpcService, resourceId, highAvailabilityServices, heartbeatServices, slotManager, clusterPartitionTrackerFactory, jobLeaderIdService, clusterInformation, fatalErrorHandler, resourceManagerMetricGroup, AkkaUtils.getTimeoutAsTime(Preconditions.checkNotNull(flinkConfig))); this.flinkConfig = flinkConfig; this.resourceManagerDriver = Preconditions.checkNotNull(resourceManagerDriver); this.workerNodeMap = new HashMap<>(); this.pendingWorkerCounter = new PendingWorkerCounter(); this.currentAttemptUnregisteredWorkers = new HashMap<>(); }

Target:
public ActiveResourceManager( ResourceManagerDriver<WorkerType> resourceManagerDriver, Configuration flinkConfig, RpcService rpcService, ResourceID resourceId, HighAvailabilityServices highAvailabilityServices, HeartbeatServices heartbeatServices, SlotManager slotManager, ResourceManagerPartitionTrackerFactory clusterPartitionTrackerFactory, JobLeaderIdService jobLeaderIdService, ClusterInformation clusterInformation, FatalErrorHandler fatalErrorHandler, ResourceManagerMetricGroup resourceManagerMetricGroup) { super( rpcService, resourceId, highAvailabilityServices, heartbeatServices, slotManager, clusterPartitionTrackerFactory, jobLeaderIdService, clusterInformation, fatalErrorHandler, resourceManagerMetricGroup, AkkaUtils.getTimeoutAsTime(Preconditions.checkNotNull(flinkConfig))); this.flinkConfig = flinkConfig; this.resourceManagerDriver = resourceManagerDriver; this.workerNodeMap = new HashMap<>(); this.pendingWorkerCounter = new PendingWorkerCounter(); this.currentAttemptUnregisteredWorkers = new HashMap<>(); }
Source:
public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.contribution_activity_notification_menu, menu); if (!isThereUnreadNotifications) { menu.findItem(R.id.notifications).setIcon(ContextCompat.getDrawable(this, R.drawable.ic_notification_white_clip_art)); } else { final View notification=menu.findItem(R.id.notifications).getActionView(); txtViewCount=notification.findViewById(R.id.notification_count_badge); txtViewCount.setText(String.valueOf(1)); } this.menu = menu; updateMenuItem(); return true; }

Target:
public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.contribution_activity_notification_menu, menu); notificationsMenuItem = menu.findItem(R.id.notifications); final View notification = notificationsMenuItem.getActionView(); notificationCount = notification.findViewById(R.id.notification_count_badge); notification.setOnClickListener(view -> NotificationActivity.startYourself(MainActivity.this)); this.menu = menu; updateMenuItem(); setNotificationCount(); return true; }
Source:
public Long getTimestamp(MessageAndMetadata<byte[], byte[]> kafkaMessage) { return null; }

Target:
public long getTimestamp(MessageAndMetadata<byte[], byte[]> kafkaMessage) { return 0l; }
Source:
private void waitMoveTasksToFinish(ExecutorService moveRegionsPool, List<Future<Boolean>> taskList, long timeoutInSeconds) throws Exception { try { if (!moveRegionsPool.awaitTermination(timeoutInSeconds, TimeUnit.SECONDS)) { moveRegionsPool.shutdownNow(); } } catch (InterruptedException e) { moveRegionsPool.shutdownNow(); Thread.currentThread().interrupt(); } for (Future<Boolean> future : taskList) { try { if (!future.get(5, TimeUnit.SECONDS)) { LOG.error("Was Not able to move region....Exiting Now"); throw new Exception("Could not move region Exception"); } } catch (InterruptedException e) { LOG.error("Interrupted while waiting for Thread to Complete " + e.getMessage(), e); throw e; } catch (ExecutionException e) { if (e.getCause() instanceof UnknownRegionException) { LOG.debug("Ignore unknown region, it might have been split/merged."); } else { LOG.error("Got Exception From Thread While moving region {}", e.getMessage(), e); throw e; } } catch (CancellationException e) { LOG.error("Thread for moving region cancelled. Timeout for cancellation:" + timeoutInSeconds + "secs", e); throw e; } } }

Target:
private void waitMoveTasksToFinish(ExecutorService moveRegionsPool, List<Future<Boolean>> taskList, long timeoutInSeconds) throws Exception { try { if (!moveRegionsPool.awaitTermination(timeoutInSeconds, TimeUnit.SECONDS)) { moveRegionsPool.shutdownNow(); } } catch (InterruptedException e) { moveRegionsPool.shutdownNow(); Thread.currentThread().interrupt(); } for (Future<Boolean> future : taskList) { try { if (!future.get(5, TimeUnit.SECONDS)) { LOG.error("Was Not able to move region....Exiting Now"); throw new Exception("Could not move region Exception"); } } catch (InterruptedException e) { LOG.error("Interrupted while waiting for Thread to Complete " + e.getMessage(), e); throw e; } catch (ExecutionException e) { boolean ignoreFailure = ignoreRegionMoveFailure(e); if (ignoreFailure) { LOG.debug("Ignore region move failure, it might have been split/merged.", e); } else { LOG.error("Got Exception From Thread While moving region {}", e.getMessage(), e); throw e; } } catch (CancellationException e) { LOG.error("Thread for moving region cancelled. Timeout for cancellation:" + timeoutInSeconds + "secs", e); throw e; } } }
Source:
protected void executeQueryCommand() { List<Disk> diskList = DbFacade.getInstance() .getDiskDao() .getAllAttachableDisksByPoolId(getParameters().getStoragePoolId(), getParameters().getVmId(), getUserID(), getParameters().isFiltered()); ArrayList<Disk> filteredDiskList = new ArrayList<Disk>(); VM vm = DbFacade.getInstance().getVmDao().get(getParameters().getVmId()); List<String> supportedDiskInterfaceNames = getOsRepository().getDiskInterfaces(vm.getOs(), vm.getVdsGroupCompatibilityVersion()); List<DiskInterface> supportedDiskInterfaces = new ArrayList<DiskInterface>(); for (String interfaceName : supportedDiskInterfaceNames) { try { supportedDiskInterfaces.add(DiskInterface.valueOf(interfaceName)); } catch (IllegalArgumentException e) { } } for (Disk disk : diskList) { if (supportedDiskInterfaces.contains(disk.getDiskInterface())) { filteredDiskList.add(disk); } } setReturnValue(filteredDiskList); }

Target:
protected void executeQueryCommand() { List<Disk> diskList = DbFacade.getInstance() .getDiskDao() .getAllAttachableDisksByPoolId(getParameters().getStoragePoolId(), getParameters().getVmId(), getUserID(), getParameters().isFiltered()); if (diskList == null || diskList.isEmpty()) { setReturnValue(Collections.emptyList()); return; } ArrayList<Disk> filteredDiskList = new ArrayList<Disk>(); VM vm = DbFacade.getInstance().getVmDao().get(getParameters().getVmId(), getUserID(), getParameters().isFiltered()); if (vm == null) { setReturnValue(Collections.emptyList()); return; } List<String> supportedDiskInterfaceNames = getOsRepository().getDiskInterfaces(vm.getOs(), vm.getVdsGroupCompatibilityVersion()); HashSet<DiskInterface> supportedDiskInterfaces = new HashSet<DiskInterface>(); for (String interfaceName : supportedDiskInterfaceNames) { try { supportedDiskInterfaces.add(DiskInterface.valueOf(interfaceName)); } catch (IllegalArgumentException e) { LOG.errorFormat("Can't find the value {0} in the enum DiskInterface. Error: {1}", ((interfaceName == null) ? "null" : interfaceName), e.toString()); } } for (Disk disk : diskList) { if (supportedDiskInterfaces.contains(disk.getDiskInterface())) { filteredDiskList.add(disk); } } setReturnValue(filteredDiskList); }
Source:
public void addUnspentTransactionOutput(StoredTransactionOutput out) throws BlockStoreException { maybeConnect(); PreparedStatement s = null; String dbAddress = ""; int type = 0; Script outputScript = null; try { outputScript = new Script(out.getScriptBytes()); } catch (ScriptException e) { log.info("Could not parse script for output: " + out.getHash().toString()); } if (outputScript != null && (outputScript.isSentToAddress() || outputScript.isSentToRawPubKey() || outputScript.isPayToScriptHash())) { if (outputScript.isSentToAddress()) { Address targetAddr = new Address(params, outputScript.getPubKeyHash()); dbAddress = targetAddr.toString(); type = 1; } else if (outputScript.isSentToRawPubKey()) { dbAddress = outputScript.getFromAddress(params).toString(); type = 2; } else { dbAddress = Address.fromP2SHHash(params, outputScript.getPubKeyHash()).toString(); type = 3; } } try { s = conn.get().prepareStatement(getInsertOpenoutputsSQL()); s.setBytes(1, out.getHash().getBytes()); s.setInt(2, (int) out.getIndex()); s.setInt(3, out.getHeight()); s.setBytes(4, BigInteger.valueOf(out.getValue().value).toByteArray()); s.setBytes(5, out.getScriptBytes()); s.setString(6, dbAddress); s.setInt(7, type); s.executeUpdate(); s.close(); } catch (SQLException e) { if (!(e.getSQLState().equals(getDuplicateKeyErrorCode()))) throw new BlockStoreException(e); } finally { if (s != null) try { s.close(); } catch (SQLException e) { throw new BlockStoreException(e); } } }

Target:
public void addUnspentTransactionOutput(StoredTransactionOutput out) throws BlockStoreException { maybeConnect(); PreparedStatement s = null; String dbAddress = ""; int type = 0; Script outputScript = null; try { outputScript = new Script(out.getScriptBytes()); } catch (ScriptException e) { log.info("Could not parse script for output: " + out.getHash().toString()); } if (outputScript != null && (outputScript.isSentToAddress() || outputScript.isSentToRawPubKey() || outputScript.isPayToScriptHash())) { if (outputScript.isSentToAddress()) { Address targetAddr = new Address(params, outputScript.getPubKeyHash()); dbAddress = targetAddr.toString(); type = 1; } else if (outputScript.isSentToRawPubKey()) { dbAddress = outputScript.getFromAddress(params).toString(); type = 2; } else { dbAddress = Address.fromP2SHHash(params, outputScript.getPubKeyHash()).toString(); type = 3; } } try { s = conn.get().prepareStatement(getInsertOpenoutputsSQL()); s.setBytes(1, out.getHash().getBytes()); s.setInt(2, (int) out.getIndex()); s.setInt(3, out.getHeight()); s.setLong(4, out.getValue().value); s.setBytes(5, out.getScriptBytes()); s.setString(6, dbAddress); s.setInt(7, type); s.setBoolean(8, out.isCoinbase()); s.executeUpdate(); s.close(); } catch (SQLException e) { if (!(e.getSQLState().equals(getDuplicateKeyErrorCode()))) throw new BlockStoreException(e); } finally { if (s != null) { try { s.close(); } catch (SQLException e) { throw new BlockStoreException(e); } } } }
Source:
public RequestTemplate create(Object[] argv) { RequestTemplate mutable = new RequestTemplate(metadata.template()); if (metadata.urlIndex() != null) { int urlIndex = metadata.urlIndex(); checkArgument(argv[urlIndex] != null, "URI parameter %s was null", urlIndex); mutable.insert(0, String.valueOf(argv[urlIndex])); } Map<String, Object> varBuilder = new LinkedHashMap<String, Object>(); for (Entry<Integer, Collection<String>> entry : metadata.indexToName().entrySet()) { int i = entry.getKey(); Object value = argv[entry.getKey()]; if (value != null) { if (indexToExpander.containsKey(i)) { value = indexToExpander.get(i).expand(value); } for (String name : entry.getValue()) { varBuilder.put(name, value); } } } RequestTemplate template = resolve(argv, mutable, varBuilder); return addQueryMapQueryParameters(argv, template); }

Target:
public RequestTemplate create(Object[] argv) { RequestTemplate mutable = new RequestTemplate(metadata.template()); if (metadata.urlIndex() != null) { int urlIndex = metadata.urlIndex(); checkArgument(argv[urlIndex] != null, "URI parameter %s was null", urlIndex); mutable.insert(0, String.valueOf(argv[urlIndex])); } Map<String, Object> varBuilder = new LinkedHashMap<String, Object>(); for (Entry<Integer, Collection<String>> entry : metadata.indexToName().entrySet()) { int i = entry.getKey(); Object value = argv[entry.getKey()]; if (value != null) { if (indexToExpander.containsKey(i)) { value = indexToExpander.get(i).expand(value); } for (String name : entry.getValue()) { varBuilder.put(name, value); } } } RequestTemplate template = resolve(argv, mutable, varBuilder); if (metadata.queryMapIndex() != null) { template = addQueryMapQueryParameters(argv, template); } return template; }
Source:
public boolean perform(AbstractBuild<?, ?> build, BuildListener listener, long effectiveTimeout) { long effectiveTimeoutMinutes = MINUTES.convert(effectiveTimeout,MILLISECONDS); listener.getLogger().println(hudson.plugins.build_timeout.Messages.Timeout_Message( effectiveTimeoutMinutes, hudson.plugins.build_timeout.Messages.Timeout_Aborted()) ); Executor e = build.getExecutor(); if (e != null) { e.interrupt(Result.ABORTED); } build.setResult(Result.ABORTED); return true; }

Target:
public boolean perform(AbstractBuild<?, ?> build, BuildListener listener, long effectiveTimeout) { long effectiveTimeoutMinutes = MINUTES.convert(effectiveTimeout,MILLISECONDS); listener.getLogger().println(hudson.plugins.build_timeout.Messages.Timeout_Message( effectiveTimeoutMinutes, hudson.plugins.build_timeout.Messages.Timeout_Aborted()) ); Executor e = build.getExecutor(); if (e != null) { e.interrupt(Result.ABORTED); } return true; }
Source:
private String extractDefinitionLine(String typeDeclaration) { String typeLine = ""; String[] lines = typeDeclaration.split("\n"); for (String line : lines) { typeLine = typeLine + "\n" + line; if (line.contains("{")) { break; } } return typeLine; }

Target:
private String extractDefinitionLine(String typeDeclaration) { String typeLine = ""; String[] lines = typeDeclaration.split("\n"); for (String line : lines) { typeLine = line; if (line.contains("{")) { break; } } return typeLine; }
Source:
void process() throws Exception { processCount.inc(); if (receiveBuffer == null) { logger.warning("No receiving buffer configured. Skipping inbound processing."); return; } lastReadTime = currentTimeMillis(); int readBytes = socketChannel.read(receiveBuffer); if (readBytes == -1) { throw new EOFException("Remote socket closed!"); } bytesRead.inc(readBytes); InboundHandler[] localHandlers = handlers; boolean cleanPipeline; boolean unregisterRead; do { cleanPipeline = true; unregisterRead = false; for (int handlerIndex = 0; handlerIndex < localHandlers.length; handlerIndex++) { InboundHandler handler = localHandlers[handlerIndex]; HandlerStatus handlerStatus = handler.onRead(); if (localHandlers != handlers) { handlerIndex = -1; localHandlers = handlers; continue; } switch (handlerStatus) { case CLEAN: break; case DIRTY: cleanPipeline = false; break; case BLOCKED: cleanPipeline = true; unregisterRead = true; break; default: throw new IllegalStateException(); } } } while (!cleanPipeline); if (unregisterRead) { unregisterOp(OP_READ); } }

Target:
void process() throws Exception { processCount.inc(); lastReadTime = currentTimeMillis(); int readBytes = socketChannel.read(receiveBuffer); if (readBytes == -1) { throw new EOFException("Remote socket closed!"); } bytesRead.inc(readBytes); InboundHandler[] localHandlers = handlers; boolean cleanPipeline; boolean unregisterRead; do { cleanPipeline = true; unregisterRead = false; for (int handlerIndex = 0; handlerIndex < localHandlers.length; handlerIndex++) { InboundHandler handler = localHandlers[handlerIndex]; HandlerStatus handlerStatus = handler.onRead(); if (localHandlers != handlers) { handlerIndex = -1; localHandlers = handlers; continue; } switch (handlerStatus) { case CLEAN: break; case DIRTY: cleanPipeline = false; break; case BLOCKED: cleanPipeline = true; unregisterRead = true; break; default: throw new IllegalStateException(); } } } while (!cleanPipeline); if (unregisterRead) { unregisterOp(OP_READ); } }
Source:
public Iterable<Rule> getRules(TriggerTypes triggerType, String channel, String event) { List<Rule> result = Lists.newArrayList(); switch (triggerType) { case TRIGGER: Set<Rule> rules = triggerEventTriggeredRules.get(channel); if (rules == null) { return Collections.emptyList(); } for (Rule rule : rules) { for (EventTrigger t : rule.getEventtrigger()) { if (t instanceof EventEmittedTrigger) { EventEmittedTrigger et = (EventEmittedTrigger) t; if (et.getChannel().equals(channel)) { if (et.getTrigger() == null) { result.add(rule); } else if ((et.getTrigger() != null && et.getTrigger().equals(event))) { result.add(rule); } } } } } break; default: return Collections.emptyList(); } return result; }

Target:
public Iterable<Rule> getRules(TriggerTypes triggerType, String channel, String event) { List<Rule> result = Lists.newArrayList(); switch (triggerType) { case TRIGGER: Set<Rule> rules = triggerEventTriggeredRules.get(channel); if (rules == null) { return Collections.emptyList(); } for (Rule rule : rules) { for (EventTrigger t : rule.getEventtrigger()) { if (t instanceof EventEmittedTrigger) { EventEmittedTrigger et = (EventEmittedTrigger) t; if (et.getChannel().equals(channel) && (et.getTrigger() == null || et.getTrigger().equals(event))) { result.add(rule); } } } } break; default: return Collections.emptyList(); } return result; }
Source:
public void checkRenderHeader() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Arrays.asList(ROW_HEIGHT, ROW_HEIGHT * 2, ROW_HEIGHT * 3)); final GridHeaderRenderContext context = mock(GridHeaderRenderContext.class); doReturn(model.getColumns()).when(context).getAllColumns(); doReturn(model.getColumns()).when(context).getBlockColumns(); final List<RendererCommand> commands = renderer.renderHeader(model, context, rendererHelper, ri); assertThat(commands).isNotNull(); assertThat(commands).asList().hasSize(2); assertRenderingCommands(commands, RenderHeaderBackgroundCommand.class, RenderHeaderGridLinesCommand.class); verify(columnRenderer).renderHeader(anyList(), any(GridHeaderColumnRenderContext.class), eq(ri)); final ArgumentCaptor<Rectangle> rectangleCaptor = ArgumentCaptor.forClass(Rectangle.class); final Group parent = mock(Group.class); commands.stream().filter(c -> c instanceof RenderHeaderBackgroundCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(rectangleCaptor.capture()); assertRenderedRectangle(rectangleCaptor.getValue(), column.getWidth(), BaseGridWidgetRenderingTestUtils.HEADER_HEIGHT); reset(parent); final ArgumentCaptor<Line> lineCaptor = ArgumentCaptor.forClass(Line.class); commands.stream().filter(c -> c instanceof RenderHeaderGridLinesCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(lineCaptor.capture()); final Line line = lineCaptor.getValue(); assertEquals(column.getWidth(), line.getBoundingBox().getWidth(), 0.5); }

Target:
public void checkRenderHeader() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Arrays.asList(0d, ROW_HEIGHT, ROW_HEIGHT * 2)); final GridHeaderRenderContext context = mock(GridHeaderRenderContext.class); doReturn(model.getColumns()).when(context).getAllColumns(); doReturn(model.getColumns()).when(context).getBlockColumns(); final List<RendererCommand> commands = renderer.renderHeader(model, context, rendererHelper, ri); assertThat(commands).isNotNull(); assertThat(commands).asList().hasSize(2); assertRenderingCommands(commands, RenderHeaderBackgroundCommand.class, RenderHeaderGridLinesCommand.class); verify(columnRenderer).renderHeader(anyList(), any(GridHeaderColumnRenderContext.class), eq(ri)); final ArgumentCaptor<Rectangle> rectangleCaptor = ArgumentCaptor.forClass(Rectangle.class); final Group parent = mock(Group.class); commands.stream().filter(c -> c instanceof RenderHeaderBackgroundCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(rectangleCaptor.capture()); assertRenderedRectangle(rectangleCaptor.getValue(), column.getWidth(), BaseGridWidgetRenderingTestUtils.HEADER_HEIGHT); reset(parent); final ArgumentCaptor<Line> lineCaptor = ArgumentCaptor.forClass(Line.class); commands.stream().filter(c -> c instanceof RenderHeaderGridLinesCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(lineCaptor.capture()); final Line line = lineCaptor.getValue(); assertEquals(column.getWidth(), line.getBoundingBox().getWidth(), 0.5); }
Source:
public BinaryContent transform(Metacard metacard, Map<String, Serializable> arguments) throws CatalogTransformerException { if (metacard == null) { throw new CatalogTransformerException("Null metacard cannot be transformed into RTF"); } ByteArrayInputStream rtfStream = Optional.of(metacard).map(this::toRtf).map(this::rtfStringToInputStream).orElse(null); return asBinaryContent(rtfStream); }

Target:
public BinaryContent transform(Metacard metacard, Map<String, Serializable> arguments) throws CatalogTransformerException { if (metacard == null) { throw new CatalogTransformerException("Null metacard cannot be transformed into RTF"); } ByteArrayInputStream rtfStream = Optional.of(metacard) .map(this::toRtf) .map(this::rtfStringToInputStream) .orElseThrow(this::emptyRtfException); return new BinaryContentImpl(rtfStream, mimeType); }
Source:
public File getLastContextScreenshot() { List<File> screenshots = currentContextScreenshots.get(); return screenshots == null || screenshots.isEmpty() ? null : screenshots.get(screenshots.size() - 1); }

Target:
public Optional<File> getLastContextScreenshot() { List<File> screenshots = currentContextScreenshots.get(); return getLastScreenshot(screenshots); }
Source:
} catch (MimeTypeParseException e) { LOGGER.warn("Failure creating MIME type", e); throw new ExceptionInInitializerError(e); }

Target:
} catch (MimeTypeParseException e) { throw new ExceptionInInitializerError(e); }
Source:
private boolean isAttributeAvailable(String attributeName, Iterable<String> attributeNames) { if (attributeName == null || Iterables.contains(attributeNames, attributeName)) { return true; } return false; }

Target:
private boolean isAttributeAvailable(String attributeName, Iterable<String> attributeNames) { return (attributeName == null || Iterables.contains(attributeNames, attributeName)); }
Source:
public String getFilePath() { switch (m_option) { case PLAIN: case BATCH: return m_file.getPath(); case INLINEBATCH: default: String filePath = (m_context == null) ? "no file" : m_context.getFilePath(); assert(m_option == FileOption.INLINEBATCH); return "(inline batch delimited by '" + m_delimiter + "' in " + filePath + ")"; } }

Target:
public String getFilePath() { switch (m_option) { case PLAIN: case BATCH: return m_file.getPath(); case INLINEBATCH: default: String filePath = (m_context == null) ? "AdHoc DDL Input" : m_context.getFilePath(); assert(m_option == FileOption.INLINEBATCH); return "(inline batch delimited by '" + m_delimiter + "' in " + filePath + ")"; } }
Source:
public void start(final ServiceConfiguration<?> config, final ServiceProvider serviceProvider) { this.serviceLocator = (ServiceLocator)serviceProvider; }

Target:
public void start(final ServiceConfiguration<?> config, final ServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; }
Source:
private String scriptLauncherCmd(ShellController c, FilePath ws, String interpreter, String scriptPath, String cookieValue, String cookieVariable) throws IOException, InterruptedException { String cmd; FilePath logFile = c.getLogFile(ws); FilePath resultFile = c.getResultFile(ws); FilePath controlDir = c.controlDir(ws); if (capturingOutput) { cmd = String.format("pid=$$; { while [ \\( -d /proc/$pid -o \\! -d /proc/$$ \\) -a -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2> '%s'; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, c.getOutputFile(ws), logFile, resultFile, resultFile, resultFile); } else { cmd = String.format("pid=$$; { while [ \\( -d /proc/$pid -o \\! -d /proc/$$ \\) -a -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2>&1; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, logFile, resultFile, resultFile, resultFile); } return cmd; }

Target:
private String scriptLauncherCmd(ShellController c, FilePath ws, String interpreter, String scriptPath, String cookieValue, String cookieVariable) throws IOException, InterruptedException { String cmd; FilePath logFile = c.getLogFile(ws); FilePath resultFile = c.getResultFile(ws); FilePath controlDir = c.controlDir(ws); if (capturingOutput) { cmd = String.format("{ while [ -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2> '%s'; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, c.getOutputFile(ws), logFile, resultFile, resultFile, resultFile); } else { cmd = String.format("{ while [ -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2>&1; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, logFile, resultFile, resultFile, resultFile); } return cmd; }
Source:
protected ConfigurationBuilder getConfiguration() { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.persistence() .addStore(DummyInMemoryStoreConfigurationBuilder.class) .segmented(true) .storeName(this.getClass().getName()) .transaction().transactionMode(TransactionMode.TRANSACTIONAL); return cfg; }

Target:
protected ConfigurationBuilder getConfiguration() { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.persistence() .addStore(DummyInMemoryStoreConfigurationBuilder.class) .segmented(segmented) .storeName(this.getClass().getName()) .transaction().transactionMode(TransactionMode.TRANSACTIONAL); return cfg; }
Source:
public static int getMaxPresets(final Player player) { int max = ConfigManager.getConfig().getInt("Properties.MaxPresets"); if (player.isOp()) { return max; } for (int i = max; i > 0; i--) { if (player.hasPermission("bending.command.preset.create." + i)) { return(i); } } return 0; }

Target:
public static int getMaxPresets(final Player player) { int max = ConfigManager.getConfig().getInt("Properties.MaxPresets"); if (player.isOp()) { return max; } for (int i = max; i > 0; i--) { if (player.hasPermission("bending.command.preset.create." + i)) { return i; } } return 0; }
Source:
public Boolean call() { CallManagerImpl.EventedCaller<E> caller = batcher.getCaller(); DatabaseClient client = batcher.getClient(callNumber); Calendar callTime = Calendar.getInstance(); E output = null; try { output = caller.callForEvent(client, args); } catch (Throwable throwable) { if (fireFailureListeners) { CallManagerImpl.CallEventImpl input = new CallManagerImpl.CallEventImpl(client, args); initEvent(input, callTime); batcher.sendThrowableToListeners(throwable, "failure calling " + caller.getEndpointPath() + " {}", input); return false; } else if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } else { throw new DataMovementException("Failed to retry call", throwable); } } initEvent(output, callTime); batcher.sendSuccessToListeners(output); if(batcher.inputType == Void.class) { CallArgs newInput = batcher.callArgsGenerator.apply(output); if(newInput != null) { batcher.submitCall((CallArgsImpl) newInput); } } return true; }

Target:
public Boolean call() { CallManagerImpl.EventedCaller<E> caller = batcher.getCaller(); DatabaseClient client = batcher.getClient(callNumber); Calendar callTime = Calendar.getInstance(); E output = null; try { output = caller.callForEvent(client, args); } catch (Throwable throwable) { if (fireFailureListeners) { CallManagerImpl.CallEventImpl input = new CallManagerImpl.CallEventImpl(client, args); initEvent(input, callTime); batcher.sendThrowableToListeners(throwable, "failure calling " + caller.getEndpointPath() + " {}", input); return false; } else if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } else { throw new DataMovementException("Failed to retry call", throwable); } } initEvent(output, callTime); batcher.sendSuccessToListeners(output); if(batcher.callArgsGenerator != null) { CallArgs newInput = batcher.callArgsGenerator.apply(output); if(newInput != null) { if(!(newInput instanceof CallArgsImpl)) throw new MarkLogicInternalException("Unsupported implementation of call arguments."); batcher.submitCall((CallArgsImpl) newInput); } } return true; }
Source:
public synchronized void removeConnection(Socket conn) { try { connections.remove(conn); conn.close(); } catch (IOException ioe) { tsLogger.i18NLogger.warn_could_not_close_transaction_listener_connection(conn, ioe); } finally { notifyAll(); } }

Target:
public synchronized void removeConnection(Socket conn) { connections.remove(conn); try { conn.close(); } catch (IOException ioe) { tsLogger.i18NLogger.warn_could_not_close_transaction_listener_connection(conn, ioe); } finally { notifyAll(); } }
Source:
public static void initOutputElements() { Set<File> files = listBuiltinFiles().values().stream() .map(p -> p.toFile()) .collect(Collectors.toSet()); listFiles().values().stream() .forEach(f -> files.add(f)); for (File xmlFile : files) { if (!xmlValidate(xmlFile).isOK()) { continue; } preloadXmlAnalysesOutput(xmlFile); } }

Target:
public static void initOutputElements() { Set<File> files = listBuiltinFiles().values().stream() .map(p -> p.toFile()) .collect(Collectors.toSet()); listFiles().values().stream() .forEach(f -> files.add(f)); for (File xmlFile : files) { preloadXmlAnalysesOutput(xmlFile); } }
Source:
public List<String> run() { List<String> errorMessageList = new ArrayList<>(); errorMessageList.addAll(checkArguments()); if (errorMessageList.isEmpty()) { ByteArrayOutputStream commandExecutionOutput = new ByteArrayOutputStream(); int resultCode = -1; List<String> generationCommand = createGenerationCommand(); try { SystemCommand sc = new SystemCommand(new File(JMeterUtils.getJMeterBinDir()), COMMAND_TIMEOUT, 100, null, null, commandExecutionOutput, null); LOGGER.debug("Running report generation"); resultCode = sc.run(generationCommand); if (resultCode != 0) { errorMessageList.add(commandExecutionOutput.toString()); LOGGER.info("The HTML report generation failed and returned : {}", commandExecutionOutput); return errorMessageList; } } catch (InterruptedException | IOException e) { errorMessageList.add(commandExecutionOutput.toString()); if (LOGGER.isErrorEnabled()) { LOGGER.error("Error during HTML report generation : {}", e.getMessage(), e); } } LOGGER.debug("SystemCommand ran : returned : {}", generationCommand, resultCode); return errorMessageList; } return errorMessageList; }

Target:
public List<String> run() { List<String> errorMessageList = new ArrayList<>(); errorMessageList.addAll(checkArguments()); if (!errorMessageList.isEmpty()) { return errorMessageList; } ByteArrayOutputStream commandExecutionOutput = new ByteArrayOutputStream(); int resultCode = -1; List<String> generationCommand = createGenerationCommand(); try { SystemCommand sc = new SystemCommand(new File(JMeterUtils.getJMeterBinDir()), COMMAND_TIMEOUT, 100, null, null, commandExecutionOutput, null); LOGGER.debug("Running report generation"); resultCode = sc.run(generationCommand); if (resultCode != 0) { errorMessageList.add(commandExecutionOutput.toString()); LOGGER.info("The HTML report generation failed and returned: {}", commandExecutionOutput); return errorMessageList; } } catch (InterruptedException | IOException e) { errorMessageList.add(commandExecutionOutput.toString()); if (LOGGER.isErrorEnabled()) { LOGGER.error("Error during HTML report generation: {}", e.getMessage(), e); } } LOGGER.debug("SystemCommand ran: returned: {}", generationCommand, resultCode); return errorMessageList; }
Source:
public int getPortNumber() { return portNumbers[0]; }

Target:
public int getPortNumber() { if (portNumbers == null || portNumbers.length == 0) { return 0; } return portNumbers[0]; }
Source:
public void onEnter() { try { getContext().unregisterAuthorizationUpdates(); } catch (final RuntimeException ex) { getLog().error("Unexpected fail during removing callback for registration updates", ex); } try { if (null != exception) { getOut().onException(exception); } } finally { try { getContext().unregisterSession(); getContext().getZkClient().close(); } catch (IOException e) { getLog().error("Unexpected fail to release zk connection", e); } finally { switchState(StreamingContext.DEAD_STATE); } } }

Target:
public void onEnter() { try { getContext().unregisterAuthorizationUpdates(); } catch (final RuntimeException ex) { getLog().error("Unexpected fail during removing callback for registration updates", ex); } try { if (null != exception) { getOut().onException(exception); } } finally { try { getContext().unregisterSession(); } finally { switchState(StreamingContext.DEAD_STATE); } try { getContext().getZkClient().close(); } catch (final IOException e) { getLog().error("Unexpected fail to release zk connection", e); } } }
Source:
public void execute() throws MinimesosException { String marathonJson; try { marathonJson = getMarathonJson(); } catch (IOException e) { throw new MinimesosException("Failed to read JSON", e); } MesosCluster cluster = ClusterRepository.loadCluster(new MesosClusterContainersFactory()); if (cluster != null) { Marathon marathon = cluster.getMarathon(); if (marathon == null) { throw new MinimesosException("Marathon container is not found in cluster " + cluster.getClusterId()); } marathon.deployApp(marathonJson); } else { throw new MinimesosException("Running cluster is not found"); } }

Target:
public void execute() throws MinimesosException { MesosCluster cluster = ClusterRepository.loadCluster(new MesosClusterContainersFactory()); if (cluster != null) { Marathon marathon = cluster.getMarathon(); if (marathon == null) { throw new MinimesosException("Marathon container is not found in cluster " + cluster.getClusterId()); } String marathonJson; try { marathonJson = getMarathonJson(); } catch (IOException e) { throw new MinimesosException("Failed to read JSON", e); } marathon.deployApp(marathonJson); } else { throw new MinimesosException("Running cluster is not found"); } }