id int64 1 49k | buggy stringlengths 34 37.5k | fixed stringlengths 2 37k |
|---|---|---|
4,401 | }
public MySQLTable getTable (final String name) {
return new MySQLTable(this, name);
}
public MySQLConnection obtainConnection () {
<BUG>final MySQLConnection connection = new MySQLConnection(this.dataSource);
connection.open();</BUG>
return connection;
}
public void releaseConnection (final MySQLConnection connection) {
| public String getDBName () {
return this.dbName;
final MySQLConnection connection = new MySQLConnection(this);
connection.open();
|
4,402 | ti.run(file.getAbsolutePath(), fromMessages);
Parameters.repaintAll();
}
public void initSearch()
{
<BUG>Parameters.stFrame.mainPanel.highlighted = new HashSet<AbstractVertex>();
Parameters.bytecodeArea.clear();</BUG>
Parameters.rightArea.setText("");
}
public String getSearchInput(searchType search)
| this.mainPanel.resetHighlighted(null);
Parameters.bytecodeArea.clear();
|
4,403 | package com.mebigfatguy.fbcontrib.detect;
import org.apache.bcel.classfile.Code;
<BUG>import org.objectweb.asm.Type;
import com.mebigfatguy.fbcontrib.utils.BugType;
import com.mebigfatguy.fbcontrib.utils.Values;</BUG>
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
| import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
import com.mebigfatguy.fbcontrib.utils.Values;
|
4,404 | private boolean processInvokeSpecial() {
String clsName = getClassConstantOperand();
if ("java/io/File".equals(clsName)) {
String methodName = getNameConstantOperand();
String sig = getSigConstantOperand();
<BUG>if (Values.CONSTRUCTOR.equals(methodName) && (Type.getArgumentTypes(sig).length == 1) && (stack.getStackDepth() > 0)) {
</BUG>
OpcodeStack.Item item = stack.getStackItem(0);
if (item.getUserValue() != null) {
bugReporter.reportBug(new BugInstance(this, BugType.CRF_CONFLATING_RESOURCES_AND_FILES.name(), NORMAL_PRIORITY).addClass(this)
| if (Values.CONSTRUCTOR.equals(methodName) && (SignatureUtils.getNumParameters(sig) == 1) && (stack.getStackDepth() > 0)) {
|
4,405 | import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.Type;
<BUG>import com.mebigfatguy.fbcontrib.utils.BugType;
import com.mebigfatguy.fbcontrib.utils.ToString;</BUG>
import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet;
import com.mebigfatguy.fbcontrib.utils.Values;
import edu.umd.cs.findbugs.BugInstance;
| import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
import com.mebigfatguy.fbcontrib.utils.ToString;
|
4,406 | stack.sawOpcode(this, seen);
}
}
private void processInvoke() {
String sig = getSigConstantOperand();
<BUG>int argCount = Type.getArgumentTypes(sig).length;
if (stack.getStackDepth() > argCount) {</BUG>
OpcodeStack.Item invokeeItem = stack.getStackItem(argCount);
XField fieldOnWhichMethodIsInvoked = invokeeItem.getXField();
if (fieldOnWhichMethodIsInvoked != null) {
| int argCount = SignatureUtils.getNumParameters(sig);
if (stack.getStackDepth() > argCount) {
|
4,407 | String clsName = getClassConstantOperand();
String methodName = getNameConstantOperand();
FQMethod m = new FQMethod(clsName, methodName, ANY_PARMS);
if (COPY_METHODS.contains(m)) {
String signature = getSigConstantOperand();
<BUG>Type[] argTypes = Type.getArgumentTypes(signature);
if (stack.getStackDepth() >= argTypes.length) {
for (int i = 0; i < argTypes.length; i++) {
</BUG>
OpcodeStack.Item itm = stack.getStackItem(i);
| int numArguments = SignatureUtils.getNumParameters(signature);
if (stack.getStackDepth() >= numArguments) {
for (int i = 0; i < numArguments; i++) {
|
4,408 | import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;
import org.apache.bcel.classfile.Method;
<BUG>import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.BugType;
import com.mebigfatguy.fbcontrib.utils.ToString;</BUG>
import com.mebigfatguy.fbcontrib.utils.UnmodifiableList;
import edu.umd.cs.findbugs.BugInstance;
| import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
import com.mebigfatguy.fbcontrib.utils.ToString;
|
4,409 | new InvalidPattern("javax/swing/BorderFactory#createEtchedBorder\\(I.*\\)Ljavax/swing/border/Border;",
ParameterInfo.createIntegerParameterInfo(0, true, EtchedBorder.LOWERED, EtchedBorder.RAISED)),
new InvalidPattern("javax/swing/JScrollBar#\\<init\\>\\(I.*\\)V",
ParameterInfo.createIntegerParameterInfo(0, true, Adjustable.HORIZONTAL, Adjustable.VERTICAL)),
new InvalidPattern("java/lang/Thread#setPriority\\(I\\)V",
<BUG>new ParameterInfo<Integer>(0, true, Range.createIntegerRange(Thread.MIN_PRIORITY, Thread.MAX_PRIORITY))),
new InvalidPattern("java/math/BigDecimal#divide\\(Ljava/math/BigDecimal;.*I\\)Ljava/math/BigDecimal;",
new ParameterInfo<Integer>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))),
new InvalidPattern("java/math/BigDecimal#setScale\\(II\\)Ljava/math/BigDecimal;",
new ParameterInfo<Integer>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))),
new InvalidPattern("java/sql/Connection#createStatement\\(II\\)Ljava/sql/Statement;", ParameterInfo.createIntegerParameterInfo(0, true,</BUG>
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE)),
| new ParameterInfo<>(0, true, Range.createIntegerRange(Thread.MIN_PRIORITY, Thread.MAX_PRIORITY))),
new ParameterInfo<>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))),
new ParameterInfo<>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))),
new InvalidPattern("java/sql/Connection#createStatement\\(II\\)Ljava/sql/Statement;", ParameterInfo.createIntegerParameterInfo(0, true,
|
4,410 | String mInfo = getClassConstantOperand() + '#' + getNameConstantOperand() + sig;
for (InvalidPattern entry : PATTERNS) {
Matcher m = entry.getPattern().matcher(mInfo);
if (m.matches()) {
for (ParameterInfo<?> info : entry.getParmInfo()) {
<BUG>int parmOffset = info.fromStart ? Type.getArgumentTypes(sig).length - info.parameterOffset - 1 : info.parameterOffset;
</BUG>
if (stack.getStackDepth() > parmOffset) {
OpcodeStack.Item item = stack.getStackItem(parmOffset);
Comparable cons = (Comparable) item.getConstant();
| int parmOffset = info.fromStart ? SignatureUtils.getNumParameters(sig) - info.parameterOffset - 1 : info.parameterOffset;
|
4,411 | if (stack.getStackDepth() > parmOffset) {
OpcodeStack.Item item = stack.getStackItem(parmOffset);
Comparable cons = (Comparable) item.getConstant();
if (!info.isValid(cons)) {
int badParm = 1
<BUG>+ (info.fromStart ? info.parameterOffset : Type.getArgumentTypes(sig).length - info.parameterOffset - 1);
</BUG>
bugReporter.reportBug(new BugInstance(this, BugType.ICA_INVALID_CONSTANT_ARGUMENT.name(), NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this).addString("Parameter " + badParm));
break;
| + (info.fromStart ? info.parameterOffset : SignatureUtils.getNumParameters(sig) - info.parameterOffset - 1);
|
4,412 | private Range<T> range;
@SafeVarargs
public ParameterInfo(int offset, boolean start, T... values) {
parameterOffset = offset;
fromStart = start;
<BUG>validValues = new HashSet<T>(Arrays.asList(values));
range = null;</BUG>
}
public ParameterInfo(int offset, boolean start, Range<T> rng) {
parameterOffset = offset;
| validValues = new HashSet<>(Arrays.asList(values));
range = null;
|
4,413 | public Range(T f, T t) {
from = f;
to = t;
}
public static Range<Integer> createIntegerRange(int f, int t) {
<BUG>return new Range<Integer>(Integer.valueOf(f), Integer.valueOf(t));
}</BUG>
public T getFrom() {
return from;
}
| return new Range<>(Integer.valueOf(f), Integer.valueOf(t));
|
4,414 | stack.sawOpcode(this, seen);
}
}
private void processNormalInvoke() {
String signature = getSigConstantOperand();
<BUG>int numParms = Type.getArgumentTypes(signature).length;
if (stack.getStackDepth() <= numParms) {</BUG>
return;
}
OpcodeStack.Item item = stack.getStackItem(numParms);
| int numParms = SignatureUtils.getNumParameters(signature);
if (stack.getStackDepth() <= numParms) {
|
4,415 | new QMethod("listIterator", "()Ljava/util/ListIterator;"),
new QMethod("listIterator", "(I)Ljava/util/ListIterator;")
);
private final BugReporter bugReporter;
private final OpcodeStack stack = new OpcodeStack();
<BUG>private final Map<String, FieldInfo> fieldsReported = new HashMap<String, FieldInfo>(10);
public DubiousListCollection(final BugReporter bugReporter) {</BUG>
this.bugReporter = bugReporter;
}
@Override
| private final Map<String, FieldInfo> fieldsReported = new HashMap<>(10);
public DubiousListCollection(final BugReporter bugReporter) {
|
4,416 | case INVOKESPECIAL:
case INVOKESTATIC:
case INVOKEDYNAMIC:
numMethodCalls++;
if (seen != INVOKESTATIC) {
<BUG>int numParms = Type.getArgumentTypes(getSigConstantOperand()).length;
if (stack.getStackDepth() > numParms) {</BUG>
OpcodeStack.Item itm = stack.getStackItem(numParms);
if (itm.getRegisterNumber() == 0) {
Set<CalledMethod> calledMethods;
| int numParms = SignatureUtils.getNumParameters(getSigConstantOperand());
if (stack.getStackDepth() > numParms) {
|
4,417 | private enum Units {
NANOS, MICROS, MILLIS, SECONDS, MINUTES, HOURS, DAYS, CALLER
};
private static final Map<FQMethod, Units> TIME_UNIT_GENERATING_METHODS;
static {
<BUG>Map<FQMethod, Units> tugm = new HashMap<FQMethod, Units>(50);
tugm.put(new FQMethod("java/lang/System", "currentTimeMillis", "()J"), Units.MILLIS);</BUG>
tugm.put(new FQMethod("java/lang/System", "nanoTime", "()J"), Units.NANOS);
tugm.put(new FQMethod("java/sql/Timestamp", "getTime", "()J"), Units.MILLIS);
tugm.put(new FQMethod("java/sql/Timestamp", "getNanos", "()I"), Units.NANOS);
| Map<FQMethod, Units> tugm = new HashMap<>(50);
tugm.put(new FQMethod("java/lang/System", "currentTimeMillis", "()J"), Units.MILLIS);
|
4,418 | tugm.put(new FQMethod("java/time/LocalTime", "toSecondOfDay", "()I"), Units.SECONDS);
TIME_UNIT_GENERATING_METHODS = Collections.<FQMethod, Units> unmodifiableMap(tugm);
}
private static final Map<String, Units> TIMEUNIT_TO_UNITS;
static {
<BUG>Map<String, Units> tutu = new HashMap<String, Units>();
tutu.put("NANOSECONDS", Units.NANOS);</BUG>
tutu.put("MICROSECONDS", Units.MICROS);
tutu.put("MILLISECONDS", Units.MILLIS);
tutu.put("SECONDS", Units.SECONDS);
| Map<String, Units> tutu = new HashMap<>();
tutu.put("NANOSECONDS", Units.NANOS);
|
4,419 | private Units processInvoke() {
String signature = getSigConstantOperand();
FQMethod methodCall = new FQMethod(getClassConstantOperand(), getNameConstantOperand(), signature);
Units unit = TIME_UNIT_GENERATING_METHODS.get(methodCall);
if (unit == Units.CALLER) {
<BUG>int offset = Type.getArgumentTypes(signature).length;
if (stack.getStackDepth() > offset) {</BUG>
OpcodeStack.Item item = stack.getStackItem(offset);
unit = (Units) item.getUserValue();
} else {
| int offset = SignatureUtils.getNumParameters(signature);
if (stack.getStackDepth() > offset) {
|
4,420 | import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.bcel.classfile.Code;
<BUG>import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.utils.ToString;</BUG>
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
import edu.umd.cs.findbugs.BytecodeScanningDetector;
| import com.mebigfatguy.fbcontrib.utils.SignatureUtils;
import com.mebigfatguy.fbcontrib.utils.ToString;
|
4,421 | BugReporter bugReporter;
OpcodeStack stack;
Map<KeyType, Map<String, Map<String, List<SourceInfo>>>> parmInfo;
public InconsistentKeyNameCasing(BugReporter reporter) {
bugReporter = reporter;
<BUG>parmInfo = new EnumMap<KeyType, Map<String, Map<String, List<SourceInfo>>>>(KeyType.class);
parmInfo.put(KeyType.ATTRIBUTE, new HashMap<String, Map<String, List<SourceInfo>>>());</BUG>
parmInfo.put(KeyType.PARAMETER, new HashMap<String, Map<String, List<SourceInfo>>>());
}
@Override
| parmInfo = new EnumMap<>(KeyType.class);
parmInfo.put(KeyType.ATTRIBUTE, new HashMap<String, Map<String, List<SourceInfo>>>());
|
4,422 | } else {
updateMemo();
callback.updateMemo();
}
dismiss();
<BUG>}else{
</BUG>
Toast.makeText(getActivity(), getString(R.string.toast_memo_empty), Toast.LENGTH_SHORT).show();
}
}
| [DELETED] |
4,423 | }
@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);
|
4,424 | 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);
|
4,425 | 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(
|
4,426 | 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 {
|
4,427 | 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;
|
4,428 | 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) {
|
4,429 | 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;
|
4,430 | cacheBaseDir = new File(cacheBaseDir, pathEntry);
}
return new File(cacheBaseDir, cacheKey);
}
private File determineBaseDir(File globalCacheDir, File projectCacheDir) {
<BUG>if (baseDir != null) {
return new File(baseDir, ".gradle");
}</BUG>
if (project != null) {
return getProjectCacheDir(projectCacheDir);
| [DELETED] |
4,431 | package org.gradle.cache;
import java.util.Map;
public interface CacheBuilder<T> {
enum VersionStrategy {
CachePerVersion,
<BUG>SharedCache,
SharedCacheInvalidateOnVersionChange,</BUG>
}
CacheBuilder<T> withProperties(Map<String, ?> properties);
CacheBuilder<T> withLayout(CacheLayout layout);
| SharedCache
|
4,432 | this.validator = validator;
return this;
}
public T open() {
File cacheBaseDir = layout.getCacheDir(globalCacheDir, projectCacheDir, key);
<BUG>Map<String, ?> props = layout.applyLayoutProperties(properties);
return doOpen(cacheBaseDir, props, validator);
</BUG>
}
protected abstract T doOpen(File cacheDir, Map<String, ?> properties, CacheValidator validator);
| return doOpen(cacheBaseDir, properties, validator);
|
4,433 | import org.gradle.cache.internal.CacheLayoutBuilder;
import org.gradle.cache.internal.FileLockManager;
import org.gradle.initialization.ClassLoaderRegistry;
import org.gradle.initialization.GradleLauncherFactory;
import org.gradle.internal.classpath.ClassPath;
<BUG>import org.gradle.internal.classpath.DefaultClassPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URLClassLoader;
import static org.gradle.cache.internal.filelock.LockOptionsBuilder.mode;</BUG>
public class BuildSourceBuilder {
| import org.gradle.util.GradleVersion;
import java.io.File;
import java.util.Collections;
import static org.gradle.cache.internal.filelock.LockOptionsBuilder.mode;
|
4,434 | import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.StaticallyInject;
<BUG>import org.apache.ambari.server.api.resources.OperatingSystemResourceDefinition;
import org.apache.ambari.server.api.services.AmbariMetaInfo;</BUG>
import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
| import org.apache.ambari.server.api.resources.RepositoryResourceDefinition;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
|
4,435 | import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
<BUG>import org.apache.ambari.server.orm.dao.StackDAO;
import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;</BUG>
import org.apache.ambari.server.orm.entities.StackEntity;
import org.apache.ambari.server.security.authorization.ResourceType;
import org.apache.ambari.server.security.authorization.RoleAuthorization;
| import org.apache.ambari.server.orm.entities.OperatingSystemEntity;
import org.apache.ambari.server.orm.entities.RepositoryEntity;
import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
|
4,436 | import org.apache.ambari.server.state.repository.VersionDefinitionXml;
import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
<BUG>import org.apache.commons.lang.math.NumberUtils;
import com.google.common.collect.Sets;</BUG>
import com.google.inject.Inject;
import com.google.inject.Provider;
@StaticallyInject
| import org.codehaus.jackson.node.ArrayNode;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.ObjectNode;
import com.google.common.collect.Sets;
|
4,437 | protected static final String VERSION_DEF_RELEASE_BUILD = "VersionDefinition/release/build";
protected static final String VERSION_DEF_RELEASE_NOTES = "VersionDefinition/release/notes";
protected static final String VERSION_DEF_RELEASE_COMPATIBLE_WITH = "VersionDefinition/release/compatible_with";
protected static final String VERSION_DEF_AVAILABLE_SERVICES = "VersionDefinition/services";
protected static final String VERSION_DEF_STACK_SERVICES = "VersionDefinition/stack_services";
<BUG>protected static final String SHOW_AVAILABLE = "VersionDefinition/show_available";
public static final String SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID = new OperatingSystemResourceDefinition().getPluralName();</BUG>
@Inject
private static RepositoryVersionDAO s_repoVersionDAO;
@Inject
| public static final String DIRECTIVE_DRY_RUN = "dry_run";
public static final String SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID = new OperatingSystemResourceDefinition().getPluralName();
|
4,438 | static {
KEY_PROPERTY_IDS.put(Resource.Type.VersionDefinition, VERSION_DEF_ID);
}
VersionDefinitionResourceProvider() {
super(PROPERTY_IDS, KEY_PROPERTY_IDS);
<BUG>setRequiredCreateAuthorizations(EnumSet.of(RoleAuthorization.AMBARI_MANAGE_STACK_VERSIONS));
setRequiredGetAuthorizations(EnumSet.of(
RoleAuthorization.AMBARI_MANAGE_STACK_VERSIONS));</BUG>
}
@Override
| setRequiredGetAuthorizations(EnumSet.of(RoleAuthorization.AMBARI_MANAGE_STACK_VERSIONS));
|
4,439 | VersionDefinitionXml xml = s_metaInfo.get().getVersionDefinition(id);
if (null == xml) {
throw new NoSuchResourceException(String.format("Could not find version %s",
id));
}
<BUG>results.add(toResource(id, xml, requestPropertyIds));
</BUG>
}
} else {
List<RepositoryVersionEntity> versions = s_repoVersionDAO.findAllDefinitions();
| results.add(toResource(id, xml, requestPropertyIds, true));
|
4,440 | protected RequestStatus deleteResourcesAuthorized(Predicate predicate)
throws SystemException, UnsupportedPropertyException,
NoSuchResourceException, NoSuchParentResourceException {
throw new SystemException("Cannot delete Version Definitions");
}
<BUG>private void checkForParent(XmlHolder holder, RepositoryVersionEntity entity) throws AmbariException {
if (entity.getType() != RepositoryType.PATCH) {</BUG>
return;
}
List<RepositoryVersionEntity> entities = s_repoVersionDAO.findByStack(entity.getStackId());
| private void checkForParent(XmlHolder holder) throws AmbariException {
RepositoryVersionEntity entity = holder.entity;
if (entity.getType() != RepositoryType.PATCH) {
|
4,441 | definitionUrl, e.getMessage());
throw new AmbariException(err, e);
}
return holder;
}
<BUG>protected RepositoryVersionEntity toRepositoryVersionEntity(XmlHolder holder) throws AmbariException {
</BUG>
RepositoryVersionEntity entity = new RepositoryVersionEntity();
StackId stackId = new StackId(holder.xml.release.stackId);
StackEntity stackEntity = s_stackDAO.find(stackId.getStackName(), stackId.getStackVersion());
| protected void toRepositoryVersionEntity(XmlHolder holder) throws AmbariException {
|
4,442 | package org.apache.ambari.server.api.resources;
import java.util.Collections;
<BUG>import java.util.Set;
import org.apache.ambari.server.controller.spi.Resource;</BUG>
import org.apache.ambari.server.controller.spi.Resource.Type;
public class VersionDefinitionResourceDefinition extends BaseResourceDefinition {
public VersionDefinitionResourceDefinition() {
| import java.util.Collection;
import org.apache.ambari.server.controller.internal.VersionDefinitionResourceProvider;
import org.apache.ambari.server.controller.spi.Resource;
|
4,443 | customTokens.put("%%mlFinalForestsPerHost%%", hubConfig.finalForestsPerHost.toString());
customTokens.put("%%mlTraceAppserverName%%", hubConfig.traceHttpName);
customTokens.put("%%mlTracePort%%", hubConfig.tracePort.toString());
customTokens.put("%%mlTraceDbName%%", hubConfig.traceDbName);
customTokens.put("%%mlTraceForestsPerHost%%", hubConfig.traceForestsPerHost.toString());
<BUG>customTokens.put("%%mlModulesDbName%%", hubConfig.modulesDbName);
}</BUG>
public void init() {
try {
LOGGER.error("PLUGINS DIR: " + pluginsDir.toString());
| customTokens.put("%%mlTriggersDbName%%", hubConfig.triggersDbName);
customTokens.put("%%mlSchemasDbName%%", hubConfig.schemasDbName);
}
|
4,444 | import java.sql.SQLException;
import java.sql.Statement;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
<BUG>import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;</BUG>
import java.util.concurrent.locks.Lock;
| import java.util.HashMap;
import java.util.Map;
import java.util.Set;
|
4,445 | if (msgin != null) {
try {
msgin.close();
} catch (IOException e) {
}
<BUG>}
}
}
protected void updateSourceSequence(SourceSequence seq)
</BUG>
throws SQLException {
| releaseResources(stmt, null);
protected void storeMessage(Identifier sid, RMMessage msg, boolean outbound)
throws IOException, SQLException {
storeMessage(connection, sid, msg, outbound);
protected void updateSourceSequence(Connection con, SourceSequence seq)
|
4,446 | } catch (SQLException ex) {
if (!isTableExistsError(ex)) {
throw ex;
} else {
LOG.fine("Table CXF_RM_SRC_SEQUENCES already exists.");
<BUG>verifyTable(SRC_SEQUENCES_TABLE_NAME, SRC_SEQUENCES_TABLE_COLS);
</BUG>
}
} finally {
stmt.close();
| verifyTable(con, SRC_SEQUENCES_TABLE_NAME, SRC_SEQUENCES_TABLE_COLS);
|
4,447 | } catch (SQLException ex) {
if (!isTableExistsError(ex)) {
throw ex;
} else {
LOG.fine("Table CXF_RM_DEST_SEQUENCES already exists.");
<BUG>verifyTable(DEST_SEQUENCES_TABLE_NAME, DEST_SEQUENCES_TABLE_COLS);
</BUG>
}
} finally {
stmt.close();
| LOG.fine("Table CXF_RM_SRC_SEQUENCES already exists.");
verifyTable(con, SRC_SEQUENCES_TABLE_NAME, SRC_SEQUENCES_TABLE_COLS);
|
4,448 | }
} finally {
stmt.close();
}
for (String tableName : new String[] {OUTBOUND_MSGS_TABLE_NAME, INBOUND_MSGS_TABLE_NAME}) {
<BUG>stmt = connection.createStatement();
try {</BUG>
stmt.executeUpdate(MessageFormat.format(CREATE_MESSAGES_TABLE_STMT, tableName));
} catch (SQLException ex) {
if (!isTableExistsError(ex)) {
| stmt = con.createStatement();
try {
stmt.executeUpdate(CREATE_DEST_SEQUENCES_TABLE_STMT);
|
4,449 | throw ex;
} else {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Table " + tableName + " already exists.");
}
<BUG>verifyTable(tableName, MESSAGES_TABLE_COLS);
</BUG>
}
} finally {
stmt.close();
| LOG.fine("Table CXF_RM_SRC_SEQUENCES already exists.");
verifyTable(con, SRC_SEQUENCES_TABLE_NAME, SRC_SEQUENCES_TABLE_COLS);
|
4,450 | if (newCols.size() > 0) {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Table " + tableName + " needs additional columns");
}
for (String[] newCol : newCols) {
<BUG>Statement st = connection.createStatement();
try {</BUG>
st.executeUpdate(MessageFormat.format(ALTER_TABLE_STMT_STR,
tableName, newCol[0], newCol[1]));
if (LOG.isLoggable(Level.FINE)) {
| Statement st = con.createStatement();
try {
|
4,451 | if (nextReconnectAttempt < System.currentTimeMillis()) {
nextReconnectAttempt = System.currentTimeMillis() + reconnectDelay;
reconnectDelay = reconnectDelay * useExponentialBackOff;
}
}
<BUG>}
public static void deleteDatabaseFiles() {</BUG>
deleteDatabaseFiles(DEFAULT_DATABASE_NAME, true);
}
public static void deleteDatabaseFiles(String dbName, boolean now) {
| public static void deleteDatabaseFiles() {
|
4,452 | } else {
updateMemo();
callback.updateMemo();
}
dismiss();
<BUG>}else{
</BUG>
Toast.makeText(getActivity(), getString(R.string.toast_memo_empty), Toast.LENGTH_SHORT).show();
}
}
| [DELETED] |
4,453 | }
@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);
|
4,454 | 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);
|
4,455 | 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(
|
4,456 | 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 {
|
4,457 | 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;
|
4,458 | 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) {
|
4,459 | 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;
|
4,460 | import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
<BUG>import java.io.InputStreamReader;
import java.net.URI;</BUG>
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
| import java.lang.reflect.Type;
import java.net.URI;
|
4,461 | String type) {
MockResponder responder = new MockResponder();
String uri = String.format("/v2/apps/%s/%s/%s/status", appId, type, flowId);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri);
httpHandler.getStatus(request, responder, appId, type, flowId);
<BUG>Preconditions.checkArgument(responder.getStatus().getCode() == 200, "get status" + " " + type + "failed");
JsonReader jsonReader = new JsonReader(new InputStreamReader
(new ChannelBufferInputStream(ChannelBuffers.wrappedBuffer
(responder.getResponseContent())), Charsets.UTF_8));
Map<String, String> json = GSON.fromJson(jsonReader,
new TypeToken<Map<String, String>>() { }.getType());</BUG>
return json.get("status");
| String uri = String.format("/v2/apps/%s/%s/%s/stop", appId, type, flowId);
httpHandler.stopProgram(request, responder, appId, type, flowId);
Preconditions.checkArgument(responder.getStatus().getCode() == 200, "stop" + " " + type + "failed");
|
4,462 | public static List<RunRecord> getHistory(AppFabricHttpHandler httpHandler, String appId, String wflowId) {
MockResponder responder = new MockResponder();
String uri = String.format("/v2/apps/%s/workflows/%s/history", appId, wflowId);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
httpHandler.runnableHistory(request, responder, appId, "workflows", wflowId);
<BUG>Preconditions.checkArgument(responder.getStatus().getCode() == 200, " getting workflow schedules failed");
JsonReader jsonReader = new JsonReader(new InputStreamReader
(new ChannelBufferInputStream(ChannelBuffers.wrappedBuffer
(responder.getResponseContent())), Charsets.UTF_8));
List<Map<String, String>> runList = GSON.fromJson(jsonReader,
new TypeToken<List<Map<String, String>>>() { }.getType());</BUG>
List<RunRecord> runRecords = Lists.newArrayList();
| List<Map<String, String>> runList = responder.decodeResponseContent(new TypeToken<List<Map<String, String>>>() { });
|
4,463 | String schedId) {
MockResponder responder = new MockResponder();
String uri = String.format("/v2/apps/%s/workflows/%s/schedules/%s/status", appId, wflowId, schedId);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
httpHandler.getScheuleState(request, responder, appId, wflowId, schedId);
<BUG>Preconditions.checkArgument(responder.getStatus().getCode() == 200, " getting workflow schedules failed");
JsonReader jsonReader = new JsonReader(new InputStreamReader
(new ChannelBufferInputStream(ChannelBuffers.wrappedBuffer
(responder.getResponseContent())), Charsets.UTF_8));
Map<String, String> json = GSON.fromJson(jsonReader,
new TypeToken<Map<String, String>>() { }.getType());</BUG>
return json.get("status");
| String uri = String.format("/v2/apps/%s/workflows/%s/schedules/%s/suspend", appId, wflowId, schedId);
httpHandler.workflowScheduleSuspend(request, responder, appId, wflowId, schedId);
|
4,464 | import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
<BUG>import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferOutputStream;</BUG>
import org.jboss.netty.buffer.ChannelBuffers;
| import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import org.jboss.netty.buffer.ChannelBufferInputStream;
import org.jboss.netty.buffer.ChannelBufferOutputStream;
|
4,465 | import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferOutputStream;</BUG>
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import java.io.File;
<BUG>import java.io.IOException;
import java.io.OutputStreamWriter;</BUG>
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
public final class MockResponder implements HttpResponder {
| import org.jboss.netty.buffer.ChannelBufferInputStream;
import org.jboss.netty.buffer.ChannelBufferOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
|
4,466 | }
};
public HttpResponseStatus getStatus() {
return status;
}
<BUG>public byte[] getResponseContent() {
return content;
}</BUG>
@Override
public void sendJson(HttpResponseStatus status, Object object) {
| public <T> T decodeResponseContent(TypeToken<T> type) {
JsonReader jsonReader = new JsonReader(new InputStreamReader
(new ChannelBufferInputStream(content), Charsets.UTF_8));
T response = GSON.fromJson(jsonReader, type.getType());
return response;
|
4,467 | public ReportElement getBase() {
return base;
}
@Override
public float print(PDDocument document, PDPageContentStream stream, int pageNumber, float startX, float startY, float allowedWidth) throws IOException {
<BUG>PDPage currPage = (PDPage) document.getDocumentCatalog().getPages().get(pageNo);
PDPageContentStream pageStream = new PDPageContentStream(document, currPage, true, false);
</BUG>
base.print(document, pageStream, pageNo, x, y, width);
pageStream.close();
| PDPage currPage = document.getDocumentCatalog().getPages().get(pageNo);
PDPageContentStream pageStream = new PDPageContentStream(document, currPage, PDPageContentStream.AppendMode.APPEND, false);
|
4,468 | public PdfTextStyle(String config) {
Assert.hasText(config);
String[] split = config.split(",");
Assert.isTrue(split.length == 3, "config must look like: 10,Times-Roman,#000000");
fontSize = Integer.parseInt(split[0]);
<BUG>font = resolveStandard14Name(split[1]);
color = new Color(Integer.valueOf(split[2].substring(1), 16));</BUG>
}
public int getFontSize() {
return fontSize;
| font = getFont(split[1]);
color = new Color(Integer.valueOf(split[2].substring(1), 16));
|
4,469 | package cc.catalysts.boot.report.pdf.elements;
import cc.catalysts.boot.report.pdf.config.PdfTextStyle;
import cc.catalysts.boot.report.pdf.utils.ReportAlignType;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
<BUG>import org.apache.pdfbox.pdmodel.font.PDFont;
import org.slf4j.Logger;</BUG>
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import java.io.IOException;
| import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.util.Matrix;
import org.slf4j.Logger;
|
4,470 | addTextSimple(stream, textConfig, textX, nextLineY, "");
return nextLineY;
}
try {
<BUG>String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, fixedText);
</BUG>
float x = calculateAlignPosition(textX, align, textConfig, allowedWidth, split[0]);
if (!underline) {
addTextSimple(stream, textConfig, x, nextLineY, split[0]);
} else {
| String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, text);
|
4,471 | public static void addTextSimple(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) {
try {
stream.setFont(textConfig.getFont(), textConfig.getFontSize());
stream.setNonStrokingColor(textConfig.getColor());
stream.beginText();
<BUG>stream.newLineAtOffset(textX, textY);
stream.showText(text);</BUG>
} catch (Exception e) {
LOG.warn("Could not add text: " + e.getClass() + " - " + e.getMessage());
}
| stream.setTextMatrix(new Matrix(1,0,0,1, textX, textY));
stream.showText(text);
|
4,472 | public static void addTextSimpleUnderlined(PDPageContentStream stream, PdfTextStyle textConfig, float textX, float textY, String text) {
addTextSimple(stream, textConfig, textX, textY, text);
try {
float lineOffset = textConfig.getFontSize() / 8F;
stream.setStrokingColor(textConfig.getColor());
<BUG>stream.setLineWidth(0.5F);
stream.drawLine(textX, textY - lineOffset, textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset);
</BUG>
stream.stroke();
} catch (IOException e) {
| stream.moveTo(textX, textY - lineOffset);
stream.lineTo(textX + getTextWidth(textConfig.getFont(), textConfig.getFontSize(), text), textY - lineOffset);
|
4,473 | list.add(text.length());
return list;
}
public static String[] splitText(PDFont font, int fontSize, float allowedWidth, String text) {
String endPart = "";
<BUG>String shortenedText = text;
List<String> breakSplitted = Arrays.asList(shortenedText.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList());
if (breakSplitted.size() > 1) {</BUG>
String[] splittedFirst = splitText(font, fontSize, allowedWidth, breakSplitted.get(0));
StringBuilder remaining = new StringBuilder(splittedFirst[1] == null ? "" : splittedFirst[1] + "\n");
| List<String> breakSplitted = Arrays.asList(text.split("(\\r\\n)|(\\n)|(\\n\\r)")).stream().collect(Collectors.toList());
if (breakSplitted.size() > 1) {
|
4,474 | package cc.catalysts.boot.report.pdf.elements;
import org.apache.pdfbox.pdmodel.PDDocument;
<BUG>import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
import java.io.IOException;</BUG>
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
| import org.apache.pdfbox.pdmodel.PDPageContentStream;
import java.io.IOException;
|
4,475 | }
@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)
|
4,476 | 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))
|
4,477 | 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)
|
4,478 | 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");
|
4,479 | 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");
|
4,480 | }
@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);
|
4,481 | 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);
|
4,482 | 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);
|
4,483 | 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);
|
4,484 | public boolean load() {
try {
Class clazz = Class.forName("tv.vanhal.jacb.gui.BenchContainer");
craftMatrixField = clazz.getField("craftMatrix");
return true;
<BUG>} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {</BUG>
e.printStackTrace();
| } catch (ClassNotFoundException | NoSuchFieldException e) {
|
4,485 | tileEntityField = containerClass.getDeclaredField("tileEntity");
tileEntityField.setAccessible(true);
Class tileEntityClass = Class.forName("thaumcraft.common.tiles.crafting.TileArcaneWorkbench");
inventoryField = tileEntityClass.getField("inventory");
return true;
<BUG>} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {</BUG>
e.printStackTrace();
| } catch (ClassNotFoundException | NoSuchFieldException e) {
|
4,486 | try {
Class clazz = Class.forName("de.eydamos.backpack.inventory.container.ContainerWorkbenchBackpack");
craftingGridField = clazz.getDeclaredField("craftingGrid");
craftingGridField.setAccessible(true);
return true;
<BUG>} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {</BUG>
e.printStackTrace();
| } catch (ClassNotFoundException | NoSuchFieldException e) {
|
4,487 | public void clearGrid(EntityPlayer entityPlayer, Container container, IInventory craftMatrix) {
clearGrid(entityPlayer, container, craftMatrix, 0, craftMatrix.getSizeInventory());
}
@Override
public void clearGrid(EntityPlayer entityPlayer, Container container, IInventory craftMatrix, int start, int size) {
<BUG>for(int i = start; i < size; i++) {
</BUG>
ItemStack itemStack = craftMatrix.getStackInSlot(i);
if(itemStack != null) {
if (entityPlayer.inventory.addItemStackToInventory(itemStack)) {
| for(int i = start; i < start + size; i++) {
|
4,488 | if (!(sender instanceof Player)) {
sender.sendMessage(plugin.getCore().getMessage("no-console"));
return true;
}
if (plugin.isBungeeCord()) {
<BUG>plugin.sendBungeeActivateMessage(sender, sender.getName(), false);
String message = plugin.getCore().getMessage("wait-on-proxy");
if (message != null) {
sender.sendMessage(message);
}</BUG>
} else {
| plugin.getCore().sendLocaleMessage("wait-on-proxy", sender);
|
4,489 | profile.setUuid(null);
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
plugin.getCore().getStorage().save(profile);
});
} else {
<BUG>sender.sendMessage(plugin.getCore().getMessage("not-premium"));
}</BUG>
}
return true;
} else {
| plugin.getCore().sendLocaleMessage("not-premium", sender);
|
4,490 | if (profile == null) {
sender.sendMessage("Error occured");
return;
}
if (profile.getUserId() != -1 && !profile.isPremium()) {
<BUG>sender.sendMessage(plugin.getCore().getMessage("not-premium-other"));
} else {
sender.sendMessage(plugin.getCore().getMessage("remove-premium"));
profile.setPremium(false);</BUG>
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
| plugin.getCore().sendLocaleMessage("not-premium-other", sender);
plugin.getCore().sendLocaleMessage("remove-premium", sender);
profile.setPremium(false);
|
4,491 | import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.core.PlayerProfile;
import com.github.games647.fastlogin.core.shared.JoinManagement;
import java.util.Random;
<BUG>import java.util.logging.Level;
import org.bukkit.entity.Player;
public class NameCheckTask extends JoinManagement<Player, ProtocolLibLoginSource> implements Runnable {
private final FastLoginBukkit plugin;</BUG>
private final PacketEvent packetEvent;
| import org.bukkit.command.CommandSender;
public class NameCheckTask extends JoinManagement<Player, CommandSender, ProtocolLibLoginSource>
private final FastLoginBukkit plugin;
|
4,492 | BukkitLoginSession session = plugin.getSessions().get(fromPlayer.getAddress().toString());
if (session == null) {
disconnect(plugin.getCore().getMessage("invalid-requst"), true
, "Player {0} tried to send encryption response at invalid state", fromPlayer.getAddress());
} else {
<BUG>String ip = fromPlayer.getAddress().getAddress().getHostAddress();
plugin.getCore().getPendingLogins().remove(ip + session.getUsername());</BUG>
verifyResponse(session);
}
} finally {
| [DELETED] |
4,493 | if (core != null) {
core.close();
}
getServer().getOnlinePlayers().forEach(player -> player.removeMetadata(getName(), this));
}
<BUG>public BukkitCore getCore() {
return core;</BUG>
}
public void sendBungeeActivateMessage(CommandSender sender, String target, boolean activate) {
if (sender instanceof Player) {
| public FastLoginCore<Player, CommandSender, FastLoginBukkit> getCore() {
return core;
|
4,494 | String id = '/' + address.getAddress().getHostAddress() + ':' + address.getPort();
if ("AUTO_LOGIN".equalsIgnoreCase(subchannel)) {
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true);
playerSession.setVerified(true);
plugin.getSessions().put(id, playerSession);
<BUG>Bukkit.getScheduler().runTaskAsynchronously(plugin, new ForceLoginTask(plugin, player));
</BUG>
} else if ("AUTO_REGISTER".equalsIgnoreCase(subchannel)) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
| Bukkit.getScheduler().runTaskAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player));
|
4,495 | try {
if (authPlugin == null || !authPlugin.isRegistered(playerName)) {
BukkitLoginSession playerSession = new BukkitLoginSession(playerName, false);
playerSession.setVerified(true);
plugin.getSessions().put(id, playerSession);
<BUG>new ForceLoginTask(plugin, player).run();
</BUG>
}
} catch (Exception ex) {
plugin.getLogger().log(Level.SEVERE, "Failed to query isRegistered", ex);
| new ForceLoginTask(plugin.getCore(), player).run();
|
4,496 | for (Cell cell : result.listCells()) {
String key = Bytes.toString(CellUtil.cloneQualifier(cell));
if (!Graph.Hidden.isHidden(key)) {
ValueType propType = ValueType.valueOf(((Byte)ValueUtils.deserialize(CellUtil.cloneValue(cell))).intValue());
props.put(key, propType);
<BUG>} else if (key.equals(Constants.VERTEX_ID)) {
</BUG>
idType = ValueType.valueOf(((Byte)ValueUtils.deserialize(CellUtil.cloneValue(cell))).intValue());
} else if (key.equals(Constants.CREATED_AT)) {
createdAt = ValueUtils.deserialize(CellUtil.cloneValue(cell));
| } else if (key.equals(Constants.ELEMENT_ID)) {
|
4,497 | public static final String LABEL = Graph.Hidden.hide("l");
public static final String FROM = Graph.Hidden.hide("f");
public static final String TO = Graph.Hidden.hide("t");
public static final String CREATED_AT = Graph.Hidden.hide("c");
public static final String UPDATED_AT = Graph.Hidden.hide("u");
<BUG>public static final String UNIQUE = Graph.Hidden.hide("q");
public static final String EDGE_ID = Graph.Hidden.hide("e");</BUG>
public static final String VERTEX_ID = Graph.Hidden.hide("v");
public static final String INDEX_STATE = Graph.Hidden.hide("x");
public static final byte[] LABEL_BYTES = Bytes.toBytes(LABEL);
| public static final String ELEMENT_ID = Graph.Hidden.hide("i");
public static final String EDGE_ID = Graph.Hidden.hide("e");
|
4,498 | public void updateLabel(ElementType type, String label, String propertyKey, ValueType propertyType) {
if (!config.getUseSchema()) {
throw new HBaseGraphException("Schema not enabled");
}
refreshSchema();
<BUG>LabelMetadata labelMetadata = labels.get(new LabelMetadata.Key(type, label));
</BUG>
labelMetadataModel.addPropertyMetadata(labelMetadata, propertyKey, propertyType);
labelMetadata.propertyTypes().put(propertyKey, propertyType);
}
| LabelMetadata labelMetadata = validateLabel(type, label);
|
4,499 | public Set<String> getPropertyKeys() {
return new HashSet<>(getProperties().keySet());
}
public void setProperty(String key, Object value) {
ElementHelper.validateProperty(key, value);
<BUG>graph.validateProperty(label, getElementType(), key, value);
</BUG>
Object oldValue = null;
boolean hasIndex = hasIndex(OperationType.WRITE, key);
if (hasIndex) {
| graph.validateProperty(getElementType(), label, key, value);
|
4,500 | Put put = new Put(graph.getLabelMetadataModel().serialize(label.key()));
put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES,
ValueUtils.serialize(label.createdAt()));
put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.UPDATED_AT_BYTES,
ValueUtils.serialize(label.updatedAt()));
<BUG>put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.VERTEX_ID_BYTES,
</BUG>
ValueUtils.serialize(label.idType().getCode()));
label.propertyTypes().entrySet().forEach(entry -> {
put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Bytes.toBytes(entry.getKey()),
| put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.ELEMENT_ID_BYTES,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.