auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean errorOccured(final int status, final String msg, final Object device) { switch (status) { case -1: case 803 : case 902 : warning(status, null); break; case 801 : case 805 : case 815 : case 903 : case 905 : case 1020 : fatalError(status, "Exit the applciation; might have to reboot ISY"); break; case 781 : case 802 : case 813 : case 904 : case 906 : case 907 : case 1021 : case 1022 : case 1023 : case 1024 : case 1025 : case 1026 : case 1050 : case 1051 : case 1100 : case 1200 : case 1301 : offLine(status, device); break; case 604 : case 701 : case 1000 : case 4000 : case 5000 : case 5001 : case 9000 : humanInterventionRequired(status, null); offLine(status, device); break; } return false; }

Target:
public boolean errorOccured(final int status, final String msg, final Object device) { switch (status) { case -1: case 803 : case 902 : warning(status, null); break; case 801 : case 805 : case 815 : case 903 : case 905 : case 1020 : fatalError(status, "Exit the application; might have to reboot ISY"); break; case 781 : case 802 : case 813 : case 904 : case 906 : case 907 : case 1021 : case 1022 : case 1023 : case 1024 : case 1025 : case 1026 : case 1050 : case 1051 : case 1100 : case 1200 : case 1301 : offLine(status, device); break; case 604 : case 701 : case 1000 : case 4000 : case 5000 : case 5001 : case 9000 : humanInterventionRequired(status, null); offLine(status, device); break; } return false; }
Source:
public void onChunkPrePopulate(PopulateChunkEvent.Pre event) { World world = (World) event.world; int chunkStartX = event.chunkX; int chunkStartZ = event.chunkZ; Chunk chunk = (Chunk) event.chunkProvider.provideChunk(event.chunkX, event.chunkZ); if (chunk == null) { throw new NullPointerException("Failed to populate chunk at (" + event.chunkX + "," + event.chunkZ + ")"); } for (Populator populator : ((SpongeWorldGenerator) world.getWorldGenerator()).accessPopulators()) { populator.populate(chunk, event.rand); } for (Populator populator : world.getBiome(chunkStartX + 15, chunkStartZ + 15).getPopulators()) { populator.populate(chunk, event.rand); } }

Target:
public void onChunkPrePopulate(PopulateChunkEvent.Pre event) { World world = (World) event.world; int chunkStartX = event.chunkX; int chunkStartZ = event.chunkZ; Chunk chunk = (Chunk) event.chunkProvider.provideChunk(event.chunkX, event.chunkZ); if (chunk == null) { throw new NullPointerException("Failed to populate chunk at (" + event.chunkX + "," + event.chunkZ + ")"); } for (Populator populator : ((IMixinWorld) world).getPopulators()) { populator.populate(chunk, event.rand); } for (Populator populator : world.getBiome(chunkStartX + 15, chunkStartZ + 15).getPopulators()) { populator.populate(chunk, event.rand); } }
Source:
private void handleOpenTabIntent(Intent intent) { String tabIdentifier = intent.getStringExtra(ARG_OPEN_TAB); if (StringUtils.isNotBlank(tabIdentifier)) { switch (tabIdentifier) { case ARG_NOTIFICATIONS: mViewPager.setCurrentItem(WPMainTabAdapter.TAB_NOTIFS); break; } } else { AppLog.e(T.MAIN, "WPMainActivity.handleOpenIntent called with an invalid argument."); } }

Target:
private void handleOpenTabIntent(Intent intent) { String tabIdentifier = intent.getStringExtra(ARG_OPEN_TAB); if (!TextUtils.isEmpty(tabIdentifier)) { switch (tabIdentifier) { case ARG_NOTIFICATIONS: mViewPager.setCurrentItem(WPMainTabAdapter.TAB_NOTIFS); break; } } else { AppLog.e(T.MAIN, "WPMainActivity.handleOpenIntent called with an invalid argument."); } }
Source:
private void handleUnmanagedCommands() { List<AsyncTask> asyncTasks = DbFacade.getInstance().getAsyncTaskDao().getAll(); Set<Guid> asyncTaskManagerManagedCommands = asyncTasks.stream().filter(x -> x.getVdsmTaskId() != null) .map(x -> x.getRootCommandId()).collect(Collectors.toSet()); asyncTaskManagerManagedCommands.addAll(asyncTasks.stream().filter(x -> x.getVdsmTaskId() != null) .map(x -> x.getCommandId()).collect(Collectors.toSet())); ENDED_WITH_FAILURE. getCommands(false).stream() .filter(x -> !x.isCallbackEnabled() && x.getCommandStatus() == CommandStatus.ACTIVE && !asyncTaskManagerManagedCommands.contains(x.getId())) .forEach(x -> commandsCache.updateCommandStatus(x.getId(), CommandStatus.ENDED_WITH_FAILURE)); }

Target:
private void handleUnmanagedCommands() { List<AsyncTask> asyncTasks = asyncTaskDao.getAll(); Stream<AsyncTask> taskStream = asyncTasks.stream().filter(x -> x.getVdsmTaskId() != null); Set<Guid> asyncTaskManagerManagedCommands = taskStream .map(x -> x.getRootCommandId()).collect(Collectors.toSet()); asyncTaskManagerManagedCommands.addAll(taskStream .map(x -> x.getCommandId()).collect(Collectors.toSet())); ENDED_WITH_FAILURE. getCommands(false).stream() .filter(x -> !x.isCallbackEnabled()) .filter(x -> x.getCommandStatus() == CommandStatus.ACTIVE) .filter(x -> !asyncTaskManagerManagedCommands.contains(x.getId())) .forEach(x -> commandsCache.updateCommandStatus(x.getId(), CommandStatus.ENDED_WITH_FAILURE)); }
Source:
public void testLogToFile() throws IOException { final File logFile = File.createTempFile(getClass().getSimpleName(), ".tmp"); logFile.deleteOnExit(); Log.setGlobalPrintStream(new PrintStream(new FileOutputStream(logFile.getPath(), true))); final String words = "Hello World"; log.info(words); final List<String> list = Files.readAllLines(logFile.toPath()); Assert.assertEquals(list.size(), 1); Assert.assertTrue(list.get(0).contains(words)); }

