id
int64
1
49k
buggy
stringlengths
34
37.5k
fixed
stringlengths
2
37k
16,901
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)
16,902
.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))
16,903
.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))
16,904
@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;
16,905
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; }
16,906
return configDirectory; } public boolean isLoaded() { return loaded; } <BUG>public static Cause getCause() { return instance().pluginCause; }</BUG> public EconomyService getEconomyService() { return economyService;
[DELETED]
16,907
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.*;
16,908
.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))
16,909
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) -> {
16,910
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);
16,911
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);
16,912
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() + "\"");
16,913
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() + "\"");
16,914
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
16,915
.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")
16,916
} else { updateMemo(); callback.updateMemo(); } dismiss(); <BUG>}else{ </BUG> Toast.makeText(getActivity(), getString(R.string.toast_memo_empty), Toast.LENGTH_SHORT).show(); } }
[DELETED]
16,917
} @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_memo); <BUG>ChinaPhoneHelper.setStatusBar(this,true); </BUG> topicId = getIntent().getLongExtra("topicId", -1); if (topicId == -1) { finish();
ChinaPhoneHelper.setStatusBar(this, true);
16,918
MemoEntry.COLUMN_REF_TOPIC__ID + " = ?" , new String[]{String.valueOf(topicId)}); } public Cursor selectMemo(long topicId) { Cursor c = db.query(MemoEntry.TABLE_NAME, null, MemoEntry.COLUMN_REF_TOPIC__ID + " = ?", new String[]{String.valueOf(topicId)}, null, null, <BUG>MemoEntry._ID + " DESC", null); </BUG> if (c != null) { c.moveToFirst(); }
MemoEntry.COLUMN_ORDER + " ASC", null);
16,919
MemoEntry._ID + " = ?", new String[]{String.valueOf(memoId)}); } public long updateMemoContent(long memoId, String memoContent) { ContentValues values = new ContentValues(); <BUG>values.put(MemoEntry.COLUMN_CONTENT, memoContent); return db.update(</BUG> MemoEntry.TABLE_NAME, values, MemoEntry._ID + " = ?",
return db.update(
16,920
import android.widget.RelativeLayout; import android.widget.TextView; import com.kiminonawa.mydiary.R; import com.kiminonawa.mydiary.db.DBManager; import com.kiminonawa.mydiary.shared.EditMode; <BUG>import com.kiminonawa.mydiary.shared.ThemeManager; import java.util.List; public class MemoAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements EditMode { </BUG> private List<MemoEntity> memoList;
import com.marshalchen.ultimaterecyclerview.dragsortadapter.DragSortAdapter; public class MemoAdapter extends DragSortAdapter<DragSortAdapter.ViewHolder> implements EditMode {
16,921
private DBManager dbManager; private boolean isEditMode = false; private EditMemoDialogFragment.MemoCallback callback; private static final int TYPE_HEADER = 0; private static final int TYPE_ITEM = 1; <BUG>public MemoAdapter(FragmentActivity activity, long topicId, List<MemoEntity> memoList, DBManager dbManager, EditMemoDialogFragment.MemoCallback callback) { this.mActivity = activity;</BUG> this.topicId = topicId; this.memoList = memoList;
public MemoAdapter(FragmentActivity activity, long topicId, List<MemoEntity> memoList, DBManager dbManager, EditMemoDialogFragment.MemoCallback callback, RecyclerView recyclerView) { super(recyclerView); this.mActivity = activity;
16,922
this.memoList = memoList; this.dbManager = dbManager; this.callback = callback; } @Override <BUG>public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { </BUG> View view; if (isEditMode) { if (viewType == TYPE_HEADER) {
public DragSortAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
16,923
editMemoDialogFragment.show(mActivity.getSupportFragmentManager(), "editMemoDialogFragment"); } }); } } <BUG>protected class MemoViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { private View rootView; private TextView TV_memo_item_content;</BUG> private ImageView IV_memo_item_delete;
protected class MemoViewHolder extends DragSortAdapter.ViewHolder implements View.OnClickListener, View.OnLongClickListener { private ImageView IV_memo_item_dot; private TextView TV_memo_item_content;
16,924
if(worldIn.getTileEntity(pos) != null){ TileEntity te = worldIn.getTileEntity(pos); if(te.hasCapability(Capabilities.HEAT_HANDLER_CAPABILITY, null) && te.getCapability(Capabilities.HEAT_HANDLER_CAPABILITY, null).getTemp() >= -273D + mult){ te.getCapability(Capabilities.HEAT_HANDLER_CAPABILITY, null).addHeat(-mult); } <BUG>for(EnumFacing dir : EnumFacing.values()){ if(te.hasCapability(Capabilities.ROTARY_HANDLER_CAPABILITY, dir)){ te.getCapability(Capabilities.ROTARY_HANDLER_CAPABILITY, dir).addEnergy(-mult, false, false); break;</BUG> }
if(te.hasCapability(Capabilities.HEAT_HANDLER_CAPABILITY, null)){ te.getCapability(Capabilities.HEAT_HANDLER_CAPABILITY, null).addHeat(mult);
16,925
public static double betterRound(double numIn, int decPlac){ double opOn = Math.round(numIn * Math.pow(10, decPlac)) / Math.pow(10D, decPlac); return opOn; } public static double centerCeil(double numIn, int tiers){ <BUG>return ((numIn > 0) ? Math.ceil(numIn * tiers) : Math.floor(numIn * tiers)) / tiers; </BUG> } public static double findEfficiency(double speedIn, double lowerLimit, double upperLimit){ speedIn = Math.abs(speedIn);
return ((numIn > 0) ? Math.ceil(numIn * (double) tiers) : Math.floor(numIn * (double) tiers)) / (double) tiers;
16,926
package com.Da_Technomancer.crossroads.API; import com.Da_Technomancer.crossroads.API.DefaultStorageHelper.DefaultStorage; import com.Da_Technomancer.crossroads.API.heat.DefaultHeatHandler; import com.Da_Technomancer.crossroads.API.heat.IHeatHandler; import com.Da_Technomancer.crossroads.API.magic.DefaultMagicHandler; <BUG>import com.Da_Technomancer.crossroads.API.magic.IMagicHandler; import com.Da_Technomancer.crossroads.API.rotary.DefaultRotaryHandler; import com.Da_Technomancer.crossroads.API.rotary.IRotaryHandler; </BUG> import net.minecraftforge.common.capabilities.Capability;
import com.Da_Technomancer.crossroads.API.rotary.DefaultAxleHandler; import com.Da_Technomancer.crossroads.API.rotary.DefaultCogHandler; import com.Da_Technomancer.crossroads.API.rotary.IAxleHandler; import com.Da_Technomancer.crossroads.API.rotary.ICogHandler;
16,927
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; public class Capabilities{ @CapabilityInject(IHeatHandler.class) <BUG>public static Capability<IHeatHandler> HEAT_HANDLER_CAPABILITY = null; @CapabilityInject(IRotaryHandler.class) public static Capability<IRotaryHandler> ROTARY_HANDLER_CAPABILITY = null; </BUG> @CapabilityInject(IMagicHandler.class)
@CapabilityInject(IAxleHandler.class) public static Capability<IAxleHandler> AXLE_HANDLER_CAPABILITY = null; @CapabilityInject(ICogHandler.class) public static Capability<ICogHandler> COG_HANDLER_CAPABILITY = null;
16,928
public IEffect getMixEffect(Color col){ if(col == null){ return effect; } int top = Math.max(col.getBlue(), Math.max(col.getRed(), col.getGreen())); <BUG>if(top < rand.nextInt(128) + 128){ return voidEffect;</BUG> } return effect; }
if(top != 255){ return voidEffect;
16,929
import org.apache.cxf.rs.security.oauth2.jwt.Algorithm; public class RSAOaepKeyEncryptionAlgorithm extends AbstractWrapKeyEncryptionAlgorithm { private static final Set<String> SUPPORTED_ALGORITHMS = new HashSet<String>( Arrays.asList(Algorithm.RSA_OAEP.getJwtName(), Algorithm.RSA_OAEP_256.getJwtName())); <BUG>public RSAOaepKeyEncryptionAlgorithm(RSAPublicKey publicKey) { this(publicKey, null, true); } public RSAOaepKeyEncryptionAlgorithm(RSAPublicKey publicKey, boolean wrap) { this(publicKey, null, wrap); }</BUG> public RSAOaepKeyEncryptionAlgorithm(RSAPublicKey publicKey, String jweAlgo) {
[DELETED]
16,930
Properties props = ResourceUtils.loadProperties(propLoc, bus); if (JwkUtils.JWK_KEY_STORE_TYPE.equals(props.get(CryptoUtils.RSSEC_KEY_STORE_TYPE))) { JsonWebKey jwk = JwkUtils.loadJsonWebKey(m, props, JsonWebKey.KEY_OPER_ENCRYPT); keyEncryptionAlgo = jwk.getAlgorithm(); if (JsonWebKey.KEY_TYPE_RSA.equals(jwk.getKeyType())) { <BUG>keyEncryptionProvider = new RSAOaepKeyEncryptionAlgorithm(jwk.toRSAPublicKey()); } else if (JsonWebKey.KEY_TYPE_OCTET.equals(jwk.getKeyType())) {</BUG> SecretKey key = jwk.toSecretKey(); if (Algorithm.isAesKeyWrap(keyEncryptionAlgo)) {
keyEncryptionProvider = new RSAOaepKeyEncryptionAlgorithm(jwk.toRSAPublicKey(), getKeyEncryptionAlgo(props, keyEncryptionAlgo)); } else if (JsonWebKey.KEY_TYPE_OCTET.equals(jwk.getKeyType())) {
16,931
} catch (SecurityException ex) { throw ex; } catch (Exception ex) { throw new SecurityException(ex); } <BUG>} public void setUseJweOutputStream(boolean useJweOutputStream) {</BUG> this.useJweOutputStream = useJweOutputStream; } public void setWriter(JwtHeadersWriter writer) {
private String getKeyEncryptionAlgo(Properties props, String algo) { return algo == null ? props.getProperty(JSON_WEB_ENCRYPTION_KEY_ALGO_PROP) : algo; public void setUseJweOutputStream(boolean useJweOutputStream) {
16,932
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.db.*; import org.apache.cassandra.db.columniterator.IColumnIterator; import org.apache.cassandra.db.columniterator.ICountableColumnIterator; <BUG>import org.apache.cassandra.db.marshal.AbstractType; import org.apache.cassandra.io.util.DataOutputBuffer;</BUG> import org.apache.cassandra.io.util.IIterableColumns; import org.apache.cassandra.utils.MergeIterator; public class LazilyCompactedRow extends AbstractCompactedRow implements IIterableColumns
import org.apache.cassandra.io.IColumnSerializer; import org.apache.cassandra.io.util.DataOutputBuffer;
16,933
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class StopAnalyzerProvider extends AbstractAnalyzerProvider<StopAnalyzer> { </BUG> private final Set<String> stopWords; private final StopAnalyzer stopAnalyzer; @Inject public StopAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
public class StopAnalyzerProvider extends AbstractIndexAnalyzerProvider<StopAnalyzer> {
16,934
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class StandardAnalyzerProvider extends AbstractAnalyzerProvider<StandardAnalyzer> { </BUG> private final Set<String> stopWords; private final int maxTokenLength; private final StandardAnalyzer standardAnalyzer;
public class StandardAnalyzerProvider extends AbstractIndexAnalyzerProvider<StandardAnalyzer> {
16,935
import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.settings.Settings; <BUG>public class KeywordAnalyzerProvider extends AbstractAnalyzerProvider<KeywordAnalyzer> { </BUG> private final KeywordAnalyzer keywordAnalyzer; @Inject public KeywordAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name);
public class KeywordAnalyzerProvider extends AbstractIndexAnalyzerProvider<KeywordAnalyzer> {
16,936
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class CzechAnalyzerProvider extends AbstractAnalyzerProvider<CzechAnalyzer> { </BUG> private final Set<?> stopWords; private final CzechAnalyzer analyzer; @Inject public CzechAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
public class CzechAnalyzerProvider extends AbstractIndexAnalyzerProvider<CzechAnalyzer> {
16,937
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class ArabicAnalyzerProvider extends AbstractAnalyzerProvider<ArabicAnalyzer> { </BUG> private final Set<String> stopWords; private final ArabicAnalyzer arabicAnalyzer; @Inject public ArabicAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
public class ArabicAnalyzerProvider extends AbstractIndexAnalyzerProvider<ArabicAnalyzer> {
16,938
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class CjkAnalyzerProvider extends AbstractAnalyzerProvider<CJKAnalyzer> { </BUG> private final Set<?> stopWords; private final CJKAnalyzer analyzer; @Inject public CjkAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
public class CjkAnalyzerProvider extends AbstractIndexAnalyzerProvider<CJKAnalyzer> {
16,939
Class<? extends TokenFilterFactory> type = tokenFilterSettings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "TokenFilterFactory"); if (type == null) { throw new IllegalArgumentException("Token Filter [" + tokenFilterName + "] must have a type associated with it"); } tokenFilterBinder.addBinding(tokenFilterName).toProvider(FactoryProvider.newFactory(TokenFilterFactoryFactory.class, type)).in(Scopes.SINGLETON); <BUG>} for (AnalysisBinderProcessor processor : processors) { processor.processTokenFilters(tokenFilterBinder, tokenFiltersSettings); </BUG> }
AnalysisBinderProcessor.TokenFiltersBindings tokenFiltersBindings = new AnalysisBinderProcessor.TokenFiltersBindings(tokenFilterBinder, tokenFiltersSettings); processor.processTokenFilters(tokenFiltersBindings);
16,940
Class<? extends TokenizerFactory> type = tokenizerSettings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "TokenizerFactory"); if (type == null) { throw new IllegalArgumentException("Tokenizer [" + tokenizerName + "] must have a type associated with it"); } tokenizerBinder.addBinding(tokenizerName).toProvider(FactoryProvider.newFactory(TokenizerFactoryFactory.class, type)).in(Scopes.SINGLETON); <BUG>} for (AnalysisBinderProcessor processor : processors) { processor.processTokenizers(tokenizerBinder, tokenizersSettings); </BUG> }
AnalysisBinderProcessor.TokenizersBindings tokenizersBindings = new AnalysisBinderProcessor.TokenizersBindings(tokenizerBinder, tokenizersSettings); processor.processTokenizers(tokenizersBindings);
16,941
} else { throw new IllegalArgumentException("Analyzer [" + analyzerName + "] must have a type associated with it or a tokenizer"); } } analyzerBinder.addBinding(analyzerName).toProvider(FactoryProvider.newFactory(AnalyzerProviderFactory.class, type)).in(Scopes.SINGLETON); <BUG>} for (AnalysisBinderProcessor processor : processors) { processor.processAnalyzers(analyzerBinder, analyzersSettings); </BUG> }
AnalysisBinderProcessor.AnalyzersBindings analyzersBindings = new AnalysisBinderProcessor.AnalyzersBindings(analyzerBinder, analyzersSettings, indicesAnalysisService); processor.processAnalyzers(analyzersBindings);
16,942
import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; <BUG>public class ThaiAnalyzerProvider extends AbstractAnalyzerProvider<ThaiAnalyzer> { </BUG> private final ThaiAnalyzer analyzer; @Inject public ThaiAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name);
public class ThaiAnalyzerProvider extends AbstractIndexAnalyzerProvider<ThaiAnalyzer> {
16,943
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class PersianAnalyzerProvider extends AbstractAnalyzerProvider<PersianAnalyzer> { </BUG> private final Set<?> stopWords; private final PersianAnalyzer analyzer; @Inject public PersianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
public class PersianAnalyzerProvider extends AbstractIndexAnalyzerProvider<PersianAnalyzer> {
16,944
import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.settings.Settings; <BUG>public class ChineseAnalyzerProvider extends AbstractAnalyzerProvider<ChineseAnalyzer> { </BUG> private final ChineseAnalyzer analyzer; @Inject public ChineseAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name);
public class ChineseAnalyzerProvider extends AbstractIndexAnalyzerProvider<ChineseAnalyzer> {
16,945
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class BrazilianAnalyzerProvider extends AbstractAnalyzerProvider<BrazilianAnalyzer> { </BUG> private final Set<?> stopWords; private final Set<?> stemExclusion; private final BrazilianAnalyzer analyzer;
public class BrazilianAnalyzerProvider extends AbstractIndexAnalyzerProvider<BrazilianAnalyzer> {
16,946
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class GermanAnalyzerProvider extends AbstractAnalyzerProvider<GermanAnalyzer> { </BUG> private final Set<?> stopWords; private final Set<?> stemExclusion; private final GermanAnalyzer analyzer;
public class GermanAnalyzerProvider extends AbstractIndexAnalyzerProvider<GermanAnalyzer> {
16,947
import org.elasticsearch.util.settings.ImmutableSettings; import org.elasticsearch.util.settings.Settings; import java.util.List; import java.util.Map; import static org.elasticsearch.util.collect.Lists.*; <BUG>public class CustomAnalyzerProvider extends AbstractAnalyzerProvider<CustomAnalyzer> { </BUG> private final TokenizerFactory tokenizerFactory; private final TokenFilterFactory[] tokenFilterFactories; private final CustomAnalyzer customAnalyzer;
public class CustomAnalyzerProvider extends AbstractIndexAnalyzerProvider<CustomAnalyzer> {
16,948
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class DutchAnalyzerProvider extends AbstractAnalyzerProvider<DutchAnalyzer> { </BUG> private final Set<?> stopWords; private final Set<?> stemExclusion; private final DutchAnalyzer analyzer;
public class DutchAnalyzerProvider extends AbstractIndexAnalyzerProvider<DutchAnalyzer> {
16,949
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class FrenchAnalyzerProvider extends AbstractAnalyzerProvider<FrenchAnalyzer> { </BUG> private final Set<?> stopWords; private final Set<?> stemExclusion; private final FrenchAnalyzer analyzer;
public class FrenchAnalyzerProvider extends AbstractIndexAnalyzerProvider<FrenchAnalyzer> {
16,950
import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.settings.Settings; <BUG>public class SimpleAnalyzerProvider extends AbstractAnalyzerProvider<SimpleAnalyzer> { </BUG> private final SimpleAnalyzer simpleAnalyzer; @Inject public SimpleAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name);
public class SimpleAnalyzerProvider extends AbstractIndexAnalyzerProvider<SimpleAnalyzer> {
16,951
import org.elasticsearch.util.collect.Iterators; import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; <BUG>public class RussianAnalyzerProvider extends AbstractAnalyzerProvider<RussianAnalyzer> { </BUG> private final RussianAnalyzer analyzer; @Inject public RussianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name);
public class RussianAnalyzerProvider extends AbstractIndexAnalyzerProvider<RussianAnalyzer> {
16,952
import org.elasticsearch.util.inject.Inject; import org.elasticsearch.util.inject.assistedinject.Assisted; import org.elasticsearch.util.lucene.Lucene; import org.elasticsearch.util.settings.Settings; import java.util.Set; <BUG>public class GreekAnalyzerProvider extends AbstractAnalyzerProvider<GreekAnalyzer> { </BUG> private final Set<?> stopWords; private final GreekAnalyzer analyzer; @Inject public GreekAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
public class GreekAnalyzerProvider extends AbstractIndexAnalyzerProvider<GreekAnalyzer> {
16,953
import org.mule.transformer.types.DataTypeFactory; import org.mule.transport.AbstractConnector; import org.junit.Test; <BUG>import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue;</BUG> public abstract class AbstractConfigBuilderTestCase extends AbstractScriptConfigBuilderTestCase { public AbstractConfigBuilderTestCase(boolean legacy)
[DELETED]
16,954
super.testEndpointConfig(); ImmutableEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint("waterMelonEndpoint"); assertNotNull(endpoint); assertEquals("UTF-8-TEST", endpoint.getEncoding()); assertEquals("test.queue", endpoint.getEndpointURI().getAddress()); <BUG>Service service = muleContext.getRegistry().lookupService("appleComponent2"); </BUG> assertNotNull(service); } @Test
FlowConstruct service = muleContext.getRegistry().lookupFlowConstruct("appleComponent2");
16,955
assertNotNull(service); } @Test public void testExceptionStrategy2() { <BUG>Service service = muleContext.getRegistry().lookupService("appleComponent"); </BUG> assertNotNull(service.getExceptionListener()); assertTrue(service.getExceptionListener() instanceof MessagingExceptionHandler); }
Flow service = (Flow) muleContext.getRegistry().lookupFlowConstruct("appleComponent");
16,956
assertEquals(4002, pp.getMaxWait()); assertEquals(PoolingProfile.WHEN_EXHAUSTED_FAIL, pp.getExhaustedAction()); assertEquals(PoolingProfile.INITIALISE_ALL, pp.getInitialisationPolicy()); } @Test <BUG>public void testQueueProfileConfig() { Service service = muleContext.getRegistry().lookupService("appleComponent2"); QueueProfile qp = ((SedaService)service).getQueueProfile(); assertEquals(102, qp.getMaxOutstandingMessages()); } @Test</BUG> public void testEndpointProperties() throws Exception
[DELETED]
16,957
assertEquals(102, qp.getMaxOutstandingMessages()); } @Test</BUG> public void testEndpointProperties() throws Exception { <BUG>Service service = muleContext.getRegistry().lookupService("appleComponent2"); InboundEndpoint inEndpoint = ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoint( "transactedInboundEndpoint");</BUG> assertNotNull(inEndpoint);
assertEquals(4002, pp.getMaxWait()); assertEquals(PoolingProfile.WHEN_EXHAUSTED_FAIL, pp.getExhaustedAction()); assertEquals(PoolingProfile.INITIALISE_ALL, pp.getInitialisationPolicy()); @Test Flow service = (Flow) muleContext.getRegistry().lookupFlowConstruct("appleComponent2"); InboundEndpoint inEndpoint = (InboundEndpoint) ((CompositeMessageSource) service.getMessageSource()).getSources().get(1);
16,958
assertEquals("true", muleContext.getRegistry().lookupObject("doCompression")); assertEquals("this was set from the manager properties!", muleContext.getRegistry().lookupObject("beanProperty1")); assertNotNull(muleContext.getRegistry().lookupObject("OS_Version")); } @Test <BUG>public void testBindngProxyCreation() { Service orange = muleContext.getRegistry().lookupService("orangeComponent"); assertNotNull(orange); assertTrue(orange.getComponent() instanceof JavaComponent); InterfaceBinding r = ((JavaComponent) orange.getComponent()).getInterfaceBindings().get(0); assertNotNull(r); } @Test</BUG> public void testMuleConfiguration()
[DELETED]
16,959
assertNotNull(r); } @Test</BUG> public void testMuleConfiguration() { <BUG>assertEquals(10,muleContext.getConfiguration().getDefaultResponseTimeout()); assertEquals(20,muleContext.getConfiguration().getDefaultTransactionTimeout()); assertEquals(30,muleContext.getConfiguration().getShutdownTimeout()); </BUG> }
assertEquals("true", muleContext.getRegistry().lookupObject("doCompression")); assertEquals("this was set from the manager properties!", muleContext.getRegistry().lookupObject("beanProperty1")); assertNotNull(muleContext.getRegistry().lookupObject("OS_Version")); @Test assertEquals(10, muleContext.getConfiguration().getDefaultResponseTimeout()); assertEquals(20, muleContext.getConfiguration().getDefaultTransactionTimeout()); assertEquals(30, muleContext.getConfiguration().getShutdownTimeout());
16,960
assertEquals(LoggingInterceptor.class, interceptorStack.getInterceptors().get(2).getClass()); } @Test public void testInterceptors() { <BUG>Service service = muleContext.getRegistry().lookupService("orangeComponent"); AbstractComponent component = (AbstractComponent) service.getComponent(); </BUG> assertEquals(3, component.getInterceptors().size());
Flow service = (Flow) muleContext.getRegistry().lookupFlowConstruct("orangeComponent"); AbstractComponent component = (AbstractComponent) service.getMessageProcessors().get(0);
16,961
import org.mule.transformer.TransformerUtils;</BUG> import org.mule.transformer.types.DataTypeFactory; import java.util.List; import java.util.Map; import org.junit.Test; <BUG>import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue;</BUG> public abstract class AbstractScriptConfigBuilderTestCase extends org.mule.tck.junit4.FunctionalTestCase
import org.mule.exception.AbstractExceptionListener; import org.mule.routing.filters.MessagePropertyFilter; import org.mule.tck.testmodels.fruit.FruitCleaner; import org.mule.tck.testmodels.mule.TestCompressionTransformer;
16,962
assertTrue(responseTransformer instanceof TestCompressionTransformer); } @Test public void testExceptionStrategy() { <BUG>Service service = muleContext.getRegistry().lookupService("orangeComponent"); assertNotNull(muleContext.getRegistry().lookupModel("main").getExceptionListener());</BUG> assertNotNull(service.getExceptionListener()); assertTrue(((AbstractExceptionListener) service.getExceptionListener()).getMessageProcessors().size() > 0);
Flow service = (Flow) muleContext.getRegistry().lookupFlowConstruct("orangeComponent");
16,963
assertEquals(1, route1.getRoutes().size()); } @Test</BUG> public void testBindingConfig() { <BUG>Service service = muleContext.getRegistry().lookupService("orangeComponent"); assertNotNull(service.getComponent()); assertTrue(service.getComponent() instanceof JavaComponent); List<InterfaceBinding> bindings= ((JavaComponent) service.getComponent()).getInterfaceBindings(); </BUG> assertNotNull(bindings);
assertEquals("prop1", props.get("prop1")); assertEquals("prop2", props.get("prop2")); assertEquals(6, endpoint.getProperties().size()); @Test Flow service = (Flow) muleContext.getRegistry().lookupFlowConstruct("orangeComponent"); assertNotNull(service.getMessageProcessors().get(0)); assertTrue((service.getMessageProcessors().get(0) instanceof JavaComponent)); List<InterfaceBinding> bindings= ((JavaComponent) service.getMessageProcessors().get(0)).getInterfaceBindings();
16,964
} @RootTask static Task<Exec.Result> exec(String parameter, int number) { Task<String> task1 = MyTask.create(parameter); Task<Integer> task2 = Adder.create(number, number + 2); <BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh") .in(() -> task1)</BUG> .in(() -> task2) .process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\""))); }
return Task.named("exec", "/bin/sh").ofType(Exec.Result.class) .in(() -> task1)
16,965
return args; } static class MyTask { static final int PLUS = 10; static Task<String> create(String parameter) { <BUG>return Task.ofType(String.class).named("MyTask", parameter) .in(() -> Adder.create(parameter.length(), PLUS))</BUG> .in(() -> Fib.create(parameter.length())) .process((sum, fib) -> something(parameter, sum, fib)); }
return Task.named("MyTask", parameter).ofType(String.class) .in(() -> Adder.create(parameter.length(), PLUS))
16,966
final String instanceField = "from instance"; final TaskContext context = TaskContext.inmem(); final AwaitingConsumer<String> val = new AwaitingConsumer<>(); @Test public void shouldJavaUtilSerialize() throws Exception { <BUG>Task<Long> task1 = Task.ofType(Long.class).named("Foo", "Bar", 39) .process(() -> 9999L); Task<String> task2 = Task.ofType(String.class).named("Baz", 40) .in(() -> task1)</BUG> .ins(() -> singletonList(task1))
Task<Long> task1 = Task.named("Foo", "Bar", 39).ofType(Long.class) Task<String> task2 = Task.named("Baz", 40).ofType(String.class) .in(() -> task1)
16,967
assertEquals(des.id().name(), "Baz"); assertEquals(val.awaitAndGet(), "[9999] hello 10004"); } @Test(expected = NotSerializableException.class) public void shouldNotSerializeWithInstanceFieldReference() throws Exception { <BUG>Task<String> task = Task.ofType(String.class).named("WithRef") .process(() -> instanceField + " causes an outer reference");</BUG> serialize(task); } @Test
Task<String> task = Task.named("WithRef").ofType(String.class) .process(() -> instanceField + " causes an outer reference");
16,968
serialize(task); } @Test public void shouldSerializeWithLocalReference() throws Exception { String local = instanceField; <BUG>Task<String> task = Task.ofType(String.class).named("WithLocalRef") .process(() -> local + " won't cause an outer reference");</BUG> serialize(task); Task<String> des = deserialize(); context.evaluate(des).consume(val);
Task<String> task = Task.named("WithLocalRef").ofType(String.class) .process(() -> local + " won't cause an outer reference");
16,969
} @RootTask public static Task<String> standardArgs(int first, String second) { firstInt = first; secondString = second; <BUG>return Task.ofType(String.class).named("StandardArgs", first, second) .process(() -> second + " " + first * 100);</BUG> } @Test public void shouldParseFlags() throws Exception {
return Task.named("StandardArgs", first, second).ofType(String.class) .process(() -> second + " " + first * 100);
16,970
assertThat(parsedEnum, is(CustomEnum.BAR)); } @RootTask public static Task<String> enums(CustomEnum enm) { parsedEnum = enm; <BUG>return Task.ofType(String.class).named("Enums", enm) .process(enm::toString);</BUG> } @Test public void shouldParseCustomTypes() throws Exception {
return Task.named("Enums", enm).ofType(String.class) .process(enm::toString);
16,971
assertThat(parsedType.content, is("blarg parsed for you!")); } @RootTask public static Task<String> customType(CustomType myType) { parsedType = myType; <BUG>return Task.ofType(String.class).named("Types", myType.content) .process(() -> myType.content);</BUG> } public enum CustomEnum { BAR
return Task.named("Types", myType.content).ofType(String.class) .process(() -> myType.content);
16,972
TaskContext taskContext = TaskContext.inmem(); TaskContext.Value<Long> value = taskContext.evaluate(fib92); value.consume(f92 -> System.out.println("fib(92) = " + f92)); } static Task<Long> create(long n) { <BUG>TaskBuilder<Long> fib = Task.ofType(Long.class).named("Fib", n); </BUG> if (n < 2) { return fib .process(() -> n);
TaskBuilder<Long> fib = Task.named("Fib", n).ofType(Long.class);
16,973
package com.cronutils.model.time.generator; import java.util.Collections; <BUG>import java.util.List; import org.apache.commons.lang3.Validate;</BUG> import com.cronutils.model.field.CronField; import com.cronutils.model.field.expression.FieldExpression; public abstract class FieldValueGenerator {
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
16,974
import java.util.ResourceBundle; import java.util.function.Function;</BUG> class DescriptionStrategyFactory { private DescriptionStrategyFactory() {} public static DescriptionStrategy daysOfWeekInstance(final ResourceBundle bundle, final FieldExpression expression) { <BUG>final Function<Integer, String> nominal = integer -> new DateTime().withDayOfWeek(integer).dayOfWeek().getAsText(bundle.getLocale()); </BUG> NominalDescriptionStrategy dow = new NominalDescriptionStrategy(bundle, nominal, expression); dow.addDescription(fieldExpression -> { if (fieldExpression instanceof On) {
import java.util.function.Function; import com.cronutils.model.field.expression.FieldExpression; import com.cronutils.model.field.expression.On; final Function<Integer, String> nominal = integer -> DayOfWeek.of(integer).getDisplayName(TextStyle.FULL, bundle.getLocale());
16,975
return dom; } public static DescriptionStrategy monthsInstance(final ResourceBundle bundle, final FieldExpression expression) { return new NominalDescriptionStrategy( bundle, <BUG>integer -> new DateTime().withMonthOfYear(integer).monthOfYear().getAsText(bundle.getLocale()), expression</BUG> ); } public static DescriptionStrategy plainInstance(ResourceBundle bundle, final FieldExpression expression) {
integer -> Month.of(integer).getDisplayName(TextStyle.FULL, bundle.getLocale()), expression
16,976
<BUG>package com.cronutils.model.time.generator; import com.cronutils.mapper.WeekDay;</BUG> import com.cronutils.model.field.CronField; import com.cronutils.model.field.CronFieldName; import com.cronutils.model.field.constraint.FieldConstraintsBuilder;
import java.time.LocalDate; import java.util.Collections; import java.util.List; import java.util.Set; import org.apache.commons.lang3.Validate; import com.cronutils.mapper.WeekDay;
16,977
import com.cronutils.model.field.expression.Between; import com.cronutils.model.field.expression.FieldExpression; import com.cronutils.parser.CronParserField; import com.google.common.collect.Lists; import com.google.common.collect.Sets; <BUG>import org.apache.commons.lang3.Validate; import org.joda.time.DateTime; import java.util.Collections; import java.util.List; import java.util.Set;</BUG> class BetweenDayOfWeekValueGenerator extends FieldValueGenerator {
[DELETED]
16,978
<BUG>package com.cronutils.model.time.generator; import com.cronutils.model.field.CronField;</BUG> import com.cronutils.model.field.CronFieldName; import com.cronutils.model.field.expression.FieldExpression; import com.cronutils.model.field.expression.On;
import java.time.DayOfWeek; import java.time.LocalDate; import java.util.List; import org.apache.commons.lang3.Validate; import com.cronutils.model.field.CronField;
16,979
import com.cronutils.model.field.CronField;</BUG> import com.cronutils.model.field.CronFieldName; import com.cronutils.model.field.expression.FieldExpression; import com.cronutils.model.field.expression.On; import com.google.common.collect.Lists; <BUG>import org.apache.commons.lang3.Validate; import org.joda.time.DateTime; import java.util.List;</BUG> class OnDayOfMonthValueGenerator extends FieldValueGenerator { private int year;
package com.cronutils.model.time.generator; import java.time.DayOfWeek; import java.time.LocalDate; import java.util.List; import com.cronutils.model.field.CronField;
16,980
class OnDayOfMonthValueGenerator extends FieldValueGenerator { private int year; private int month; public OnDayOfMonthValueGenerator(CronField cronField, int year, int month) { super(cronField); <BUG>Validate.isTrue(CronFieldName.DAY_OF_MONTH.equals(cronField.getField()), "CronField does not belong to day of month"); this.year = year;</BUG> this.month = month; }
Validate.isTrue(CronFieldName.DAY_OF_MONTH.equals(cronField.getField()), "CronField does not belong to day of" + " month"); this.year = year;
16,981
package com.cronutils.mapper; public class ConstantsMapper { private ConstantsMapper() {} public static final WeekDay QUARTZ_WEEK_DAY = new WeekDay(2, false); <BUG>public static final WeekDay JODATIME_WEEK_DAY = new WeekDay(1, false); </BUG> public static final WeekDay CRONTAB_WEEK_DAY = new WeekDay(1, true); public static int weekDayMapping(WeekDay source, WeekDay target, int weekday){ return source.mapTo(weekday, target);
public static final WeekDay JAVA8 = new WeekDay(1, false);
16,982
return nextMatch; } catch (NoSuchValueException e) { throw new IllegalArgumentException(e); } } <BUG>DateTime nextClosestMatch(DateTime date) throws NoSuchValueException { </BUG> List<Integer> year = yearsValueGenerator.generateCandidates(date.getYear(), date.getYear()); TimeNode days = null; int lowestMonth = months.getValues().get(0);
ZonedDateTime nextClosestMatch(ZonedDateTime date) throws NoSuchValueException {
16,983
boolean questionMarkSupported = cronDefinition.getFieldDefinition(DAY_OF_WEEK).getConstraints().getSpecialChars().contains(QUESTION_MARK); if(questionMarkSupported){ return new TimeNode( generateDayCandidatesQuestionMarkSupported( <BUG>date.getYear(), date.getMonthOfYear(), </BUG> ((DayOfWeekFieldDefinition) cronDefinition.getFieldDefinition(DAY_OF_WEEK) ).getMondayDoWValue()
date.getYear(), date.getMonthValue(),
16,984
) ); }else{ return new TimeNode( generateDayCandidatesQuestionMarkNotSupported( <BUG>date.getYear(), date.getMonthOfYear(), </BUG> ((DayOfWeekFieldDefinition) cronDefinition.getFieldDefinition(DAY_OF_WEEK) ).getMondayDoWValue()
date.getYear(), date.getMonthValue(),
16,985
} public DateTime lastExecution(DateTime date){ </BUG> Validate.notNull(date); try { <BUG>DateTime previousMatch = previousClosestMatch(date); </BUG> if(previousMatch.equals(date)){ previousMatch = previousClosestMatch(date.minusSeconds(1)); }
public java.time.Duration timeToNextExecution(ZonedDateTime date){ return java.time.Duration.between(date, nextExecution(date)); public ZonedDateTime lastExecution(ZonedDateTime date){ ZonedDateTime previousMatch = previousClosestMatch(date);
16,986
return previousMatch; } catch (NoSuchValueException e) { throw new IllegalArgumentException(e); } } <BUG>public Duration timeFromLastExecution(DateTime date){ return new Interval(lastExecution(date), date).toDuration(); } public boolean isMatch(DateTime date){ </BUG> return nextExecution(lastExecution(date)).equals(date);
[DELETED]
16,987
<BUG>package com.cronutils.model.time.generator; import com.cronutils.model.field.CronField;</BUG> import com.cronutils.model.field.expression.Every; import com.cronutils.model.field.expression.FieldExpression; import com.google.common.annotations.VisibleForTesting;
import java.time.ZonedDateTime; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.cronutils.model.field.CronField;
16,988
import com.cronutils.model.field.CronField;</BUG> import com.cronutils.model.field.expression.Every; import com.cronutils.model.field.expression.FieldExpression; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; <BUG>import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List;</BUG> class EveryFieldValueGenerator extends FieldValueGenerator {
package com.cronutils.model.time.generator; import java.time.ZonedDateTime; import java.util.List; import com.cronutils.model.field.CronField;
16,989
private static final Logger log = LoggerFactory.getLogger(EveryFieldValueGenerator.class); public EveryFieldValueGenerator(CronField cronField) { super(cronField); log.trace(String.format( "processing \"%s\" at %s", <BUG>cronField.getExpression().asString(), DateTime.now() </BUG> )); } @Override
cronField.getExpression().asString(), ZonedDateTime.now()
16,990
_log.error("Uninvited dbLookup received with replies going to " + fromKey + " (tunnel " + _message.getReplyTunnel() + ")"); } return; } <BUG>LeaseSet ls = getContext().netDb().lookupLeaseSetLocally(_message.getSearchKey()); if (ls != null) { boolean isLocal = getContext().clientManager().isLocal(ls.getDestination());</BUG> boolean shouldPublishLocal = isLocal && getContext().clientManager().shouldPublishLeaseSet(_message.getSearchKey());
DatabaseEntry dbe = getContext().netDb().lookupLocally(_message.getSearchKey()); if (dbe != null && dbe.getType() == DatabaseEntry.KEY_TYPE_LEASESET) { LeaseSet ls = (LeaseSet) dbe; boolean isLocal = getContext().clientManager().isLocal(ls.getDestination());
16,991
Set<Hash> routerHashSet = getNearestRouters(); sendClosest(_message.getSearchKey(), routerHashSet, fromKey, _message.getReplyTunnel()); } } else { if (_log.shouldLog(Log.INFO)) <BUG>_log.info("We have LS " + _message.getSearchKey().toBase64() + ", NOT answering query - local? " + isLocal + " shouldPublish? " + shouldPublishLocal +</BUG> " RAP? " + ls.getReceivedAsPublished() + " RAR? " + ls.getReceivedAsReply()); getContext().statManager().addRateData("netDb.lookupsMatchedRemoteNotClosest", 1, 0); Set<Hash> routerHashSet = getNearestRouters();
_log.info("We have LS " + _message.getSearchKey() + ", NOT answering query - local? " + isLocal + " shouldPublish? " + shouldPublishLocal +
16,992
" RAP? " + ls.getReceivedAsPublished() + " RAR? " + ls.getReceivedAsReply()); getContext().statManager().addRateData("netDb.lookupsMatchedRemoteNotClosest", 1, 0); Set<Hash> routerHashSet = getNearestRouters(); sendClosest(_message.getSearchKey(), routerHashSet, fromKey, _message.getReplyTunnel()); } <BUG>} else { RouterInfo info = getContext().netDb().lookupRouterInfoLocally(_message.getSearchKey()); if ( (info != null) && (info.isCurrent(EXPIRE_DELAY)) ) { if ( (info.getIdentity().isHidden()) || (isUnreachable(info) && !publishUnreachable()) ) {</BUG> if (_log.shouldLog(Log.DEBUG))
} else if (dbe != null && dbe.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) { RouterInfo info = (RouterInfo) dbe; if (info.isCurrent(EXPIRE_DELAY)) { if ( (info.getIdentity().isHidden()) || (isUnreachable(info) && !publishUnreachable()) ) {
16,993
Set<Hash> us = new HashSet<Hash>(1); us.add(getContext().routerHash()); sendClosest(_message.getSearchKey(), us, fromKey, _message.getReplyTunnel()); } else { if (_log.shouldLog(Log.DEBUG)) <BUG>_log.debug("We do have key " + _message.getSearchKey().toBase64() + " locally as a router info. sending to " + fromKey.toBase64()); sendData(_message.getSearchKey(), info, fromKey, _message.getReplyTunnel());</BUG> } } else {
_log.debug("We do have key " + _message.getSearchKey() + " locally as a router info. sending to " + fromKey); sendData(_message.getSearchKey(), info, fromKey, _message.getReplyTunnel());
16,994
if (!key.equals(data.getHash())) { _log.error("Hash mismatch HDLMJ"); return; } if (_log.shouldLog(Log.DEBUG)) <BUG>_log.debug("Sending data matching key " + key.toBase64() + " to peer " + toPeer.toBase64() + " tunnel " + replyTunnel);</BUG> DatabaseStoreMessage msg = new DatabaseStoreMessage(getContext()); if (data.getType() == DatabaseEntry.KEY_TYPE_LEASESET) { getContext().statManager().addRateData("netDb.lookupsMatchedLeaseSet", 1, 0);
_log.debug("Sending data matching key " + key + " to peer " + toPeer + " tunnel " + replyTunnel);
16,995
getContext().statManager().addRateData("netDb.lookupsHandled", 1, 0); sendMessage(msg, toPeer, replyTunnel); } protected void sendClosest(Hash key, Set<Hash> routerHashes, Hash toPeer, TunnelId replyTunnel) { if (_log.shouldLog(Log.DEBUG)) <BUG>_log.debug("Sending closest routers to key " + key.toBase64() + ": # peers = " + routerHashes.size() + " tunnel " + replyTunnel);</BUG> DatabaseSearchReplyMessage msg = new DatabaseSearchReplyMessage(getContext()); msg.setFromHash(getContext().routerHash()); msg.setSearchKey(key);
_log.debug("Sending closest routers to key " + key + ": # peers = " + routerHashes.size() + " tunnel " + replyTunnel);
16,996
String localizedfieldLabel = LocalizationUtil.getPreferencesValue( preferences, "fieldLabel" + i, themeDisplay.getLanguageId()); if (Validator.isNull(fieldLabel)) { break; } <BUG>fieldLabels.add(fieldLabel); sb.append(prepareFieldForCSVExport(localizedfieldLabel)); } sb.delete( sb.length() - PortletPropsValues.CSV_SEPARATOR.length(), sb.length()); sb.append(CharPool.NEW_LINE);</BUG> if (Validator.isNotNull(databaseTableName)) {
sb.append(getCSVFormatedValue(localizedfieldLabel)); sb.append(PortletPropsValues.CSV_SEPARATOR); sb.setIndex(sb.index() - 1); sb.append(CharPool.NEW_LINE);
16,997
for (ExpandoRow row : rows) { for (String fieldName : fieldLabels) { String data = ExpandoValueLocalServiceUtil.getData( themeDisplay.getCompanyId(), WebFormUtil.class.getName(), databaseTableName, <BUG>fieldName, row.getClassPK(), StringPool.BLANK); sb.append(prepareFieldForCSVExport(data)); } sb.delete( sb.length() - PortletPropsValues.CSV_SEPARATOR.length(), sb.length()); sb.append(CharPool.NEW_LINE);</BUG> }
sb.append(getCSVFormatedValue(data)); sb.append(PortletPropsValues.CSV_SEPARATOR);
16,998
} @RootTask static Task<Exec.Result> exec(String parameter, int number) { Task<String> task1 = MyTask.create(parameter); Task<Integer> task2 = Adder.create(number, number + 2); <BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh") .in(() -> task1)</BUG> .in(() -> task2) .process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\""))); }
return Task.named("exec", "/bin/sh").ofType(Exec.Result.class) .in(() -> task1)
16,999
return args; } static class MyTask { static final int PLUS = 10; static Task<String> create(String parameter) { <BUG>return Task.ofType(String.class).named("MyTask", parameter) .in(() -> Adder.create(parameter.length(), PLUS))</BUG> .in(() -> Fib.create(parameter.length())) .process((sum, fib) -> something(parameter, sum, fib)); }
return Task.named("MyTask", parameter).ofType(String.class) .in(() -> Adder.create(parameter.length(), PLUS))
17,000
final String instanceField = "from instance"; final TaskContext context = TaskContext.inmem(); final AwaitingConsumer<String> val = new AwaitingConsumer<>(); @Test public void shouldJavaUtilSerialize() throws Exception { <BUG>Task<Long> task1 = Task.ofType(Long.class).named("Foo", "Bar", 39) .process(() -> 9999L); Task<String> task2 = Task.ofType(String.class).named("Baz", 40) .in(() -> task1)</BUG> .ins(() -> singletonList(task1))
Task<Long> task1 = Task.named("Foo", "Bar", 39).ofType(Long.class) Task<String> task2 = Task.named("Baz", 40).ofType(String.class) .in(() -> task1)