output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
@Override
public String doImportFolder(HttpServletRequest request, MultipartFile file) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
String folderId = request.getParameter("folderId");
final String originalFileName = new String(file.getOr... | #vulnerable code
@Override
public String doImportFolder(HttpServletRequest request, MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
String folderId = request.getParameter("folderId");
final String originalFileName = new String(file.getOr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String checkImportFolder(HttpServletRequest request) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final String folderName = request.getParameter("folderName");
... | #vulnerable code
@Override
public String checkImportFolder(HttpServletRequest request) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final String folderName = request.getParameter("folderName... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final Str... | #vulnerable code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
fin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void createDefaultAccountPropertiesFile() {
Printer.instance.print("正在生成初始账户配置文件(" + this.confdir + ACCOUNT_PROPERTIES_FILE + ")...");
final Properties dap = new Properties();
dap.setProperty(DEFAULT_ACCOUNT_ID + ".pwd", DEFAULT_ACCOUNT_PWD);
dap.setProperty(DEFA... | #vulnerable code
private void createDefaultAccountPropertiesFile() {
Printer.instance.print("正在生成初始账户配置文件(" + this.confdir + ACCOUNT_PROPERTIES_FILE + ")...");
final Properties dap = new Properties();
dap.setProperty(DEFAULT_ACCOUNT_ID + ".pwd", DEFAULT_ACCOUNT_PWD);
dap.setPropert... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void doDownloadFile(final HttpServletRequest request, final HttpServletResponse response) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
if (ConfigureReader.instance().authorized(account, AccountAuth.DOWNLOAD_FILES)) {
final String ... | #vulnerable code
public void doDownloadFile(final HttpServletRequest request, final HttpServletResponse response) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
if (ConfigureReader.instance().authorized(account, AccountAuth.DOWNLOAD_FILES)) {
final S... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public File getFileFromBlocks(Node f) {
// 检查该节点对应的文件块存放于哪个位置(主文件系统/扩展存储区)
try {
File file = null;
if (f.getFilePath().startsWith("file_")) {// 存放于主文件系统中
// 直接从主文件系统的文件块存放区获得对应的文件块
file = new File(ConfigureReader.instance().getFileBlockPath(), f.getFilePath());... | #vulnerable code
public File getFileFromBlocks(Node f) {
// 检查该节点对应的文件块存放于哪个位置(主文件系统/扩展存储区)
try {
File file = null;
if (f.getFilePath().startsWith("file_")) {// 存放于主文件系统中
// 直接从主文件系统的文件块存放区获得对应的文件块
file = getBlockFromExtendPath(new File(ConfigureReader.instance().getFileB... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean addAll(Collection<? extends T> collection) {
boolean success = true;
for (T element : collection) {
success &= internalAdd(element);
}
return success;
} | #vulnerable code
@Override
public boolean addAll(Collection<? extends T> collection) {
boolean success = true;
for (T element : collection) {
success &= internalAdd(element, false);
}
refreshStorage(true);
return success;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void clear() {
Map<String, String> savedHash = nest.hgetAll();
for (Map.Entry<String, String> entry : savedHash.entrySet()) {
nest.hdel(entry.getKey());
}
nest.del();
} | #vulnerable code
@Override
public void clear() {
Map<String, String> savedHash = nest.hgetAll();
for (Map.Entry<String, String> entry : savedHash.entrySet()) {
V value = JOhm.get(valueClazz, Integer.parseInt(entry.getValue()));
value.delete();... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean addAll(Collection<? extends T> c) {
boolean success = true;
for (T element : c) {
success &= internalAdd(element);
}
return success;
} | #vulnerable code
@Override
public boolean addAll(Collection<? extends T> c) {
boolean success = true;
for (T element : c) {
success &= internalAdd(element, false);
}
refreshStorage(true);
return success;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void clear() {
nest.del();
} | #vulnerable code
@Override
public void clear() {
nest.del();
refreshStorage(true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean add(T e) {
return internalAdd(e);
} | #vulnerable code
@Override
public boolean add(T e) {
return internalAdd(e, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int size() {
int repoSize = nest.llen();
return repoSize;
} | #vulnerable code
@Override
public int size() {
int repoSize = nest.llen();
if (repoSize != elements.size()) {
refreshStorage(true);
}
return repoSize;
}
#location 3
#vulnerabili... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean internalRemove(T element) {
boolean success = false;
if (element != null) {
success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.srem(JOhmUtils.getId(element).toString()) > 0;
unindexValue... | #vulnerable code
private boolean internalRemove(T element) {
boolean success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.srem(JOhmUtils.getId(element).toString()) > 0;
unindexValue(element);
return success;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean internalAdd(T element) {
boolean success = false;
if (element != null) {
success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.sadd(JOhmUtils.getId(element).toString()) > 0;
indexValue(elem... | #vulnerable code
private boolean internalAdd(T element) {
boolean success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.sadd(JOhmUtils.getId(element).toString()) > 0;
indexValue(element);
return success;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean addAll(int index, Collection<? extends T> c) {
for (T element : c) {
internalIndexedAdd(index++, element);
}
return true;
} | #vulnerable code
@Override
public boolean addAll(int index, Collection<? extends T> c) {
for (T element : c) {
internalIndexedAdd(index++, element, false);
}
refreshStorage(true);
return true;
}
#location 4... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public T set(int index, T element) {
T previousElement = this.get(index);
internalIndexedAdd(index, element);
return previousElement;
} | #vulnerable code
@Override
public T set(int index, T element) {
T previousElement = this.get(index);
internalIndexedAdd(index, element, true);
return previousElement;
}
#location 4
#vulnerability t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int size() {
int repoSize = nest.hlen();
return repoSize;
} | #vulnerable code
@Override
public int size() {
int repoSize = nest.hlen();
if (repoSize != backingMap.size()) {
refreshStorage(true);
}
return repoSize;
}
#location 3
#vulnerabi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean internalRemove(T element) {
boolean success = false;
if (element != null) {
success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.srem(JOhmUtils.getId(element).toString()) > 0;
unindexValue... | #vulnerable code
private boolean internalRemove(T element) {
boolean success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.srem(JOhmUtils.getId(element).toString()) > 0;
unindexValue(element);
return success;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void clear() {
Map<String, String> savedHash = nest.hgetAll();
for (Map.Entry<String, String> entry : savedHash.entrySet()) {
nest.hdel(entry.getKey());
}
nest.del();
} | #vulnerable code
@Override
public void clear() {
Map<String, String> savedHash = nest.hgetAll();
for (Map.Entry<String, String> entry : savedHash.entrySet()) {
V value = JOhm.get(valueClazz, Integer.parseInt(entry.getValue()));
value.delete();... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
@SuppressWarnings("unchecked")
public boolean removeAll(Collection<?> c) {
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iterator.hasNext()) {
... | #vulnerable code
@Override
@SuppressWarnings("unchecked")
public boolean removeAll(Collection<?> c) {
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iterator.hasNext()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
@SuppressWarnings("unchecked")
public boolean retainAll(Collection<?> c) {
this.clear();
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iterator.h... | #vulnerable code
@Override
@SuppressWarnings("unchecked")
public boolean retainAll(Collection<?> c) {
this.clear();
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iter... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public V remove(Object key) {
V value = get(key);
nest.hdel(key.toString());
return value;
} | #vulnerable code
@Override
public V remove(Object key) {
V value = get(key);
value.delete();
nest.hdel(key.toString());
return value;
}
#location 4
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public T remove(int index) {
return internalIndexedRemove(index);
} | #vulnerable code
@Override
public T remove(int index) {
return internalIndexedRemove(index, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldSetCollectionAutomatically() {
User user = new User();
assertNotNull(user.getLikes());
assertTrue(user.getLikes().getClass().equals(RedisList.class));
assertTrue(user.getPurchases().getClass().equals(RedisSet.class))... | #vulnerable code
@Test
public void shouldSetCollectionAutomatically() {
User user = new User();
assertNotNull(user.getLikes());
assertTrue(user.getLikes().getClass().equals(RedisList.class));
assertTrue(user.getPurchases().getClass().equals(RedisSet.c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean remove(Object o) {
return internalRemove(o);
} | #vulnerable code
@Override
public boolean remove(Object o) {
return internalRemove(o, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void internalIndexedAdd(int index, T element) {
if (element != null) {
nest.cat(JOhmUtils.getId(owner)).cat(field.getName()).lset(index,
JOhmUtils.getId(element).toString());
indexValue(element);
}
} | #vulnerable code
private void internalIndexedAdd(int index, T element) {
nest.cat(JOhmUtils.getId(owner)).cat(field.getName()).lset(index,
JOhmUtils.getId(element).toString());
indexValue(element);
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public V remove(Object key) {
V value = get(key);
nest.hdel(key.toString());
return value;
} | #vulnerable code
@Override
public V remove(Object key) {
V value = get(key);
value.delete();
nest.hdel(key.toString());
return value;
}
#location 5
#vulnerability type THREAD_SAFETY_VIOLATI... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean internalRemove(T element) {
boolean success = false;
if (element != null) {
Integer lrem = nest.cat(JOhmUtils.getId(owner))
.cat(field.getName()).lrem(1,
JOhmUtils.getId(element).toStr... | #vulnerable code
private boolean internalRemove(T element) {
Integer lrem = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.lrem(1, JOhmUtils.getId(element).toString());
unindexValue(element);
return lrem > 0;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void clear() {
nest.del();
} | #vulnerable code
@Override
public void clear() {
nest.del();
elements.clear();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean remove(Object o) {
return internalRemove(o);
} | #vulnerable code
@Override
public boolean remove(Object o) {
return internalRemove(o, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean add(T element) {
return internalAdd(element);
} | #vulnerable code
@Override
public boolean add(T element) {
return internalAdd(element, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopyIn) {
for (Map.Entry<? extends K, ? extends V> entry : mapToCopyIn.entrySet()) {
internalPut(entry.getKey(), entry.getValue());
}
} | #vulnerable code
@Override
public void putAll(Map<? extends K, ? extends V> mapToCopyIn) {
for (Map.Entry<? extends K, ? extends V> entry : mapToCopyIn.entrySet()) {
internalPut(entry.getKey(), entry.getValue(), false);
}
refreshStorage(true);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("unchecked")
@Override
public boolean removeAll(Collection<?> c) {
boolean success = true;
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
while (iterator.hasNext()) {
... | #vulnerable code
@SuppressWarnings("unchecked")
@Override
public boolean removeAll(Collection<?> c) {
boolean success = true;
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
while (iterator.hasNext()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void checkModelSearch() {
User user1 = new User();
user1.setName("model1");
user1.setRoom("tworoom");
user1.setAge(88);
user1.setSalary(9999.99f);
user1.setInitial('m');
JOhm.save(user1);
Long id... | #vulnerable code
@Test
public void checkModelSearch() {
User user1 = new User();
user1.setName("model1");
user1.setRoom("tworoom");
user1.setAge(88);
user1.setSalary(9999.99f);
user1.setInitial('m');
JOhm.save(user1);
i... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int size() {
int repoSize = nest.smembers().size();
return repoSize;
} | #vulnerable code
@Override
public int size() {
int repoSize = nest.smembers().size();
if (repoSize != elements.size()) {
refreshStorage(true);
}
return repoSize;
}
#location 3
#... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
@SuppressWarnings("unchecked")
public boolean retainAll(Collection<?> c) {
this.clear();
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iterator.h... | #vulnerable code
@Override
@SuppressWarnings("unchecked")
public boolean retainAll(Collection<?> c) {
this.clear();
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iter... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void add(int index, T element) {
internalIndexedAdd(index, element);
} | #vulnerable code
@Override
public void add(int index, T element) {
internalIndexedAdd(index, element, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean internalAdd(T element) {
boolean success = false;
if (element != null) {
success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.rpush(JOhmUtils.getId(element).toString()) > 0;
indexValue(ele... | #vulnerable code
private boolean internalAdd(T element) {
boolean success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName())
.rpush(JOhmUtils.getId(element).toString()) > 0;
indexValue(element);
return success;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void cannotSearchAfterDeletingIndexes() {
User user = new User();
user.setAge(88);
JOhm.save(user);
user.setAge(77); // younger
JOhm.save(user);
user.setAge(66); // younger still
JOhm.save(user);
... | #vulnerable code
@Test
public void cannotSearchAfterDeletingIndexes() {
User user = new User();
user.setAge(88);
JOhm.save(user);
user.setAge(77); // younger
JOhm.save(user);
user.setAge(66); // younger still
JOhm.save(user);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean hasNext()
{
if(currentIteratorHasNext())
{
return true;
}
loadNextChunkIterator();
return currentIteratorHasNext();
} | #vulnerable code
@Override
public boolean hasNext()
{
return currentIteratorHasNext() || possibleChunksRemaining();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public FetchResponse fetch(RequestMeta meta) {
if (riak == null)
throw new IllegalStateException("Cannot fetch an object without a RiakClient");
FetchResponse r = riak.fetch(bucket, key, meta);
if (r.getObject() != null) {
Riak... | #vulnerable code
public FetchResponse fetch(RequestMeta meta) {
if (riak == null)
throw new IllegalStateException("Cannot fetch an object without a RiakClient");
FetchResponse r = riak.fetch(bucket, key, meta);
if (r.isSuccess()) {
this.c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
RiakConnection getConnection() throws IOException {
return getConnection(true);
} | #vulnerable code
RiakConnection getConnection() throws IOException {
RiakConnection c = connections.get();
if (c == null || !c.endIdleAndCheckValid()) {
c = new RiakConnection(addr, port);
if (this.clientID != null) {
setClientID(clientID);
}
} else {
// we're fine! ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public RawFetchResponse fetch(String bucket, String key) {
return doFetch(bucket, key, null, false);
} | #vulnerable code
public RawFetchResponse fetch(String bucket, String key) {
return fetch(bucket, key, null);
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void send(int code, MessageLite req) throws IOException {
int len = req.getSerializedSize();
dout.writeInt(len + 1);
dout.write(code);
req.writeTo(dout);
dout.flush();
} | #vulnerable code
void receive_code(int code) throws IOException, RiakError {
int len = din.readInt();
int get_code = din.read();
if (code == RiakClient.MSG_ErrorResp) {
RpbErrorResp err = com.basho.riak.pbc.RPB.RpbErrorResp.parseFrom(din);
throw new RiakError(err);
}
if (le... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean findNext() throws IOException {
if (currentPartStream != null) {
InputStream is = currentPartStream.branch();
try {
while (is.read() != -1) { /* nop */} // advance stream to end of next boundary
... | #vulnerable code
private boolean findNext() throws IOException {
if (currentPartStream != null && !currentPartStream.done()) {
InputStream is = new OneTokenInputStream(stream, boundary);
try {
while (is.read() != -1) { /* nop */}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void send(int code, MessageLite req) throws IOException {
int len = req.getSerializedSize();
dout.writeInt(len + 1);
dout.write(code);
req.writeTo(dout);
dout.flush();
} | #vulnerable code
byte[] receive(int code) throws IOException {
int len = din.readInt();
int get_code = din.read();
byte[] data = null;
if (len > 1) {
data = new byte[len - 1];
din.readFully(data);
}
if (get_code == RiakClient.MSG_Erro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public WriteBucket enableForSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
addPrecommitHook(NamedErlangFunction.SEARCH_PRECOMMIT_HOOK);
builder.search(true);
return this;
} | #vulnerable code
public WriteBucket enableForSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
builder.addPrecommitHook(NamedErlangFunction.SEARCH_PRECOMMIT_HOOK).search(true);
return this;
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void send(int code, MessageLite req) throws IOException {
int len = req.getSerializedSize();
dout.writeInt(len + 1);
dout.write(code);
req.writeTo(dout);
dout.flush();
} | #vulnerable code
void close() {
if (isClosed())
return;
try {
sock.close();
din = null;
dout = null;
sock = null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
#location 7
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void readPlainTextValuesWithCoverageContextContinuouslyWithReturnBody()
throws ExecutionException, InterruptedException, UnknownHostException
{
final Map<String, RiakObject> results = performFBReadWithCoverageContext(true, true, false)... | #vulnerable code
@Test
public void readPlainTextValuesWithCoverageContextContinuouslyWithReturnBody()
throws ExecutionException, InterruptedException, UnknownHostException
{
final Map<String, RiakObject> results = performFBReadWithCoverageContext(true, true);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void testListBucketsStreaming(Namespace namespace) throws InterruptedException, ExecutionException
{
ListBuckets listBucketsCommand = new ListBuckets.Builder(namespace.getBucketType()).build();
final RiakFuture<ListBuckets.StreamingResponse, Binar... | #vulnerable code
private void testListBucketsStreaming(Namespace namespace) throws InterruptedException, ExecutionException
{
ListBuckets listBucketsCommand = new ListBuckets.Builder(namespace.getBucketType()).build();
final RiakFuture<ListBuckets.StreamingResponse,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Bucket execute() throws RiakRetryFailedException {
final BucketProperties propsToStore = builder.precommitHooks(precommitHooks).postcommitHooks(postcommitHooks).build();
retrier.attempt(new Callable<Void>() {
public Void call() throws Excep... | #vulnerable code
public Bucket execute() throws RiakRetryFailedException {
final BucketProperties propsToStore = builder.build();
retrier.attempt(new Callable<Void>() {
public Void call() throws Exception {
client.updateBucket(name, propsToSt... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void setClientID(ByteString id) throws IOException {
if(id.size() > Constants.RIAK_CLIENT_ID_LENGTH) {
id = ByteString.copyFrom(id.toByteArray(), 0, Constants.RIAK_CLIENT_ID_LENGTH);
}
this.clientId = id.toByteArray();
} | #vulnerable code
public void setClientID(ByteString id) throws IOException {
if(id.size() > Constants.RIAK_CLIENT_ID_LENGTH) {
id = ByteString.copyFrom(id.toByteArray(), 0, Constants.RIAK_CLIENT_ID_LENGTH);
}
RpbSetClientIdReq req = RPB.RpbSetClientIdReq.newBuilder().s... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected SecondaryIndexQueryOperation.Response convert(List<Object> rawResponse)
{
SecondaryIndexQueryOperation.Response.Builder responseBuilder =
new SecondaryIndexQueryOperation.Response.Builder();
final boolean isIndexBod... | #vulnerable code
@Override
protected SecondaryIndexQueryOperation.Response convert(List<Object> rawResponse)
{
SecondaryIndexQueryOperation.Response.Builder responseBuilder =
new SecondaryIndexQueryOperation.Response.Builder();
for (Object o : ra... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void send(int code, MessageLite req) throws IOException {
int len = req.getSerializedSize();
dout.writeInt(len + 1);
dout.write(code);
req.writeTo(dout);
dout.flush();
} | #vulnerable code
void close() {
if (isClosed())
return;
try {
sock.close();
din = null;
dout = null;
sock = null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
#location 8
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public WriteBucket addPrecommitHook(NamedFunction preCommitHook) {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_PRECOMMIT);
if(preCommitHook != null) {
if(precommitHooks == null) {
precommitHooks = new ArrayList<NamedFunction... | #vulnerable code
public WriteBucket addPrecommitHook(NamedFunction preCommitHook) {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_PRECOMMIT);
builder.addPrecommitHook(preCommitHook);
return this;
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void send(int code, MessageLite req) throws IOException {
int len = req.getSerializedSize();
dout.writeInt(len + 1);
dout.write(code);
req.writeTo(dout);
dout.flush();
} | #vulnerable code
void send(int code) throws IOException {
dout.writeInt(1);
dout.write(code);
dout.flush();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
RiakConnection getConnection() throws IOException {
RiakConnection c = pool.getConnection(clientId);
return c;
} | #vulnerable code
RiakConnection getConnection(boolean setClientId) throws IOException {
RiakConnection c = connections.get();
if (c == null || !c.endIdleAndCheckValid()) {
c = new RiakConnection(addr, port, bufferSizeKb);
if (this.clientID != null &... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void warmUp() throws IOException {
for (int i = 0; i < this.initialSize; i++) {
RiakConnection c = getConnection();
c.beginIdle();
available.add(c);
}
} | #vulnerable code
private void warmUp() throws IOException {
if (permits.tryAcquire(initialSize)) {
for (int i = 0; i < this.initialSize; i++) {
RiakConnection c =
new RiakConnection(this.host, this.port,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void send(int code, MessageLite req) throws IOException {
int len = req.getSerializedSize();
dout.writeInt(len + 1);
dout.write(code);
req.writeTo(dout);
dout.flush();
} | #vulnerable code
void close() {
if (isClosed())
return;
try {
sock.close();
din = null;
dout = null;
sock = null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
#location 9
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getClientID() throws IOException {
RiakConnection c = getConnection();
try {
c.send(MSG_GetClientIdReq);
byte[] data = c.receive(MSG_GetClientIdResp);
if (data == null)
return null;
RpbGetClientIdResp res = RPB.RpbGetClientIdResp.parseFrom(data)... | #vulnerable code
public String getClientID() throws IOException {
RiakConnection c = getConnection();
try {
c.send(MSG_GetClientIdReq);
byte[] data = c.receive(MSG_GetClientIdResp);
if (data == null)
return null;
RpbGetClientIdResp res = RPB.RpbGetClientIdResp.parseFrom... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public WriteBucket disableSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
if (precommitHooks != null) {
precommitHooks.remove(NamedErlangFunction.SEARCH_PRECOMMIT_HOOK);
}
builder.search(false);
retur... | #vulnerable code
public WriteBucket disableSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
if (existingPrecommitHooks != null) {
synchronized (existingPrecommitHooks) {
existingPrecommitHooks.remove(NamedErlangFunction.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testInterruptedExceptionDealtWith() throws InterruptedException
{
final Throwable[] ex = {null};
int timeout = 1000;
Thread testThread = new Thread(() ->
{
try
{
@SuppressWarnin... | #vulnerable code
@Test
public void testInterruptedExceptionDealtWith() throws InterruptedException
{
final boolean[] caught = {false};
final InterruptedException[] ie = {null};
int timeout = 1000;
Thread t = new Thread(() ->
{
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void extract() throws IOException {
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination file if exists
if (destination.exists() && destination.isDirectory()) {
FileUtils.delete(destination.toPath... | #vulnerable code
public void extract() throws IOException {
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination file if exists
removeDirectory(destination);
ZipInputStream zipInputStream = new ZipInputStream(new FileInp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<String, Set<String>> readIndexFiles() {
// checking cache
if (entries != null) {
return entries;
}
entries = new HashMap<String, Set<String>>();
List<PluginWrapper> plugins = pluginManager.getPlugins();
... | #vulnerable code
private Map<String, Set<String>> readIndexFiles() {
// checking cache
if (entries != null) {
return entries;
}
entries = new HashMap<String, Set<String>>();
List<PluginWrapper> startedPlugins = pluginManager.getStart... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void createDisabledFile() throws IOException {
List<String> plugins = new ArrayList<>();
plugins.add("plugin-2");
writeLines(plugins, "disabled.txt");
} | #vulnerable code
private void createDisabledFile() throws IOException {
File file = testFolder.newFile("disabled.txt");
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf-8"))) {
writer.write("plugin-2\r\n");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void resolveDependencies() throws PluginException {
DependencyResolver dependencyResolver = new DependencyResolver(unresolvedPlugins);
resolvedPlugins = dependencyResolver.getSortedPlugins();
for (PluginWrapper pluginWrapper : resolvedPlugins) {
unre... | #vulnerable code
private void resolveDependencies() {
DependencyResolver dependencyResolver = new DependencyResolver(unresolvedPlugins);
resolvedPlugins = dependencyResolver.getSortedDependencies();
for (Plugin plugin : resolvedPlugins) {
unresolvedPlugins.remove... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void extract() throws IOException {
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination file if exists
if (destination.exists() && destination.isDirectory()) {
FileUtils.delete(destination.toPath... | #vulnerable code
public void extract() throws IOException {
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination file if exists
removeDirectory(destination);
ZipInputStream zipInputStream = new ZipInputStream(new FileInp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<String, Set<String>> readIndexFiles() {
// checking cache
if (entries != null) {
return entries;
}
entries = new LinkedHashMap<String, Set<String>>();
readClasspathIndexFiles();
readPluginsIndexFiles();... | #vulnerable code
private Map<String, Set<String>> readIndexFiles() {
// checking cache
if (entries != null) {
return entries;
}
entries = new HashMap<String, Set<String>>();
List<PluginWrapper> plugins = pluginManager.getPlugins();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void extract() throws IOException {
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination file if exists
if (destination.exists() && destination.isDirectory()) {
FileUtils.delete(destination.toPath... | #vulnerable code
public void extract() throws IOException {
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination file if exists
removeDirectory(destination);
ZipInputStream zipInputStream = new ZipInputStream(new FileInp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected Manifest readManifest(Path pluginPath) throws PluginException {
if (FileUtils.isJarFile(pluginPath)) {
try(JarFile jar = new JarFile(pluginPath.toFile())) {
Manifest manifest = jar.getManifest();
if (manifest != nu... | #vulnerable code
protected Manifest readManifest(Path pluginPath) throws PluginException {
if (FileUtils.isJarFile(pluginPath)) {
try {
Manifest manifest = new JarFile(pluginPath.toFile()).getManifest();
if (manifest != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
}
for (Element element : roundEnv.getElementsAnnotatedWith(Extension.class)) {
// check i... | #vulnerable code
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
}
for (Element element : roundEnv.getElementsAnnotatedWith(Extension.class)) {
// chec... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Map<String, Set<String>> readPluginsStorages() {
log.debug("Reading extensions storages from plugins");
Map<String, Set<String>> result = new LinkedHashMap<>();
List<PluginWrapper> plugins = pluginManager.getPlugins();
for... | #vulnerable code
@Override
public Map<String, Set<String>> readPluginsStorages() {
log.debug("Reading extensions storages from plugins");
Map<String, Set<String>> result = new LinkedHashMap<>();
List<PluginWrapper> plugins = pluginManager.getPlugins();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Map<String, Set<String>> readClasspathStorages() {
log.debug("Reading extensions storages from classpath");
Map<String, Set<String>> result = new LinkedHashMap<>();
Set<String> bucket = new HashSet<>();
try {
E... | #vulnerable code
@Override
public Map<String, Set<String>> readClasspathStorages() {
log.debug("Reading extensions storages from classpath");
Map<String, Set<String>> result = new LinkedHashMap<>();
Set<String> bucket = new HashSet<>();
try {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String loadPlugin(File pluginArchiveFile) {
if (pluginArchiveFile == null || !pluginArchiveFile.exists()) {
throw new IllegalArgumentException(String.format("Specified plugin %s does not exist!", pluginArchiveFile));
}
File pluginDirectory = null;
t... | #vulnerable code
@Override
public String loadPlugin(File pluginArchiveFile) {
if (pluginArchiveFile == null || !pluginArchiveFile.exists()) {
throw new IllegalArgumentException(String.format("Specified plugin %s does not exist!", pluginArchiveFile));
}
File pluginDirectory = nul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getTitle() {
return title;
} | #vulnerable code
public String getTitle() throws IOException, ParseException {
if (title != null) {
return title;
}
if (url == null)
throw new IOException("URL needs to be present");
return info(url).get("title").toString();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean isMod() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("is_mod").toString());
} | #vulnerable code
public boolean isMod() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("is_mod").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public double created() throws IOException, ParseException {
return Double.parseDouble(getUserInformation().get("created").toString());
} | #vulnerable code
public double created() throws IOException, ParseException {
return Double.parseDouble(info().get("created").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public double createdUTC() throws IOException, ParseException {
return Double.parseDouble(getUserInformation().get("created_utc").toString());
} | #vulnerable code
public double createdUTC() throws IOException, ParseException {
return Double.parseDouble(info().get("created_utc").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean hasMail() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("has_mail").toString());
} | #vulnerable code
public boolean hasMail() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("has_mail").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public double created() throws IOException, ParseException {
return Double.parseDouble(getUserInformation().get("created").toString());
} | #vulnerable code
public double created() throws IOException, ParseException {
return Double.parseDouble(info().get("created").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean isGold() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("is_gold").toString());
} | #vulnerable code
public boolean isGold() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("is_gold").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String id() throws IOException, ParseException {
return getUserInformation().get("id").toString();
} | #vulnerable code
public String id() throws IOException, ParseException {
return info().get("id").toString();
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void parseRecursive(List<Comment> comments, JSONObject object) throws RetrievalFailedException, RedditError {
assert comments != null : "List of comments must be instantiated.";
assert object != null : "JSON Object must be instantiated.";
// Get... | #vulnerable code
protected void parseRecursive(List<Comment> comments, JSONObject object) throws RetrievalFailedException, RedditError {
assert comments != null : "List of comments must be instantiated.";
assert object != null : "JSON Object must be instantiated.";
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getSubreddit() {
return subreddit;
} | #vulnerable code
public String getSubreddit() throws IOException, ParseException {
if (subreddit != null) {
return subreddit;
}
if (url == null)
throw new IOException("URL needs to be present");
return info(url).get("subreddit").t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean hasModMail() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("has_mod_mail").toString());
} | #vulnerable code
public boolean hasModMail() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("has_mod_mail").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int linkKarma() throws IOException, ParseException {
return Integer.parseInt(Utils.toString(getUserInformation().get("link_karma")));
} | #vulnerable code
public int linkKarma() throws IOException, ParseException {
return Integer.parseInt(Utils.toString(info().get("link_karma")));
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<Subreddit> parse(String url) throws RetrievalFailedException, RedditError {
// Determine cookie
String cookie = (user == null) ? null : user.getCookie();
// List of subreddits
List<Subreddit> subreddits = new LinkedList<Subreddit... | #vulnerable code
public List<Subreddit> parse(String url) throws RetrievalFailedException, RedditError {
// Determine cookie
String cookie = (user == null) ? null : user.getCookie();
// List of subreddits
List<Subreddit> subreddits = new LinkedList<Sub... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getAuthor() {
return author;
} | #vulnerable code
public String getAuthor() throws IOException, ParseException {
if (author != null) {
return author;
}
if (url == null)
throw new IOException("URL needs to be present");
return info(url).get("author").toString();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String id() throws IOException, ParseException {
return getUserInformation().get("id").toString();
} | #vulnerable code
public String id() throws IOException, ParseException {
return info().get("id").toString();
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static LinkedList<Submission> getSubmissions(String redditName,
Popularity type, Page frontpage, User user) throws IOException, ParseException {
LinkedList<Submission> submissions = new LinkedList<Submission>();
String urlString ... | #vulnerable code
public static LinkedList<Submission> getSubmissions(String redditName,
Popularity type, Page frontpage, User user) throws IOException, ParseException {
LinkedList<Submission> submissions = new LinkedList<Submission>();
String urlS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean isGold() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("is_gold").toString());
} | #vulnerable code
public boolean isGold() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("is_gold").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public double createdUTC() throws IOException, ParseException {
return Double.parseDouble(getUserInformation().get("created_utc").toString());
} | #vulnerable code
public double createdUTC() throws IOException, ParseException {
return Double.parseDouble(info().get("created_utc").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public LinkedList<Submission> getSubmissions(String redditName,
Popularity type, Page frontpage, User user) throws IOException, ParseException {
LinkedList<Submission> submissions = new LinkedList<Submission>();
String urlString = "/r/"... | #vulnerable code
public LinkedList<Submission> getSubmissions(String redditName,
Popularity type, Page frontpage, User user) throws IOException, ParseException {
LinkedList<Submission> submissions = new LinkedList<Submission>();
String urlString =... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean hasModMail() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("has_mod_mail").toString());
} | #vulnerable code
public boolean hasModMail() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("has_mod_mail").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int commentKarma() throws IOException, ParseException {
return Integer.parseInt(Utils.toString(getUserInformation().get("comment_karma")));
} | #vulnerable code
public int commentKarma() throws IOException, ParseException {
return Integer.parseInt(Utils.toString(info().get("comment_karma")));
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public double getCreatedUTC() {
return createdUTC;
} | #vulnerable code
public double getCreatedUTC() throws IOException, ParseException {
createdUTC = Double.parseDouble(info(url).get("created_utc").toString());
return createdUTC;
}
#location 2
#vulnerability typ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean hasMail() throws IOException, ParseException {
return Boolean.parseBoolean(getUserInformation().get("has_mail").toString());
} | #vulnerable code
public boolean hasMail() throws IOException, ParseException {
return Boolean.parseBoolean(info().get("has_mail").toString());
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf = new S... | #vulnerable code
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf =... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void processEvents(int readyCount) throws IOReactorException {
processSessionRequests();
if (readyCount > 0) {
Set<SelectionKey> selectedKeys = this.selector.selectedKeys();
for (Iterator<SelectionKey> i... | #vulnerable code
@Override
protected void processEvents(int readyCount) throws IOReactorException {
processSessionRequests();
if (readyCount > 0) {
Set<SelectionKey> selectedKeys = this.selector.selectedKeys();
for (Iterator<Selection... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testInvalidInput() throws Exception {
String s = "stuff";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBu... | #vulnerable code
@Test
public void testInvalidInput() throws Exception {
String s = "stuff";
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {s}, "US-ASCII");
HttpParams params = new BasicHttpParams();
Sessio... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.