Target:
public void testLogToFile() throws IOException { final File logFile = File.createTempFile(getClass().getSimpleName(), ".tmp"); logFile.deleteOnExit(); final Log.LogLevel originalLogLevel = Log.getGlobalLogLevel(); final PrintStream originalStream = Log.getGlobalPrintStream(); try (final PrintStream stream = new PrintStream(new FileOutputStream(logFile.getPath(), true))) { Log.setGlobalPrintStream(stream); Log.setGlobalLogLevel(Log.LogLevel.DEBUG); final String words = "Hello World"; log.info(words); final List<String> list = Files.readAllLines(logFile.toPath()); Assert.assertEquals(Log.getGlobalLogLevel(), Log.LogLevel.DEBUG); Assert.assertEquals(list.size(), 1); Assert.assertTrue(list.get(0).contains(words)); } finally { Log.setGlobalLogLevel(originalLogLevel); Log.setGlobalPrintStream(originalStream); } }
Source:
protected @NonNull List<IMarkerEvent> getViewMarkerList(long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) { ITimeGraphEntry[] expandedElements = getTimeGraphViewer().getExpandedElements(); List<IMarkerEvent> markers = new ArrayList<>(); for (ITimeGraphEntry element : expandedElements) { if (((TimeGraphEntry) element).getModel() instanceof SpanLifeEntryModel) { SpanLifeEntryModel model = (SpanLifeEntryModel) ((TimeGraphEntry) element).getModel(); for (LogEvent log : model.getLogs()) { markers.add(new SpanMarkerEvent(element, log.fTime, MARKER_COLOR, log.fType)); } } } return markers; }

Target:
protected @NonNull List<IMarkerEvent> getViewMarkerList(long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) { ITimeGraphEntry[] expandedElements = getTimeGraphViewer().getExpandedElements(); List<IMarkerEvent> markers = new ArrayList<>(); for (ITimeGraphEntry element : expandedElements) { if (((TimeGraphEntry) element).getModel() instanceof SpanLifeEntryModel) { SpanLifeEntryModel model = (SpanLifeEntryModel) ((TimeGraphEntry) element).getModel(); for (LogEvent log : model.getLogs()) { markers.add(new SpanMarkerEvent(element, log.getTime(), MARKER_COLOR, log.getType())); } } } return markers; }
Source:
public static Iterable<Diff> getAssociatedDiffs(final Diff diffRoot, Iterable<Diff> subDiffs, boolean leftToRight) { return null; }

Target:
public static Iterable<Diff> getAssociatedDiffs(final Diff diffRoot, Iterable<Diff> subDiffs, boolean leftToRight) { return Collections.emptyList(); }
Source:
private void preCheckPermission() throws IOException, AccessControlException { if (shouldIgnorePreCheckPermission()) { return; } Path hbaseDir = FSUtils.getRootDir(getConf()); FileSystem fs = hbaseDir.getFileSystem(getConf()); UserProvider userProvider = UserProvider.instantiate(getConf()); UserGroupInformation ugi = userProvider.getCurrent().getUGI(); FileStatus[] files = fs.listStatus(hbaseDir); for (FileStatus file : files) { try { fs.access(file.getPath(), FsAction.WRITE); } catch (AccessControlException ace) { LOG.warn("Got AccessDeniedException when preCheckPermission ", ace); errors.reportError(ERROR_CODE.WRONG_USAGE, "Current user " + ugi.getUserName() + " does not have write perms to " + file.getPath() + ". Please rerun hbck as hdfs user " + file.getOwner()); throw ace; } } }

Target:
private void preCheckPermission() throws IOException { if (shouldIgnorePreCheckPermission()) { return; } Path hbaseDir = FSUtils.getRootDir(getConf()); FileSystem fs = hbaseDir.getFileSystem(getConf()); UserProvider userProvider = UserProvider.instantiate(getConf()); UserGroupInformation ugi = userProvider.getCurrent().getUGI(); FileStatus[] files = fs.listStatus(hbaseDir); for (FileStatus file : files) { try { fs.access(file.getPath(), FsAction.WRITE); } catch (AccessControlException ace) { LOG.warn("Got AccessDeniedException when preCheckPermission ", ace); errors.reportError(ERROR_CODE.WRONG_USAGE, "Current user " + ugi.getUserName() + " does not have write perms to " + file.getPath() + ". Please rerun hbck as hdfs user " + file.getOwner()); throw ace; } } }
Source:
public ElementData render() { ElementData result = new ElementData("Differential privacy"); result.addProperty("Epsilon", epsilon); result.addProperty("Delta", delta); result.addProperty("Uniqueness threshold (k)", getK()); result.addProperty("Sampling probability (beta)", getBeta()); return result; }

Target:
public ElementData render() { ElementData result = new ElementData("Differential privacy"); result.addProperty("Epsilon", epsilon); result.addProperty("Delta", delta); try { result.addProperty("Uniqueness threshold (k)", getK()); result.addProperty("Sampling probability (beta)", getBeta()); } catch (Exception e) { } return result; }
Source:
public FatekColorItem(Item item, List<String> confItems) throws BindingConfigParseException { super(item, confItems); step = getParamsFromConfAsInt(confItems, "step", 5); if (confItems.size() < 3 || confItems.size() > 5) { throw new BindingConfigParseException( "Incorect binding for color item- should be: plcName:R1:R2:R3[:R4][:RGB|HSB]"); } try { reg1 = Reg.parse(confItems.get(0)); reg2 = Reg.parse(confItems.get(1)); reg3 = Reg.parse(confItems.get(2)); } catch (UnknownRegNameException e) { throw new BindingConfigParseException(e.getMessage()); } if (confItems.size() == 4) { try { reg4 = Reg.parse(confItems.get(3)); } catch (UnknownRegNameException e) { initColorMode(confItems.get(3)); } } if (confItems.size() == 5) { try { reg4 = Reg.parse(confItems.get(3)); } catch (UnknownRegNameException e) { throw new BindingConfigParseException(e.getMessage()); } initColorMode(confItems.get(4)); } if (reg1.isDiscrete() || reg2.isDiscrete() || reg3.isDiscrete()) { throw new BindingConfigParseException( "Please use data reg for color item"); } }

