auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected Blob replaceURLsByAbsolutePaths(Blob blob, Path tempDirectory) throws IOException { String initialBlobContent = blob.getString(); String blobContentWithAbsolutePaths = initialBlobContent; String regex = "src=\"((.*?)/nuxeo/nxfile/(.*?)/([0-9a-z-]+)/files:files/([0-9])+/file/(.*?))\""; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(initialBlobContent); while (matcher.find()) { String url = matcher.group(1); String docId = matcher.group(4); int fileIndex = Integer.parseInt(matcher.group(5)); IdRef docIdRef = new IdRef(docId); DocumentModel doc = session.getDocument(docIdRef); List<Map<String, Object>> docFiles = (List<Map<String, Object>>) doc.getProperty("files", "files"); Map<String, Object> imageDoc = docFiles.get(fileIndex); Blob imageBlob = (Blob) imageDoc.get("file"); File imageFile = new File(tempDirectory + "/" + imageDoc.get("filename")); imageBlob.transferTo(imageFile); blobContentWithAbsolutePaths = blobContentWithAbsolutePaths.replaceAll(url, imageFile.toPath().toString()); } if (blobContentWithAbsolutePaths.equals(initialBlobContent)) { return blob; } Blob newBlob = new StringBlob(blobContentWithAbsolutePaths, blob.getMimeType(), blob.getEncoding()); newBlob.setFilename(blob.getFilename()); newBlob.setDigest(blob.getDigest()); return newBlob; }

Target:
protected Blob replaceURLsByAbsolutePaths(Blob blob, Path tempDirectory) throws IOException { String initialBlobContent = blob.getString(); String blobContentWithAbsolutePaths = initialBlobContent; DownloadService downloadService = Framework.getService(DownloadService.class); List<Map<String, String>> parsedUrls = downloadService.parseDownloadUrlsInHtmlLinks(initialBlobContent); for (Map<String, String> parsedUrl : parsedUrls) { try { CoreSession session = CoreInstance.openCoreSession(parsedUrl.get("repository")); IdRef docIdRef = new IdRef(parsedUrl.get("id")); DocumentModel doc = session.getDocument(docIdRef); List<Map<String, Object>> docFiles = (List<Map<String, Object>>) doc.getPropertyValue("files:files"); int fileIndex = Integer.parseInt(parsedUrl.get("index")); if (docFiles == null || docFiles.size() <= fileIndex) { break; } Map<String, Object> imageDoc = docFiles.get(fileIndex); if (imageDoc == null) { break; } Blob imageBlob = (Blob) imageDoc.get("file"); if (imageBlob == null) { break; } String sanitizedFilename = FileUtils.sanitizeFilename((String) imageDoc.get("filename")); File imageFile = tempDirectory.resolve(sanitizedFilename).toFile(); imageBlob.transferTo(imageFile); session.close(); blobContentWithAbsolutePaths = blobContentWithAbsolutePaths.replaceAll(parsedUrl.get("url"), imageFile.toPath().toString()); } catch (DocumentNotFoundException | DocumentSecurityException | NumberFormatException e) { break; } } if (blobContentWithAbsolutePaths.equals(initialBlobContent)) { return blob; } Blob newBlob = new StringBlob(blobContentWithAbsolutePaths, blob.getMimeType(), blob.getEncoding()); newBlob.setFilename(blob.getFilename()); return newBlob; }
Source:
public String toString() { return "PushResponse {" + "active='" + active + '\'' + ", iden='" + iden + '\'' + ", type='" + type + '\'' + ", dismissed=" + dismissed + ", direction='" + direction + '\'' + ", senderIdentifier='" + senderIdentifier + '\'' + ", senderEmail='" + senderEmail + '\'' + ", senderEmailNormalized='" + senderEmailNormalized + '\'' + ", senderName='" + senderName + '\'' + ", receiverIdentifer='" + receiverIdentifer + '\'' + ", receiverEmail='" + receiverEmail + '\'' + ", receiverEmailNormalized='" + receiverEmailNormalized + '\'' + ", title='" + title + '\'' + ", body='" + body + '\'' + ", errorCode='" + errorCode + '\'' + ", pushError=" + pushError + '}'; }

Target:
public String toString() { return "PushResponse {" + "active='" + active + '\'' + ", iden='" + iden + '\'' + ", type='" + type + '\'' + ", dismissed=" + dismissed + ", direction='" + direction + '\'' + ", senderIdentifier='" + senderIdentifier + '\'' + ", senderEmail='" + senderEmail + '\'' + ", senderEmailNormalized='" + senderEmailNormalized + '\'' + ", senderName='" + senderName + '\'' + ", receiverIdentifier='" + receiverIdentifier + '\'' + ", receiverEmail='" + receiverEmail + '\'' + ", receiverEmailNormalized='" + receiverEmailNormalized + '\'' + ", title='" + title + '\'' + ", body='" + body + '\'' + ", errorCode='" + errorCode + '\'' + ", pushError=" + pushError + '}'; }
Source:
public void testGetEnumValues() { Ds3EnumConstant alpha = new Ds3EnumConstant("ALPHA", null); Ds3EnumConstant bravo = new Ds3EnumConstant("BRAVO", null); final ImmutableList.Builder<Ds3EnumConstant> builder = ImmutableList.builder(); builder.add(alpha); builder.add(bravo); final ImmutableList<Ds3EnumConstant> enumConstants = builder.build(); final String expectedResult = " ALPHA,\n" + " BRAVO"; final String result = TypeHelper.getEnumValues(enumConstants); assertThat(result, is(expectedResult)); }

Target:
public void testGetEnumValues() { final Ds3EnumConstant alpha = new Ds3EnumConstant("ALPHA", null); final Ds3EnumConstant bravo = new Ds3EnumConstant("BRAVO", null); final ImmutableList.Builder<Ds3EnumConstant> builder = ImmutableList.builder(); builder.add(alpha); builder.add(bravo); final ImmutableList<Ds3EnumConstant> enumConstants = builder.build(); final String expectedResult = " ALPHA,\n" + " BRAVO"; final String result = TypeHelper.getEnumValues(enumConstants); assertThat(result, is(expectedResult)); }
Source:
private String getCoursePaginationList(List<String> coursePaginationList) throws EntityDoesNotExistException { String courseName = ""; List<CourseAttributes> courses = logic.getCoursesForStudentAccount(account.googleId); java.util.Collections.sort(courses); for (int i = 0; i < courses.size(); i++) { CourseAttributes course = courses.get(i); coursePaginationList.add(course.id); if (courseId == "") { courseId = course.id; } if (course.id.equals(courseId)) { courseName = course.id + " : " + course.name; } } if (courseName.equals("")) { throw new EntityDoesNotExistException("Trying to access a course that does not exist."); } return courseName; }

