input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
public AsteriskChannel getDialedChannel()
{
return dialedChannel;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public AsteriskChannel getDialedChannel()
{
synchronized(dialedChannels) {
for (AsteriskChannel channel:dialedChannels) {
if (channel != null) return channel;
}
}
return null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected AsteriskVersion determineVersion() throws IOException, TimeoutException
{
int attempts = 0;
// if ("Asterisk Call Manager/1.1".equals(protocolIdentifier.value))
// {
// return AsteriskVersion.ASTERISK_1_6;
// }
... | #fixed code
protected AsteriskVersion determineVersion() throws IOException, TimeoutException
{
int attempts = 0;
logger.info("Got asterisk protocol identifier version " + protocolIdentifier.getValue());
while (attempts++ < MAX_VERSION_ATTEMPTS)
{
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.warn("origi... | #fixed code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.info("originate c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewCallerIdEvent(NewCallerIdEvent event)
{
AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
// NewCallerIdEvent can occur for an existing channel that now has a different un... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
this.channels = new HashSet<AsteriskChannelImpl>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String toString()
{
final StringBuffer sb;
sb = new StringBuffer("AsteriskAgent[");
sb.append("agentId='").append(getAgentId()).append("',");
sb.append("name='").append(getName()).append("',");
sb.append(... | #fixed code
@Override
public String toString()
{
final StringBuffer sb;
sb = new StringBuffer("AsteriskAgent[");
sb.append("agentId='").append(getAgentId()).append("',");
sb.append("name='").append(getName()).append("',");
sb.append("state... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public AsteriskChannel getDialingChannel()
{
return dialingChannel;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public AsteriskChannel getDialingChannel()
{
synchronized(dialingChannels) {
if (dialingChannels.isEmpty()) return null;
return dialingChannels.get(0);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onManagerEvent(final org.asteriskjava.manager.event.ManagerEvent event)
{
// logger.error(event);
boolean wanted = false;
/**
* Dump any events we arn't interested in ASAP to minimise the
* process... | #fixed code
@Override
public void onManagerEvent(final org.asteriskjava.manager.event.ManagerEvent event)
{
// logger.error(event);
boolean wanted = false;
/**
* Dump any events we arn't interested in ASAP to minimise the
* processing ov... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewCallerIdEvent(NewCallerIdEvent event)
{
AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
// NewCallerIdEvent can occur for an existing channel that now has a different un... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
this.channels = new HashSet<AsteriskChannelImpl>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected AsteriskVersion determineVersion() throws IOException, TimeoutException
{
int attempts = 0;
// if ("Asterisk Call Manager/1.1".equals(protocolIdentifier.value))
// {
// return AsteriskVersion.ASTERISK_1_6;
// }
... | #fixed code
protected AsteriskVersion determineVersion() throws IOException, TimeoutException
{
int attempts = 0;
// if ("Asterisk Call Manager/1.1".equals(protocolIdentifier.value))
// {
// return AsteriskVersion.ASTERISK_1_6;
// }
w... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ResponseEvents sendEventGeneratingAction(
EventGeneratingAction action, long timeout) throws IOException,
EventTimeoutException, IllegalArgumentException,
IllegalStateException
{
final ResponseEventsImpl responseEve... | #fixed code
public ResponseEvents sendEventGeneratingAction(
EventGeneratingAction action, long timeout) throws IOException,
EventTimeoutException, IllegalArgumentException,
IllegalStateException
{
final ResponseEventsImpl responseEvents;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewStateEvent(NewStateEvent event)
{
AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
// NewStateEvent can occur for an existing channel that now has a different unique id (... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewChannelEvent(NewChannelEvent event)
{
final AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
if (event.getChannel() == null)
{
logger.info("Ig... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
this.channels = new HashSet<AsteriskChannelImpl>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public AsteriskChannel originateToApplication(String channel, String application, String data, long timeout) throws ManagerCommunicationException
{
return originateToApplication(channel, application, data, timeout, null, null);
}
... | #fixed code
public AsteriskChannel originateToApplication(String channel, String application, String data, long timeout) throws ManagerCommunicationException, NoSuchChannelException
{
return originateToApplication(channel, application, data, timeout, null, null);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.debug("orig... | #fixed code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.debug("originate ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.debug("orig... | #fixed code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.debug("originate ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.warn("origi... | #fixed code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.info("originate c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void fastScannerSpeedTest(Pattern pattern) throws Exception
{
try
{
for (int i = 10; i-- > 0;)
{
InputStreamReader reader = getReader();
System.out.print("Fast " + i + ":\t");
... | #fixed code
private void fastScannerSpeedTest(Pattern pattern) throws Exception
{
try
{
for (int i = 10; i-- > 0;)
{
Socket echoSocket = new Socket("127.0.0.1", FastScannerTestSocketSource.portNumber);
InputStre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleQueueMemberStatusEvent(QueueMemberStatusEvent event)
{
AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue());
if (queue == null)
{
logger.error("Ignored QueueMemberStatusEvent for unknown queue " + event.getQ... | #fixed code
QueueManager(AsteriskServerImpl server, ChannelManager channelManager)
{
this.server = server;
this.channelManager = channelManager;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.debug("orig... | #fixed code
OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap<String, String> myVars,
final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context)
{
OriginateBaseClass.logger.debug("originate ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewCallerIdEvent(NewCallerIdEvent event)
{
AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
// NewCallerIdEvent can occur for an existing channel that now has a different un... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
this.channels = new HashSet<AsteriskChannelImpl>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewCallerIdEvent(NewCallerIdEvent event)
{
AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
// NewCallerIdEvent can occur for an existing channel that now has a different un... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
this.channels = new HashSet<AsteriskChannelImpl>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ResponseEvents sendEventGeneratingAction(
EventGeneratingAction action, long timeout) throws IOException,
EventTimeoutException, IllegalArgumentException,
IllegalStateException
{
ResponseEventsImpl responseEvents;
... | #fixed code
public ResponseEvents sendEventGeneratingAction(
EventGeneratingAction action, long timeout) throws IOException,
EventTimeoutException, IllegalArgumentException,
IllegalStateException
{
ResponseEventsImpl responseEvents;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void handleNewCallerIdEvent(NewCallerIdEvent event)
{
AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());
if (channel == null)
{
// NewCallerIdEvent can occur for an existing channel that now has a different un... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void disconnected()
{
if (traceScheduledExecutorService != null)
{
traceScheduledExecutorService.shutdown();
}
synchronized (channels)
{
channels.clear();
}
}
#l... | #fixed code
ChannelManager(AsteriskServerImpl server)
{
this.server = server;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public ReadablePeriod deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException
{
JsonToken t = p.currentToken();
if (t == JsonToken.VALUE_STRING) {
String str = p.getText().trim();
if (st... | #fixed code
@Override
public ReadablePeriod deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException
{
JsonToken t = p.currentToken();
if (t == JsonToken.VALUE_STRING) {
return _fromString(p, ctxt, p.getText());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private boolean isZipFile(final File file) throws IOException {
final DataInputStream in = new DataInputStream(new FileInputStream(file));
final int n = in.readInt();
in.close();
return n == 0x504b0304;
}
... | #fixed code
private boolean isZipFile(final File file) {
DataInputStream in = null;
try {
in = new DataInputStream(new FileInputStream(file));
final int n = in.readInt();
return n == 0x504b0304;
} catch (IOException ex) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateTranslationProgressMap(String langCode, int value) {
if (getDefaultLanguageCode().equals(langCode)) {
return;
}
double defsize = getDefaultLanguage().size();
double approved = value;
Map<String, Integer> progress = getTranslationProgressMa... | #fixed code
private void updateTranslationProgressMap(String langCode, int value) {
if (getDefaultLanguageCode().equals(langCode)) {
return;
}
double defsize = getDefaultLanguage().size();
double approved = value;
Map<String, Integer> progress = getTranslationProgressMap();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTaskCreate() {
setupContextForTaskExecutionListener();
DefaultTaskListenerConfiguration.TestTaskExecutionListener taskExecutionListener =
context.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
TaskExecution taskE... | #fixed code
@Test
public void testTaskCreate() {
setupContextForTaskExecutionListener();
DefaultTaskListenerConfiguration.TestTaskExecutionListener taskExecutionListener =
context.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class);
TaskExecution taskExecuti... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAnnotationCreate() throws Exception {
setupContextForAnnotatedListener();
DefaultAnnotationConfiguration.AnnotatedTaskListener annotatedListener =
context.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
TaskExecution ta... | #fixed code
@Test
public void testAnnotationCreate() throws Exception {
setupContextForAnnotatedListener();
DefaultAnnotationConfiguration.AnnotatedTaskListener annotatedListener =
context.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class);
TaskExecution taskExec... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
String authentication = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
String method = re... | #fixed code
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
String authentication = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
String method = request.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
File getImage() {
//获取当前时间作为名字
Date current = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String curDate = df.format(current);
File curPhoto = new File(HERO_PATH, curDate + ".png");
//截屏存到手机本地... | #fixed code
File getImage() {
//获取当前时间作为名字
Date current = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String curDate = df.format(current);
File curPhoto = new File(HERO_PATH, curDate + ".png");
//截屏存到手机本地
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Long search(String question) throws IOException {
String path = "http://www.baidu.com/s?tn=ichuner&lm=-1&word=" +
URLEncoder.encode(question, "gb2312") + "&rn=1";
boolean findIt = false;
String line = null;
while (!findIt)... | #fixed code
Search(String question) {
this.question = question;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Long searchAndOpen(String question) throws IOException {
String path = "http://www.baidu.com/s?tn=ichuner&lm=-1&word=" +
URLEncoder.encode(question, "gb2312") + "&rn=20";
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHan... | #fixed code
private Long searchAndOpen(String question) throws IOException {
String path = null;
try {
path = "http://www.baidu.com/s?tn=ichuner&lm=-1&word=" +
URLEncoder.encode(question, "gb2312") + "&rn=20";
//获取操作系统的名字
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Long search(String question) throws IOException {
String path = "http://www.baidu.com/s?tn=ichuner&lm=-1&word=" +
URLEncoder.encode(question, "gb2312") + "&rn=1";
boolean findIt = false;
String line = null;
while (!findIt)... | #fixed code
Search(String question) {
this.question = question;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
// Setting the width and height of frame
frame.setSize(500, 800);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
String path=MainGUI.class.getProtectionDomain().g... | #fixed code
public static void main(String[] args) throws IOException {
// Setting the width and height of frame
frame.setSize(500, 800);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
try{
loadConfig();
}catch (Exceptio... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请选择您要使用的文字识别方式\n1.TessOCR\n2.百度OCR");
System.out.println("默认使用TessOCR,选择后回车");
OCR o... | #fixed code
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请选择您要使用的文字识别方式\n1.TessOCR\n2.百度OCR");
System.out.println("默认使用TessOCR,选择后回车,不能为空");
String... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
File getImage() {
//获取当前时间作为名字
Date current = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String curDate = df.format(current);
File curPhoto = new File(HERO_PATH, curDate + ".png");
//截屏存到手机本地... | #fixed code
File getImage() {
//获取当前时间作为名字
Date current = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String curDate = df.format(current);
File curPhoto = new File(HERO_PATH, curDate + ".png");
//截屏存到手机本地
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("http://jsql-injection.googlecode.com/git/.version").openConnection();
con.setReadTimeout(60000);
con.setConnect... | #fixed code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("https://raw.githubusercontent.com/ron190/jsql-injection/master/.version").openConnection();
con.setReadTimeout(60000);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | #fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("http://jsql-injection.googlecode.com/git/.version").openConnection();
con.setReadTimeout(60000);
con.setConnect... | #fixed code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("https://raw.githubusercontent.com/ron190/jsql-injection/master/.version").openConnection();
con.setReadTimeout(60000);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void start(Class<?> clazz,String path) throws Exception {
long start = System.currentTimeMillis();
//init application
AppConfig.getInstance().setRootPackageName(clazz.getPackage().getName());
AppConfig.getInstance().setRo... | #fixed code
public static void start(Class<?> clazz,String path) throws Exception {
InitSetting.setting(clazz,path) ;
NettyBootStrap.startServer();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void handlePostValidate(UIInput component) {
final BeanValidator beanValidator = getBeanValidator(component);
final String originalValidationGroups = (String) component.getAttributes().remove(ATTRIBUTE_ORIGINAL_VALIDATION_GROUPS);
beanValidator.setValidationG... | #fixed code
private void handlePostValidate(UIInput component) {
BeanValidator beanValidator = getBeanValidator(component);
if (beanValidator != null) {
String originalValidationGroups = (String) component.getAttributes().remove(ATTRIBUTE_ORIGINAL_VALIDATION_GROUPS);
beanValidato... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStat... | #fixed code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStateExcep... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Produces
@Param
public <V> ParamValue<V> produce(InjectionPoint injectionPoint) {
Param requestParameter = getQualifier(injectionPoint, Param.class);
FacesContext context = getContext();
UIComponent component = getViewRoot();
/... | #fixed code
@SuppressWarnings("unchecked")
@Produces
@Param
public <V> ParamValue<V> produce(InjectionPoint injectionPoint) {
// @Param is the annotation on the injection point that holds all data for this request parameter
Param requestParameter = getQualifier(injectionPoint, Param... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass) {
return getInstance(beanManager, resolve(beanManager, beanClass), true);
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass) {
Bean<T> bean = resolve(beanManager, beanClass);
return (bean != null) ? getInstance(beanManager, bean, true) : null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void encodeBegin(FacesContext context) throws IOException {
Components.validateHasNoChildren(this);
try {
ExternalContext externalContext = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getReque... | #fixed code
@Override
public void encodeBegin(FacesContext context) throws IOException {
Components.validateHasNoChildren(this);
ExternalContext externalContext = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
HttpServ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@OnClose
public void close(Session session) {
BeanManager.INSTANCE.getReference(PushContextImpl.class).remove(session); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
}
#location 3
#vulnerability typ... | #fixed code
@OnClose
public void close(Session session) {
BeanManager.INSTANCE.getReference(SocketPushContext.class).remove(session); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
ResourceHandler handler = context.getApplication().getResourceHandler();
resources = new LinkedHashSet<>();
contentLen... | #fixed code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
resources = new LinkedHashSet<>();
contentLength = 0;
lastModified = 0;
for (ResourceIdentifier resourceIdentifier : reso... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> T getReference(BeanManager beanManager, Class<T> beanClass) {
return getReference(beanManager, resolve(beanManager, beanClass));
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public static <T> T getReference(BeanManager beanManager, Class<T> beanClass) {
Bean<T> bean = resolve(beanManager, beanClass);
return (bean != null) ? getReference(beanManager, bean) : null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@OnOpen
public void open(Session session, @PathParam("channel") String channel) {
BeanManager.INSTANCE.getReference(PushContextImpl.class).add(session, channel); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
}
#location 3
... | #fixed code
@OnOpen
public void open(Session session, @PathParam("channel") String channel) {
BeanManager.INSTANCE.getReference(SocketPushContext.class).add(session, channel); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <S extends Serializable> Map<S, Set<Future<Void>>> send(Object message, Collection<S> users) {
SocketSessionManager manager = SocketSessionManager.getInstance();
Map<S, Set<Future<Void>>> resultsByUser = new HashMap<>(users.size());
for (S user : u... | #fixed code
@Override
public <S extends Serializable> Map<S, Set<Future<Void>>> send(Object message, Collection<S> users) {
Map<S, Set<Future<Void>>> resultsByUser = new HashMap<>(users.size());
for (S user : users) {
Set<String> userChannelIds = userManager.getUserChannelIds(user,... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
BeanManager.INSTANCE.getReference(ViewScopeManager.class).preDestroyView();
}
}
#location 4
... | #fixed code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
getReference(ViewScopeManager.class).preDestroyView();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
... | #fixed code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
if ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
public static <T> void destroy(BeanManager beanManager, T instance) {
if (instance instanceof Class) {
destroy(beanManager, (Class<T>) instance, new Annotation[0]);
}
else if (instance instanceof Bean) {
destroy(beanManager, (Bea... | #fixed code
@SuppressWarnings("unchecked")
public static <T> void destroy(BeanManager beanManager, T instance) {
if (instance instanceof Class) { // Java prefers T over Class<T> when varargs is not specified :(
destroy(beanManager, (Class<T>) instance, new Annotation[0]);
}
else {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState... | #fixed code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState(conte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
BeanManager.INSTANCE.getReference(EagerBeansRepository.class).instantiateApplicationScoped();
FacesViews.addMappings(event.getServletContext());
CacheInitializer.loadProvide... | #fixed code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
EagerBeansRepository.getInstance().instantiateApplicationScoped();
FacesViews.addMappings(event.getServletContext());
CacheInitializer.loadProviderAndRegisterFilter(event.getServl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
String string = submittedValue;
if (!isEmpty(string)) {
DecimalFormat formatter = getFormatter();
String symbol = getSymbol(formatter);
if (!string.con... | #fixed code
@Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
String string = submittedValue;
if (!isEmpty(string)) {
DecimalFormat formatter = getFormatter();
if (formatter != null) {
String symbol = getSymbol(formatt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void handlePreValidate(UIInput component) {
final BeanValidator beanValidator = getBeanValidator(component);
final String newValidationGroups = disabled ? NoValidationGroup.class.getName() : validationGroups;
final String originalValidationGroups = beanValida... | #fixed code
private void handlePreValidate(UIInput component) {
BeanValidator beanValidator = getBeanValidator(component);
if (beanValidator == null) {
return;
}
String newValidationGroups = disabled ? NoValidationGroup.class.getName() : validationGroups;
String originalValid... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState... | #fixed code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState(conte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
if (SocketFacesListener.register(context,... | #fixed code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
if (SocketFacesListener.register(context, this)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStat... | #fixed code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStateExcep... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
try {
EagerBeansRepository.getInstance().instantiateApplicationScoped();
FacesViews.addMappings(event.getServletContext());
CacheInitializer.loadProviderAndRegisterFil... | #fixed code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
try {
ServletContext servletContext = event.getServletContext();
EagerBeansRepository.instantiateApplicationScopedAndRegisterListener(servletContext);
FacesViews.addMappings... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
ResourceHandler handler = context.getApplication().getResourceHandler();
resources = new LinkedHashSet<>();
contentLen... | #fixed code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
resources = new LinkedHashSet<>();
contentLength = 0;
lastModified = 0;
for (ResourceIdentifier resourceIdentifier : reso... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
... | #fixed code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
if ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass, boolean create) {
return getInstance(beanManager, resolve(beanManager, beanClass), create);
}
#location 2
#vulnerability type NULL_DERE... | #fixed code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass, boolean create) {
Bean<T> bean = resolve(beanManager, beanClass);
return (bean != null) ? getInstance(beanManager, bean, create) : null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
String channel = getChannel();
if (cha... | #fixed code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
String channel = getChannel();
if (channel =... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStat... | #fixed code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStateExcep... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
BeanManager.INSTANCE.getReference(ViewScopeManager.class).preDestroyView();
}
}
#location 4
... | #fixed code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
processPreDestroyView();
}
else if (event instanceof PostRestoreStateEvent && "unload".equals(getRequestParameter("omnifaces.event")))... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Set<Future<Void>> send(Object message) {
return SocketSessionManager.getInstance().send(getChannelId(channel, sessionScopeIds, viewScopeIds), message);
}
#location 3
#vulnerability type NULL_DER... | #fixed code
@Override
public Set<Future<Void>> send(Object message) {
return sessionManager.send(getChannelId(channel, sessionScopeIds, viewScopeIds), message);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) {
return (InjectionPoint) beanManager.getInjectableReference(
resolve(beanManager, InjectionPointGenerator.class).getInjectionPoints().iterator().nex... | #fixed code
public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) {
Bean<InjectionPointGenerator> bean = resolve(beanManager, InjectionPointGenerator.class);
return (bean != null) ? (InjectionPoint) beanManager.getInjectab... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processAction(ActionEvent event) throws AbortProcessingException {
FacesContext context = FacesContext.getCurrentInstance();
PartialViewContext partialViewContext = context.getPartialViewContext();
if (partialViewContext.isAjaxRequest()) {
... | #fixed code
@Override
public void processAction(ActionEvent event) throws AbortProcessingException {
FacesContext context = FacesContext.getCurrentInstance();
PartialViewContext partialViewContext = context.getPartialViewContext();
if (partialViewContext.isAjaxRequest()) {
Collec... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private TreeModel<T> getPreviousSibling(TreeModel<T> parent, int index) {
if (isRoot()) {
return null;
}
else if (index >= 0) {
return parent.getChildren().get(index);
}
else {
TreeModel<T> previousParent = parent.getPreviousSibling();
return getPrevi... | #fixed code
private TreeModel<T> getPreviousSibling(TreeModel<T> parent, int index) {
if (parent == null) {
return null;
}
else if (index >= 0) {
return parent.getChildren().get(index);
}
else {
TreeModel<T> previousParent = parent.getPreviousSibling();
return getPrevi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldBeAbleToConvertNumbers(){
assertThat(((Character) converter.convert("r", char.class, errors, bundle)).charValue(), is(equalTo('r')));
}
#location 3
#vulnerability type NULL... | #fixed code
@Test
public void shouldBeAbleToConvertNumbers(){
assertThat(((Character) converter.convert("r", char.class, bundle)).charValue(), is(equalTo('r')));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void prepareRemotingContainer() throws IOException, InterruptedException {
// if remoting container already exists, we reuse it
if (context.getRemotingContainer() != null) {
if (driver.hasContainer(localLauncher, context.getRemotingCo... | #fixed code
public void prepareRemotingContainer() throws IOException, InterruptedException {
// if remoting container already exists, we reuse it
if (context.getRemotingContainer() != null) {
if (driver.hasContainer(localLauncher, context.getRemotingContaine... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void readerWriterTest() throws URISyntaxException, IOException, TransformationException, SAXException {
File file = new File(HTMLDocContentStructureConvertersTest.class.getResource(modelFilePath).toURI());
String expectedHTML = FileUtils... | #fixed code
@Test
public void readerWriterTest() throws URISyntaxException, IOException, TransformationException, SAXException {
File file = new File(HTMLDocContentStructureConvertersTest.class.getResource(modelFilePath).toURI());
String expectedHTML = FileUtils.readF... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public BxDocument getDocument() throws TransformationException {
InputStreamReader isr = new InputStreamReader(inputStream);
TrueVizToBxDocumentReader reader = new TrueVizToBxDocumentReader();
return new BxDocument().setPages(reader.read(isr));
... | #fixed code
public BxDocument getDocument() throws TransformationException {
InputStreamReader isr = null;
try {
isr = new InputStreamReader(inputStream, "UTF-8");
TrueVizToBxDocumentReader reader = new TrueVizToBxDocumentReader();
retu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws AnalysisException, TransformationException, IOException {
// args[0] path to xml directory
if(args.length != 1) {
System.err.println("Source directory needed!");
System.exit(1);
}
InputStreamReader modelISR = new ... | #fixed code
public static void main(String[] args) throws AnalysisException, TransformationException, IOException {
// args[0] path to xml directory
if(args.length != 1) {
System.err.println("Source directory needed!");
System.exit(1);
}
SVMInitialZoneClassifier classifier ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException, CloneNotSupportedException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection")... | #fixed code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException, CloneNotSupportedException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void toLibSVM(List<TrainingElement<BxZoneLabel>> trainingElements, String filePath) {
try {
FileWriter fstream = new FileWriter(filePath);
BufferedWriter svmDataFile = new BufferedWriter(fstream);
for (TrainingEl... | #fixed code
public static void toLibSVM(List<TrainingElement<BxZoneLabel>> trainingElements, String filePath) throws IOException {
BufferedWriter svmDataFile = null;
try {
FileWriter fstream = new FileWriter(filePath);
svmDataFile = new BufferedWriter... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
String dirPath = directory.getPath();
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocumen... | #fixed code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
String dirPath = directory.getPath();
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocument>();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection");
options.addOption(... | #fixed code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException, CloneNotSupportedException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static BxDocument getDocument(File file) throws IOException, TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
BxDocument newDoc = new BxDocument();
InputStream is = new FileInputStream(file);
... | #fixed code
public static BxDocument getDocument(File file) throws IOException, TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
BxDocument newDoc = new BxDocument();
InputStream is = new FileInputStream(file);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void loadModelFromFile(String modelFilePath, String rangeFilePath) throws IOException {
BufferedReader modelFile = new BufferedReader(new InputStreamReader(new FileInputStream(modelFilePath)));
BufferedReader rangeFile = null;
if (rangeFil... | #fixed code
public void loadModelFromFile(String modelFilePath, String rangeFilePath) throws IOException {
BufferedReader modelFile = new BufferedReader(new InputStreamReader(new FileInputStream(modelFilePath), "UTF-8"));
BufferedReader rangeFile = null;
if (range... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocument>();
for (File file : FileUtils.list... | #fixed code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocument>();
for (File file : FileUtils.listFiles(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"));
BxDocument inDoc = new BxDocument().setPages(new TrueVizToBxDocumentReader().r... | #fixed code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException, UnsupportedEncodingException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"), "UTF-8");
BxDocument inDoc = new BxDocument().setPages(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"));
BxDocument inDoc = new BxDocument().setPages(new TrueVizToBxDocumentReader().r... | #fixed code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException, UnsupportedEncodingException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"), "UTF-8");
BxDocument inDoc = new BxDocument().setPages(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException {
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class.getResourceAsStream(modelFilePath));
BufferedReader modelFile = new BufferedReader(... | #fixed code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException {
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class.getResourceAsStream(modelFilePath), "UTF-8");
BufferedReader modelFile = new BufferedRead... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getErrorMessage() {
String res = "";
if (error != null) {
res = error.getMessage();
if(res==null || res.isEmpty()) {
res = "Exception is: "+res.getClass().toString();
}
} else {
... | #fixed code
public String getErrorMessage() {
String res;
if (error != null) {
res = error.getMessage();
if(res==null || res.isEmpty()) {
res = "Exception is: "+error.getClass().toString();
}
} else {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testImporter() throws IOException, ParserConfigurationException, SAXException,
TransformationException {
BxPage page = new TrueVizToBxDocumentReader().read(new InputStreamReader(TrueVizToBxDocumentReaderTest.class.getResourceAsS... | #fixed code
@Test
public void testImporter() throws IOException, ParserConfigurationException, SAXException,
TransformationException {
BxPage page = new TrueVizToBxDocumentReader().read(new InputStreamReader(TrueVizToBxDocumentReaderTest.class.getResourceAsStream(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void metadataExtractionTest() throws AnalysisException, JDOMException, IOException, SAXException, TransformationException, URISyntaxException {
InputStream expStream = AbstractBibReferenceExtractorTest.class.getResourceAsStream(EXP_FILE);
... | #fixed code
@Test
public void metadataExtractionTest() throws AnalysisException, JDOMException, IOException, SAXException, TransformationException, URISyntaxException {
InputStream expStream = AbstractBibReferenceExtractorTest.class.getResourceAsStream(EXP_FILE);
Buff... | 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.