Target:
public FatekColorItem(Item item, List<String> confItems) throws BindingConfigParseException { super(item, confItems); step = getParamsFromConfAsInt(confItems, "step", 5); if (confItems.size() < 3 || confItems.size() > 5) { throw new BindingConfigParseException( "Incorrect binding for color item - should be: plcName:R1:R2:R3[:R4][:RGB|HSB]"); } try { reg1 = Reg.parse(confItems.get(0)); reg2 = Reg.parse(confItems.get(1)); reg3 = Reg.parse(confItems.get(2)); } catch (UnknownRegNameException e) { throw new BindingConfigParseException(e.getMessage()); } if (confItems.size() == 4) { try { reg4 = Reg.parse(confItems.get(3)); } catch (UnknownRegNameException e) { initColorMode(confItems.get(3)); } } if (confItems.size() == 5) { try { reg4 = Reg.parse(confItems.get(3)); } catch (UnknownRegNameException e) { throw new BindingConfigParseException(e.getMessage()); } initColorMode(confItems.get(4)); } if (reg1.isDiscrete() || reg2.isDiscrete() || reg3.isDiscrete()) { throw new BindingConfigParseException( "Please use data reg for color item"); } }
Source:
ListenableFuture<HeaderCacheElement> asyncRefresh() { if (isAppEngine) { SettableFuture<HeaderCacheElement> f = SettableFuture.create(); try { f.set(syncRefresh()); } catch (Exception e) { f.setException(e); } return f; } synchronized (this.isRefreshing) { if (!this.isRefreshing.compareAndSet(false, true)) { this.futureToken = executor.submit(new Callable<HeaderCacheElement>() { @Override public HeaderCacheElement call() throws Exception { HeaderCacheElement newToken = refreshCredentialsWithRetry(); synchronized (RefreshingOAuth2CredentialsInterceptor.this) { headerCache.set(newToken); futureToken = null; isRefreshing.set(false); } return newToken; } }); } return this.futureToken; } }

Target:
ListenableFuture<HeaderCacheElement> asyncRefresh() { if (isAppEngine) { SettableFuture<HeaderCacheElement> f = SettableFuture.create(); try { f.set(syncRefresh()); } catch (Exception e) { f.setException(e); } return f; } synchronized (this.isRefreshing) { if (!this.isRefreshing.compareAndSet(false, true)) { this.futureToken = executor.submit(new Callable<HeaderCacheElement>() { @Override public HeaderCacheElement call() throws Exception { try { HeaderCacheElement newToken = refreshCredentialsWithRetry(); headerCache.set(newToken); return newToken; } finally { synchronized (isRefreshing) { futureToken = null; isRefreshing.set(false); } } } }); } return this.futureToken; } }
Source:
public AssignmentHandler(TabletServer server, KeyExtent extent, int retryAttempt) { this.server = server; this.onlineTablets = server.getOnlineTabletsRaw(); this.unopenedTablets = server.getUnopenedTablets(); this.openingTablets = server.getOpeningTablets(); this.extent = extent; this.retryAttempt = retryAttempt; }

Target:
public AssignmentHandler(TabletServer server, KeyExtent extent, int retryAttempt) { this.server = server; this.extent = extent; this.retryAttempt = retryAttempt; }
Source:
public File move(File source, File target) throws IOException { if (target.isDirectory()) { Path path = Files.move(source.toPath(), Paths.get(target.getAbsolutePath(), source.getName()), ATOMIC_MOVE); return path.toFile(); } this.renameFile(source, target); return target; }

Target:
public File move(File source, File target) throws IOException { if (target.isDirectory()) { Path path = Files.move(source.toPath(), Paths.get(target.getAbsolutePath(), source.getName()), ATOMIC_MOVE); return path.toFile(); } Path path = Files.move(source.toPath(), target.toPath(), ATOMIC_MOVE); return path.toFile(); }
Source:
public ActivityCenterResponseDto getAppActivityCenterResponseData(String loginName, Source source, Integer index, Integer pageSize) { List<ActivityModel> activityModels = activityMapper.findOperatingActivities(source); List<ActivityCenterDataDto> activityCenterDataDtos = new ArrayList<>(); for (ActivityModel activityModel : activityModels) { activityCenterDataDtos.add(new ActivityCenterDataDto(activityModel)); } ActivityCenterResponseDto activityCenterResponseDto = new ActivityCenterResponseDto(); activityCenterResponseDto.setIndex(index); activityCenterResponseDto.setPageSize(pageSize); activityCenterResponseDto.setTotalCount(activityCenterDataDtos.size()); if (null == index || null == pageSize) { activityCenterResponseDto.setActivities(activityCenterDataDtos); } else { List<ActivityCenterDataDto> results = new ArrayList<>(); for (int startIndex = (index - 1) * pageSize, endIndex = index * pageSize <= activityCenterDataDtos.size() ? index * pageSize : activityCenterDataDtos.size(); startIndex < endIndex; ++startIndex) { results.add(activityCenterDataDtos.get(startIndex)); } activityCenterResponseDto.setActivities(results); } return activityCenterResponseDto; }

Target:
public ActivityCenterResponseDto getAppActivityCenterResponseData(String loginName, Source source, Integer index, Integer pageSize) { if (null == index) { index = 1; } if (null == pageSize) { pageSize = 10; } List<ActivityModel> activityModels = activityMapper.findActiveActivities(source, (index - 1) * pageSize, pageSize); List<ActivityCenterDataDto> activityCenterDataDtos = new ArrayList<>(); for (ActivityModel activityModel : activityModels) { activityCenterDataDtos.add(new ActivityCenterDataDto(activityModel)); } ActivityCenterResponseDto activityCenterResponseDto = new ActivityCenterResponseDto(); activityCenterResponseDto.setIndex(index); activityCenterResponseDto.setPageSize(pageSize); activityCenterResponseDto.setTotalCount(activityMapper.countActiveActivities(source)); activityCenterResponseDto.setActivities(activityCenterDataDtos); return activityCenterResponseDto; }
Source:
Optional<ResponseConstructor> get(Class<? extends Response<?>> responseClass) { if (!this.cache.containsKey(responseClass)) { this.cache.put(responseClass, Arrays.stream(responseClass.getDeclaredConstructors()) .filter(constructor -> { int paramCount = constructor.getParameterCount(); return paramCount >= 3 && paramCount <= 5; }) .sorted(Comparator.comparingInt(Constructor::getParameterCount)) .findFirst() .flatMap(constructor -> { try { MethodHandles.Lookup lookup = MethodHandles.lookup(); MethodHandle ctrMethodHandle = lookup.unreflectConstructor(constructor); switch (constructor.getParameterCount()) { case 3: Object f3 = LambdaMetafactory.metafactory(lookup, "apply", MethodType.methodType(Response3.class), MethodType.methodType(Object.class, Object.class, int.class, Object.class), ctrMethodHandle, ctrMethodHandle.type()).getTarget().invoke(); return Optional.of(new ResponseConstructor(3, f3)); case 4: Object f4 = LambdaMetafactory.metafactory(lookup, "apply", MethodType.methodType(Response4.class), MethodType.methodType(Object.class, Object.class, int.class, Object.class, Object.class), ctrMethodHandle, ctrMethodHandle.type()).getTarget().invoke(); return Optional.of(new ResponseConstructor(4, f4)); case 5: Object f5 = LambdaMetafactory.metafactory(lookup, "apply", MethodType.methodType(Response5.class), MethodType.methodType(Object.class, Object.class, int.class, Object.class, Object.class, Object.class), ctrMethodHandle, ctrMethodHandle.type()) .getTarget().invoke(); return Optional.of(new ResponseConstructor(5, f5)); default: return Optional.empty(); } } catch (Throwable t) { throw logger.logExceptionAsError(new RuntimeException(t)); } })); } return this.cache.get(responseClass); }