Target:
private String getCoursePaginationList(List<String> coursePaginationList) throws EntityDoesNotExistException { String courseName = ""; List<CourseAttributes> courses = logic.getCoursesForStudentAccount(account.googleId); java.util.Collections.sort(courses); for (int i = 0; i < courses.size(); i++) { CourseAttributes course = courses.get(i); coursePaginationList.add(course.id); if (courseId.isEmpty()) { courseId = course.id; } if (course.id.equals(courseId)) { courseName = course.id + " : " + course.name; } } if (courseName.equals("")) { throw new EntityDoesNotExistException("Trying to access a course that does not exist."); } return courseName; }
Source:
public double getVoltageSafely() throws InvalidSensorException { readStatus3(); if (System.currentTimeMillis() - lastRead > PDP.MAX_AGE) { throw new InvalidSensorException("Can not read voltage from PDP"); } return cachedVoltage; }

Target:
public double getVoltageSafely() throws InvalidSensorException { readStatus(3); if (System.currentTimeMillis() - lastRead > PDP.MAX_AGE) { throw new InvalidSensorException("Can not read voltage from PDP"); } return cachedVoltage; }
Source:
public byte[] signData(byte[] inputData) throws EncryptionException { try { PrivateKey privateKey = this.getPrivate(); Signature signer = Signature.getInstance("SHA1withDSA"); signer.initSign(privateKey); signer.update(inputData); return (signer.sign()); } catch (Exception e) { throw new EncryptionException("DSA signing failed", e); } }

