output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
public static List<String> readFileAsLines(File inItem) {
String path = inItem.getPath();
return readFileAsLines(path);
} | #vulnerable code
public static List<String> readFileAsLines(File inItem) {
BufferedReader in = null;
List<String> lines = new ArrayList<>();
try {
in = new BufferedReader(
new FileReader(inItem)
);
String s ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) {
ZhihuConfiguration configuration = new ZhihuConfiguration();
String pipelinePath = configuration.getMemberPath();
Spider spider = Spider.create(new ZhihuMemberPageProcessor())
.setScheduler(new ... | #vulnerable code
public static void main(String[] args) {
String pipelinePath = "/Users/brian/todo/data/webmagic";
String tokenPath = "/Users/brian/todo/data/backup/url_tokens/users.txt";
ZhihuMemberUrlTokenGetter getter = new ZhihuMemberUrlTokenGetter();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@BeforeClass
public void setup() {
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(htmlFilePath);
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
} | #vulnerable code
@BeforeClass
public void setup() {
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(htmlFilePath);
ExtentXReporter extentx = new ExtentXReporter("localhost");
extentx.config().setProjectName("extentreports");
extentx.config()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@BeforeClass
public void beforeClass() {
ExtentManager.createInstance(filePath);
ExtentTestManager.setReporter(ExtentManager.getInstance());
} | #vulnerable code
@BeforeClass
public void beforeClass() {
ExtentManager.createInstance(filePath);
ExtentXReporter extentx = new ExtentXReporter("localhost");
extentx.config().setProjectName("extentreports-pro");
extentx.config().setReportName... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onScreenCaptureAdded(Test test, ScreenCapture screenCapture) throws IOException {
storeUrl();
screenCapture.setReportObjectId(reportId);
createMedia(test, screenCapture);
initMedia();
... | #vulnerable code
@Override
public void onScreenCaptureAdded(Test test, ScreenCapture screenCapture) throws IOException {
storeUrl();
screenCapture.setReportObjectId(reportId);
createMedia(test, screenCapture);
if (media == null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetAzureTokenCredentials() throws Exception {
// 1. use azure-secret.json
File testConfigDir = new File(this.getClass().getResource("/azure-login/azure-secret.json").getFile()).getParentFile();
TestHelper.injectEnvironmentVari... | #vulnerable code
@Test
public void testGetAzureTokenCredentials() throws Exception {
// 1. use azure-secret.json
File testConfigDir = new File(this.getClass().getResource("/azure-login/azure-secret.json").getFile()).getParentFile();
TestHelper.injectEnvironme... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected boolean isInstallingExtensionNeeded(Set<BindingEnum> bindingTypes) {
final JsonObject hostJson = readHostJson();
final JsonObject extensionBundle = hostJson == null ? null : hostJson.getAsJsonObject(EXTENSION_BUNDLE);
if (extensionBundle != n... | #vulnerable code
protected boolean isInstallingExtensionNeeded(Set<BindingEnum> bindingTypes) {
final JsonObject hostJson = readHostJson();
final JsonObject extensionBundle = hostJson.getAsJsonObject(EXTENSION_BUNDLE);
if (extensionBundle != null && extensionBund... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetAzureTokenCredentials() throws Exception {
// 1. use azure-secret.json
File testConfigDir = new File(this.getClass().getResource("/azure-login/azure-secret.json").getFile()).getParentFile();
TestHelper.injectEnvironmentVari... | #vulnerable code
@Test
public void testGetAzureTokenCredentials() throws Exception {
// 1. use azure-secret.json
File testConfigDir = new File(this.getClass().getResource("/azure-login/azure-secret.json").getFile()).getParentFile();
TestHelper.injectEnvironme... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@IocBean(name = "beetlsqlConnectionSource")
public ConnectionSource createConnectionSource(@Inject DataSource dataSource) {
DataSource[] slaves = null;
if (Lang.loadClassQuite("org.nutz.boot.starter.jdbc.DataSourceStarter") != null) {
DataSource slaveDa... | #vulnerable code
@IocBean(name = "beetlsqlConnectionSource")
public ConnectionSource createConnectionSource(@Inject DataSource dataSource) {
DataSource[] slaves = null;
if (Lang.loadClassQuite("org.nutz.boot.starter.jdbc.DataSourceStarter") != null) {
DataSource s... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
if (printProcDoc) {
PropDocReader docReader = new PropDocReader(ctx);
docReader.load();
Logs.get().info("Configure Manual:\r... | #vulnerable code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
if (printProcDoc) {
PropDocReader docReader = new PropDocReader(ctx);
docReader.load();
Logs.get().info("Configure Man... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareStarterClassList() throws Exception {
HashSet<String> classNames = new HashSet<>();
Enumeration<URL> _en = ctx.getClassLoader().getResources("META-INF/nutz/org.nutz.boot.starter.NbStarter");
while (_en.hasMoreElements()) {
... | #vulnerable code
public void prepareStarterClassList() throws Exception {
starterClasses = new ArrayList<>();
HashSet<String> classNames = new HashSet<>();
Enumeration<URL> _en = ctx.getClassLoader().getResources("META-INF/nutz/org.nutz.boot.starter.NbStarter");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareIoc() {
if (ctx.getIoc() == null) {
ctx.setIoc(new NutIoc(ctx.getComboIocLoader()));
}
// 把核心对象放进ioc容器
if (!ctx.ioc.has("appContext")){
Ioc2 ioc2 = (Ioc2)ctx.getIoc();
ioc2.getIocContext().... | #vulnerable code
public void prepareIoc() throws Exception {
if (ctx.getComboIocLoader() == null) {
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
List<String> args = new ArrayList<>();
args.add("*js");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whenPrepa... | #vulnerable code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whenPrepa... | #vulnerable code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
try {
if (execute()) {
synchronized (lock) {
lock.wait();
}
}
// 收尾
_shutdown();
}
catch (Throwable e) {
Logs.get().erro... | #vulnerable code
public void run() {
try {
_run();
}
catch (Throwable e) {
Logs.get().error("something happen", e);
}
}
#location 3
#vulnerability type THREAD_SAFETY_VIO... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whenPrepa... | #vulnerable code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareConfigureLoader() throws Exception {
if (ctx.getConfigureLoader() == null) {
ConfigureLoader configureLoader = null;
InputStream ins = ctx.getResourceLoader().get("META-INF/nutz/org.nutz.boot.config.ConfigureLoader");
... | #vulnerable code
public void prepareConfigureLoader() throws Exception {
if (ctx.getConfigureLoader() == null) {
String cnfLoader = ctx.getEnvHolder().get("nutz.boot.base.ConfigureLoader");
ConfigureLoader configureLoader;
if (Strings.isBlank(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareIoc() throws Exception {
if (ctx.getComboIocLoader() == null) {
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
List<String> args = new ArrayList<>();
args.add("*js");
arg... | #vulnerable code
public void prepareIoc() throws Exception {
if (ctx.getComboIocLoader() == null) {
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
List<String> args = new ArrayList<>();
args.add("*js");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whenPrepa... | #vulnerable code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareIoc() {
if (ctx.getIoc() == null) {
ctx.setIoc(new NutIoc(ctx.getComboIocLoader()));
}
// 把核心对象放进ioc容器
if (!ctx.ioc.has("appContext")){
Ioc2 ioc2 = (Ioc2)ctx.getIoc();
ioc2.getIocContext().... | #vulnerable code
public void prepareIoc() throws Exception {
if (ctx.getComboIocLoader() == null) {
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
List<String> args = new ArrayList<>();
args.add("*js");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void init() throws Exception {
// 创建基础服务器
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setIdleTimeout(getThreadPoolIdleTimeout());
threadPool.setMinThreads(getMinThreads());
threadPool.setMaxThreads(getMaxThr... | #vulnerable code
public void init() throws Exception {
// 创建基础服务器
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setIdleTimeout(getThreadPoolIdleTimeout());
threadPool.setMinThreads(getMinThreads());
threadPool.setMaxThreads(get... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whenPrepa... | #vulnerable code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
// 依次启动
try {
ctx.init();
ctx.startServers();
if (ctx.getMainClass().getAnnotation(IocBean.class) ... | #vulnerable code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
if (printProcDoc) {
PropDocReader docReader = new PropDocReader(ctx);
docReader.load();
Logs.get().inf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareIoc() throws Exception {
if (ctx.getComboIocLoader() == null) {
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
List<String> args = new ArrayList<>();
args.add("*js");
arg... | #vulnerable code
public void prepareIoc() throws Exception {
if (ctx.getComboIocLoader() == null) {
int asyncPoolSize = ctx.getConfigureLoader().get().getInt("nutz.ioc.async.poolSize", 64);
List<String> args = new ArrayList<>();
args.add("*js");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareBasic() throws Exception {
// 检查ClassLoader的情况
if (ctx.getClassLoader() == null)
ctx.setClassLoader(NbApp.class.getClassLoader());
if (ctx.getEnvHolder() == null) {
ctx.setEnvHolder(new SystemProperti... | #vulnerable code
public void prepareBasic() throws Exception {
if (this.ctx == null) {
ctx = AppContext.getDefault();
}
if (ctx.getMainClass() == null && mainClass != null)
ctx.setMainClass(mainClass);
// 检查ClassLoader的情况
if (... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
// 依次启动
try {
ctx.init();
ctx.startServers();
if (ctx.getMainClass().getAnnotation(IocBean.class) ... | #vulnerable code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
if (printProcDoc) {
PropDocReader docReader = new PropDocReader(ctx);
docReader.load();
Logs.get().inf... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
if (printProcDoc) {
PropDocReader docReader = new PropDocReader(ctx);
docReader.load();
Logs.get().info("Configure Manual:\r... | #vulnerable code
public void _run() throws Exception {
Stopwatch sw = Stopwatch.begin();
// 各种预备操作
this.prepare();
if (printProcDoc) {
PropDocReader docReader = new PropDocReader(ctx);
docReader.load();
Logs.get().info("Configure Man... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whenPrepa... | #vulnerable code
public void prepare() throws Exception {
if (prepared)
return;
// 初始化上下文
listeners.forEach((listener)->listener.whenPrepareBasic(this, EventType.before));
this.prepareBasic();
listeners.forEach((listener)->listener.whe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping("/logout")
public String logout(HttpServletRequest request) {
HttpSession session = request.getSession();
if (session != null) {
session.invalidate();
}
return "redirect:/";
} | #vulnerable code
@RequestMapping("/logout")
public String logout(HttpServletRequest request) {
HttpSession session = request.getSession();
// 注销本地会话
if (session != null) {
session.invalidate();
}
// 如果是客户端发起的注销请求
String token = (String) session.getAttribute(AuthConst.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBugSentences() throws IOException {
String[] bugSentences = new String[] { "干脆就把那部蒙人的闲法给废了拉倒!RT @laoshipukong : 27日,全国人大常委会第三次审议侵权责任法草案,删除了有关医疗损害责任“举证倒置”的规定。在医患纠纷中本已处于弱势地位的消费者由此将陷入万劫不复的境地。 " };
JiebaAnalyzer analyzer = new JiebaAnalyz... | #vulnerable code
@Test
public void testBugSentences() throws IOException {
String[] bugSentences = new String[] { "干脆就把那部蒙人的闲法给废了拉倒!RT @laoshipukong : 27日,全国人大常委会第三次审议侵权责任法草案,删除了有关医疗损害责任“举证倒置”的规定。在医患纠纷中本已处于弱势地位的消费者由此将陷入万劫不复的境地。 " };
JiebaAnalyzer analyzer = new Jieba... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void test() throws IOException {
JiebaAnalyzer analyzer = new JiebaAnalyzer("index", new File("data"), true);
for (String sentence : sentences) {
TokenStream tokenStream = analyzer.tokenStream(null,
new StringR... | #vulnerable code
@Test
public void test() throws IOException {
JiebaAnalyzer analyzer = new JiebaAnalyzer("index", new File("data"),
true);
for (String sentence : sentences) {
TokenStream tokenStream = analyzer.tokenStream(null,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSegModeOther() throws IOException {
JiebaAnalyzer analyzer = new JiebaAnalyzer("other", new File("data"),
true);
for (String sentence : sentences) {
TokenStream tokenStream = analyzer.tokenStream(null,
... | #vulnerable code
@Test
public void testSegModeOther() throws IOException {
JiebaAnalyzer analyzer = new JiebaAnalyzer("other", new File("data"),
true);
for (String sentence : sentences) {
TokenStream tokenStream = analyzer.tokenStream(nul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = "/cluster/info/ajax", method = RequestMethod.GET)
public void clusterAjax(HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
response.setHeader("Ch... | #vulnerable code
@RequestMapping(value = "/cluster/info/ajax", method = RequestMethod.GET)
public void clusterAjax(HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
response.setHead... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = "/consumer/offset/{group}/{topic}/ajax", method = RequestMethod.GET)
public void offsetDetailAjax(@PathVariable("group") String group, @PathVariable("topic") String topic, HttpServletResponse response, HttpServletRequest request) {
response.setContentT... | #vulnerable code
@RequestMapping(value = "/consumer/offset/{group}/{topic}/ajax", method = RequestMethod.GET)
public void offsetDetailAjax(@PathVariable("group") String group, @PathVariable("topic") String topic, HttpServletResponse response, HttpServletRequest request) {
response.setCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static long getLogSize(List<String> hosts, String topic, int partition) {
LOG.info("Find leader hosts [" + hosts + "]");
PartitionMetadata metadata = findLeader(hosts, topic, partition);
if (metadata == null) {
LOG.error("[KafkaClusterUtils.getLogSize()] - Can't ... | #vulnerable code
public static long getLogSize(List<String> hosts, String topic, int partition) {
LOG.info("Find leader hosts [" + hosts + "]");
PartitionMetadata metadata = findLeader(hosts, topic, partition);
if (metadata == null) {
LOG.error("[KafkaClusterUtils.getLogSize()] - ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = "/dash/kafka/ajax", method = RequestMethod.GET)
public void dashboardAjax(HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
response.setHeader("Ch... | #vulnerable code
@RequestMapping(value = "/dash/kafka/ajax", method = RequestMethod.GET)
public void dashboardAjax(HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
response.setHead... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = "/topic/meta/{tname}/ajax", method = RequestMethod.GET)
public void topicMetaAjax(@PathVariable("tname") String tname, HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharact... | #vulnerable code
@RequestMapping(value = "/topic/meta/{tname}/ajax", method = RequestMethod.GET)
public void topicMetaAjax(@PathVariable("tname") String tname, HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setC... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = "/consumer/offset/{group}/{topic}/realtime/ajax", method = RequestMethod.GET)
public void offsetGraphAjax(@PathVariable("group") String group, @PathVariable("topic") String topic, HttpServletResponse response, HttpServletRequest request) {
response.set... | #vulnerable code
@RequestMapping(value = "/consumer/offset/{group}/{topic}/realtime/ajax", method = RequestMethod.GET)
public void offsetGraphAjax(@PathVariable("group") String group, @PathVariable("topic") String topic, HttpServletResponse response, HttpServletRequest request) {
respon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static List<KafkaMetaDomain> findLeader(String topic) {
List<KafkaMetaDomain> list = new ArrayList<>();
SimpleConsumer consumer = null;
for (KafkaBrokerDomain broker : getBrokers()) {
try {
consumer = new SimpleConsumer(broker.getHost(), broker.getPort(), 10... | #vulnerable code
public static List<KafkaMetaDomain> findLeader(String topic) {
List<KafkaMetaDomain> list = new ArrayList<>();
SimpleConsumer consumer = null;
for (KafkaBrokerDomain broker : getBrokers()) {
try {
consumer = new SimpleConsumer(broker.getHost(), broker.getPort... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = "/alarm/topic/ajax", method = RequestMethod.GET)
public void alarmTopicAjax(HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
response.setHeader("... | #vulnerable code
@RequestMapping(value = "/alarm/topic/ajax", method = RequestMethod.GET)
public void alarmTopicAjax(HttpServletResponse response, HttpServletRequest request) {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
response.setHe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<ColumnInfo> getMetaData(String tableName) throws Exception {
// 获取主键
ResultSet keyResultSet = connection.getMetaData().getPrimaryKeys(null, getSchema(connection), tableName.toUpperCase());
String primaryKey = null;
if (keyResultSet.... | #vulnerable code
public List<ColumnInfo> getMetaData(String tableName) throws SQLException {
// 获取主键
ResultSet keyResultSet = connection.getMetaData().getPrimaryKeys(null, null, tableName);
String primaryKey = null;
if (keyResultSet.next()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Set<RaftPeerId> getHigherPriorityPeers(RaftConfiguration conf) {
Set<RaftPeerId> higherPriorityPeers = new HashSet<>();
int currPriority = conf.getPeer(server.getId()).getPriority();
final Collection<RaftPeer> peers = conf.getAllPeers();
for (RaftPeer ... | #vulnerable code
private Set<RaftPeerId> getHigherPriorityPeers(RaftConfiguration conf) {
Set<RaftPeerId> higherPriorityPeers = new HashSet<>();
int currPriority = conf.getPeer(server.getId()).getPriority();
Collection<RaftPeer> peers = conf.getPeers();
for (RaftPeer pee... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void runTestDataStream(){
final int bufferSize = 1024*1024;
final int bufferNum = 10;
final DataStreamOutput out = client.stream();
DataStreamClientImpl.DataStreamOutputImpl impl = (DataStreamClientImpl.DataStreamOutputImpl) out;
final List<Completab... | #vulnerable code
public void runTestDataStream(){
final int bufferSize = 1024*1024;
final int bufferNum = 10;
final DataStreamOutput out = client.stream();
//send request
final List<CompletableFuture<DataStreamReply>> futures = new ArrayList<>();
futures.add(sendR... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws IOException {
VerificationTool tool = new VerificationTool();
JCommander jc = JCommander.newBuilder()
.addObject(tool)
.build();
jc.parse(args);
if (tool.hel... | #vulnerable code
public static void main(String[] args) {
VerificationTool tool = new VerificationTool();
JCommander.newBuilder()
.addObject(tool)
.build()
.parse(args);
System.out.println(tool.metaQuorum);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void checkFollowerCommitLagsLeader(MiniRaftCluster cluster) {
List<RaftServerImpl> followers = cluster.getFollowers();
RaftServerImpl leader = cluster.getLeader();
Gauge leaderCommitGauge = RaftServerMetrics
.getPeerCommitIndexGauge(leader, l... | #vulnerable code
private static void checkFollowerCommitLagsLeader(MiniRaftCluster cluster) {
List<RaftServerImpl> followers = cluster.getFollowers();
RaftServerImpl leader = cluster.getLeader();
RatisMetricRegistry leaderMetricsRegistry =
RatisMetrics.getMetricRegist... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static Map<RaftPeer, NettyRpcService> initRpcServices(
Collection<RaftServer> servers, RaftConfiguration conf) {
final Map<RaftPeer, NettyRpcService> peerRpcs = new HashMap<>();
for (RaftServer s : servers) {
final NettyRpcService rpc = newNettyRpcS... | #vulnerable code
private static Map<RaftPeer, NettyRpcService> initRpcServices(
Collection<RaftServer> servers, RaftConfiguration conf) {
final Map<RaftPeer, NettyRpcService> peerRpcs = new HashMap<>();
for (RaftServer s : servers) {
final String address = getAddress(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void saveMD5File(File dataFile, String digestString)
throws IOException {
File md5File = getDigestFileForFile(dataFile);
String md5Line = digestString + " *" + dataFile.getName() + "\n";
try (AtomicFileOutputStream afos
= new AtomicFil... | #vulnerable code
private static void saveMD5File(File dataFile, String digestString)
throws IOException {
File md5File = getDigestFileForFile(dataFile);
String md5Line = digestString + " *" + dataFile.getName() + "\n";
AtomicFileOutputStream afos = new AtomicFileOutputS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@BeforeClass
public static void beforeClass() {
cluster = new LogServiceCluster(3);
cluster.createWorkers(3);
workers = cluster.getWorkers();
assert(workers.size() == 3);
} | #vulnerable code
@BeforeClass
public static void beforeClass() {
cluster = new LogServiceCluster(3);
cluster.createWorkers(3);
List<LogServer> workers = cluster.getWorkers();
assert(workers.size() == 3);
}
#location 6 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void assertServer(MiniRaftCluster cluster, ClientId clientId, long callId, long oldLastApplied) throws Exception {
final long leaderApplied = cluster.getLeader().getInfo().getLastAppliedIndex();
// make sure retry cache has the entry
for (RaftServer.Division ... | #vulnerable code
public void assertServer(MiniRaftCluster cluster, ClientId clientId, long callId, long oldLastApplied) throws Exception {
final long leaderApplied = RaftServerTestUtil.getLastAppliedIndex(cluster.getLeader());
// make sure retry cache has the entry
for (RaftSe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void setupServer(){
servers = new ArrayList<>(peers.size());
singleDataStreamStateMachines = new ArrayList<>(peers.size());
// start stream servers on raft peers.
for (int i = 0; i < peers.size(); i++) {
SingleDataStreamStateMachine singleDataStrea... | #vulnerable code
private void setupServer(){
servers = new ArrayList<>(peers.size());
singleDataStreamStateMachines = new ArrayList<>(peers.size());
// start stream servers on raft peers.
for (int i = 0; i < peers.size(); i++) {
SingleDataStreamStateMachine singleDat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testZeroSizeInProgressFile() throws Exception {
final RaftStorage storage = RaftStorageTestUtils.newRaftStorage(storageDir);
final File file = storage.getStorageDir().getOpenLogFile(0);
storage.close();
// create zero size in-progress file
... | #vulnerable code
@Test
public void testZeroSizeInProgressFile() throws Exception {
final RaftStorage storage = new RaftStorage(storageDir, StartupOption.REGULAR);
final File file = storage.getStorageDir().getOpenLogFile(0);
storage.close();
// create zero size in-progre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDataStreamDisabled() throws Exception {
try {
setup(1);
final RaftClient client = newRaftClientForDataStream();
exception.expect(UnsupportedOperationException.class);
exception.expectMessage(DisabledDataStreamClientFactory.cla... | #vulnerable code
@Test
public void testDataStreamDisabled() throws Exception {
try {
setup(1);
final DataStreamClientImpl client = newDataStreamClientImpl();
exception.expect(UnsupportedOperationException.class);
exception.expectMessage(DisabledDataStreamClie... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(timeout = 1000)
public void testMultipleTasks() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance();
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
Assert.ass... | #vulnerable code
@Test(timeout = 1000)
public void testMultipleTasks() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance(1);
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
Ass... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<String, List<CompletableFuture<DataStreamReply>>> streamWrite(
List<String> paths, FileStoreClient fileStoreClient) throws IOException {
Map<String, List<CompletableFuture<DataStreamReply>>> fileMap = new HashMap<>();
for(String path : paths) {
F... | #vulnerable code
private Map<String, List<CompletableFuture<DataStreamReply>>> streamWrite(
List<String> paths, FileStoreClient fileStoreClient) throws IOException {
Map<String, List<CompletableFuture<DataStreamReply>>> fileMap = new HashMap<>();
for(String path : paths) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void setup(int numServers){
final List<RaftPeer> peers = Arrays.stream(MiniRaftCluster.generateIds(numServers, 0))
.map(RaftPeerId::valueOf)
.map(id -> new RaftPeer(id, NetUtils.createLocalServerAddress()))
.collect(Collectors.toList());
... | #vulnerable code
protected void setup(int numServers){
peers = Arrays.stream(MiniRaftCluster.generateIds(numServers, 0))
.map(RaftPeerId::valueOf)
.map(id -> new RaftPeer(id, NetUtils.createLocalServerAddress()))
.collect(Collectors.toList());
servers = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void assertServer(MiniRaftCluster cluster, ClientId clientId, long callId, long oldLastApplied) throws Exception {
final long leaderApplied = RaftServerTestUtil.getLastAppliedIndex(cluster.getLeader());
// make sure retry cache has the entry
for (RaftServer.D... | #vulnerable code
public void assertServer(MiniRaftCluster cluster, ClientId clientId, long callId, long oldLastApplied) throws Exception {
long leaderApplied = cluster.getLeader().getState().getLastAppliedIndex();
// make sure retry cache has the entry
for (RaftServerImpl serv... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(timeout = 1000)
public void testRestartingScheduler() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance();
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
Asse... | #vulnerable code
@Test(timeout = 1000)
public void testRestartingScheduler() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance(1);
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(timeout = 1000)
public void testSingleTask() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance();
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
Assert.assert... | #vulnerable code
@Test(timeout = 1000)
public void testSingleTask() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance(1);
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
Assert... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDataStreamDisabled() throws Exception {
try {
setup(1);
final RaftClient client = newRaftClientForDataStream();
exception.expect(UnsupportedOperationException.class);
exception.expectMessage(DisabledDataStreamClientFactory.cla... | #vulnerable code
@Test
public void testDataStreamDisabled() throws Exception {
try {
setup(1);
final DataStreamClientImpl client = newDataStreamClientImpl();
exception.expect(UnsupportedOperationException.class);
exception.expectMessage(DisabledDataStreamClie... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(timeout = 1000)
public void testExtendingGracePeriod() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance();
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
Ass... | #vulnerable code
@Test(timeout = 1000)
public void testExtendingGracePeriod() throws Exception {
final TimeoutScheduler scheduler = TimeoutScheduler.newInstance(1);
final TimeDuration grace = TimeDuration.valueOf(100, TimeUnit.MILLISECONDS);
scheduler.setGracePeriod(grace);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void operation(RaftClient client) throws IOException {
List<String> paths = generateFiles();
FileStoreClient fileStoreClient = new FileStoreClient(client);
System.out.println("Starting Async write now ");
long startTime = System.currentTim... | #vulnerable code
@Override
protected void operation(RaftClient client) throws IOException {
int length = Integer.parseInt(size);
int num = Integer.parseInt(numFiles);
AtomicLong totalBytes = new AtomicLong(0);
String entropy = RandomStringUtils.randomAlphanumeric(10);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String toString() {
return name + "(c" + getCommitIndex() + ",m" + getMatchIndex() + ",n" + getNextIndex()
+ ", attendVote=" + attendVote +
", lastRpcSendTime=" + lastRpcSendTime.get().elapsedTimeMs() +
", lastRpcResponseTime=" + l... | #vulnerable code
@Override
public String toString() {
return peer.getId() + "(next=" + nextIndex + ", match=" + matchIndex + "," +
" attendVote=" + attendVote +
", lastRpcSendTime=" + lastRpcSendTime.get().elapsedTimeMs() +
", lastRpcResponseTime=" + lastRpcR... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Inventory deserializeInventory(JsonElement data, String title) {
Preconditions.checkArgument(data.isJsonPrimitive());
return InventorySerialization.decodeInventory(data.getAsString(), title);
} | #vulnerable code
public static Inventory deserializeInventory(JsonElement data, String title) {
Preconditions.checkArgument(data.isJsonPrimitive());
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data.getAsString()))) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void enable() {
// provide an info command
if (getConfig().getBoolean("info-command", true)) {
Commands.create()
.handler(c -> LoaderUtils.getHelperImplementationPlugins().stream()
... | #vulnerable code
@Override
protected void enable() {
// provide an info command
Commands.create()
.handler(c -> {
LoaderUtils.getHelperImplementationPlugins().stream()
.sorted(Comparator.comparing(Plugin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ItemStack deserializeItemstack(JsonElement data) {
Preconditions.checkArgument(data.isJsonPrimitive());
return InventorySerialization.decodeItemStack(data.getAsString());
} | #vulnerable code
public static ItemStack deserializeItemstack(JsonElement data) {
Preconditions.checkArgument(data.isJsonPrimitive());
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data.getAsString()))) {
try (Bukkit... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public final void onEnable() {
// schedule cleanup of the registry
Scheduler.builder()
.async()
.after(10, TimeUnit.SECONDS)
.every(30, TimeUnit.SECONDS)
.run(terminableRegistry::cle... | #vulnerable code
@Override
public final void onEnable() {
// schedule cleanup of the registry
Scheduler.runTaskRepeatingAsync(terminableRegistry::cleanup, 600L, 600L).bindWith(terminableRegistry);
// call subclass
enable();
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ItemStack[] deserializeItemstacks(JsonElement data) {
Preconditions.checkArgument(data.isJsonPrimitive());
return InventorySerialization.decodeItemStacks(data.getAsString());
} | #vulnerable code
public static ItemStack[] deserializeItemstacks(JsonElement data) {
Preconditions.checkArgument(data.isJsonPrimitive());
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data.getAsString()))) {
try (Buk... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized boolean saveApi(ApiResult apiResult) {
boolean successful = false;
Connection connection;
PreparedStatement preparedStatement = null;
try {
connection = this.dbConfig.getConnection();
preparedStatem... | #vulnerable code
public synchronized boolean saveApi(ApiResult apiResult) {
boolean successful = false;
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbC... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized boolean saveApi(ApiResult apiResult) {
boolean successful = false;
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbConfig.... | #vulnerable code
public synchronized boolean saveApi(ApiResult apiResult) {
boolean successful = false;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.dbConfig.getConnection();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void getGitChangeSets() throws IOException, GitAPIException {
Repository localRepository = new FileRepository(new File("./repo/server/.git"));
Git git = new Git(localRepository);
Iterable<RevCommit> logs = git.log().call();
List<String... | #vulnerable code
public void getGitChangeSets() throws IOException, GitAPIException {
Repository localRepository = new FileRepository(new File("./repo/server/.git"));
Git git = new Git(localRepository);
Iterable<RevCommit> logs = git.log().call();
List<... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static List<String> readFileLinesGuessEncoding(String filePath, int maxFileLineDepth) throws IOException {
List<String> fileLines = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), guessC... | #vulnerable code
public static List<String> readFileLinesGuessEncoding(String filePath, int maxFileLineDepth) throws IOException {
BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(filePath), guessCharset(new File(filePath))));
List<... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void execute(JobExecutionContext context) throws JobExecutionException {
if (isEnabled() == false) {
return;
}
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while(CodeIndexer.shouldPauseAdding()) {
S... | #vulnerable code
public void execute(JobExecutionContext context) throws JobExecutionException {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while(CodeIndexer.shouldPauseAdding()) {
Singleton.getLogger().info("Pausing parser.");
retu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized void deleteRepoByName(String repositoryName) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbConfig.getConnection();
... | #vulnerable code
public synchronized void deleteRepoByName(String repositoryName) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.dbConfig.getConnection();
stmt = conn.prepareStateme... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public SlocCount countStats(String contents, String languageName) {
if (contents == null || contents.isEmpty()) {
return new SlocCount();
}
FileClassifierResult fileClassifierResult = this.database.get(languageName);
State current... | #vulnerable code
public SlocCount countStats(String contents, String languageName) {
if (contents == null || contents.isEmpty()) {
return new SlocCount();
}
FileClassifierResult fileClassifierResult = this.database.get(languageName);
State c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String languageGuesser(String fileName) {
fileName = fileName.toLowerCase();
String extension;
Optional<String> lang = this.checkIfExtentionExists(fileName);
if (!lang.isPresent()) {
extension = this.getExtension(fileName);... | #vulnerable code
public String languageGuesser(String fileName) {
fileName = fileName.toLowerCase();
String extension = this.getExtension(fileName);
for (String key: database.keySet()) {
FileClassifierResult fileClassifierResult = database.get(key);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static List<String> readFileLines(String filePath, int maxFileLineDepth) throws FileNotFoundException {
List<String> lines = new ArrayList<>();
Scanner input = new Scanner(new File(filePath));
try {
int counter = 0;
whil... | #vulnerable code
public static List<String> readFileLines(String filePath, int maxFileLineDepth) throws FileNotFoundException {
List<String> lines = new ArrayList<>();
Scanner input = new Scanner(new File(filePath));
int counter = 0;
while(input.hasNext... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public synchronized boolean saveRepo(RepoResult repoResult) {
RepoResult existing = this.getRepoByName(repoResult.getName());
this.cache.remove(repoResult.getName());
boolean isNew = false;
Connection connection = null;
... | #vulnerable code
@Override
public synchronized boolean saveRepo(RepoResult repoResult) {
RepoResult existing = this.getRepoByName(repoResult.getName());
this.cache.remove(repoResult.getName());
boolean isNew = false;
Connection conn = null;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public RepositoryChanged updateSvnRepository(String repoName, String repoRemoteLocation, String repoUserName, String repoPassword, String repoLocations, boolean useCredentials) {
boolean changed = false;
List<String> changedFiles = new ArrayList<>();
L... | #vulnerable code
public RepositoryChanged updateSvnRepository(String repoName, String repoRemoteLocation, String repoUserName, String repoPassword, String repoLocations, boolean useCredentials) {
boolean changed = false;
List<String> changedFiles = new ArrayList<>();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized void createTableIfMissing() {
Connection connection;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbConfig.getConnection();
preparedStatement = conn... | #vulnerable code
public synchronized void createTableIfMissing() {
Connection connection;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbConfig.getConnection();
preparedStatement... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized void deleteApiByPublicKey(String publicKey) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbConfig.getConnection();
p... | #vulnerable code
public synchronized void deleteApiByPublicKey(String publicKey) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = this.dbConfig.getConnection();
stmt = conn.prepareStatemen... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized void deleteApiByPublicKey(String publicKey) {
Connection connection;
PreparedStatement preparedStatement = null;
try {
connection = this.dbConfig.getConnection();
preparedStatement = connection.prepareStatem... | #vulnerable code
public synchronized void deleteApiByPublicKey(String publicKey) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = this.dbConfig.getConnection();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<CodeOwner> getBlameInfoExternal(int codeLinesSize, String repoName, String repoLocations, String fileName) {
List<CodeOwner> codeOwners = new ArrayList<>(codeLinesSize);
// -w is to ignore whitespace bug
ProcessBuilder processBuilder = new... | #vulnerable code
public List<CodeOwner> getBlameInfoExternal(int codeLinesSize, String repoName, String repoLocations, String fileName) {
List<CodeOwner> codeOwners = new ArrayList<>(codeLinesSize);
// -w is to ignore whitespace bug
ProcessBuilder processBuilder... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static java.util.Properties getProperties() {
if (properties == null) {
properties = new java.util.Properties();
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream("searchcode.... | #vulnerable code
public static java.util.Properties getProperties() {
if (properties == null) {
properties = new java.util.Properties();
try {
properties.load(new FileInputStream("searchcode.properties"));
} catch (IOException ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testRepoSaveDelete() {
this.repo.saveRepo(new RepoResult(-1, "myname", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
Optional<RepoResult> repoResult = this.repo.getRepoByName("myname");
RepoResult result = repoResu... | #vulnerable code
public void testRepoSaveDelete() {
this.repo.saveRepo(new RepoResult(-1, "myname", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
RepoResult result = this.repo.getRepoByName("myname");
assertThat(result.getName()).isEqua... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public RepositoryChanged checkoutSvnRepository(String repoName, String repoRemoteLocation, String repoUserName, String repoPassword, String repoLocations, boolean useCredentials) {
boolean successful = false;
Singleton.getLogger().info("Attempting to checkout ... | #vulnerable code
public RepositoryChanged checkoutSvnRepository(String repoName, String repoRemoteLocation, String repoUserName, String repoPassword, String repoLocations, boolean useCredentials) {
boolean successful = false;
Singleton.getLogger().info("Attempting to che... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testIsBinaryWhiteListedExtension() {
SearchcodeLib sl = new SearchcodeLib();
ArrayList<String> codeLines = new ArrayList<>();
codeLines.add("你你你你你你你你你你你你你你你你你你你你你你你你你你你");
FileClassifier fileClassifier = new FileClassifier();
... | #vulnerable code
public void testIsBinaryWhiteListedExtension() {
SearchcodeLib sl = new SearchcodeLib();
ArrayList<String> codeLines = new ArrayList<>();
codeLines.add("你你你你你你你你你你你你你你你你你你你你你你你你你你你");
FileClassifier fileClassifier = new FileClassifier();... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void indexDocument(Queue<CodeIndexDocument> documentQueue) throws IOException {
// Need to connect to each sphinx config eventually
SphinxSearchConfig sphinxSearchConfig = new SphinxSearchConfig();
Connection connection = null;
... | #vulnerable code
@Override
public void indexDocument(Queue<CodeIndexDocument> documentQueue) throws IOException {
// Need to connect to each sphinx config eventually
SphinxSearchConfig sphinxSearchConfig = new SphinxSearchConfig();
Connection connection = nul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private CodeOwner getInfoExternal(int codeLinesSize, String repoName, String repoLocations, String fileName) {
CodeOwner owner = new CodeOwner("Unknown", codeLinesSize, (int)(System.currentTimeMillis() / 1000));
ProcessBuilder processBuilder = new ProcessBuil... | #vulnerable code
private CodeOwner getInfoExternal(int codeLinesSize, String repoName, String repoLocations, String fileName) {
CodeOwner owner = new CodeOwner("Unknown", codeLinesSize, (int)(System.currentTimeMillis() / 1000));
ProcessBuilder processBuilder = new Proce... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public synchronized boolean saveRepo(RepoResult repoResult) {
RepoResult existing = this.getRepoByName(repoResult.getName());
this.cache.remove(repoResult.getName());
boolean isNew = false;
Connection connection = null;
... | #vulnerable code
@Override
public synchronized boolean saveRepo(RepoResult repoResult) {
RepoResult existing = this.getRepoByName(repoResult.getName());
this.cache.remove(repoResult.getName());
boolean isNew = false;
Connection conn = null;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public SourceCodeDTO saveCode(CodeIndexDocument codeIndexDocument) {
Optional<SourceCodeDTO> existing = this.getByCodeIndexDocument(codeIndexDocument);
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.dbCo... | #vulnerable code
public SourceCodeDTO saveCode(CodeIndexDocument codeIndexDocument) {
Optional<SourceCodeDTO> existing = this.getByCodeIndexDocument(codeIndexDocument);
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = thi... | 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.