Target:
ResponseConstructor get(Class<? extends Response<?>> responseClass) { return this.cache.computeIfAbsent(responseClass, this::locateResponseConstructor); }
Source:
public abstract void run() throws Exception; @Override public String toString() { return "ZkEvent[description: " + _description + "; session: " + _sessionId + "]"; }

Target:
public abstract void run() throws Exception; @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ZkEvent[description: ").append(_description); if (_sessionId != null) { sb.append("; session: ").append(_sessionId); } sb.append("]"); return sb.toString(); }
Source:
public static List<FeedbackParticipantType> getParticipantListFromCommaSeparatedValues( String commaSeparatedValues) { List<FeedbackParticipantType> participantList = new ArrayList<FeedbackParticipantType>(); if (commaSeparatedValues == null || commaSeparatedValues.isEmpty()) { return participantList; } String[] splitString = commaSeparatedValues.split(","); for (String str : splitString) { participantList.add(FeedbackParticipantType.valueOf(str)); } return participantList; }

Target:
public static List<FeedbackParticipantType> getParticipantListFromCommaSeparatedValues( String commaSeparatedValues) { List<FeedbackParticipantType> participantList = new ArrayList<FeedbackParticipantType>(); if (commaSeparatedValues == null || commaSeparatedValues.isEmpty()) { return participantList; } for (String str : commaSeparatedValues.split(",")) { participantList.add(FeedbackParticipantType.valueOf(str)); } return participantList; }
Source:
public Optional<String> resolveUpstreamDNS(String address) { try { if (address.contains(":")) { HostAndPort hostAndPort = HostAndPort.fromString(address); try { InetAddresses.forString(hostAndPort.getHost()); return Optional.of(address); } catch (IllegalArgumentException e) { } String cached = resolveCache.getIfPresent(hostAndPort.getHost()); String ip; int port = hostAndPort.getPort(); if (cached != null) { ip = cached; } else { ip = InetAddress.getByName(hostAndPort.getHost()).getHostAddress(); resolveCache.put(hostAndPort.getHost(), ip); } return Optional.of(String.format("%s:%d", ip, port)); } else { try { InetAddresses.forString(address); return Optional.of(address); } catch (IllegalArgumentException e) { } return Optional.of(InetAddress.getByName(address).getHostAddress()); } } catch (UnknownHostException uhe) { return Optional.absent(); } }

Target:
public Optional<String> resolveUpstreamDNS(String address) { String host; Optional<Integer> port = Optional.absent(); if (address.contains(":")) { HostAndPort hostAndPort = HostAndPort.fromString(address); host = hostAndPort.getHost(); port = Optional.of(hostAndPort.getPort()); } else { host = address; } try { InetAddresses.forString(host); return Optional.of(address); } catch (IllegalArgumentException e) { } try { String cached = resolveCache.getIfPresent(host); String ip; if (cached != null) { ip = cached; } else { ip = InetAddress.getByName(host).getHostAddress(); resolveCache.put(host, ip); } if (port.isPresent()) { return Optional.of(String.format("%s:%d", ip, port.get())); } else { return Optional.of(String.format("%s", ip)); } } catch (UnknownHostException uhe) { return Optional.absent(); } }
Source:
public String call() { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { getRootCAList(bos); return bos.toString("utf-8"); } catch (UnsupportedEncodingException e) { return bos.toString(); } }

Target:
public String call() { StringWriter writer = new StringWriter(); getRootCAList(writer); return writer.toString(); }
Source:
public static String unescape(StringElement stringElement) { String lowerCasePrefix = stringElement.prefix().toLowerCase(Locale.ROOT); String valueWithoutQuotes = stringElement.trimmedQuotesValue(); boolean isEscaped = lowerCasePrefix.indexOf('r') == -1; boolean isBytesLiteral = lowerCasePrefix.indexOf('b') != -1; if (isEscaped) { boolean support16Bits = !isBytesLiteral; valueWithoutQuotes = unescapeString(valueWithoutQuotes, support16Bits); } return valueWithoutQuotes; }

Target:
public static String unescape(StringElement stringElement) { String lowerCasePrefix = stringElement.prefix().toLowerCase(Locale.ROOT); String valueWithoutQuotes = stringElement.trimmedQuotesValue(); boolean isEscaped = lowerCasePrefix.indexOf('r') == -1; boolean isBytesLiteral = lowerCasePrefix.indexOf('b') != -1; if (isEscaped) { valueWithoutQuotes = unescapeString(valueWithoutQuotes, isBytesLiteral); } return valueWithoutQuotes; }
Source:
ResultModel buildResultModelFromFunctionResults(RestoreRedundancyResults results, boolean isStatusCommand) { if (results.getRegionResults().size() == 0 && results.getIncludedRegionsWithNoMembers().size() == 0) { return createNoMembersResultModel(); } if (!results.getSuccess()) { return createErrorResultModel(results.getStatusMessage()); } ResultModel result = new ResultModel(); if (results.getIncludedRegionsWithNoMembers().size() > 0) { addRegionsWithNoMembersSection(results.getIncludedRegionsWithNoMembers(), result); } addSummarySection(result, results); addZeroRedundancySection(result, results); addUnderRedundancySection(result, results); addSatisfiedRedundancySection(result, results); if (!isStatusCommand) { addPrimariesSection(result, results); if (results.getRegionOperationStatus().equals(RestoreRedundancyResults.Status.FAILURE)) { result.setStatus(Result.Status.ERROR); } } return result; }

