input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
public final void build() {
LOGGER.info("Starting tree reconstruction");
Project inbox = new Project();
inbox.setName("Inbox");
inbox.setId("__%%Inbox"); // to give deterministic JSON/XML output
Context noContext = new Context()... | #fixed code
public final void build() {
LOGGER.info("Starting tree reconstruction");
Project inbox = beanFactory.getBean("project", Project.class);
inbox.setName("Inbox");
inbox.setId("__%%Inbox"); // to give deterministic JSON/XML output
Context... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean within(Date date, String lower, String upper) throws ParseException {
Date lowerDate = date(lower);
Date upperDate = date(upper);
return date != null && date.getTime() >= lowerDate.getTime() && date.getTime() <= upperDate.getTime()... | #fixed code
public boolean within(Date date, String lower, String upper) throws ParseException {
LOGGER.debug("within({},{},{})", date, lower, upper);
Date lowerDate = date(lower);
Date upperDate = date(upper);
boolean result = date != null && date.getTime... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
ApplicationContext appContext = ApplicationContextFactory.create();
Main main = appContext.getBean("main", Main.class);
if (!main.procesPreLoadOptions(args)) {
LOGGER.debug(... | #fixed code
public static void main(String[] args) throws Exception {
ApplicationContext appContext = ApplicationContextFactory.getContext();
Main main = appContext.getBean("main", Main.class);
if (!main.procesPreLoadOptions(args)) {
LOGGER.debug("E... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void writeToLog(String type, String content) {
String t = ServerTimeUtil.accurateToLogName();
File f = new File(logs, t + ".klog");
FileWriter fw = null;
if (f.exists()) {
try {
fw = new FileWriter(f, true);
fw.write("\r\n\r\nTIME:\r\n" + ServerT... | #fixed code
private void writeToLog(String type, String content) {
writerThread.execute(()->{
String t = ServerTimeUtil.accurateToLogName();
File f = new File(logs, t + ".klog");
FileWriter fw = null;
if (f.exists()) {
try {
fw = new FileWriter(f, true);
fw.write... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void downloadCheckedFilesZip(final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final String zipname = request.getParameter("zipId");
if (zipname != null && !zipname.equals("ERROR")) {
final String tfPath = ConfigureRe... | #fixed code
public void downloadCheckedFilesZip(final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final String zipname = request.getParameter("zipId");
if (zipname != null && !zipname.equals("ERROR")) {
final String tfPath = ConfigureReader.i... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void getFolderView(String folderId) throws Exception {
try {
currentView = FileSystemManager.getInstance().getFolderView(folderId);
filesTable.updateValues(currentView.getFolders(), currentView.getFiles());
window.setTitle("kiftd-" + currentView.getCurre... | #fixed code
private void getFolderView(String folderId) throws Exception {
try {
currentView = FileSystemManager.getInstance().getFolderView(folderId);
if(currentView!=null && currentView.getCurrent()!=null) {
filesTable.updateValues(currentView.getFolders(), currentView.getFile... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void writeToLog(String type, String content) {
String t = ServerTimeUtil.accurateToLogName();
File f = new File(logs, t + ".klog");
FileWriter fw = null;
if (f.exists()) {
try {
fw = new FileWriter(f, true);
fw.write("\r\n\r\nTIME:\r\n" + ServerT... | #fixed code
private void writeToLog(String type, String content) {
writerThread.execute(()->{
String t = ServerTimeUtil.accurateToLogName();
File f = new File(logs, t + ".klog");
FileWriter fw = null;
if (f.exists()) {
try {
fw = new FileWriter(f, true);
fw.write... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final Str... | #fixed code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final String fn... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final Str... | #fixed code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final String fn... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void writeRangeFileStream(HttpServletRequest request, HttpServletResponse response, File fo, String fname,
String contentType) {
long skipLength = 0;// 下载时跳过的字节数
long downLength = 0;// 需要继续下载的字节数
boolean hasEnd = false;// 是否具备结束字节声明
try {
response.s... | #fixed code
protected void writeRangeFileStream(HttpServletRequest request, HttpServletResponse response, File fo, String fname,
String contentType) {
long fileLength = fo.length(); // 记录文件大小
long pastLength = 0; // 记录已下载文件大小
int rangeSwitch = 0; // 0:从头开始的全文下载;1:从某字节开始的下载(bytes=27... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void getCondensedPicture(final HttpServletRequest request, final HttpServletResponse response) {
// TODO 自动生成的方法存根
if (ConfigureReader.instance().authorized((String) request.getSession().getAttribute("ACCOUNT"),
AccountAuth.DOWNLOAD_FILES)) {
S... | #fixed code
@Override
public void getCondensedPicture(final HttpServletRequest request, final HttpServletResponse response) {
// TODO 自动生成的方法存根
if (ConfigureReader.instance().authorized((String) request.getSession().getAttribute("ACCOUNT"),
AccountAuth.DOWNLOAD_FILES)) {
String ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed 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.getOriginal... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean removeAddedAuthByFolderId(List<String> fIds) {
if(fIds == null || fIds.size() == 0) {
return false;
}
Set<String> configs=accountp.stringPropertieNames();
List<String> invalidConfigs = new ArrayList<>();
for(String fId:fIds) {
for (String con... | #fixed code
public boolean removeAddedAuthByFolderId(List<String> fIds) {
if (fIds == null || fIds.size() == 0) {
return false;
}
Set<String> configs = accountp.stringPropertieNames();
List<String> invalidConfigs = new ArrayList<>();
for (String fId : fIds) {
for (String con... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean deleteFromFileBlocks(Node f) {
// 先判断一下文件块所在的存储区
File rootPath = new File(ConfigureReader.instance().getFileBlockPath());
if (!f.getFilePath().startsWith("file_")) {// 存放于主文件系统中
short index = Short.parseShort(f.getFilePath().substring(0, f.getFilePa... | #fixed code
public boolean deleteFromFileBlocks(Node f) {
// 获取对应的文件块对象
File file = getFileFromBlocks(f);
if (file != null) {
return file.delete();// 执行删除操作
}
return false;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed 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.getOriginal... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String getVideoTranscodeStatus(HttpServletRequest request) {
if (ConfigureReader.instance().isEnableFFMPEG()) {
String fId = request.getParameter("fileId");
if (fId != null) {
try {
return vtu.getTranscodeProcess(fId);
} catch (Except... | #fixed code
@Override
public String getVideoTranscodeStatus(HttpServletRequest request) {
if (kfl.getFFMPEGExecutablePath() != null) {
String fId = request.getParameter("fileId");
if (fId != null) {
try {
return vtu.getTranscodeProcess(fId);
} catch (Exception e) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final Str... | #fixed code
public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response,
final MultipartFile file) {
String account = (String) request.getSession().getAttribute("ACCOUNT");
final String folderId = request.getParameter("folderId");
final String or... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void getLRContextByUTF8(String fileId, HttpServletRequest request, HttpServletResponse response) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
// 权限检查
if (fileId != null) {
Node n = nm.queryById(fileId);
if (n... | #fixed code
@Override
public void getLRContextByUTF8(String fileId, HttpServletRequest request, HttpServletResponse response) {
final String account = (String) request.getSession().getAttribute("ACCOUNT");
// 权限检查
if (fileId != null) {
Node n = nm.queryById(fileId);
if (n != nu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String checkLoginRequest(final HttpServletRequest request, final HttpSession session) {
final String encrypted = request.getParameter("encrypted");
final String loginInfoStr = DecryptionUtil.dncryption(encrypted, ku.getPrivateKey());
try {
final LoginInfoPo... | #fixed code
public String checkLoginRequest(final HttpServletRequest request, final HttpSession session) {
final String encrypted = request.getParameter("encrypted");
try {
final String loginInfoStr = DecryptionUtil.dncryption(encrypted, ku.getPrivateKey());
final LoginInfoPojo in... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void deleteFolder(String folderId) throws SQLException {
Folder f = selectFolderById(folderId);
List<Node> nodes = selectNodesByFolderId(folderId);
int size = nodes.size();
// 删除该文件夹内的所有文件
for (int i = 0; i < size && gono; i++) {
deleteFile(nodes.get(i... | #fixed code
private void deleteFolder(String folderId) throws SQLException {
Folder f = selectFolderById(folderId);
List<Node> nodes = selectNodesByFolderId(folderId);
int size = nodes.size();
if(f==null) {
return;
}
// 删除该文件夹内的所有文件
for (int i = 0; i < size && gono; i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public File getFileFromBlocks(Node f) {
// 检查该节点对应的文件块存放于哪个位置(主文件系统/扩展存储区)
try {
File file = null;
if (f.getFilePath().startsWith("file_")) {// 存放于主文件系统中
// 直接从主文件系统的文件块存放区获得对应的文件块
file = getBlockFromExtendPath(new File(ConfigureReader.instance().getFileB... | #fixed code
public File getFileFromBlocks(Node f) {
// 检查该节点对应的文件块存放于哪个位置(主文件系统/扩展存储区)
try {
File file = null;
if (f.getFilePath().startsWith("file_")) {// 存放于主文件系统中
// 直接从主文件系统的文件块存放区获得对应的文件块
file = new File(ConfigureReader.instance().getFileBlockPath(), f.getFilePath());... | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #fixed code
@Override
public boolean addAll(Collection<? extends T> collection) {
boolean success = true;
for (T element : collection) {
success &= internalAdd(element);
}
return success;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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();... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #fixed code
@Override
public boolean addAll(Collection<? extends T> c) {
boolean success = true;
for (T element : c) {
success &= internalAdd(element);
}
return success;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void clear() {
nest.del();
refreshStorage(true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public void clear() {
nest.del();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean add(T e) {
return internalAdd(e, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public boolean add(T e) {
return internalAdd(e);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int size() {
int repoSize = nest.llen();
if (repoSize != elements.size()) {
refreshStorage(true);
}
return repoSize;
}
#location 3
#vulnerabili... | #fixed code
@Override
public int size() {
int repoSize = nest.llen();
return repoSize;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Override
public boolean addAll(int index, Collection<? extends T> c) {
for (T element : c) {
internalIndexedAdd(index++, element);
}
return true;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Override
public T set(int index, T element) {
T previousElement = this.get(index);
internalIndexedAdd(index, element);
return previousElement;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int size() {
int repoSize = nest.hlen();
if (repoSize != backingMap.size()) {
refreshStorage(true);
}
return repoSize;
}
#location 3
#vulnerabi... | #fixed code
@Override
public int size() {
int repoSize = nest.hlen();
return repoSize;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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();... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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()) {
... | #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()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 | #fixed code
@Override
public V remove(Object key) {
V value = get(key);
nest.hdel(key.toString());
return value;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public T remove(int index) {
return internalIndexedRemove(index, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public T remove(int index) {
return internalIndexedRemove(index);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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))... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean remove(Object o) {
return internalRemove(o, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public boolean remove(Object o) {
return internalRemove(o);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public V put(K key, V value) {
V previousValue = get(key);
internalPut(key, value, true);
return previousValue;
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public V put(K key, V value) {
V previousValue = get(key);
internalPut(key, value);
return previousValue;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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
... | #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);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Override
public V remove(Object key) {
V value = get(key);
nest.hdel(key.toString());
return value;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Override
public boolean retainAll(Collection<?> c) {
this.clear();
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iter... | #fixed code
@SuppressWarnings("unchecked")
@Override
public boolean retainAll(Collection<?> c) {
this.clear();
Iterator<? extends Model> iterator = (Iterator<? extends Model>) c
.iterator();
boolean success = true;
while (iterator.h... | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void clear() {
nest.del();
elements.clear();
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public void clear() {
nest.del();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean remove(Object o) {
return internalRemove(o, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public boolean remove(Object o) {
return internalRemove(o);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean add(T element) {
return internalAdd(element, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public boolean add(T element) {
return internalAdd(element);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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());
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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()) {
... | #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()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int size() {
int repoSize = nest.smembers().size();
if (repoSize != elements.size()) {
refreshStorage(true);
}
return repoSize;
}
#location 3
#... | #fixed code
@Override
public int size() {
int repoSize = nest.smembers().size();
return repoSize;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void add(int index, T element) {
internalIndexedAdd(index, element, true);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public void add(int index, T element) {
internalIndexedAdd(index, element);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean hasNext()
{
return currentIteratorHasNext() || possibleChunksRemaining();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
@Override
public boolean hasNext()
{
if(currentIteratorHasNext())
{
return true;
}
loadNextChunkIterator();
return currentIteratorHasNext();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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 6
... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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! ... | #fixed code
RiakConnection getConnection() throws IOException {
return getConnection(true);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public RawFetchResponse fetch(String bucket, String key) {
return fetch(bucket, key, null);
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public RawFetchResponse fetch(String bucket, String key) {
return doFetch(bucket, key, null, false);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private boolean findNext() throws IOException {
if (currentPartStream != null && !currentPartStream.done()) {
InputStream is = new OneTokenInputStream(stream, boundary);
try {
while (is.read() != -1) { /* nop */}
... | #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
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public WriteBucket enableForSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
builder.addPrecommitHook(NamedErlangFunction.SEARCH_PRECOMMIT_HOOK).search(true);
return this;
}
#location 3
... | #fixed code
public WriteBucket enableForSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
addPrecommitHook(NamedErlangFunction.SEARCH_PRECOMMIT_HOOK);
builder.search(true);
return this;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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
... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void readPlainTextValuesWithCoverageContextContinuouslyWithReturnBody()
throws ExecutionException, InterruptedException, UnknownHostException
{
final Map<String, RiakObject> results = performFBReadWithCoverageContext(true, true);... | #fixed code
@Test
public void readPlainTextValuesWithCoverageContextContinuouslyWithReturnBody()
throws ExecutionException, InterruptedException, UnknownHostException
{
final Map<String, RiakObject> results = performFBReadWithCoverageContext(true, true, false)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void testListBucketsStreaming(Namespace namespace) throws InterruptedException, ExecutionException
{
ListBuckets listBucketsCommand = new ListBuckets.Builder(namespace.getBucketType()).build();
final RiakFuture<ListBuckets.StreamingResponse,... | #fixed code
private void testListBucketsStreaming(Namespace namespace) throws InterruptedException, ExecutionException
{
ListBuckets listBucketsCommand = new ListBuckets.Builder(namespace.getBucketType()).build();
final RiakFuture<ListBuckets.StreamingResponse, Binar... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected SecondaryIndexQueryOperation.Response convert(List<Object> rawResponse)
{
SecondaryIndexQueryOperation.Response.Builder responseBuilder =
new SecondaryIndexQueryOperation.Response.Builder();
for (Object o : ra... | #fixed code
@Override
protected SecondaryIndexQueryOperation.Response convert(List<Object> rawResponse)
{
SecondaryIndexQueryOperation.Response.Builder responseBuilder =
new SecondaryIndexQueryOperation.Response.Builder();
final boolean isIndexBod... | Below is the vulnerable code, please generate the patch based on the following information. |
#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
... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public WriteBucket addPrecommitHook(NamedFunction preCommitHook) {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_PRECOMMIT);
builder.addPrecommitHook(preCommitHook);
return this;
}
#location 3
... | #fixed code
public WriteBucket addPrecommitHook(NamedFunction preCommitHook) {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_PRECOMMIT);
if(preCommitHook != null) {
if(precommitHooks == null) {
precommitHooks = new ArrayList<NamedFunction... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void send(int code) throws IOException {
dout.writeInt(1);
dout.write(code);
dout.flush();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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 &... | #fixed code
RiakConnection getConnection() throws IOException {
RiakConnection c = pool.getConnection(clientId);
return c;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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,
... | #fixed code
private void warmUp() throws IOException {
for (int i = 0; i < this.initialSize; i++) {
RiakConnection c = getConnection();
c.beginIdle();
available.add(c);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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
... | #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();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public WriteBucket disableSearch() {
httpOnly(client.getTransport(), Constants.FL_SCHEMA_SEARCH);
if (existingPrecommitHooks != null) {
synchronized (existingPrecommitHooks) {
existingPrecommitHooks.remove(NamedErlangFunction.... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInterruptedExceptionDealtWith() throws InterruptedException
{
final boolean[] caught = {false};
final InterruptedException[] ie = {null};
int timeout = 1000;
Thread t = new Thread(() ->
{
... | #fixed code
@Test
public void testInterruptedExceptionDealtWith() throws InterruptedException
{
final Throwable[] ex = {null};
int timeout = 1000;
Thread testThread = new Thread(() ->
{
try
{
@SuppressWarnin... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public RawFetchResponse fetch(String bucket, String key) {
return fetch(bucket, key, null);
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public RawFetchResponse fetch(String bucket, String key) {
return fetch(bucket, key, null, false);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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");
... | #fixed code
private void createDisabledFile() throws IOException {
List<String> plugins = new ArrayList<>();
plugins.add("plugin-2");
writeLines(plugins, "disabled.txt");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void resolveDependencies() {
DependencyResolver dependencyResolver = new DependencyResolver(unresolvedPlugins);
resolvedPlugins = dependencyResolver.getSortedDependencies();
for (Plugin plugin : resolvedPlugins) {
unresolvedPlugins.remove... | #fixed code
private void resolveDependencies() throws PluginException {
DependencyResolver dependencyResolver = new DependencyResolver(unresolvedPlugins);
resolvedPlugins = dependencyResolver.getSortedPlugins();
for (PluginWrapper pluginWrapper : resolvedPlugins) {
unre... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | 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.