Target:
public byte[] signData(byte[] inputData) throws EncryptionException { try { PrivateKey privateKey = this.getPrivate(); Signature signer = Signature.getInstance("SHA1withDSA"); signer.initSign(privateKey); signer.update(inputData); return (signer.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { throw new EncryptionException("DSA signing failed", e); } }
Source:
public UUID getCoordinator() { return rtState.top.nodesByOrder.values().stream() .filter(n -> !n.isClient()) .map(ZookeeperClusterNode::id) .findFirst() .orElse(null); }

Target:
public UUID getCoordinator() { return rtState.top.nodesByOrder.values().stream() .filter(n -> !n.isClient() && !n.isDaemon()) .map(ZookeeperClusterNode::id) .findFirst() .orElse(null); }
Source:
public void shouldFilterNonEmptyList() { final List<Integer> list = Collections.unmodifiableList( IntStream.range(0, 4).boxed().collect(Collectors.toList()) ); final List<Integer> actual = ListOps.filter(list, x -> x % 2 > 0); final List<Integer> expected = Arrays.asList(1, 3); assertNotNull(actual); assertFalse(actual.isEmpty()); assertEquals(expected, actual); }

Target:
public void shouldFilterNonEmptyList() { Predicate<Integer> predicate = x -> x % 2 > 0; final List<Integer> list = Collections.unmodifiableList( IntStream.range(0, 100).boxed().collect(Collectors.toList()) ); final List<Integer> actual = ListOps.filter(list, predicate); final List<Integer> expected = list.stream() .filter(predicate) .collect(Collectors.toList()); assertNotNull(actual); assertFalse(actual.isEmpty()); assertEquals(expected, actual); }
Source:
public String getComponentType() { return "r2dbc:reactive-inbound-channel-adapter"; }

Target:
public String getComponentType() { return "r2dbc:inbound-channel-adapter"; }
Source:
default <E> DataTransactionResult transform(int x, int y, int z, Key<? extends BaseValue<E>> key, Function<E, E> function) { if (supports(x, y, z, key)) { Optional<E> optional = get(x, y, z, key); if (optional.isPresent()) { return offer(x, y, z, key, function.apply(optional.get())); } } return DataTransactionBuilder.failNoData(); }

Target:
default <E> DataTransactionResult transform(int x, int y, int z, Key<? extends BaseValue<E>> key, Function<E, E> function) { if (supports(x, y, z, key)) { final Optional<E> optional = get(x, y, z, key); if (optional.isPresent()) { return offer(x, y, z, key, function.apply(optional.get())); } } return DataTransactionBuilder.failNoData(); }
Source:
public void jobStartedNotification(String scriptId, String assignedJobId) { if (jobGraph == null) { jobGraph = PigStats.get().getJobGraph(); } log.info("jobStartedNotification - jobId " + assignedJobId + ", jobGraph:\n" + jobGraph); for (JobStats jobStats : jobGraph) { if (assignedJobId.equals(jobStats.getJobId())) { log.info("jobStartedNotification - scope " + jobStats.getName() + " is jobId " + assignedJobId); DAGNode<PigJob> node = this.dagNodeNameMap.get(jobStats.getName()); if (node == null) { log.warn("jobStartedNotification - unrecognized operator name found (" + jobStats.getName() + ") for jobId " + assignedJobId); } else { node.getJob().setId(assignedJobId); if (jobClient == null) { addMapReduceJobState(node.getJob(), null); } else { addMapReduceJobState(node.getJob(), jobClient); } dagNodeJobIdMap.put(node.getJob().getId(), node); pushEvent(scriptId, new Event.JobStartedEvent(node)); } } } }

Target:
public void jobStartedNotification(String scriptId, String assignedJobId) { log.info("jobStartedNotification - jobId " + assignedJobId + ", jobGraph:\n" + getJobGraph()); for (JobStats jobStats : getJobGraph()) { if (assignedJobId.equals(jobStats.getJobId())) { log.info("jobStartedNotification - scope " + jobStats.getName() + " is jobId " + assignedJobId); DAGNode<PigJob> node = this.dagNodeNameMap.get(jobStats.getName()); if (node == null) { log.warn("jobStartedNotification - unrecognized operator name found (" + jobStats.getName() + ") for jobId " + assignedJobId); } else { node.getJob().setId(assignedJobId); addMapReduceJobState(node.getJob()); dagNodeJobIdMap.put(node.getJob().getId(), node); pushEvent(scriptId, new Event.JobStartedEvent(node)); } } } }
Source:
public void initializeOnMaster(ClassLoader loader) throws Exception { super.initializeOnMaster(loader); while (true) { synchronized (lock) { if (!blocking) { return; } lock.wait(10); } } }

Target:
public void initializeOnMaster(ClassLoader loader) throws Exception { super.initializeOnMaster(loader); oneShotLatch.await(); }
Source:
static Object[] grouped(Object[] array, int groupSize) { assert array.length > groupSize; final Object[] results = copy(empty(), 1 + ((array.length - 1) / groupSize)); results[0] = copyRange(array, 0, groupSize); for (int start = groupSize, i = 1; start < array.length; i++) { final int nextLength = Math.min(groupSize, array.length - (i * groupSize)); results[i] = copyRange(array, start, start + nextLength); start += nextLength; } return results; }

Target:
static Object[] grouped(Object[] array, int groupSize) { assert array.length > groupSize; final Object[] results = newInstance(1 + ((array.length - 1) / groupSize)); results[0] = copyRange(array, 0, groupSize); for (int start = groupSize, i = 1; start < array.length; i++) { final int nextLength = Math.min(groupSize, array.length - (i * groupSize)); results[i] = copyRange(array, start, start + nextLength); start += nextLength; } return results; }
Source:
public void passivateAll() throws PersistenceException { if (enabled && !skipOnStop) { long start = timeService.time(); log.passivatingAllEntries(); List<MarshalledEntry> entries = StreamSupport .stream(container.spliterator(), false) .map(e -> marshalledEntryFactory.newMarshalledEntry(e.getKey(), e.getValue(), internalMetadata(e))) .collect(Collectors.toList()); persistenceManager.writeBatchToAllNonTxStores(entries, BOTH, 0); log.passivatedEntries(entries.size(), Util.prettyPrintTime(timeService.timeDuration(start, TimeUnit.MILLISECONDS))); } }

Target:
public void passivateAll() throws PersistenceException { if (enabled && !skipOnStop) { long start = timeService.time(); log.passivatingAllEntries(); int count = container.sizeIncludingExpired(); Iterable<MarshalledEntry> iterable = () -> new IteratorMapper<>(container.iterator(), e -> marshalledEntryFactory.newMarshalledEntry(e.getKey(), e.getValue(), internalMetadata(e))); persistenceManager.writeBatchToAllNonTxStores(iterable, BOTH, 0); log.passivatedEntries(count, Util.prettyPrintTime(timeService.timeDuration(start, TimeUnit.MILLISECONDS))); } }
Source:
public void onError(Throwable e) { if (hasTooManyElements) { return; } child.onError(e); }

Target:
public void onError(Throwable e) { if (hasTooManyElements) { RxJavaPluginUtils.handleException(e); return; } child.onError(e); }
Source:
private FunctionTranslator(Map<FunctionMetadata, MethodHandle> functionMapping) { this.functionMapping = functionMapping; }

Target:
private FunctionTranslator(Map<FunctionMetadata, MethodHandle> functionMapping) { this.functionMapping = requireNonNull(functionMapping, "functionMapping is null"); }
Source:
public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; MiniSiteHolder holder; if (row == null) { LayoutInflater inflater = mActivity.getLayoutInflater(); row = inflater.inflate(R.layout.mini_site_list_row, parent, false); holder = new MiniSiteHolder(); holder.photosView = (CoverPhotoPagerView) row.findViewById(R.id.cover_photo_pager_view); holder.coverPhotoLabel = (TextView) row.findViewById(R.id.cover_photo_label); holder.topLabel = (TextView) row.findViewById(R.id.top_label); row.setTag(holder); } else { holder = (MiniSiteHolder)row.getTag(); } final MiniSite miniSite = mMiniSites.get(position); holder.photosView.configureWithPhotos(miniSite.getPhotos()); holder.coverPhotoLabel.setText(String.format("%s Field Reports", miniSite.getFieldReportsCount())); holder.topLabel.setText(miniSite.getName()); final TapGestureListener listener = new TapGestureListener(mActivity, mSite, miniSite); final GestureDetectorCompat gesture = new GestureDetectorCompat(mActivity, listener); row.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActivity.replaceFragment(MiniSiteFragment.newInstance(mSite, miniSite)); } }); holder.photosView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { gesture.onTouchEvent(event); return false; } }); return row; }

Target:
public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; MiniSiteHolder holder; if (row == null) { LayoutInflater inflater = mActivity.getLayoutInflater(); row = inflater.inflate(R.layout.mini_site_list_row, parent, false); holder = new MiniSiteHolder(); holder.photosView = (CoverPhotoPagerView) row.findViewById(R.id.cover_photo_pager_view); holder.topLabel = (TextView) row.findViewById(R.id.top_label); row.setTag(holder); } else { holder = (MiniSiteHolder)row.getTag(); } final MiniSite miniSite = mMiniSites.get(position); holder.photosView.configureWithPhotos(miniSite.getPhotos()); holder.topLabel.setText(miniSite.getName()); if (mSite != null) { final TapGestureListener listener = new TapGestureListener(mActivity, mSite, miniSite); final GestureDetectorCompat gesture = new GestureDetectorCompat(mActivity, listener); row.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActivity.replaceFragment(MiniSiteFragment.newInstance(mSite, miniSite)); } }); holder.photosView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { gesture.onTouchEvent(event); return false; } }); } return row; }
Source:
public void testRobotIsCreatedWithCorrectInitialPositionAndOrientation() { final GridPosition initialGridPosition = new GridPosition(0, 0); final Robot robot = new Robot(initialGridPosition, Orientation.NORTH); assertEquals(robot.getOrientation(), initialOrientation); assertEquals(robot.getGridPosition(), initialGridPosition); }