Target:
ResultModel buildResultModelFromFunctionResults(RestoreRedundancyResults results, boolean isStatusCommand) { if (results.getRegionResults().isEmpty() && results.getIncludedRegionsWithNoMembers().isEmpty()) { return createNoMembersResultModel(); } if (!results.getSuccess()) { return createErrorResultModel(results.getStatusMessage()); } ResultModel result = new ResultModel(); if (!results.getIncludedRegionsWithNoMembers().isEmpty()) { addRegionsWithNoMembersSection(results.getIncludedRegionsWithNoMembers(), result); } addSummarySection(result, results); addZeroRedundancySection(result, results); addUnderRedundancySection(result, results); addSatisfiedRedundancySection(result, results); if (!isStatusCommand) { addPrimariesSection(result, results); if (results.getRegionOperationStatus() == RestoreRedundancyResults.Status.FAILURE) { result.setStatus(Result.Status.ERROR); } } return result; }
Source:
public ExternalCompressor getCompressorForMethod( final BlockCompressionMethod compressionMethod, final int compressorSpecificArg) { switch (compressionMethod) { case RAW: ValidationUtils.validateArg( compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG, String.format(argErrorMessage, compressorSpecificArg, compressionMethod)); return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg); case GZIP: return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg); case LZMA: ValidationUtils.validateArg( compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG, String.format(argErrorMessage, compressorSpecificArg, compressionMethod)); return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg); case RANS: final int ransArg = compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG ? RANS.ORDER.ZERO.ordinal() : compressorSpecificArg; final Tuple<BlockCompressionMethod, Integer> compressorTuple = new Tuple<>( BlockCompressionMethod.RANS, ransArg); if (!compressorCache.containsKey(compressorTuple)) { if (sharedRANS == null) { sharedRANS = new RANS(); } compressorCache.put( new Tuple(BlockCompressionMethod.RANS, ransArg), new RANSExternalCompressor(ransArg, sharedRANS) ); } return getCachedCompressorForMethod(compressorTuple.a, compressorTuple.b); case BZIP2: ValidationUtils.validateArg( compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG, String.format(argErrorMessage, compressorSpecificArg, compressionMethod)); return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg); default: throw new IllegalArgumentException(String.format("Unknown compression method %s", compressionMethod)); } }

Target:
public ExternalCompressor getCompressorForMethod( final BlockCompressionMethod compressionMethod, final int compressorSpecificArg) { switch (compressionMethod) { case GZIP: return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg); case BZIP2: case RAW: case LZMA: ValidationUtils.validateArg( compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG, String.format(argErrorMessage, compressorSpecificArg, compressionMethod)); return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg); case RANS: final int ransArg = compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG ? RANS.ORDER.ZERO.ordinal() : compressorSpecificArg; final Tuple<BlockCompressionMethod, Integer> compressorTuple = new Tuple<>( BlockCompressionMethod.RANS, ransArg); if (!compressorCache.containsKey(compressorTuple)) { if (sharedRANS == null) { sharedRANS = new RANS(); } compressorCache.put( new Tuple(BlockCompressionMethod.RANS, ransArg), new RANSExternalCompressor(ransArg, sharedRANS) ); } return getCachedCompressorForMethod(compressorTuple.a, compressorTuple.b); default: throw new IllegalArgumentException(String.format("Unknown compression method %s", compressionMethod)); } }
Source:
public static String computeXoauth(String username, String authToken) throws UnsupportedEncodingException { return new String(Base64.encodeBase64( ("user="+username+"\001auth=Bearer "+authToken+"\001\001").getBytes() ),US_ASCII); }

Target:
public static String computeXoauth(String username, String authToken) throws UnsupportedEncodingException { return new String( Base64.encodeBase64(String.format(XOAUTH_FORMAT, username, authToken).getBytes()), US_ASCII); }
Source:
private Set<InetSocketAddress> refreshLocalHosts(List<TokenRange> tokenRanges) { Set<InetSocketAddress> localHosts = Sets.newHashSet(); if (myLocation.isPresent()) { for (TokenRange tokenRange : tokenRanges) { for (EndpointDetails details : tokenRange.getEndpoint_details()) { if (details.isSetDatacenter() && details.isSetRack() && details.isSetHost() && myLocation.get().equals(HostLocation.of(details.getDatacenter(), details.getRack()))) { localHosts.add(getAddressForHostThrowUnchecked(details.getHost())); } } } } return localHosts; }

Target:
private Set<InetSocketAddress> refreshLocalHosts(List<TokenRange> tokenRanges) { Optional<HostLocation> myLocation = myLocationSupplier.get(); if (!myLocation.isPresent()) { return ImmutableSet.of(); } Set<InetSocketAddress> newLocalHosts = tokenRanges.stream() .map(TokenRange::getEndpoint_details) .flatMap(Collection::stream) .filter(details -> isHostLocal(details, myLocation.get())) .map(EndpointDetails::getHost) .map(this::getAddressForHostThrowUnchecked) .collect(Collectors.toSet()); if (newLocalHosts.isEmpty()) { log.warn("No local hosts found"); } return newLocalHosts; }
Source:
public static CounterConfiguration parsedConfigToConfig(AbstractCounterConfiguration configuration) { if (configuration instanceof StrongCounterConfiguration) { if (((StrongCounterConfiguration) configuration).isBound()) { return CounterConfiguration.builder(CounterType.BOUNDED_STRONG).initialValue(configuration.initialValue()) .lowerBound(((StrongCounterConfiguration) configuration).lowerBound()) .upperBound(((StrongCounterConfiguration) configuration).upperBound()) .storage(configuration.storage()).build(); } else { return CounterConfiguration.builder(CounterType.UNBOUNDED_STRONG).initialValue(configuration.initialValue()) .storage(configuration.storage()).build(); } } else if (configuration instanceof WeakCounterConfiguration) { return CounterConfiguration.builder(CounterType.WEAK).initialValue(configuration.initialValue()) .storage(configuration.storage()) .concurrencyLevel(((WeakCounterConfiguration) configuration).concurrencyLevel()).build(); } throw new IllegalStateException( "[should never happen] unknown CounterConfiguration class: " + configuration.getClass()); }

