id
int64
1
49k
buggy
stringlengths
34
37.5k
fixed
stringlengths
2
37k
14,401
import org.spongepowered.api.world.Locatable; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; import javax.annotation.Nullable; import java.util.List; <BUG>import java.util.Optional; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG> public class CommandDelete extends FCCommandBase { private static final FlagMapper MAPPER = map -> key -> value -> { map.put(key, value);
import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
14,402
.append(Text.of(TextColors.GREEN, "Usage: ")) .append(getUsage(source)) .build()); return CommandResult.empty(); } else if (isIn(REGIONS_ALIASES, parse.args[0])) { <BUG>if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!")); IRegion region = FGManager.getInstance().getRegion(parse.args[1]); </BUG> boolean isWorldRegion = false; if (region == null) {
String regionName = parse.args[1]; IRegion region = FGManager.getInstance().getRegion(regionName).orElse(null);
14,403
</BUG> isWorldRegion = true; } if (region == null) <BUG>throw new CommandException(Text.of("No region exists with the name \"" + parse.args[1] + "\"!")); if (region instanceof GlobalWorldRegion) { </BUG> throw new CommandException(Text.of("You may not delete the global region!")); }
if (world == null) throw new CommandException(Text.of("No world exists with name \"" + worldName + "\"!")); if (world == null) throw new CommandException(Text.of("Must specify a world!")); region = FGManager.getInstance().getWorldRegion(world, regionName).orElse(null); throw new CommandException(Text.of("No region exists with the name \"" + regionName + "\"!")); if (region instanceof IGlobal) {
14,404
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region" ); return CommandResult.success(); } else if (isIn(HANDLERS_ALIASES, parse.args[0])) { if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!")); <BUG>IHandler handler = FGManager.getInstance().gethandler(parse.args[1]); if (handler == null) throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1); if (handler instanceof GlobalHandler)</BUG> throw new CommandException(Text.of("You may not delete the global handler!"));
Optional<IHandler> handlerOpt = FGManager.getInstance().gethandler(parse.args[1]); if (!handlerOpt.isPresent()) IHandler handler = handlerOpt.get(); if (handler instanceof GlobalHandler)
14,405
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
14,406
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
14,407
@Dependency(id = "foxcore") }, description = "A world protection plugin built for SpongeAPI. Requires FoxCore.", authors = {"gravityfox"}, url = "https://github.com/FoxDenStudio/FoxGuard") <BUG>public final class FoxGuardMain { public final Cause pluginCause = Cause.builder().named("plugin", this).build(); private static FoxGuardMain instanceField;</BUG> @Inject private Logger logger;
private static FoxGuardMain instanceField;
14,408
private UserStorageService userStorage; private EconomyService economyService = null; private boolean loaded = false; private FCCommandDispatcher fgDispatcher; public static FoxGuardMain instance() { <BUG>return instanceField; }</BUG> @Listener public void construct(GameConstructionEvent event) { instanceField = this;
} public static Cause getCause() { return instance().pluginCause; }
14,409
return configDirectory; } public boolean isLoaded() { return loaded; } <BUG>public static Cause getCause() { return instance().pluginCause; }</BUG> public EconomyService getEconomyService() { return economyService;
[DELETED]
14,410
import org.spongepowered.api.world.Locatable; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; import javax.annotation.Nullable; import java.util.*; <BUG>import java.util.stream.Collectors; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG> public class CommandHere extends FCCommandBase { private static final String[] PRIORITY_ALIASES = {"priority", "prio", "p"}; private static final FlagMapper MAPPER = map -> key -> value -> {
import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
14,411
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index > 0) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
14,412
private static FGStorageManager instance; private final Logger logger = FoxGuardMain.instance().getLogger();</BUG> private final Set<LoadEntry> loaded = new HashSet<>(); private final Path directory = getDirectory(); private final Map<String, Path> worldDirectories; <BUG>private FGStorageManager() { defaultModifiedMap = new CacheMap<>((k, m) -> {</BUG> if (k instanceof IFGObject) { m.put((IFGObject) k, true); return true;
public final HashMap<IFGObject, Boolean> defaultModifiedMap; private final UserStorageService userStorageService; private final Logger logger = FoxGuardMain.instance().getLogger(); userStorageService = FoxGuardMain.instance().getUserStorage(); defaultModifiedMap = new CacheMap<>((k, m) -> {
14,413
String name = fgObject.getName(); Path singleDir = dir.resolve(name.toLowerCase()); </BUG> boolean shouldSave = fgObject.shouldSave(); if (force || shouldSave) { <BUG>logger.info((shouldSave ? "S" : "Force s") + "aving handler \"" + name + "\" in directory: " + singleDir); </BUG> constructDirectory(singleDir); try { fgObject.save(singleDir);
UUID owner = fgObject.getOwner(); boolean isOwned = !owner.equals(SERVER_UUID); Optional<User> userOwner = userStorageService.get(owner); String logName = (userOwner.isPresent() ? userOwner.get().getName() + ":" : "") + (isOwned ? owner + ":" : "") + name; if (fgObject.autoSave()) { Path singleDir = serverDir.resolve(name.toLowerCase()); logger.info((shouldSave ? "S" : "Force s") + "aving handler " + logName + " in directory: " + singleDir);
14,414
if (fgObject.autoSave()) { Path singleDir = dir.resolve(name.toLowerCase()); </BUG> boolean shouldSave = fgObject.shouldSave(); if (force || shouldSave) { <BUG>logger.info((shouldSave ? "S" : "Force s") + "aving world region \"" + name + "\" in directory: " + singleDir); </BUG> constructDirectory(singleDir); try { fgObject.save(singleDir);
Path singleDir = serverDir.resolve(name.toLowerCase()); logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
14,415
public synchronized void loadRegionLinks() { logger.info("Loading region links"); try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) { Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen(); linksMap.entrySet().forEach(entry -> { <BUG>IRegion region = FGManager.getInstance().getRegion(entry.getKey()); if (region != null) { logger.info("Loading links for region \"" + region.getName() + "\"");</BUG> String handlersString = entry.getValue();
Optional<IRegion> regionOpt = FGManager.getInstance().getRegion(entry.getKey()); if (regionOpt.isPresent()) { IRegion region = regionOpt.get(); logger.info("Loading links for region \"" + region.getName() + "\"");
14,416
public synchronized void loadWorldRegionLinks(World world) { logger.info("Loading world region links for world \"" + world.getName() + "\""); try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) { Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen(); linksMap.entrySet().forEach(entry -> { <BUG>IRegion region = FGManager.getInstance().getWorldRegion(world, entry.getKey()); if (region != null) { logger.info("Loading links for world region \"" + region.getName() + "\"");</BUG> String handlersString = entry.getValue();
Optional<IWorldRegion> regionOpt = FGManager.getInstance().getWorldRegion(world, entry.getKey()); if (regionOpt.isPresent()) { IWorldRegion region = regionOpt.get(); logger.info("Loading links for world region \"" + region.getName() + "\"");
14,417
StringBuilder builder = new StringBuilder(); for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) { builder.append(it.next().getName()); if (it.hasNext()) builder.append(","); } <BUG>return builder.toString(); }</BUG> private final class LoadEntry { public final String name; public final Type type;
public enum Type { REGION, WREGION, HANDLER
14,418
.autoCloseQuotes(true) .leaveFinalAsIs(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "worldregion", "handler", "controller").stream() </BUG> .filter(new StartsWithPredicate(parse.current.token)) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "worldregion", "handler", "controller")
14,419
import models.api.responses.*; import models.api.results.DateHistogramResult; import models.api.results.SearchResult; import play.mvc.Call; import play.mvc.Http.Request; <BUG>import java.io.IOException; public class UniversalSearch { public static final int PER_PAGE = 100; private final ApiClient api;</BUG> private final String query;
import java.util.concurrent.TimeUnit; public static final int KEITH = 61; // http://en.wikipedia.org/wiki/61_(number) -> Keith private final ApiClient api;
14,420
.queryParams(timeRange.getQueryParams()) .queryParam("query", query) .queryParam("limit", pageSize) .queryParam("offset", page * pageSize) .queryParam("filter", (filter == null ? "*" : filter)) <BUG>.accept(mediaType) .execute();</BUG> } public SearchResult search() throws IOException, APIException { SearchResultResponse response = doSearch(SearchResultResponse.class, MediaType.JSON_UTF_8, PER_PAGE);
.timeout(KEITH, TimeUnit.SECONDS) .execute();
14,421
DateHistogramResponse response = api.get(DateHistogramResponse.class) .path("/search/universal/{0}/histogram", timeRange.getType().toString().toLowerCase()) .queryParam("interval", interval) .queryParam("query", query) .queryParams(timeRange.getQueryParams()) <BUG>.queryParam("filter", (filter == null ? "*" : filter)) .execute();</BUG> return new DateHistogramResult(response.query, response.time, response.interval, response.results); } public FieldStatsResponse fieldStats(String field) throws IOException, APIException {
.timeout(KEITH, TimeUnit.SECONDS) .execute();
14,422
return api.get(FieldStatsResponse.class) .path("/search/universal/{0}/stats", timeRange.getType().toString().toLowerCase()) .queryParam("field", field) .queryParam("query", query) .queryParams(timeRange.getQueryParams()) <BUG>.queryParam("filter", (filter == null ? "*" : filter)) .execute();</BUG> } public FieldTermsResponse fieldTerms(String field) throws IOException, APIException { return api.get(FieldTermsResponse.class)
.timeout(KEITH, TimeUnit.SECONDS) .execute();
14,423
return api.get(FieldTermsResponse.class) .path("/search/universal/{0}/terms", timeRange.getType().toString().toLowerCase()) .queryParam("field", field) .queryParam("query", query) .queryParams(timeRange.getQueryParams()) <BUG>.queryParam("filter", (filter == null ? "*" : filter)) .execute();</BUG> } public FieldHistogramResponse fieldHistogram(String field, String interval) throws IOException, APIException { return api.get(FieldHistogramResponse.class)
.timeout(KEITH, TimeUnit.SECONDS) .execute();
14,424
.path("/search/universal/{0}/fieldhistogram", timeRange.getType().toString().toLowerCase()) .queryParam("field", field) .queryParam("interval", interval) .queryParam("query", query) .queryParams(timeRange.getQueryParams()) <BUG>.queryParam("filter", (filter == null ? "*" : filter)) .execute();</BUG> } public Call getRoute(Request request, int page) { int relative = Tools.intSearchParamOrEmpty(request, "relative");
.timeout(KEITH, TimeUnit.SECONDS) .execute();
14,425
import org.spongepowered.api.world.Locatable; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; import javax.annotation.Nullable; import java.util.List; <BUG>import java.util.Optional; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG> public class CommandDelete extends FCCommandBase { private static final FlagMapper MAPPER = map -> key -> value -> { map.put(key, value);
import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
14,426
.append(Text.of(TextColors.GREEN, "Usage: ")) .append(getUsage(source)) .build()); return CommandResult.empty(); } else if (isIn(REGIONS_ALIASES, parse.args[0])) { <BUG>if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!")); IRegion region = FGManager.getInstance().getRegion(parse.args[1]); </BUG> boolean isWorldRegion = false; if (region == null) {
String regionName = parse.args[1]; IRegion region = FGManager.getInstance().getRegion(regionName).orElse(null);
14,427
</BUG> isWorldRegion = true; } if (region == null) <BUG>throw new CommandException(Text.of("No region exists with the name \"" + parse.args[1] + "\"!")); if (region instanceof GlobalWorldRegion) { </BUG> throw new CommandException(Text.of("You may not delete the global region!")); }
if (world == null) throw new CommandException(Text.of("No world exists with name \"" + worldName + "\"!")); if (world == null) throw new CommandException(Text.of("Must specify a world!")); region = FGManager.getInstance().getWorldRegion(world, regionName).orElse(null); throw new CommandException(Text.of("No region exists with the name \"" + regionName + "\"!")); if (region instanceof IGlobal) {
14,428
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region" ); return CommandResult.success(); } else if (isIn(HANDLERS_ALIASES, parse.args[0])) { if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!")); <BUG>IHandler handler = FGManager.getInstance().gethandler(parse.args[1]); if (handler == null) throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1); if (handler instanceof GlobalHandler)</BUG> throw new CommandException(Text.of("You may not delete the global handler!"));
Optional<IHandler> handlerOpt = FGManager.getInstance().gethandler(parse.args[1]); if (!handlerOpt.isPresent()) IHandler handler = handlerOpt.get(); if (handler instanceof GlobalHandler)
14,429
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
14,430
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
14,431
@Dependency(id = "foxcore") }, description = "A world protection plugin built for SpongeAPI. Requires FoxCore.", authors = {"gravityfox"}, url = "https://github.com/FoxDenStudio/FoxGuard") <BUG>public final class FoxGuardMain { public final Cause pluginCause = Cause.builder().named("plugin", this).build(); private static FoxGuardMain instanceField;</BUG> @Inject private Logger logger;
private static FoxGuardMain instanceField;
14,432
private UserStorageService userStorage; private EconomyService economyService = null; private boolean loaded = false; private FCCommandDispatcher fgDispatcher; public static FoxGuardMain instance() { <BUG>return instanceField; }</BUG> @Listener public void construct(GameConstructionEvent event) { instanceField = this;
} public static Cause getCause() { return instance().pluginCause; }
14,433
return configDirectory; } public boolean isLoaded() { return loaded; } <BUG>public static Cause getCause() { return instance().pluginCause; }</BUG> public EconomyService getEconomyService() { return economyService;
[DELETED]
14,434
import org.spongepowered.api.world.Locatable; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; import javax.annotation.Nullable; import java.util.*; <BUG>import java.util.stream.Collectors; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG> public class CommandHere extends FCCommandBase { private static final String[] PRIORITY_ALIASES = {"priority", "prio", "p"}; private static final FlagMapper MAPPER = map -> key -> value -> {
import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
14,435
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index > 0) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
14,436
private static FGStorageManager instance; private final Logger logger = FoxGuardMain.instance().getLogger();</BUG> private final Set<LoadEntry> loaded = new HashSet<>(); private final Path directory = getDirectory(); private final Map<String, Path> worldDirectories; <BUG>private FGStorageManager() { defaultModifiedMap = new CacheMap<>((k, m) -> {</BUG> if (k instanceof IFGObject) { m.put((IFGObject) k, true); return true;
public final HashMap<IFGObject, Boolean> defaultModifiedMap; private final UserStorageService userStorageService; private final Logger logger = FoxGuardMain.instance().getLogger(); userStorageService = FoxGuardMain.instance().getUserStorage(); defaultModifiedMap = new CacheMap<>((k, m) -> {
14,437
String name = fgObject.getName(); Path singleDir = dir.resolve(name.toLowerCase()); </BUG> boolean shouldSave = fgObject.shouldSave(); if (force || shouldSave) { <BUG>logger.info((shouldSave ? "S" : "Force s") + "aving handler \"" + name + "\" in directory: " + singleDir); </BUG> constructDirectory(singleDir); try { fgObject.save(singleDir);
UUID owner = fgObject.getOwner(); boolean isOwned = !owner.equals(SERVER_UUID); Optional<User> userOwner = userStorageService.get(owner); String logName = (userOwner.isPresent() ? userOwner.get().getName() + ":" : "") + (isOwned ? owner + ":" : "") + name; if (fgObject.autoSave()) { Path singleDir = serverDir.resolve(name.toLowerCase()); logger.info((shouldSave ? "S" : "Force s") + "aving handler " + logName + " in directory: " + singleDir);
14,438
if (fgObject.autoSave()) { Path singleDir = dir.resolve(name.toLowerCase()); </BUG> boolean shouldSave = fgObject.shouldSave(); if (force || shouldSave) { <BUG>logger.info((shouldSave ? "S" : "Force s") + "aving world region \"" + name + "\" in directory: " + singleDir); </BUG> constructDirectory(singleDir); try { fgObject.save(singleDir);
Path singleDir = serverDir.resolve(name.toLowerCase()); logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
14,439
public synchronized void loadRegionLinks() { logger.info("Loading region links"); try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) { Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen(); linksMap.entrySet().forEach(entry -> { <BUG>IRegion region = FGManager.getInstance().getRegion(entry.getKey()); if (region != null) { logger.info("Loading links for region \"" + region.getName() + "\"");</BUG> String handlersString = entry.getValue();
Optional<IRegion> regionOpt = FGManager.getInstance().getRegion(entry.getKey()); if (regionOpt.isPresent()) { IRegion region = regionOpt.get(); logger.info("Loading links for region \"" + region.getName() + "\"");
14,440
public synchronized void loadWorldRegionLinks(World world) { logger.info("Loading world region links for world \"" + world.getName() + "\""); try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) { Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen(); linksMap.entrySet().forEach(entry -> { <BUG>IRegion region = FGManager.getInstance().getWorldRegion(world, entry.getKey()); if (region != null) { logger.info("Loading links for world region \"" + region.getName() + "\"");</BUG> String handlersString = entry.getValue();
Optional<IWorldRegion> regionOpt = FGManager.getInstance().getWorldRegion(world, entry.getKey()); if (regionOpt.isPresent()) { IWorldRegion region = regionOpt.get(); logger.info("Loading links for world region \"" + region.getName() + "\"");
14,441
StringBuilder builder = new StringBuilder(); for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) { builder.append(it.next().getName()); if (it.hasNext()) builder.append(","); } <BUG>return builder.toString(); }</BUG> private final class LoadEntry { public final String name; public final Type type;
public enum Type { REGION, WREGION, HANDLER
14,442
.autoCloseQuotes(true) .leaveFinalAsIs(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "worldregion", "handler", "controller").stream() </BUG> .filter(new StartsWithPredicate(parse.current.token)) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "worldregion", "handler", "controller")
14,443
myPeers = newMyPeers; Logger.normal(this, "Added " + pn); } if(pn.recordStatus()) addPeerNodeStatus(pn.getPeerNodeStatus(), pn, false); <BUG>pn.setPeerNodeStatus(System.currentTimeMillis()); updatePMUserAlert();</BUG> if((!ignoreOpennet) && pn instanceof OpennetPeerNode) { OpennetManager opennet = node.getOpennet(); if(opennet != null)
if(!pn.isSeed()) updatePMUserAlert();
14,444
System.arraycopy(connectedPeers, 0, newConnectedPeers, 0, connectedPeers.length); newConnectedPeers[connectedPeers.length] = pn; connectedPeers = newConnectedPeers; if(logMINOR) Logger.minor(this, "Connected peers: " + connectedPeers.length); <BUG>} updatePMUserAlert();</BUG> node.lm.announceLocChange(); } public PeerNode getByPeer(Peer peer) {
if(!pn.isSeed()) updatePMUserAlert();
14,445
import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; import java.util.Collections; import java.util.List; public class DatabaseVersion implements BatchComponent, ServerComponent { <BUG>public static final int LAST_VERSION = 547; </BUG> public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL }
public static final int LAST_VERSION = 548;
14,446
this.networkRoot = new File(new File(indexPrimaryPath, networkName), "NETWORK"); this.queuesRoot = new File(new File(indexPrimaryPath, networkName), "QUEUES"); this.networkRoot.mkdirs(); this.queuesRoot.mkdirs(); ResultURLs.clearStacks(); <BUG>setConfig("heuristic.site", false); setConfig("heuristic.blekko", false); setConfig("heuristic.twitter", false); this.peers.relocate(</BUG> this.networkRoot,
setConfig(SwitchboardConstants.HEURISTIC_SITE, false); setConfig(SwitchboardConstants.HEURISTIC_BLEKKO, false); setConfig(SwitchboardConstants.HEURISTIC_TWITTER, false); this.peers.relocate(
14,447
this.tables.cleanFailURLS(getConfigLong("cleanup.failedSearchURLtimeout", -1)); } if (getConfigBool("triplestore.persistent", false)) { JenaTripleStore.saveAll(); } <BUG>if (this.crawlQueues.coreCrawlJobSize() == 0) { index.fulltext().getDefaultConfiguration().postprocessing(index);</BUG> index.fulltext().getWebgraphConfiguration().postprocessing(index); } return true;
if (this.crawlQueues.noticeURL.isEmpty()) this.crawlQueues.noticeURL.clear(); // flushes more caches index.fulltext().getDefaultConfiguration().postprocessing(index);
14,448
searchEvent.oneFeederTerminated(); } } }.start(); } <BUG>public final void heuristicSearchResults(final String host) { </BUG> new Thread() { @Override public void run() {
public final void heuristicSearchResults(final String url) {
14,449
new Thread() { @Override public void run() { final DigestURI startUrl; try { <BUG>startUrl = new DigestURI(host); </BUG> } catch (final MalformedURLException e) { Log.logException(e); return;
startUrl = new DigestURI(url);
14,450
prop.put("thisaddress", hostName); final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER); final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true) || sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true) <BUG>|| clustersearch; boolean global = post == null || (post.get("resource", "local").equals("global") && sb.peers.sizeConnected() > 0 && indexReceiveGranted); prop.put("topmenu_resource-select", (sb.peers == null || sb.peers.sizeConnected() == 0 || !indexReceiveGranted) ? 0 : global ? 1 : 2); if ( post == null || indexSegment == null || env == null || !searchAllowed ) { prop.put("searchagain", "0");</BUG> prop.put("former", "");
boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted; boolean global = post == null || (post.get("resource", "local").equals("global") && p2pmode); boolean stealthmode = p2pmode && !global; prop.put("topmenu_resource-select", stealthmode ? 2 : global ? 1 : 0); if (indexSegment == null) Log.logInfo("yacysearch", "indexSegment == null"); prop.put("searchagain", "0");
14,451
if ( heuristicBlekko >= 0 ) { querystring = querystring.replace("/heuristic/blekko", ""); modifier.add("/heuristic/blekko"); } final int heuristicTwitter = querystring.indexOf("/heuristic/twitter", 0); <BUG>if ( heuristicBlekko >= 0 ) { </BUG> querystring = querystring.replace("/heuristic/twitter", ""); modifier.add("/heuristic/twitter"); }
if ( heuristicTwitter >= 0 ) {
14,452
</BUG> for (;;) { long nanos = getCacheTimeTakenNanos; if (nanos <= Long.MAX_VALUE - duration) { <BUG>GET_CACHE_TIME_TAKEN_NANOS_UPDATER.compareAndSet(this, nanos, nanos + duration); } else { clear(); GET_CACHE_TIME_TAKEN_NANOS_UPDATER.set(this, duration); }</BUG> }
MISSES_UPDATER.addAndGet(this, number); public void increaseCacheEvictions(long number) { EVICTIONS_UPDATER.addAndGet(this, number); public void addGetTimeNanos(long duration) { if (GET_CACHE_TIME_TAKEN_NANOS_UPDATER.compareAndSet(this, nanos, nanos + duration)) { return;
14,453
</BUG> for (;;) { long nanos = putTimeTakenNanos; if (nanos <= Long.MAX_VALUE - duration) { <BUG>PUT_TIME_TAKEN_NANOS_UPDATER.compareAndSet(this, nanos, nanos + duration); } else { clear(); PUT_TIME_TAKEN_NANOS_UPDATER.set(this, duration); }</BUG> }
return; public void addPutTimeNanos(long duration) { if (PUT_TIME_TAKEN_NANOS_UPDATER.compareAndSet(this, nanos, nanos + duration)) { return;
14,454
Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.tab_qibla, container, false); final QiblaCompassView qiblaCompassView = (QiblaCompassView)rootView.findViewById(R.id.qibla_compass); qiblaCompassView.setConstants(((TextView)rootView.findViewById(R.id.bearing_north)), getText(R.string.bearing_north), ((TextView)rootView.findViewById(R.id.bearing_qibla)), getText(R.string.bearing_qibla)); <BUG>sOrientationListener = new SensorListener() { </BUG> public void onSensorChanged(int s, float v[]) { float northDirection = v[SensorManager.DATA_X]; qiblaCompassView.setDirections(northDirection, sQiblaDirection);
sOrientationListener = new android.hardware.SensorListener() {
14,455
IBEACON((byte)0x7, IBeacon.Register.values()), HAPTIC((byte)0x8, Haptic.Register.values()), DATA_PROCESSOR((byte) 0x9, DataProcessor.Register.values()), EVENT((byte)0xa, Event.Register.values()), LOGGING((byte)0xb, Logging.Register.values()), <BUG>TIMER((byte)0xc, Timer.Register.values()), DEBUG((byte)0xfe, Debug.Register.values());</BUG> public final byte opcode; private final HashMap<Byte, Register> registers; private Module(byte opcode, Register[] registers) {
I2C((byte) 0xd, com.mbientlab.metawear.api.controller.I2C.Register.values()), MACRO((byte) 0xf, Macro.Register.values()), SETTINGS((byte) 0x11, Settings.Register.values()), DEBUG((byte)0xfe, Debug.Register.values());
14,456
public void chainFilters(byte srcFilterId, byte srcSize, FilterConfig config); public void addFilter(Trigger trigger, FilterConfig config); public void addReadFilter(Trigger trigger, FilterConfig config); public void setFilterConfiguration(byte filterId, FilterConfig config); public void resetFilterState(byte filterId); <BUG>public void setFilterState(byte filterId, byte[]state); </BUG> public void removeFilter(byte filterId); public void removeAllFilters(); public void enableFilterNotify(byte filterId);
public void setFilterState(byte filterId, byte[] state);
14,457
((Callbacks) it).receivedCommandBytes(commandBytes); } } }, REMOVE_ENTRY { <BUG>@Override public byte opcode() { return 0x4; } };</BUG> @Override public Module module() { return Module.EVENT; } @Override
REMOVE_ALL_ENTRIES { @Override public byte opcode() { return 0x5; } };
14,458
import java.util.Collection; import com.mbientlab.metawear.api.MetaWearController.ModuleCallbacks; import com.mbientlab.metawear.api.MetaWearController.ModuleController; import com.mbientlab.metawear.api.Module; import static com.mbientlab.metawear.api.Module.GPIO; <BUG>public interface GPIO extends ModuleController { public enum Register implements com.mbientlab.metawear.api.Register {</BUG> SET_DIGITAL_OUTPUT { @Override public byte opcode() { return 0x1; } },
public static final byte ANALOG_DATA_SIZE= 2; public static final byte DIGITAL_DATA_SIZE= 1; public static final byte PIN_CHANGE_NOTIFY_SIZE= 1; public enum Register implements com.mbientlab.metawear.api.Register {
14,459
import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; <BUG>import android.os.Binder; import android.os.IBinder;</BUG> import android.support.v4.content.LocalBroadcastManager; public class MetaWearBleService extends Service { private enum DeviceState {
import android.os.Build; import android.os.IBinder;
14,460
"com.mbientlab.com.metawear.api.MetaWearBleService.Action.CHARACTERISTIC_READ"; public static final String RSSI_READ= "com.mbientlab.com.metawear.api.MetaWearBleService.Action.RSSI_READ"; } private class Extra { <BUG>public static final String EXPLICIT_CLOSE= "com.mbientlab.metawear.api.MetaWearBleService.Extra.EXPLICIT_CLOSE";</BUG> public static final String BLUETOOTH_DEVICE= "com.mbientlab.metawear.api.MetaWearBleService.Extra.BLUETOOTH_DEVICE"; public static final String GATT_OPERATION=
[DELETED]
14,461
"com.mbientlab.com.metawear.api.MetaWearBleService.Extra.CHARACTERISTIC_UUID"; public static final String CHARACTERISTIC_VALUE= "com.mbientlab.com.metawear.api.MetaWearBleService.Extra.CHARACTERISTIC_VALUE"; } private interface GattAction { <BUG>public void execAction(); </BUG> } private interface InternalCallback { public void process(byte[] data);
public boolean execAction();
14,462
}; } return mwBroadcastReceiver; } private void broadcastIntent(Intent intent) { <BUG>if (useLocalBroadcastMnger) { LocalBroadcastManager.getInstance(this).sendBroadcast(intent); </BUG> } else {
if (localBroadcastMngr != null) { localBroadcastMngr.sendBroadcast(intent);
14,463
mwState.deviceState= DeviceState.READING_CHARACTERISTICS; readCharacteristic(mwState); } else if (mwState.readyToClose) {</BUG> close(mwState.notifyUser); } <BUG>} execGattAction(); </BUG> } @Override
intent.putExtra(Extra.SERVICE_UUID, characteristic.getService().getUuid()); intent.putExtra(Extra.CHARACTERISTIC_UUID, characteristic.getUuid()); intent.putExtra(Extra.CHARACTERISTIC_VALUE, characteristic.getValue()); intent.putExtra(Extra.BLUETOOTH_DEVICE, mwState.mwBoard); broadcastIntent(intent); if (mwState.readyToClose && mwState.numGattActions.get() == 0) { execGattAction(true);
14,464
Intent intent= new Intent(Action.GATT_ERROR); intent.putExtra(Extra.STATUS, status); intent.putExtra(Extra.GATT_OPERATION, DeviceCallbacks.GattOperation.CHARACTERISTIC_WRITE); intent.putExtra(Extra.BLUETOOTH_DEVICE, mwState.mwBoard); broadcastIntent(intent); <BUG>} if (!mwState.commandBytes.isEmpty()) writeCommand(mwState); else mwState.deviceState= DeviceState.READY; if (mwState.deviceState == DeviceState.READY) { if (!mwState.readCharUuids.isEmpty()) { mwState.deviceState= DeviceState.READING_CHARACTERISTICS; readCharacteristic(mwState); } else if (mwState.readyToClose) {</BUG> close(mwState.notifyUser);
[DELETED]
14,465
mwState.deviceState= DeviceState.READING_CHARACTERISTICS; readCharacteristic(mwState); } else if (mwState.readyToClose) {</BUG> close(mwState.notifyUser); } <BUG>} execGattAction(); </BUG> } @Override
Intent intent= new Intent(Action.GATT_ERROR); intent.putExtra(Extra.STATUS, status); intent.putExtra(Extra.GATT_OPERATION, DeviceCallbacks.GattOperation.CHARACTERISTIC_WRITE); intent.putExtra(Extra.BLUETOOTH_DEVICE, mwState.mwBoard); broadcastIntent(intent); if (mwState.readyToClose && mwState.numGattActions.get() == 0) { execGattAction(true);
14,466
public void disableComponent(Component component) { disableNotification(component); } @Override public void enableNotification(Component component) { <BUG>writeRegister(mwState, Register.GLOBAL_ENABLE, (byte)0); writeRegister(mwState, component.enable, (byte)1); writeRegister(mwState, component.status, (byte)1); writeRegister(mwState, Register.GLOBAL_ENABLE, (byte)1); </BUG> }
[DELETED]
14,467
configurations.clear(); globalConfig= new byte[] {0, 0, 0x18, 0, 0}; } } @Override <BUG>public ThresholdConfig enableTapDetection(TapType type, Axis axis) { </BUG> byte[] tapConfig; if (!configurations.containsKey(Component.PULSE)) { tapConfig= new byte[] {0x40, 0, 0x40, 0x40, 0x50, 0x18, 0x14, 0x3c};
public TapConfig enableTapDetection(TapType type, Axis axis) {
14,468
break; } configurations.put(Component.PULSE, tapConfig); activeComponents.add(Component.PULSE); activeNotifications.add(Component.PULSE); <BUG>return new ThresholdConfig() { </BUG> @Override public ThresholdConfig withThreshold(float gravity) { byte nSteps= (byte) (gravity / MMA8452Q_G_PER_STEP);
case DOUBLE_TAP: tapConfig[0] |= 1 << (1 + 2 * axis.ordinal()); return new TapConfig() {
14,469
break; case ORIENTATION: config[2]= (byte) (Math.max(100 / (10 * multiplier), 20)); break; case PULSE: <BUG>config[5]= (byte) (Math.min(Math.max(60 / (2.5 * multiplier), 5), 0.625)); config[6]= (byte) (Math.min(Math.max(200 / (5 * multiplier), 10), 1.25)); config[7]= (byte) (Math.min(Math.max(300 / (5 * multiplier), 10), 1.25)); </BUG> break;
config[5]= (byte) (Math.min(Math.max(tapDuration / (2.5 * multiplier), 5), 0.625)); config[6]= (byte) (Math.min(Math.max(tapLatency / (5 * multiplier), 10), 1.25)); config[7]= (byte) (Math.min(Math.max(tapWindow / (5 * multiplier), 10), 1.25));
14,470
</BUG> } @Override public void disableIBecon() { <BUG>writeRegister(mwState, Register.ENABLE, (byte)0); </BUG> } @Override public IBeacon setUUID(UUID uuid) { byte[] uuidBytes= ByteBuffer.wrap(new byte[16])
private ModuleController getIBeaconModule() { if (!modules.containsKey(Module.IBEACON)) { modules.put(Module.IBEACON, new IBeacon() { public void enableIBeacon() { queueRegisterAction(mwState, true, Register.ENABLE, (byte)1); queueRegisterAction(mwState, true, Register.ENABLE, (byte)0);
14,471
byte[] uuidBytes= ByteBuffer.wrap(new byte[16]) .order(ByteOrder.LITTLE_ENDIAN) .putLong(uuid.getLeastSignificantBits()) .putLong(uuid.getMostSignificantBits()) .array(); <BUG>writeRegister(mwState, Register.ADVERTISEMENT_UUID, uuidBytes); </BUG> return this; } @Override
queueRegisterAction(mwState, true, Register.ADVERTISEMENT_UUID, uuidBytes);
14,472
</BUG> } @Override public void disableNotification() { <BUG>writeRegister(mwState, Register.SWITCH_STATE, (byte)0); </BUG> } }); } return modules.get(Module.MECHANICAL_SWITCH);
private ModuleController getMechanicalSwitchModule() { if (!modules.containsKey(Module.MECHANICAL_SWITCH)) { modules.put(Module.MECHANICAL_SWITCH, new MechanicalSwitch() { public void enableNotification() { queueRegisterAction(mwState, true, Register.SWITCH_STATE, (byte)1); queueRegisterAction(mwState, true, Register.SWITCH_STATE, (byte)0);
14,473
} @Override public void setPixel(byte strand, byte pixel, byte red, byte green, byte blue) { <BUG>writeRegister(mwState, Register.PIXEL, strand, pixel, red, green, blue); </BUG> } @Override public void rotateStrand(byte strand, RotationDirection direction, byte repetitions, short delay) {
public void disableNotification() { queueRegisterAction(mwState, true, Register.SWITCH_STATE, (byte)0);
14,474
(byte)(delay & 0xff), (byte)(delay >> 8 & 0xff)); } @Override public void deinitializeStrand(byte strand) { <BUG>writeRegister(mwState, Register.DEINITIALIZE, strand); </BUG> } }); } return modules.get(Module.NEO_PIXEL);
queueRegisterAction(mwState, true, Register.DEINITIALIZE, strand);
14,475
private ModuleController getTemperatureModule() { if (!modules.containsKey(Module.TEMPERATURE)) { modules.put(Module.TEMPERATURE, new Temperature() { @Override public void readTemperature() { <BUG>readRegister(mwState, Register.TEMPERATURE, (byte) 0); </BUG> } @Override public SamplingConfigBuilder enableSampling() {
queueRegisterAction(mwState, false, Register.TEMPERATURE, (byte) 0);
14,476
public void startMotor(short pulseWidth) { startMotor(DEFAULT_DUTY_CYCLE, pulseWidth); } @Override public void startBuzzer(short pulseWidth) { <BUG>writeRegister(mwState, Register.PULSE, (byte)127, (byte)(pulseWidth & 0xff), </BUG> (byte)((pulseWidth >> 8) & 0xff), (byte)1); } @Override
queueRegisterAction(mwState, true, Register.PULSE, (byte)127, (byte)(pulseWidth & 0xff),
14,477
(byte)((pulseWidth >> 8) & 0xff), (byte)1); } @Override public void startMotor(float dutyCycle, short pulseWidth) { short converted= (short)((dutyCycle / 100.f) * 248); <BUG>writeRegister(mwState, Register.PULSE, (byte)(converted & 0xff), (byte)(pulseWidth & 0xff), </BUG> (byte)((pulseWidth >> 8) & 0xff), (byte)0); } });
queueRegisterAction(mwState, true, Register.PULSE, (byte)(converted & 0xff), (byte)(pulseWidth & 0xff),
14,478
public boolean isAboveThreshold(Axis axis); public Direction getDirection(Axis axis); } public void disableDetection(Component component, boolean saveConfig); public void disableAllDetection(boolean saveConfig); <BUG>public ThresholdConfig enableTapDetection(TapType type, Axis axis); </BUG> public ThresholdConfig enableShakeDetection(Axis axis); public AccelerometerConfig enableOrientationDetection(); public ThresholdConfig enableFreeFallDetection();
public TapConfig enableTapDetection(TapType type, Axis axis);
14,479
import org.copperengine.core.batcher.RetryingTxnBatchRunner; import org.copperengine.core.batcher.impl.BatcherImpl; import org.copperengine.core.common.WorkflowRepository; import org.copperengine.core.persistent.DatabaseDialect; import org.copperengine.core.persistent.DerbyDbDialect; <BUG>import org.copperengine.core.persistent.H2Dialect; import org.copperengine.core.persistent.OracleDialect; import org.copperengine.core.persistent.PersistentScottyEngine; import org.copperengine.core.persistent.ScottyDBStorage;</BUG> import org.copperengine.core.persistent.ScottyDBStorageInterface;
import org.copperengine.core.persistent.MySqlDialect; import org.copperengine.core.persistent.PostgreSQLDialect; import org.copperengine.core.persistent.ScottyDBStorage;
14,480
import com.google.common.base.Supplier; import com.google.common.base.Suppliers; public abstract class RdbmsEngineFactory<T extends DependencyInjector> extends AbstractPersistentEngineFactory<T> { private static final Logger logger = LoggerFactory.getLogger(RdbmsEngineFactory.class); protected final Supplier<DataSource> dataSource; <BUG>protected final Supplier<Batcher> batcher; </BUG> private int numberOfBatcherThreads = 4; public RdbmsEngineFactory(List<String> wfPackges) { super(wfPackges);
protected final Supplier<BatcherImpl> batcher;
14,481
CopperTransactionController txnController = new CopperTransactionController(); txnController.setDataSource(dataSource.get()); return txnController; } @Override <BUG>protected ScottyDBStorageInterface createDBStorage() { DatabaseDialect dialect = createDialect(dataSource.get(), workflowRepository.get(), engineIdProvider.get()); dialect.startup();</BUG> final ScottyDBStorage dbStorage = new ScottyDBStorage(); dbStorage.setDialect(dialect);
DatabaseDialect dialect = createDatabaseDialect();
14,482
import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.render.FacesRenderer; import net.bootsfaces.beans.ELTools; <BUG>import net.bootsfaces.component.ajax.AJAXRenderer; import net.bootsfaces.render.CoreRenderer;</BUG> import net.bootsfaces.render.Responsive; import net.bootsfaces.render.Tooltip; import net.bootsfaces.utils.BsfUtils;
import net.bootsfaces.component.dataTableColumn.DataTableColumn; import net.bootsfaces.render.CoreRenderer;
14,483
label, labelStyle, labelStyleClass, order, orderBy, <BUG>orderable, searchable,</BUG> style, styleClass; String toString;
searchValue, searchable,
14,484
package com.ge.predix.acs.rest; <BUG>import java.util.Set; import org.apache.commons.lang.builder.EqualsBuilder;</BUG> import org.apache.commons.lang.builder.HashCodeBuilder; import com.ge.predix.acs.model.Attribute; import io.swagger.annotations.ApiModel;
import java.util.LinkedHashSet; import org.apache.commons.lang.builder.EqualsBuilder;
14,485
hashCodeBuilder.append(this.action).append(this.resourceIdentifier).append(this.subjectIdentifier); if (null != this.subjectAttributes) { for (Attribute attribute : this.subjectAttributes) { hashCodeBuilder.append(attribute); } <BUG>} return hashCodeBuilder.toHashCode();</BUG> } @Override public boolean equals(final Object obj) {
for (String policyID : this.policySetsEvaluationOrder) { hashCodeBuilder.append(policyID); return hashCodeBuilder.toHashCode();
14,486
package com.ge.predix.acs.policy.evaluation.cache; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; <BUG>import java.util.HashSet; import java.util.List;</BUG> import java.util.Map; import java.util.Set; import java.util.stream.Collectors;
import java.util.LinkedHashSet; import java.util.List;
14,487
keys.add(key.toRedisKey()); return keys; } private void logCacheGetDebugMessages(final PolicyEvaluationRequestCacheKey key, final String redisKey, final List<String> keys, final List<String> values) { <BUG>if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("Getting timestamp for policy set: '%s', key: '%s', timestamp:'%s'.", key.getPolicySetId(), keys.get(0), values.get(0))); </BUG> LOGGER.debug(String.format("Getting timestamp for resource: '%s', key: '%s', timestamp:'%s'.",
LinkedHashSet<String> policySetIds = key.getPolicySetIds(); policySetIds.forEach(policySetId -> LOGGER policySetId, keys.get(0), values.get(0))));
14,488
this.privilegeHelper.putResource(this.acsAdminRestTemplate, resource, endpoint, this.acsZone1Headers, this.privilegeHelper.getDefaultOrgAttribute()); this.privilegeHelper.putSubject(this.acsAdminRestTemplate, subject, endpoint, this.acsZone1Headers, this.privilegeHelper.getDefaultAttribute(), this.privilegeHelper.getDefaultOrgAttribute()); String policyFile = "src/test/resources/policies/single-org-based.json"; <BUG>this.policyHelper.setTestPolicy(this.acsAdminRestTemplate, this.acsZone1Headers, endpoint, policyFile);</BUG> ResponseEntity<PolicyEvaluationResult> postForEntity = this.acsAdminRestTemplate.postForEntity( endpoint + PolicyHelper.ACS_POLICY_EVAL_API_PATH,
this.policyHelper.setTestPolicy(this.acsAdminRestTemplate, this.acsZone1Headers, endpoint, policyFile);
14,489
Assert.assertEquals(postForEntity.getStatusCode(), HttpStatus.OK); responseBody = postForEntity.getBody(); Assert.assertEquals(responseBody.getEffect(), Effect.NOT_APPLICABLE); } @Test <BUG>public void testPolicyEvalCacheWhenResourceDeleted() throws Exception { BaseResource resource = new BaseResource("/secured-by-value/sites/sanramon"); BaseSubject subject = MARISSA_V1;</BUG> PolicyEvaluationRequestV1 policyEvaluationRequest = this.policyHelper
PolicyEvaluationResult responseBody = postForEntity.getBody(); Assert.assertEquals(responseBody.getEffect(), Effect.PERMIT); this.privilegeHelper.putResource(this.acsAdminRestTemplate, resource, endpoint, this.acsZone1Headers, this.privilegeHelper.getAlternateOrgAttribute()); postForEntity = this.acsAdminRestTemplate.postForEntity(endpoint + PolicyHelper.ACS_POLICY_EVAL_API_PATH, new HttpEntity<>(policyEvaluationRequest, this.acsZone1Headers), PolicyEvaluationResult.class); public void testPolicyEvalCacheWhenSubjectChanges() throws Exception {
14,490
MARISSA_V1.getSubjectIdentifier(), "/v1/site/1/plant/asset/1", null); String endpoint = this.acsUrl; this.privilegeHelper.putSubject(this.acsAdminRestTemplate, subject, endpoint, this.acsZone1Headers, this.privilegeHelper.getDefaultAttribute(), this.privilegeHelper.getDefaultOrgAttribute()); String policyFile = "src/test/resources/policies/multiple-attribute-uri-templates.json"; <BUG>this.policyHelper.setTestPolicy(this.acsAdminRestTemplate, this.acsZone1Headers, endpoint, policyFile);</BUG> ResponseEntity<PolicyEvaluationResult> postForEntity = this.acsAdminRestTemplate.postForEntity( endpoint + PolicyHelper.ACS_POLICY_EVAL_API_PATH,
this.policyHelper.setTestPolicy(this.acsAdminRestTemplate, this.acsZone1Headers, endpoint, policyFile);
14,491
package com.ge.predix.test.utils; import static com.ge.predix.test.utils.ACSTestUtil.ACS_VERSION; import java.io.File; import java.io.IOException; import java.net.URI; <BUG>import java.util.Collections; import java.util.Random;</BUG> import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity;
import java.util.LinkedHashSet; import java.util.Random;
14,492
public PolicyEvaluationRequestV1 createRandomEvalRequest() { Random r = new Random(System.currentTimeMillis()); Set<Attribute> subjectAttributes = Collections.emptySet(); return this.createEvalRequest(ACTIONS[r.nextInt(4)], String.valueOf(r.nextLong()), "/alarms/sites/" + String.valueOf(r.nextLong()), subjectAttributes); <BUG>} public PolicyEvaluationRequestV1 createEvalRequest(final String action, final String subjectIdentifier,</BUG> final String resourceIdentifier, final Set<Attribute> subjectAttributes) { PolicyEvaluationRequestV1 policyEvaluationRequest = new PolicyEvaluationRequestV1(); policyEvaluationRequest.setAction(action);
public PolicyEvaluationRequestV1 createMultiplePolicySetsEvalRequest(final String action, final String subjectIdentifier, final String resourceIdentifier, final Set<Attribute> subjectAttributes, final LinkedHashSet<String> policySetIds) {
14,493
b.setSubjectAttributes( </BUG> new HashSet<Attribute>( Arrays.asList( new Attribute[] { <BUG>new Attribute("issuer", "role"), new Attribute("issuer", "group") }))); Assert.assertEquals(a, b);</BUG> }
b.setPolicySetsEvaluationOrder(EVALUATION_ORDER_P1_P2); Assert.assertEquals(a, b);
14,494
new Attribute("issuer", "role"), new Attribute("issuer", "group") }))); Assert.assertNotEquals(a, b); } <BUG>@Test public void testHashCodeNoAttributes() {</BUG> PolicyEvaluationRequestV1 a = new PolicyEvaluationRequestV1(); a.setSubjectIdentifier("subject"); a.setAction("GET");
b.setPolicySetsEvaluationOrder(EVALUATION_ORDER_P1_P2); Assert.assertEquals(a, b); public void testEqualsThisHasNoAttributes() {
14,495
b.setResourceIdentifier("/resource"); b.setSubjectAttributes( new HashSet<Attribute>( Arrays.asList( new Attribute[] { <BUG>new Attribute("issuer", "role"), new Attribute("issuer", "group") }))); Assert.assertEquals(a.hashCode(), b.hashCode());</BUG> }
Assert.assertNotEquals(a, b);
14,496
new Attribute("issuer", "role"), new Attribute("issuer", "group") }))); Assert.assertNotEquals(a.hashCode(), b.hashCode()); } <BUG>@Test public void testHashCodeDifferentAttributes() {</BUG> PolicyEvaluationRequestV1 a = new PolicyEvaluationRequestV1(); a.setSubjectIdentifier("subject"); a.setAction("GET");
Assert.assertNotEquals(a, b); public void testEqualsDifferentAttributes() {
14,497
import java.net.URL; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; <BUG>import com.horstmann.violet.framework.injection.bean.ManiocFramework.ManagedBean; import com.horstmann.violet.framework.property.LineStyleChoiceList;</BUG> import com.horstmann.violet.product.diagram.abstracts.AbstractGraph; import com.horstmann.violet.product.diagram.abstracts.IGraph; import com.horstmann.violet.product.diagram.abstracts.Id;
import com.horstmann.violet.framework.property.BentStyleChoiceList; import com.horstmann.violet.framework.property.LineStyleChoiceList;
14,498
import com.horstmann.violet.framework.property.LineStyleChoiceList; import com.horstmann.violet.product.diagram.abstracts.IGraph; import com.horstmann.violet.product.diagram.abstracts.edge.IEdge; import com.horstmann.violet.product.diagram.abstracts.node.INode; import com.horstmann.violet.framework.property.ArrowheadChoiceList; <BUG>import com.horstmann.violet.framework.property.BentStyle; </BUG> import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; @ManagedBean(registeredManually=true)
import com.horstmann.violet.framework.property.BentStyleChoiceList;
14,499
xStream.useAttributeFor(Point2D.Double.class, "x"); xStream.useAttributeFor(Point2D.Double.class, "y"); xStream.alias("Point2D.Double", Point2D.Double.class); xStream.addImmutableType(ArrowheadChoiceList.class); xStream.addImmutableType(LineStyleChoiceList.class); <BUG>xStream.addImmutableType(BentStyle.class); </BUG> List<IDiagramPlugin> diagramPlugins = this.pluginRegistry.getDiagramPlugins(); for (IDiagramPlugin aPlugin : diagramPlugins) { Class<? extends IGraph> graphClass = aPlugin.getGraphClass();
xStream.addImmutableType(BentStyleChoiceList.class);
14,500
{ public ArrowheadChoiceList() { super(ARROWHEAD_ICONS, ARROWHEADS); } <BUG>protected ArrowheadChoiceList(IconChoiceList<Arrowhead> copyElement) </BUG> { super(copyElement); }
protected ArrowheadChoiceList(ArrowheadChoiceList copyElement)