Target:
public void testRobotIsCreatedWithCorrectInitialPositionAndOrientation() { final Orientation initialOrientation = Orientation.NORTH; final GridPosition initialGridPosition = new GridPosition(0, 0); final Robot robot = new Robot(initialGridPosition, initialOrientation); assertEquals(robot.getOrientation(), initialOrientation); assertEquals(robot.getGridPosition(), initialGridPosition); }
Source:
public boolean deleteImage(String id) { String[] fields = VMImageToImage.decodeFieldsFromUniqueId(id); boolean custom = fields.length == 6 ? true : false; if (custom) { String group = fields[1]; String storage = fields[2]; StorageServiceKeys keys = api.getStorageAccountApi(group).getKeys(storage); BlobHelper.deleteContainerIfExists(storage, keys.key1(), "system"); return true; } return false; }

Target:
public boolean deleteImage(String id) { VMImage image = VMImageToImage.decodeFieldsFromUniqueId(id); if (image.custom()) { StorageServiceKeys keys = api.getStorageAccountApi(image.group()).getKeys(image.storage()); BlobHelper.deleteContainerIfExists(image.storage(), keys.key1(), "system"); return !BlobHelper.customImageExists(image.storage(), keys.key1()); } return false; }
Source:
public static void writeStyle(final InputStream in, final File styleFile) throws IOException { File temporaryFile = File.createTempFile(styleFile.getName(), null); BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream(temporaryFile)); try { IOUtils.copy(in, out); out.flush(); } finally { out.close(); } org.geoserver.data.util.IOUtils.rename(temporaryFile, styleFile); }

Target:
public static void writeStyle(final InputStream in, final File styleFile) throws IOException { final File temporaryFile = File.createTempFile(styleFile.getName(), null, styleFile.getParentFile()); BufferedOutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(temporaryFile)); IOUtils.copy(in, out); out.flush(); } finally { out.close(); } try { org.geoserver.data.util.IOUtils.rename(temporaryFile, styleFile); } finally { if (temporaryFile.exists()) { temporaryFile.delete(); } } }
Source:
private XStream createXStream() { XStream xStream = new XStream(new DomDriver(CHARSET)); xStream.alias("colorIDSet", ColorIDSet.class); return xStream; }

Target:
private XStream createXStream() { XStream xStream = new XStream(); xStream.alias("colorIDSet", ColorIDSet.class); return xStream; }
Source:
private ResolveStepIndexResult resolveStepInPageOccurrence(final PageSteps pageWithSteps, final StepIdentifier stepIdentifier) { if (stepIdentifier.getStepInPageOccurrence() < pageWithSteps.getSteps().size()) { StepDescription stepDescription = pageWithSteps.getSteps().get(stepIdentifier.getStepInPageOccurrence()); String screenshotFileName = stepDescription.getScreenshotFileName(); int index = stepDescription.getIndex(); return ResolveStepIndexResult.requestedIndexFound(index, screenshotFileName); } else { int redirectStepInPageOccurrence = getStepInPageOccurrenceWithMostMatchingLabels(pageWithSteps.getSteps(), stepIdentifier); StepDescription stepDescription = pageWithSteps.getSteps().get(redirectStepInPageOccurrence); int index = stepDescription.getIndex(); StepIdentifier redirectStepIdentifier = StepIdentifier.withDifferentStepInPageOccurrence(stepIdentifier, redirectStepInPageOccurrence); LOGGER.warn("stepInPageOccurrence " + stepIdentifier.getStepInPageOccurrence() + " does not exist in " + stepIdentifier + ". Redirecting to " + redirectStepIdentifier); return ResolveStepIndexResult.otherStepInPageOccurrenceFound(index, redirectStepIdentifier, stepDescription.getScreenshotFileName()); } }

Target:
private ResolveStepIndexResult resolveStepInPageOccurrence(final PageSteps pageWithSteps, final StepIdentifier stepIdentifier) { if (isStepInRangeOfPageWithSteps(pageWithSteps, stepIdentifier)) { StepDescription stepDescription = pageWithSteps.getSteps().get(stepIdentifier.getStepInPageOccurrence()); String screenshotFileName = stepDescription.getScreenshotFileName(); int index = stepDescription.getIndex(); return ResolveStepIndexResult.requestedIndexFound(index, screenshotFileName); } else { int redirectStepInPageOccurrence = getStepInPageOccurrenceWithMostMatchingLabels(pageWithSteps.getSteps(), stepIdentifier); StepDescription stepDescription = pageWithSteps.getSteps().get(redirectStepInPageOccurrence); int index = stepDescription.getIndex(); StepIdentifier redirectStepIdentifier = StepIdentifier.withDifferentStepInPageOccurrence(stepIdentifier, redirectStepInPageOccurrence); LOGGER.warn("stepInPageOccurrence " + stepIdentifier.getStepInPageOccurrence() + " does not exist in " + stepIdentifier + ". Redirecting to " + redirectStepIdentifier); return ResolveStepIndexResult.otherStepInPageOccurrenceFound(index, redirectStepIdentifier, stepDescription.getScreenshotFileName()); } }
Source:
public ShellSpout(String... command) { _command = command; _process = new ShellProcess(new JsonSerializer(), _command); }

Target:
public ShellSpout(String... command) { _command = command; }
Source:
public String toString() { return "| |"; }

Target:
public String toString() { return getName(); }
Source:
private static FileDialog createNewFileDialog(Shell parent, int style) { String[] desiredPath = fOverridePath; fOverride = false; return new FileDialog(parent, style) { @Override public String open() { return desiredPath != null ? desiredPath[0] : null; } @Override protected void checkSubclass() { } @Override public String getFileName() { return desiredPath != null ? desiredPath[0].substring(desiredPath[0].lastIndexOf(FILE_SEPARATOR) + 1) : ""; } @Override public String[] getFileNames() { return desiredPath != null? desiredPath : new String[0]; } }; }