Target:
public static CounterConfiguration parsedConfigToConfig(AbstractCounterConfiguration configuration) { if (configuration instanceof StrongCounterConfiguration) { return parsedConfigToConfig((StrongCounterConfiguration) configuration); } else if (configuration instanceof WeakCounterConfiguration) { return parsedConfigToConfig((WeakCounterConfiguration) configuration); } throw new IllegalStateException( "[should never happen] unknown CounterConfiguration class: " + configuration.getClass()); }
Source:
private void generateUpdateSignature(Method method) { generateDoc(method); Parameter mainParameter = JaxrsGeneratorUtils.getMainUpdateParameter(method); if (mainParameter == null) { System.err.println("Method \"" + method + "\" doesn't have any struct parameter"); return; } Type mainType = mainParameter.getType(); JavaTypeReference mainTypeReference = schemaNames.getXjcTypeReference(mainType); String methodName = concatenateName(method, method.getBase().getName()); javaBuffer.addLine( "default %s " + methodName + "(%s %s) {", mainTypeReference.getText(), mainTypeReference.getText(), javaNames.getJavaMemberStyleName(mainParameter.getName())); javaBuffer.addLine("throw new UnsupportedOperationException();"); javaBuffer.addLine("}"); }

Target:
private void generateUpdateSignature(Method method) { generateDoc(method); Parameter mainParameter = jaxrsGeneratorUtils.getMainUpdateParameter(method); if (mainParameter == null) { throw new IllegalStateException("Method \"" + method + "\" doesn't have any struct parameter"); } Type mainType = mainParameter.getType(); JavaTypeReference mainTypeReference = schemaNames.getXjcTypeReference(mainType); String methodName = javaNames.getJavaMemberStyleName(names.concatenate(method.getBase().getName(), method.getName())); javaBuffer.addLine( "default %s " + methodName + "(%s %s) {", mainTypeReference.getText(), mainTypeReference.getText(), javaNames.getJavaMemberStyleName(mainParameter.getName())); javaBuffer.addLine("throw new UnsupportedOperationException();"); javaBuffer.addLine("}"); }
Source:
public Query getNamedSQLQuery(String queryName) { errorIfClosed(); NamedSQLQueryDefinition nsqlqd = findNamedNativeQuery( queryName ); Query query = new NoSQLQuery( nsqlqd, this, NO_PARAMETERS ); query.setComment( "named native SQL query " + queryName ); return query; }

Target:
public Query getNamedSQLQuery(String queryName) { errorIfClosed(); NamedSQLQueryDefinition nsqlqd = findNamedNativeQuery( queryName ); Query query = new NoSQLQuery( nsqlqd, this, NO_PARAMETERS ); query.setComment( "named native query " + queryName ); return query; }
Source:
public void getContainerLogWithRestart() throws Exception { story.addStep(new Statement() { @Override public void evaluate() throws Throwable { configureCloud(); story.j.jenkins.addNode(new DumbSlave("slave", "dummy", tmp.newFolder("remoteFS").getPath(), "1", Node.Mode.NORMAL, "", new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList())); WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("getContainerLogWithRestart.groovy") , true)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); SemaphoreStep.waitForStart("wait/1", b); SemaphoreStep.success("wait/1", false); Thread.sleep(1000); } }); story.addStep(new Statement() { @SuppressWarnings("SleepWhileInLoop") @Override public void evaluate() throws Throwable { WorkflowRun b = story.j.jenkins.getItemByFullName("p", WorkflowJob.class).getBuildByNumber(1); story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)); story.j.assertLogContains("INFO: Handshaking", b); story.j.assertLogContains("INFO: Connected", b); } }); }

Target:
public void getContainerLogWithRestart() throws Exception { story.then(r -> { configureCloud(); r.jenkins.addNode(new DumbSlave("slave", "dummy", tmp.newFolder("remoteFS").getPath(), "1", Node.Mode.NORMAL, "", new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList())); WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("getContainerLogWithRestart.groovy") , true)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); r.waitForMessage("+ sleep 5", b); }); story.then(r -> { WorkflowRun b = r.jenkins.getItemByFullName("p", WorkflowJob.class).getBuildByNumber(1); r.assertBuildStatusSuccess(r.waitForCompletion(b)); r.assertLogContains("INFO: Handshaking", b); r.assertLogContains("INFO: Connected", b); }); }
Source:
public void createHttpMessage() throws IOException { msg = new org.parosproxy.paros.network.HttpMessage(); msg.setRequestHeader("GET " + URI + " HTTP/1.1"); }