Target:
private static FileDialog createNewFileDialog(Shell parent, int style) { String[] desiredPath = fOverridePath; fOverride = false; return new FileDialog(parent, style) { @Override public String open() { return desiredPath != null ? desiredPath[0] : null; } @Override protected void checkSubclass() { } @Override public String getFileName() { return getFileName(desiredPath[0]); } @Override public String[] getFileNames() { List<String> inStrings = Arrays.asList(desiredPath); List<String> outStrings = new ArrayList<>(); for (String entry : inStrings) { outStrings.add(getFileName(entry)); } return outStrings.toArray(new String[outStrings.size()]); } @Override public String getFilterPath() { return (desiredPath != null) ? new Path(desiredPath[0]).removeLastSegments(1).toString() : ""; } private String getFileName(String path) { return new Path(path).lastSegment(); } }; }
Source:
public Vector<T> slice(int beginIndex, int endIndex) { if ((beginIndex >= endIndex) || (beginIndex >= size()) || isEmpty()) { return empty(); } else if ((beginIndex <= 0) && (endIndex >= length())) { return this; } else { return take(endIndex).drop(beginIndex); } }

Target:
public Vector<T> slice(int beginIndex, int endIndex) { if ((beginIndex >= endIndex) || (beginIndex >= size()) || isEmpty()) { return empty(); } else if ((beginIndex <= 0) && (endIndex >= length())) { return this; } else { final long index = Math.max(beginIndex, 0); final long length = Math.min(endIndex, length()); HashArrayMappedTrie<Integer, T> trie = HashArrayMappedTrie.empty(); for (int i = (int) index; i < length; i++) { trie = trie.put(trie.size(), get(i)); } return wrap(trie); } }
Source:
public Map<ItemStack, ISmeltingRecipe> getRecipes() { if (recipes != null) return recipes; recipes = Maps.newHashMap(); staticView = Maps.transformValues(recipes, ISmeltingRecipe::getGenericOutput); return recipes; }

Target:
public List<ISmeltingRecipe> getRecipes() { if (recipes != null) return recipes; recipes = Lists.newArrayList(); staticView = new VanillaView(); return recipes; }
Source:
public void handleAction(ActionParameters params) throws ActionException { params.requireLoggedInUser(); int datasourceId = params.getRequiredParamInt(StatisticsHelper.PARAM_DATASOURCE_ID); int id = params.getRequiredParamInt(ActionConstants.PARAM_ID); StatisticalIndicator ind = indicatorService.findById(id, params.getUser().getId()); if(ind == null) { throw new ActionDeniedException("Unknown indicator/not the owner: " + id ); } JSONObject selectors = params.getHttpParamAsJSON(StatisticsHelper.PARAM_SELECTORS); if(selectors != null) { int regionset = params.getRequiredParamInt("regionset"); try { indicatorService.deleteIndicatorData(id, regionset, selectors.getInt("year")); } catch (JSONException ex) { throw new ActionParamsException("Year was not part of the selectors parameter"); } StatisticsHelper.flushDataFromCache(datasourceId, Integer.toString(id), regionset, selectors); } else if (!indicatorService.delete(id, params.getUser().getId())) { throw new ActionParamsException("Indicator wasn't removed: " + + id); } StatisticalDatasourcePlugin datasource = StatisticalDatasourcePluginManager.getInstance().getPlugin(datasourceId); if (datasource != null && datasource.canCache()) { } LOG.info("Deleted indicator", id); try { ResponseHelper.writeResponse(params, StatisticsHelper.toJSON(ind)); } catch (JSONException ex) { ResponseHelper.writeResponse(params, JSONHelper.createJSONObject("deleted", id)); } }

Target:
public void handleAction(ActionParameters params) throws ActionException { params.requireLoggedInUser(); int datasourceId = params.getRequiredParamInt(StatisticsHelper.PARAM_DATASOURCE_ID); int id = params.getRequiredParamInt(ActionConstants.PARAM_ID); StatisticalIndicator ind = indicatorService.findById(id, params.getUser().getId()); if(ind == null) { throw new ActionDeniedException("Unknown indicator/not the owner: " + id ); } JSONObject selectors = params.getHttpParamAsJSON(StatisticsHelper.PARAM_SELECTORS); if(selectors != null) { int regionset = params.getRequiredParamInt("regionset"); int year = parseYearSelector(selectors); indicatorService.deleteIndicatorData(id, regionset, year); LOG.info("Deleted indicator data for indicator:", id, "year:", year, "regionset:", regionset); StatisticsHelper.flushDataFromCache(datasourceId, Integer.toString(id), regionset, selectors); } else { removeIndicator(id, params.getUser().getId()); LOG.info("Deleted indicator", id); } StatisticalDatasourcePlugin datasource = StatisticalDatasourcePluginManager.getInstance().getPlugin(datasourceId); if (datasource != null && datasource.canCache()) { } try { ResponseHelper.writeResponse(params, StatisticsHelper.toJSON(ind)); } catch (JSONException ex) { ResponseHelper.writeResponse(params, JSONHelper.createJSONObject("id", id)); } }
Source:
private void stopActivityTransitionTimer() { if (this.mActivityTransitionTimerTask != null) { this.mActivityTransitionTimerTask.cancel(); } if (this.mActivityTransitionTimer != null) { this.mActivityTransitionTimer.cancel(); } mIsInBackground = false; sAppIsInTheBackground = false; }

Target:
private void stopActivityTransitionTimer() { if (this.mActivityTransitionTimerTask != null) { this.mActivityTransitionTimerTask.cancel(); } if (this.mActivityTransitionTimer != null) { this.mActivityTransitionTimer.cancel(); } sAppIsInTheBackground = false; }
Source:
public void dispose() { super.dispose(); synchronized (fBuildJobMap) { fBuildJobMap.values().forEach(Job::cancel); } if (fZoomThread != null) { fZoomThread.cancel(); } ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); getSite().getPage().removePartListener(fPartListener); getSite().getPage().removePartListener(fPartListener2); }

Target:
public void dispose() { super.dispose(); synchronized (fBuildJobMap) { fBuildJobMap.values().forEach(Job::cancel); } if (fZoomThread != null) { fZoomThread.cancel(); } deactivateContextService(); ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); IWorkbenchPartSite site = getSite(); if (site != null) { IWorkbenchPage page = site.getPage(); if (page != null) { page.removePartListener(fPartListener); page.removePartListener(fPartListener2); } } }
Source:
public static Long searchHistogram(String name, MetricRegistry mreg) { Scanner sc = new Scanner(name).useDelimiter("_"); if (!sc.hasNext()) return null; Metric m = mreg.findMetric(sc.next()); if (!(m instanceof HistogramMetric)) return null; HistogramMetric h = (HistogramMetric)m; long[] bounds = h.bounds(); long[] values = h.value(); if (!sc.hasNextLong()) return null; long lowBound = sc.nextLong(); if (!sc.hasNextLong()) { if (sc.hasNext() && INF.equals(sc.next()) && bounds[bounds.length-1] == lowBound) return values[values.length-1]; return null; } long highBound = sc.nextLong(); for (int i=0; i<bounds.length; i++) { if (bounds[i] == highBound) { if ((i == 0 && lowBound != 0) || bounds[i-1] != lowBound) return null; return values[i]; } } return null; }

Target:
public static Long searchHistogram(String name, MetricRegistry mreg) { Scanner sc = new Scanner(name).useDelimiter("_"); if (!sc.hasNext()) return null; Metric m = mreg.findMetric(sc.next()); if (!(m instanceof HistogramMetric)) return null; HistogramMetric h = (HistogramMetric)m; long[] bounds = h.bounds(); long[] values = h.value(); if (!sc.hasNextLong()) return null; long lowBound = sc.nextLong(); if (!sc.hasNextLong()) { if (sc.hasNext() && INF.equals(sc.next()) && bounds[bounds.length - 1] == lowBound) return values[values.length - 1]; return null; } long highBound = sc.nextLong(); int idx = binarySearch(bounds, highBound); if (idx < 0) return null; if ((idx == 0 && lowBound != 0) || (idx != 0 && bounds[idx - 1] != lowBound)) return null; return values[idx]; }
Source:
void produced(long c) { arbiter.produced(c); AtomicLong requestedField = requested; if (requestedField.get() != Long.MAX_VALUE) { requestedField.addAndGet(-c); } }

Target:
void produced(long c) { if (c != 0L) { arbiter.produced(c); BackpressureUtils.produced(requested, c); } }
Source:
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (viewer instanceof AbstractTreeViewer) { manager = new DeferredTreeContentManager( (AbstractTreeViewer) viewer); } super.inputChanged(viewer, oldInput, newInput); }

Target:
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (viewer instanceof AbstractTreeViewer) { manager = new DeferredTreeContentManager(this, (AbstractTreeViewer) viewer); } super.inputChanged(viewer, oldInput, newInput); }
Source:
public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); if (null != getSession().getSelectionControl()) { final AbstractCanvasHandler canvasHandler = getSession().getCanvasHandler(); final SelectionControl<AbstractCanvasHandler, Element> selectionControl = getSession().getSelectionControl(); final Collection<String> selectedItems = selectionControl.getSelectedItems(); if (selectedItems != null && !selectedItems.isEmpty()) { selectionControl.clearSelection(); timerUtils.executeWithDelay(()-> { final CommandResult<CanvasViolation> result = sessionCommandManager.execute(canvasHandler, canvasCommandFactory .delete(selectedItems.stream() .map(uuid -> canvasHandler.getGraphIndex().get(uuid)) .collect(Collectors.toList()))); if (!CommandUtils.isError(result)) { callback.onSuccess(); } else { callback.onError((V) new ClientRuntimeError("Error deleing elements [message=" + result.toString() + "]")); } }, 100); } else { callback.onError((V) new ClientRuntimeError("Cannot delete element, no element selected on canvas")); } } }

Target:
public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); if (null != getSession().getSelectionControl()) { final AbstractCanvasHandler canvasHandler = getSession().getCanvasHandler(); final SelectionControl<AbstractCanvasHandler, Element> selectionControl = getSession().getSelectionControl(); final Collection<String> selectedItems = selectionControl.getSelectedItems(); clearSelectionEvent.fire(new CanvasClearSelectionEvent(canvasHandler)); if (selectedItems != null && !selectedItems.isEmpty()) { final CommandResult<CanvasViolation> result = sessionCommandManager.execute(canvasHandler, canvasCommandFactory.delete(selectedItems.stream() .map(uuid -> canvasHandler.getGraphIndex().get(uuid)) .filter(Objects::nonNull) .collect(Collectors.toList()))); if (!CommandUtils.isError(result)) { callback.onSuccess(); } else { callback.onError((V) new ClientRuntimeError("Error deleing elements [message=" + result.toString() + "]")); } } else { callback.onError((V) new ClientRuntimeError("Cannot delete element, no element selected on canvas")); } } }
Source:
public String getFileAccessBlob(SecAccessType accesstype, String filename, String clustername, int expiryseconds, String jobid) throws Exception { DFUFileAccessResponse resp = getFileAccess(accesstype, filename, clustername, expiryseconds, jobid, false, false, false); if (resp != null) return resp.getMetaInfoBlob(); return ""; }

Target:
public String getFileAccessBlob(SecAccessType accesstype, String filename, String clustername, int expiryseconds, String jobid) throws Exception { DFUFileAccessResponse resp = getFileAccess(accesstype, filename, clustername, expiryseconds, jobid, false, false, false); if (resp == null) throw new Exception("Could not acquire file access for '" + filename + "' on cluster: '" + clustername + "'"); return resp.getMetaInfoBlob(); }
Source:
public CommandCallback getCallback() { VDS host = getVds(); if (host.getClusterSupportsGlusterService() && getParameters().isStopGlusterService()) { return new HostMaintenanceCallback(); } else { return super.getCallback(); } }

Target:
public CommandCallback getCallback() { if (getVds().getClusterSupportsGlusterService() && getParameters().isStopGlusterService()) { return new HostMaintenanceCallback(); } else { return super.getCallback(); } }
Source:
public void visitTryStatement(TryStatementTree tree) { ExecutionState blockES = new ExecutionState(executionState); executionState = blockES; scan(tree.block()); for (CatchTree catchTree : tree.catches()) { executionState = new ExecutionState(blockES.parent); scan(catchTree.block()); blockES.merge(executionState); } if (tree.finallyBlock() != null) { executionState = new ExecutionState(blockES.parent); scan(tree.finallyBlock()); executionState = blockES.parent.overrideBy(blockES.overrideBy(executionState)); } else { executionState = blockES.parent.merge(blockES); } }