Target:
public void createHttpMessage() throws IOException { msg = new HttpMessage(); msg.setRequestHeader("GET " + URI + " HTTP/1.1"); }
Source:
protected boolean attachUserToSession() { Date validTo = null; if (!StringUtils.isEmpty(getParameters().getSessionId())) { validTo = SessionDataContainer.getInstance() .getValidTo(getParameters().getSessionId()); if (validTo.compareTo(new Date(System.currentTimeMillis())) < 0) { SessionDataContainer.getInstance().removeSession(getParameters().getSessionId()); return failCanDoAction(VdcBllMessages.USER_CANNOT_LOGIN_SESSION_MISSING); } SessionDataContainer.getInstance().setUser(getParameters().getSessionId(), getCurrentUser()); } else { if (!SessionDataContainer.getInstance().setUser(getCurrentUser())) { return failCanDoAction(VdcBllMessages.USER_CANNOT_LOGIN_SESSION_MISSING); } validTo = DateUtils.addMinutes(new Date(), Config.<Integer> getValue(ConfigValues.UserSessionTimeOutInterval)); try { Date fromExtension = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ").parse(authRecord.<String> get(AuthRecord.VALID_TO)); validTo = validTo.compareTo(fromExtension) < 0 ? validTo : fromExtension; } catch (ParseException e) { log.warn("Error parsing AuthRecord.VALID_TO . Default VALID_TO value will be set on session"); } SessionDataContainer.getInstance().setValidTo(validTo); } return true; }

Target:
protected boolean attachUserToSession() { if (!StringUtils.isEmpty(getParameters().getSessionId())) { SessionDataContainer.getInstance().setUser(getParameters().getSessionId(), getCurrentUser()); } else if (!SessionDataContainer.getInstance().setUser(getCurrentUser())) { return failCanDoAction(VdcBllMessages.USER_CANNOT_LOGIN_SESSION_MISSING); } return true; }
Source:
public void updateParticipantWithMismatchedIdsUsesURL() throws Exception { TestUtils.mockPlay().withJsonBody(createJson(createJson("{'id':'id2'}"))).mock(); Result result = controller.updateParticipant("id1"); assertResult(result, 200, "Participant updated."); verify(mockParticipantService).updateParticipant(eq(study), participantCaptor.capture()); StudyParticipant persisted = participantCaptor.getValue(); assertEquals("id1", persisted.getId()); }

Target:
public void updateParticipantWithMismatchedIdsUsesURL() throws Exception { TestUtils.mockPlay().withJsonBody(createJson("{'id':'id2'}")).mock(); Result result = controller.updateParticipant("id1"); assertResult(result, 200, "Participant updated."); verify(mockParticipantService).updateParticipant(eq(study), participantCaptor.capture()); StudyParticipant persisted = participantCaptor.getValue(); assertEquals("id1", persisted.getId()); }
Source:
@Override public void sendResponse(Exchange exchange, Response response) { if (null == response.getType()) response.setType(Type.CON); top.sendResponse(exchange, response); response.setAcknowledged(true); }

Target:
@Override public void sendResponse(Exchange exchange, Response response) { if (null == response.getType()) { response.setType(Type.CON); } top.sendResponse(exchange, response); response.setAcknowledged(true); }
Source:
public boolean processLine(String line, ErrorParserManager epManager) { Matcher m = fixit.matcher(line); if (m.matches()) { IFile f = epManager.findFileName(m.group(1)); try { IMarker[] markers = f.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE); if (markers.length > 0) { IMarker lastMarker = markers[markers.length - 1]; FixitManager.getInstance().addMarker(lastMarker, m.group(2), m.group(3)); } } catch (CoreException e) { CCorePlugin.log(e); } return true; } return super.processLine(line, epManager); }

Target:
public boolean processLine(String line, ErrorParserManager epManager) { Matcher m = fixit.matcher(line); if (m.matches()) { IProject project = null; IFile f = epManager.findFileName(m.group(1)); if (f != null) { project = f.getProject(); try { ProblemMarkerInfo info = ProblemMarkerFilterManager.getInstance().getLastProblemMarker(f); String externalLocation = null; if (info.externalPath != null && !info.externalPath.isEmpty()) { externalLocation = info.externalPath.toOSString(); } IMarker[] markers = f.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE); for (IMarker marker : markers) { int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, -1); int sev = marker.getAttribute(IMarker.SEVERITY, -1); String msg = (String) marker.getAttribute(IMarker.MESSAGE); if (lineNumber == info.lineNumber && sev == info.severity && msg.equals(info.description)) { String extloc = (String) marker.getAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION); if (extloc == null || extloc.equals(externalLocation)) { if (project == null || project.equals(info.file.getProject())) { FixitManager.getInstance().addMarker(marker, m.group(2), m.group(3)); return true; } String source = (String) marker.getAttribute(IMarker.SOURCE_ID); if (project.getName().equals(source)) { FixitManager.getInstance().addMarker(marker, m.group(2), m.group(3)); return true; } } } } } catch (CoreException | NumberFormatException e) { CCorePlugin.log(e); } return true; } } return super.processLine(line, epManager); }
Source:
public void update(final float tpf) { final double numHalf = 0.5; final int numFour = 4; time += tpf; if (time > numFour) { time = 0; if (moveRight) { moveRight = false; } else { moveRight = true; } } if (moveRight) { final Vector3f vec = spatial.getLocalTranslation(); final Vector3f loc = new Vector3f((float) (vec.getX() - numHalf), vec.getY(), vec.getZ()); spatial.setLocalTranslation(loc); this.setPhysicsLocation(loc); } else { final Vector3f vec = spatial.getLocalTranslation(); final Vector3f loc = new Vector3f((float) (vec.getX() + numHalf), vec.getY(), vec.getZ()); spatial.setLocalTranslation(loc); this.setPhysicsLocation(loc); } }

Target:
public void update(final float tpf) { time += tpf; if (time > TIME_TO_MOVE_IN_ONE_DIRECTION) { time = 0; if (moveRight) { moveRight = false; } else { moveRight = true; } } if (moveRight) { final Vector3f vec = spatial.getLocalTranslation(); final Vector3f loc = new Vector3f((float) (vec.getX() - STEP_SIZE), vec.getY(), vec.getZ()); spatial.setLocalTranslation(loc); this.setPhysicsLocation(loc); } else { final Vector3f vec = spatial.getLocalTranslation(); final Vector3f loc = new Vector3f((float) (vec.getX() + STEP_SIZE), vec.getY(), vec.getZ()); spatial.setLocalTranslation(loc); this.setPhysicsLocation(loc); } }
Source:
private Throwable unwrap(Object error) { try { return ((ErrorResponse) error).getCause(); } catch (Exception e) { return (Throwable) error; } }

Target:
private Throwable unwrap(Object error) { if (error instanceof ErrorResponse) { return ((ErrorResponse) error).getCause(); } return (Throwable) error; }
Source:
public Set<String> getUntrackedFolders() { if (indexDiffFilter == null) { return Collections.<String> emptySet(); } else { HashSet<String> retVal = new HashSet<String>(indexDiffFilter.getUntrackedFolders()); retVal.removeAll(submodules); return retVal; } }

Target:
public Set<String> getUntrackedFolders() { return ((indexDiffFilter == null) ? Collections.<String> emptySet() : new HashSet<String>(indexDiffFilter.getUntrackedFolders())); }
Source:
public boolean evaluateUnaryExpression(Object rawExpression, Object resultValue, Class<?> resultClass) { if (!(rawExpression instanceof String)) { String rawClass = rawExpression == null ? null : rawExpression.getClass().getCanonicalName(); throw new IllegalArgumentException("Raw value should be a String and not a '" + rawClass + "'"); } Map<String, Object> params = new HashMap<>(); params.put(ACTUAL_VALUE_IDENTIFIER, resultValue); Object expressionResult = compileAndExecute((String) rawExpression, params); if (!(expressionResult instanceof Boolean)) { return BaseExpressionOperator.EQUALS.eval(expressionResult, resultValue, resultClass, classLoader); } return (boolean) expressionResult; }