Target:
public void visitTryStatement(TryStatementTree tree) { ExecutionState blockES = new ExecutionState(executionState); executionState = blockES; scan(tree.block()); scan(tree.resources()); for (CatchTree catchTree : tree.catches()) { executionState = new ExecutionState(blockES.parent); scan(catchTree.block()); blockES.merge(executionState); } if (tree.finallyBlock() != null) { executionState = new ExecutionState(blockES.parent); scan(tree.finallyBlock()); executionState = blockES.parent.overrideBy(blockES.overrideBy(executionState)); } else { executionState = blockES.parent.merge(blockES); } }
Source:
protected static synchronized ScheduledExecutorService executorService() { if (executorService == null) { executorService = new ScheduledThreadPoolExecutor(10, new NamingThreadFactory(new DaemonThreadFactory(), "SCMEvent")); } return executorService; }

Target:
protected static synchronized ScheduledExecutorService executorService() { if (executorService == null) { executorService = new ImpersonatingScheduledExecutorService(new ScheduledThreadPoolExecutor(10, new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()), "SCMEvent")), ACL.SYSTEM); } return executorService; }
Source:
private void adjustQuestionNumbersWithoutCommitting(int oldQuestionNumber, int newQuestionNumber, List<FeedbackQuestionAttributes> questions) { if (oldQuestionNumber < 0 || newQuestionNumber < 0) { Assumption.fail("Invalid question number"); } if (oldQuestionNumber > newQuestionNumber) { increaseQuestionNumber(newQuestionNumber, oldQuestionNumber, questions); } else if (oldQuestionNumber < newQuestionNumber) { decreaseQuestionNumber(oldQuestionNumber, newQuestionNumber, questions); } }

Target:
private void adjustQuestionNumbersWithoutCommitting( int oldQuestionNumber, int newQuestionNumber, List<FeedbackQuestionAttributes> questions) { if (oldQuestionNumber <= 0 || newQuestionNumber <= 0) { Assumption.fail("Invalid question number"); } if (oldQuestionNumber > newQuestionNumber) { increaseQuestionNumber(newQuestionNumber, oldQuestionNumber, questions); } else if (oldQuestionNumber < newQuestionNumber) { decreaseQuestionNumber(oldQuestionNumber, newQuestionNumber, questions); } }
Source:
private ScalarFunctionSplitter createScalarFunctionSplitter( int primitiveLeftFieldCount, ArrayBuffer<RexCall> extractedRexCalls, boolean isJavaTableFunction) { if (isJavaTableFunction) { return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, x -> PythonUtil.isPythonCall(x, null) ); } else { return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, PythonUtil::isNonPythonCall ); } }

Target:
private ScalarFunctionSplitter createScalarFunctionSplitter( int primitiveLeftFieldCount, ArrayBuffer<RexCall> extractedRexCalls, boolean isJavaTableFunction) { return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, isJavaTableFunction ? x -> PythonUtil.isPythonCall(x, null) : PythonUtil::isNonPythonCall ); }
Source:
private static Map<String, List<Integer>> fetchAllRelatedObjects(List<PerunBean> objects) { List<PerunBean> relatedObjects = new ArrayList<>(); Map<String, List<Integer>> mapOfBeans = new HashMap<>(); for (PerunBean object: objects) { relatedObjects.add(object); List<PerunBean> retrievedObjects = RelatedObjectsResolver.getValue(object.getBeanName()).apply(object); relatedObjects.addAll(retrievedObjects); } for (PerunBean object : relatedObjects) { if (!mapOfBeans.containsKey(object.getBeanName())) { List<Integer> listOfBeanIds = new ArrayList<>(); listOfBeanIds.add(object.getId()); mapOfBeans.put(object.getBeanName(), listOfBeanIds); } else if (!mapOfBeans.get(object.getBeanName()).contains(object.getId())) mapOfBeans.get(object.getBeanName()).add(object.getId()); } return mapOfBeans; }

Target:
private static Map<String, Set<Integer>> fetchAllRelatedObjects(List<PerunBean> objects) { List<PerunBean> relatedObjects = new ArrayList<>(); Map<String, Set<Integer>> mapOfBeans = new HashMap<>(); for (PerunBean object: objects) { relatedObjects.add(object); List<PerunBean> retrievedObjects = RelatedObjectsResolver.getValue(object.getBeanName()).apply(object); relatedObjects.addAll(retrievedObjects); } for (PerunBean object : relatedObjects) { if (!mapOfBeans.containsKey(object.getBeanName())) mapOfBeans.put(object.getBeanName(), new HashSet<>()); mapOfBeans.get(object.getBeanName()).add(object.getId()); } return mapOfBeans; }
Source:
public void putMonitoredFeed(String feedName){ MonitoredFeedsBean monitoredFeedsBean = new MonitoredFeedsBean(); monitoredFeedsBean.setFeedName(feedName); EntityManager entityManager = getEntityManager(); beginTransaction(entityManager); entityManager.persist(monitoredFeedsBean); commitAndCloseTransaction(entityManager); }

Target:
public void putMonitoredFeed(String feedName){ MonitoredFeedsBean monitoredFeedsBean = new MonitoredFeedsBean(); monitoredFeedsBean.setFeedName(feedName); EntityManager entityManager = getEntityManager(); try { beginTransaction(entityManager); entityManager.persist(monitoredFeedsBean); } finally { commitAndCloseTransaction(entityManager); } }
Source:
public static void validateRecords(short version, MemoryRecords records) { if (version >= 3) { Iterator<MutableRecordBatch> iterator = records.batches().iterator(); if (!iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " must have at least " + "one record batch"); MutableRecordBatch entry = iterator.next(); if (entry.magic() != RecordBatch.MAGIC_VALUE_V2) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain record batches with magic version 2"); if (version < 8 && entry.compressionType() == CompressionType.ZSTD) { throw new UnsupportedCompressionTypeException("Produce requests with version " + version + " are not allowed to " + "use ZStandard compression"); } if (iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain exactly one record batch"); } }

Target:
public static void validateRecords(short version, MemoryRecords records) { if (version >= 3) { Iterator<MutableRecordBatch> iterator = records.batches().iterator(); if (!iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " must have at least " + "one record batch"); MutableRecordBatch entry = iterator.next(); if (entry.magic() != RecordBatch.MAGIC_VALUE_V2) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain record batches with magic version 2"); if (version < 7 && entry.compressionType() == CompressionType.ZSTD) { throw new UnsupportedCompressionTypeException("Produce requests with version " + version + " are not allowed to " + "use ZStandard compression"); } if (iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain exactly one record batch"); } }
Source:
public Multimap<String, String> createHttpHeadersForResource(final UriInfo uriInfo, final FedoraResource resource) { final Session internalSession = sessionFactory.getInternalSession(); final IdentifierConverter<Resource, FedoraResource> translator = new DefaultIdentifierTranslator(internalSession); final Model model = createDefaultModel(); final ListMultimap<String, String> headers = ArrayListMultimap.create(); LOGGER.debug("Adding WebAC Link Header for Resource: {}", resource); nodeService.find(internalSession, resource.getPath()).getTriples(translator, PropertiesRdfContext.class) .filter(t -> model.asStatement(t).getPredicate().hasURI(WEBAC_ACCESS_CONTROL_VALUE)) .filter(t -> t.getObject().isURI()) .forEachRemaining(t -> { headers.put("Link", uriInfo.getBaseUriBuilder() .path(translator.convert(model.asStatement(t).getObject().asResource()).getPath()) + "; rel=\"acl\""); }); return headers; }

Target:
public Multimap<String, String> createHttpHeadersForResource(final UriInfo uriInfo, final FedoraResource resource) { final Session internalSession = sessionFactory.getInternalSession(); final IdentifierConverter<Resource, FedoraResource> translator = new DefaultIdentifierTranslator(internalSession); final Model model = createDefaultModel(); final ListMultimap<String, String> headers = ArrayListMultimap.create(); LOGGER.debug("Adding WebAC Link Header for Resource: {}", resource); nodeService.find(internalSession, resource.getPath()).getTriples(translator, PropertiesRdfContext.class) .filter(t -> model.asStatement(t).getPredicate().hasURI(WEBAC_ACCESS_CONTROL_VALUE)) .filter(t -> t.getObject().isURI()) .forEachRemaining(t -> { headers.put("Link", Link.fromUri(uriInfo.getBaseUriBuilder() .path(translator.convert(model.asStatement(t).getObject().asResource()).getPath()) .toString()).rel("acl").build().toString()); }); return headers; }
Source:
private String joinJvmArgs() { StringBuilder allJvmArgs = new StringBuilder(""); for (String jvmArg : jvmArgs) { String quote = isWindows() ? "\"" : ""; allJvmArgs.append(" "); allJvmArgs.append(quote); allJvmArgs.append("--jvm_arg="); allJvmArgs.append(randomizePorts(jvmArg)); allJvmArgs.append(quote); } return allJvmArgs.toString(); }

Target:
private String joinJvmArgs() { StringBuilder allJvmArgs = new StringBuilder(""); String quote = isWindows() ? "\"" : ""; for (String jvmArg : jvmArgs) { allJvmArgs.append(" "); allJvmArgs.append(quote); allJvmArgs.append("--jvm_arg="); allJvmArgs.append(randomizePorts(jvmArg)); allJvmArgs.append(quote); } return allJvmArgs.toString(); }
Source:
public void createCheckRunManyAnnotations() throws Exception { GHCheckRunBuilder.DraftOutput output = gitHub.getRepository("jglick/github-api-test") .createCheckRun("big", "4a929d464a2fae7ee899ce603250f7dab304bc4b") .withConclusion(GHCheckRun.Conclusion.SUCCESS) .withOutput("Big Run", "Lots of stuff here »"); for (int i = 0; i < 101; i++) { output.withAnnotation("stuff.txt", 1, GHCheckRun.AnnotationLevel.NOTICE, "hello #" + i).done(); } GHCheckRun checkRun = output.done().create(); assertEquals("completed", checkRun.getStatus()); assertEquals("Big Run", checkRun.getOutput().getTitle()); assertEquals(101, checkRun.getOutput().getAnnotationsCount()); assertEquals(537614832, checkRun.id); }

Target:
public void createCheckRunManyAnnotations() throws Exception { GHCheckRunBuilder.Output output = new GHCheckRunBuilder.Output("Big Run", "Lots of stuff here »"); for (int i = 0; i < 101; i++) { output.add( new GHCheckRunBuilder.Annotation("stuff.txt", 1, GHCheckRun.AnnotationLevel.NOTICE, "hello #" + i)); } GHCheckRun checkRun = gitHub.getRepository("jglick/github-api-test") .createCheckRun("big", "4a929d464a2fae7ee899ce603250f7dab304bc4b") .withConclusion(GHCheckRun.Conclusion.SUCCESS) .add(output) .create(); assertEquals("completed", checkRun.getStatus()); assertEquals("Big Run", checkRun.getOutput().getTitle()); assertEquals("Lots of stuff here »", checkRun.getOutput().getSummary()); assertEquals(101, checkRun.getOutput().getAnnotationsCount()); assertEquals(546384622, checkRun.id); }
Source:
public void testVMInsideInstall_MacOS() throws Exception { m = createMinimalConfiguration(TestEclipseDataArea.class.getName(), Constants.OS_MACOSX); File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), "../../../jre").getCanonicalFile(); m.getLauncherData().setJvm(jreLocation); m.save(false); assertNotContent(getLauncherConfigFile(), jreLocation.getAbsolutePath()); assertContent(getLauncherConfigFile(), "jre"); assertContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); assertContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "file:"); m.load(); assertEquals(jreLocation, m.getLauncherData().getJvm()); m.getLauncherData().setJvm(null); m.save(false); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); }

Target:
public void testVMInsideInstall_MacOS() throws Exception { m = createMinimalConfiguration(TestEclipseDataArea.class.getName(), Constants.OS_MACOSX); final String expectedRelativePath = "../../../jre"; File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), expectedRelativePath); m.getLauncherData().setJvm(jreLocation); m.save(false); File launcherConfigFile = getLauncherConfigFile(); assertNotContent("No absolute JRE path must be present in " + launcherConfigFile, launcherConfigFile, jreLocation.getAbsolutePath()); assertContent("Relative JRE path must be present in " + launcherConfigFile, launcherConfigFile, expectedRelativePath); }