Target:
public boolean evaluateUnaryExpression(Object rawExpression, Object resultValue, Class<?> resultClass) { if (!(rawExpression instanceof String)) { String rawClass = rawExpression == null ? null : rawExpression.getClass().getCanonicalName(); throw new IllegalArgumentException("Raw expression should be a String and not a '" + rawClass + "'"); } Map<String, Object> params = new HashMap<>(); params.put(ACTUAL_VALUE_IDENTIFIER, resultValue); Object expressionResult = compileAndExecute((String) rawExpression, params); if (!(expressionResult instanceof Boolean)) { return BaseExpressionOperator.EQUALS.eval(expressionResult, resultValue, resultClass, classLoader); } return (boolean) expressionResult; }
Source:
public SimpMessageType getMessageType() { return (simpMessageType != null) ? simpMessageType : SimpMessageType.OTHER; }

Target:
public SimpMessageType getMessageType() { return simpMessageType; }
Source:
public Map<String, String> paramsAsMap() { Map<String, String> returnableMap = new HashMap<>(); returnableMap.put("display_size", String.valueOf(this.getDisplaySize())); returnableMap.put("page", String.valueOf(this.getPage())); this.getBankStatementReference().ifPresent(bankStatementReference -> returnableMap.put("bank_statement_reference", bankStatementReference)); this.getEmail().ifPresent(email -> returnableMap.put("email", email)); this.getName().ifPresent(name -> returnableMap.put("name", name)); this.getFromDate().ifPresent(fromDate -> returnableMap.put("from_date", String.valueOf(fromDate))); this.getToDate().ifPresent(toDate -> returnableMap.put("to_date", String.valueOf(toDate))); this.getReference().ifPresent(reference -> returnableMap.put("reference", reference)); this.getState().ifPresent(state -> returnableMap.put("state", state)); return Collections.unmodifiableMap(returnableMap); }

Target:
public Map<String, String> paramsAsMap() { var params = new HashMap<String, String>(); params.put("display_size", String.valueOf(this.getDisplaySize())); params.put("page", String.valueOf(this.getPage())); this.getBankStatementReference().ifPresent(bankStatementReference -> params.put("bank_statement_reference", bankStatementReference)); this.getEmail().ifPresent(email -> params.put("email", email)); this.getName().ifPresent(name -> params.put("name", name)); this.getFromDate().ifPresent(fromDate -> params.put("from_date", String.valueOf(fromDate))); this.getToDate().ifPresent(toDate -> params.put("to_date", String.valueOf(toDate))); this.getReference().ifPresent(reference -> params.put("reference", reference)); this.getState().ifPresent(state -> params.put("state", state)); return Collections.unmodifiableMap(params); }
Source:
public void testExecutableAttributes() throws Exception { FS fs = FS.DETECTED; assumeTrue(fs.getClass().equals(FS_POSIX_Java7.class)); File f = new File(trash, "bla"); assertTrue(f.createNewFile()); assertFalse(fs.canExecute(f)); String umask = readUmask(); if (umask == null) return; char others = umask.charAt(umask.length() - 1); boolean badUmask; if (others != '0' && others != '2' && others != '4' && others != '6') { badUmask = true; } else { badUmask = false; } Set<PosixFilePermission> permissions = readPermissions(f); assertTrue(!permissions.contains(PosixFilePermission.OTHERS_EXECUTE)); assertTrue(!permissions.contains(PosixFilePermission.GROUP_EXECUTE)); assertTrue(!permissions.contains(PosixFilePermission.OWNER_EXECUTE)); fs.setExecute(f, true); RepositoryTestCase.fsTick(f); permissions = readPermissions(f); assertTrue("'owner' execute permission not set", permissions.contains(PosixFilePermission.OWNER_EXECUTE)); assertTrue("'group' execute permission not set", permissions.contains(PosixFilePermission.GROUP_EXECUTE)); if (badUmask) { assertFalse("'others' execute permission set", permissions.contains(PosixFilePermission.OTHERS_EXECUTE)); System.err.println("WARNING: your system's umask: \"" + umask + "\" doesn't allow FSJava7Test to test if setting posix" + " permissions for \"others\" works properly"); assumeFalse(badUmask); } else { assertTrue("'others' execute permission not set", permissions.contains(PosixFilePermission.OTHERS_EXECUTE)); } }

Target:
public void testExecutableAttributes() throws Exception { FS fs = FS.DETECTED; org.junit.Assume.assumeTrue(fs.getClass().equals(FS_POSIX_Java7.class)); File f = new File(trash, "bla"); assertTrue(f.createNewFile()); assertFalse(fs.canExecute(f)); String umask = readUmask(); if (umask == null) { return; } char others = umask.charAt(umask.length() - 1); boolean badUmask; if (others != '0' && others != '2' && others != '4' && others != '6') { badUmask = true; } else { badUmask = false; } Set<PosixFilePermission> permissions = readPermissions(f); assertTrue(!permissions.contains(PosixFilePermission.OTHERS_EXECUTE)); assertTrue(!permissions.contains(PosixFilePermission.GROUP_EXECUTE)); assertTrue(!permissions.contains(PosixFilePermission.OWNER_EXECUTE)); fs.setExecute(f, true); permissions = readPermissions(f); assertTrue("'owner' execute permission not set", permissions.contains(PosixFilePermission.OWNER_EXECUTE)); assertTrue("'group' execute permission not set", permissions.contains(PosixFilePermission.GROUP_EXECUTE)); if (badUmask) { assertFalse("'others' execute permission set", permissions.contains(PosixFilePermission.OTHERS_EXECUTE)); fail("Unexpected umask during test execution: " + umask); } else { assertTrue("'others' execute permission not set", permissions.contains(PosixFilePermission.OTHERS_EXECUTE)); } }
Source:
public static DataWord of(long num) { return of(ByteBuffer.allocate(8).putLong(num).array()); }

Target:
public static DataWord of(long num) { return of(ByteBuffer.allocate(Long.BYTES).putLong(num).array()); }