output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void nextTuple() {
// inactive?
if (active == false)
return;
// have anything in the buffer?
if (!buffer.isEmpty()) {
Values fields = buffer.remove();
String url = fields.get(0).toStri... | #vulnerable code
@Override
public void nextTuple() {
// inactive?
if (active == false)
return;
// have anything in the buffer?
if (!buffer.isEmpty()) {
Values fields = buffer.remove();
String url = fields.get(0).... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void nextTuple() {
// inactive?
if (active == false)
return;
// have anything in the buffer?
if (!buffer.isEmpty()) {
Values fields = buffer.remove();
String url = fields.get(0).toStri... | #vulnerable code
@Override
public void nextTuple() {
// inactive?
if (active == false)
return;
// have anything in the buffer?
if (!buffer.isEmpty()) {
Values fields = buffer.remove();
String url = fields.get(0).... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void populateBuffer() {
// not used yet or returned empty results
if (queryDate == null) {
queryDate = new Date();
lastTimeResetToNOW = Instant.now();
lastStartOffset = 0;
}
// been ru... | #vulnerable code
@Override
protected void populateBuffer() {
// not used yet or returned empty results
if (lastDate == null) {
lastDate = new Date();
lastStartOffset = 0;
}
// been running same query for too long and paging dee... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeStartESQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
// reset the value for next fetch d... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeStartESQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
// no more results?
i... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
int alreadyprocessed = 0;
int ... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
// reset the value for next fetc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void filter(String url, byte[] content, DocumentFragment doc,
ParseResult parse) {
// check whether the metadata already contains a lang value
// in which case we normalise its value and use it
Metadata m = parse.get(u... | #vulnerable code
@Override
public void filter(String url, byte[] content, DocumentFragment doc,
ParseResult parse) {
// check whether the metadata already contains a lang value
// in which case we might want to skip
if (mdSkip != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
retur... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
retur... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
SearchHits hits = response.getHits();
LOG.info("{} ES query returned {} hits in {} msec", logIdprefix,
hits.getHits().length, response.getTook().getMillis());
hasFinished =... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
SearchHits hits = response.getHits();
LOG.info("{} ES query returned {} hits in {} msec", logIdprefix,
hits.getHits().length, response.getTook().getMillis());
hasStar... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Client getClient(Map stormConf, String boltType) {
List<String> hosts = new LinkedList<>();
Object addresses = stormConf.get("es." + boltType + ".addresses");
// list
if (addresses instanceof PersistentVector) {
hosts... | #vulnerable code
public static Client getClient(Map stormConf, String boltType) {
String host = ConfUtils.getString(stormConf, "es." + boltType
+ ".hostname");
String clustername = ConfUtils.getString(stormConf, "es." + boltType
+ ".clust... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void store(String url, Status status, Metadata metadata,
Date nextFetch) throws Exception {
// the mysql insert statement
String query = tableName
+ " (url, status, nextfetchdate, metadata, bucket, host)"
... | #vulnerable code
@Override
public void store(String url, Status status, Metadata metadata,
Date nextFetch) throws Exception {
// the mysql insert statement
String query = tableName
+ " (url, status, nextfetchdate, metadata, bucket)"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void nextTuple() {
// inactive?
if (active == false)
return;
// have anything in the buffer?
if (!buffer.isEmpty()) {
Values fields = buffer.remove();
String url = fields.get(0).toStri... | #vulnerable code
@Override
public void nextTuple() {
// inactive?
if (active == false)
return;
// have anything in the buffer?
if (!buffer.isEmpty()) {
Values fields = buffer.remove();
String url = fields.get(0).... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<RegexRule> readRules(String rulesFile) {
List<RegexRule> rules = new ArrayList<RegexRule>();
try {
InputStream regexStream = getClass().getClassLoader()
.getResourceAsStream(rulesFile);
Reader reader = ... | #vulnerable code
private List<RegexRule> readRules(String rulesFile) {
List<RegexRule> rules = new ArrayList<RegexRule>();
try {
InputStream regexStream = getClass().getClassLoader()
.getResourceAsStream(rulesFile);
Reader re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void populateBuffer() {
if (queryDate == null) {
queryDate = new Date();
lastTimeResetToNOW = Instant.now();
}
String formattedLastDate = ISODateTimeFormat.dateTimeNoMillis().print(
quer... | #vulnerable code
@Override
protected void populateBuffer() {
if (lastDate == null) {
lastDate = new Date();
}
String formattedLastDate = ISODateTimeFormat.dateTimeNoMillis().print(
lastDate.getTime());
LOG.info("{} Popul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Date schedule(Status status, Metadata metadata) {
LOG.debug("Scheduling status: {}, metadata: {}", status, metadata);
String signature = metadata.getFirstValue(SIGNATURE_KEY);
String oldSignature = metadata.getFirstValue(SIGNATURE... | #vulnerable code
@Override
public Date schedule(Status status, Metadata metadata) {
LOG.debug("Scheduling status: {}, metadata: {}", status, metadata);
String signature = metadata.getFirstValue(SIGNATURE_KEY);
String oldSignature = metadata.getFirstValue(SIG... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static String getCharsetFromBOM(final byte[] byteData) {
try (BOMInputStream bomIn = new BOMInputStream(
new ByteArrayInputStream(byteData))) {
ByteOrderMark bom = bomIn.getBOM();
if (bom != null) {
retur... | #vulnerable code
private static String getCharsetFromBOM(final byte[] byteData) {
BOMInputStream bomIn = new BOMInputStream(new ByteArrayInputStream(
byteData));
try {
ByteOrderMark bom = bomIn.getBOM();
if (bom != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void nextTuple() {
if (!active)
return;
// synchronize access to buffer needed in case of asynchronous
// queries to the backend
synchronized (buffer) {
// force the refresh of the buffer even if t... | #vulnerable code
@Override
public void nextTuple() {
if (!active)
return;
// synchronize access to buffer needed in case of asynchronous
// queries to the backend
synchronized (buffer) {
if (!buffer.isEmpty()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
// reset the value for next fetch date... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
// reset the value for next fetc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void populateBuffer() {
if (lastDate == null) {
lastDate = new Date();
}
String formattedLastDate = String.format(DATEFORMAT, lastDate);
LOG.info("{} Populating buffer with nextFetchDate <= {}", logIdprefi... | #vulnerable code
@Override
protected void populateBuffer() {
if (lastDate == null) {
lastDate = String.format(DATEFORMAT, new Date());
}
LOG.info("{} Populating buffer with nextFetchDate <= {}", logIdprefix,
lastDate);
Q... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
int alreadyprocessed = 0;
int ... | #vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
SearchHit[] hits = response.getHits().getHits();
int numBuckets = hits.length;
// reset the value for next fetc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void execute(Tuple input) {
// triggered by the arrival of a tuple
// be it a tick or normal one
flushQueues();
if (isTickTuple(input)) {
_collector.ack(input);
return;
}
CountMetr... | #vulnerable code
@Override
public void execute(Tuple input) {
// main thread in charge of acking and failing
// see
// https://github.com/nathanmarz/storm/wiki/Troubleshooting#nullpointerexception-from-deep-inside-storm
int acked = 0;
int fa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | #vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_empty() {
Result<IntegerProperty> result = parseXCalProperty("", marshaller);
IntegerProperty prop = result.getValue();
assertNull(prop.getValue());
assertWarnings(0, result.getWarnings());
} | #vulnerable code
@Test
public void parseXml_empty() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "");
Result<IntegerProperty> result = marshaller.parseXml(element, params);
IntegerProperty prop = result.getValue();
assertNul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml() {
Result<Geo> result = parseXCalProperty("<latitude>12.34</latitude><longitude>56.78</longitude>", marshaller);
Geo prop = result.getValue();
assertEquals(12.34, prop.getLatitude(), 0.001);
assertEquals(56.78, prop.getLongitude(), 0.001);
... | #vulnerable code
@Test
public void parseXml() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<latitude>12.34</latitude><longitude>56.78</longitude>");
Result<Geo> result = marshaller.parseXml(element, params);
Geo prop = result... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_uri() {
Result<Attachment> result = parseXCalProperty("<uri>http://example.com/image.png</uri>", marshaller);
Attachment prop = result.getValue();
assertEquals("http://example.com/image.png", prop.getUri());
assertNull(prop.getData());
asse... | #vulnerable code
@Test
public void parseXml_uri() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<uri>http://example.com/image.png</uri>");
Result<Attachment> result = marshaller.parseXml(element, params);
Attachment prop = res... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_uri() {
Attachment prop = new Attachment("image/png", "http://example.com/image.png");
assertWriteXml("<uri>http://example.com/image.png</uri>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_uri() {
Attachment prop = new Attachment("image/png", "http://example.com/image.png");
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_missing_both() {
Geo prop = new Geo(null, null);
assertWriteXml("", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_missing_both() {
Geo prop = new Geo(null, null);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "");
assertXMLEqual(expected, actua... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void escape_newlines() throws Exception {
ICalendar ical = new ICalendar();
VEvent event = new VEvent();
event.setSummary("summary\nof event");
ical.addEvent(event);
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
write... | #vulnerable code
@Test
public void escape_newlines() throws Exception {
ICalendar ical = new ICalendar();
VEvent event = new VEvent();
event.setSummary("summary\nof event");
ical.addEvent(event);
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void experimental_property() throws Exception {
ICalendar ical = new ICalendar();
ical.addExperimentalProperty("X-NUMBER", "1");
ical.addExperimentalProperty("X-NUMBER", "2");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
... | #vulnerable code
@Test
public void experimental_property() throws Exception {
ICalendar ical = new ICalendar();
ical.addExperimentalProperty("X-NUMBER", "1");
ical.addExperimentalProperty("X-NUMBER", "2");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_data() {
Result<Attachment> result = parseXCalProperty("<binary>" + Base64.encodeBase64String("data".getBytes()) + "</binary>", marshaller);
Attachment prop = result.getValue();
assertNull(prop.getUri());
assertArrayEquals("data".getBytes(), ... | #vulnerable code
@Test
public void parseXml_data() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<binary>" + Base64.encodeBase64String("data".getBytes()) + "</binary>");
Result<Attachment> result = marshaller.parseXml(element, pa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_missing_longitude() {
Geo prop = new Geo(12.34, null);
assertWriteXml("<latitude>12.34</latitude>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_missing_longitude() {
Geo prop = new Geo(12.34, null);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<latitude>12.34</latitude>");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml() {
IntegerProperty prop = new IntegerProperty(5);
assertWriteXml("<integer>5</integer>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml() {
IntegerProperty prop = new IntegerProperty(5);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<integer>5</integer>");
assertXM... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void bad_parameter_value_chars() throws Exception {
ICalendar ical = new ICalendar();
ical.getProductId().addParameter("X-TEST", "\"test\"");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.write(ical);
writer.close... | #vulnerable code
@Test
public void bad_parameter_value_chars() throws Exception {
ICalendar ical = new ICalendar();
ical.getProductId().addParameter("X-TEST", "\"test\"");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.write(ical);
writer... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_missing_latitude() {
Result<Geo> result = parseXCalProperty("<longitude>56.78</longitude>", marshaller);
Geo prop = result.getValue();
assertNull(prop.getLatitude());
assertEquals(56.78, prop.getLongitude(), 0.001);
assertWarnings(0, result... | #vulnerable code
@Test
public void parseXml_missing_latitude() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<longitude>56.78</longitude>");
Result<Geo> result = marshaller.parseXml(element, params);
Geo prop = result.getValue... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void experimental_property_marshaller() throws Exception {
ICalendar ical = new ICalendar();
ical.addProperty(new TestProperty("one"));
ical.addProperty(new TestProperty("two"));
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw... | #vulnerable code
@Test
public void experimental_property_marshaller() throws Exception {
ICalendar ical = new ICalendar();
ical.addProperty(new TestProperty("one"));
ical.addProperty(new TestProperty("two"));
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWri... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml() {
RequestStatus prop = new RequestStatus("1.2.3");
prop.setDescription("description");
prop.setExceptionText("data");
assertWriteXml("<code>1.2.3</code><description>description</description><data>data</data>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml() {
RequestStatus prop = new RequestStatus("1.2.3");
prop.setDescription("description");
prop.setExceptionText("data");
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Documen... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml() {
Result<DateTimePropertyImpl> result = parseXCalProperty("<date-time>2013-06-11T13:43:02Z</date-time>", marshaller);
DateTimePropertyImpl prop = result.getValue();
assertEquals(datetime, prop.getValue());
assertWarnings(0, result.getWarnin... | #vulnerable code
@Test
public void parseXml() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<date-time>2013-06-11T13:43:02Z</date-time>");
Result<DateTimePropertyImpl> result = marshaller.parseXml(element, params);
DateTimePro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void jcal_draft_example2() throws Throwable {
//see: http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-05#page-27
//Note: all whitespace is removed from the expected JSON string it easier to compare it with the actual result
VTimezone usEasternTz;
ICalend... | #vulnerable code
@Test
public void jcal_draft_example2() throws Throwable {
//see: http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-05#page-27
//Note: all whitespace is removed from the expected JSON string it easier to compare it with the actual result
VTimezone usEasternTz;
I... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = CannotParseException.class)
public void parseXml_invalid() {
parseXCalProperty("<integer>invalid</integer>", marshaller);
} | #vulnerable code
@Test(expected = CannotParseException.class)
public void parseXml_invalid() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<integer>invalid</integer>");
marshaller.parseXml(element, params);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_missing_longitude() {
Result<Geo> result = parseXCalProperty("<latitude>12.34</latitude>", marshaller);
Geo prop = result.getValue();
assertEquals(12.34, prop.getLatitude(), 0.001);
assertNull(prop.getLongitude());
assertWarnings(0, result.... | #vulnerable code
@Test
public void parseXml_missing_longitude() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<latitude>12.34</latitude>");
Result<Geo> result = marshaller.parseXml(element, params);
Geo prop = result.getValue(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_data_type() {
TextPropertyMarshallerImpl marshaller = new TextPropertyMarshallerImpl(Value.CAL_ADDRESS);
Result<TextPropertyImpl> result = parseXCalProperty("<cal-address>mailto:johndoe@example.com</cal-address>", marshaller);
TextPropertyImpl ... | #vulnerable code
@Test
public void parseXml_data_type() {
TextPropertyMarshallerImpl marshaller = new TextPropertyMarshallerImpl(Value.CAL_ADDRESS);
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<cal-address>mailto:johndoe@example.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void experimental_component() throws Exception {
ICalendar ical = new ICalendar();
ical.addExperimentalComponent("X-VPARTY");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.write(ical);
writer.close();
//@format... | #vulnerable code
@Test
public void experimental_component() throws Exception {
ICalendar ical = new ICalendar();
ical.addExperimentalComponent("X-VPARTY");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.write(ical);
writer.close();
//@... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = CannotParseException.class)
public void parseXml_bad_longitude() {
parseXCalProperty("<latitude>12.34</latitude><longitude>bad</longitude>", marshaller);
} | #vulnerable code
@Test(expected = CannotParseException.class)
public void parseXml_bad_longitude() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<latitude>12.34</latitude><longitude>bad</longitude>");
marshaller.parseXml(element,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void jcal_draft_example1() throws Throwable {
//see: http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-05#page-25
//Note: all whitespace is removed from the expected JSON string it easier to compare it with the actual result
ICalendar ical = new ICalendar()... | #vulnerable code
@Test
public void jcal_draft_example1() throws Throwable {
//see: http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-05#page-25
//Note: all whitespace is removed from the expected JSON string it easier to compare it with the actual result
ICalendar ical = new ICale... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_null() {
TextPropertyImpl prop = new TextPropertyImpl(null);
assertWriteXml("<text></text>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_null() {
TextPropertyImpl prop = new TextPropertyImpl(null);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<text></text>");
asser... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void override_marshaller() throws Exception {
ICalendar ical = new ICalendar();
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.registerMarshaller(new MyVersionMarshaller());
writer.write(ical);
writer.close();
/... | #vulnerable code
@Test
public void override_marshaller() throws Exception {
ICalendar ical = new ICalendar();
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.registerMarshaller(new MyVersionMarshaller());
writer.write(ical);
writer.close()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_null() {
DateTimePropertyImpl prop = new DateTimePropertyImpl(null);
assertWriteXml("", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_null() {
DateTimePropertyImpl prop = new DateTimePropertyImpl(null);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "");
assertXMLE... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml() {
Result<IntegerProperty> result = parseXCalProperty("<integer>5</integer>", marshaller);
IntegerProperty prop = result.getValue();
assertIntEquals(5, prop.getValue());
assertWarnings(0, result.getWarnings());
} | #vulnerable code
@Test
public void parseXml() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<integer>5</integer>");
Result<IntegerProperty> result = marshaller.parseXml(element, params);
IntegerProperty prop = result.getValue(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml_missing_both() {
Result<Geo> result = parseXCalProperty("", marshaller);
Geo prop = result.getValue();
assertNull(prop.getLatitude());
assertNull(prop.getLongitude());
assertWarnings(0, result.getWarnings());
} | #vulnerable code
@Test
public void parseXml_missing_both() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "");
Result<Geo> result = marshaller.parseXml(element, params);
Geo prop = result.getValue();
assertNull(prop.getLatitud... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml() {
Geo prop = new Geo(12.34, 56.78);
assertWriteXml("<latitude>12.34</latitude><longitude>56.78</longitude>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml() {
Geo prop = new Geo(12.34, 56.78);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<latitude>12.34</latitude><longitude>56.78</lon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void example2() throws Throwable {
VTimezone usEasternTz;
ICalendar ical = new ICalendar();
ical.getProperties().clear();
ical.setProductId("-//RDU Software//NONSGML HandCal//EN");
ical.setVersion(Version.v2_0());
{
usEasternTz = new VTimezone(null);... | #vulnerable code
@Test
public void example2() throws Throwable {
VTimezone usEasternTz;
ICalendar ical = new ICalendar();
ical.getProperties().clear();
ical.setProductId("-//RDU Software//NONSGML HandCal//EN");
ical.setVersion(Version.v2_0());
{
usEasternTz = new VTimezone(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void write_example2() throws Throwable {
//see: RFC 6321 p.51
VTimezone usEasternTz;
ICalendar ical = new ICalendar();
ical.getProperties().clear();
ical.setProductId("-//Example Inc.//Example Client//EN");
ical.setVersion(Version.v2_0());
{
usEast... | #vulnerable code
@Test
public void write_example2() throws Throwable {
//see: RFC 6321 p.51
VTimezone usEasternTz;
ICalendar ical = new ICalendar();
ical.getProperties().clear();
ical.setProductId("-//Example Inc.//Example Client//EN");
ical.setVersion(Version.v2_0());
{
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void caret_encoding() throws Exception {
ICalendar ical = new ICalendar();
ical.getProductId().addParameter("X-TEST", "\"test\"");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.setCaretEncodingEnabled(true);
write... | #vulnerable code
@Test
public void caret_encoding() throws Exception {
ICalendar ical = new ICalendar();
ical.getProductId().addParameter("X-TEST", "\"test\"");
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.setCaretEncodingEnabled(true);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void experimental_component_marshaller() throws Exception {
ICalendar ical = new ICalendar();
ical.addComponent(new Party());
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.registerMarshaller(new PartyMarshaller());
... | #vulnerable code
@Test
public void experimental_component_marshaller() throws Exception {
ICalendar ical = new ICalendar();
ical.addComponent(new Party());
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.registerMarshaller(new PartyMarshalle... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_null() {
IntegerProperty prop = new IntegerProperty(null);
assertWriteXml("", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_null() {
IntegerProperty prop = new IntegerProperty(null);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "");
assertXMLEqual(expec... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parseXml() {
Result<RequestStatus> result = parseXCalProperty("<code>1.2.3</code><description>description</description><data>data</data>", marshaller);
RequestStatus prop = result.getValue();
assertEquals("1.2.3", prop.getStatusCode());
assertEquals("... | #vulnerable code
@Test
public void parseXml() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<code>1.2.3</code><description>description</description><data>data</data>");
Result<RequestStatus> result = marshaller.parseXml(element, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeXml_data() {
Attachment prop = new Attachment("image/png", "data".getBytes());
assertWriteXml("<binary>" + Base64.encodeBase64String("data".getBytes()) + "</binary>", prop, marshaller);
} | #vulnerable code
@Test
public void writeXml_data() {
Attachment prop = new Attachment("image/png", "data".getBytes());
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<binary>" ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void skipMeException() throws Exception {
ICalendar ical = new ICalendar();
ical.addProperty(new TestProperty("value"));
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.registerMarshaller(new SkipMeMarshaller());
wr... | #vulnerable code
@Test
public void skipMeException() throws Exception {
ICalendar ical = new ICalendar();
ical.addProperty(new TestProperty("value"));
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.registerMarshaller(new SkipMeMarshaller())... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void createInvertedIndex() {
if (currentIndex == null)
{
currentIndex = Index.createIndex(path,prefix);
if (currentIndex == null)
{
logger.error("No index at ("+path+","+prefix+") to build an inverted index for ");
return;
}
}
long beginTimesta... | #vulnerable code
public void createInvertedIndex() {
if (currentIndex == null)
{
currentIndex = Index.createIndex(path,prefix);
if (currentIndex == null)
{
logger.error("No index at ("+path+","+prefix+") to build an inverted index for ");
}
}
long beginTimestamp = S... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void doEvaluation(int expectedQueryCount, String qrels, float expectedMAP) throws Exception
{
// Writer w = Files.writeFileWriter(ApplicationSetup.TREC_QRELS);
// System.err.println("Writing qrel files files to " + ApplicationSetup.TREC_QRELS);
// w.write(qrels + "... | #vulnerable code
protected void doEvaluation(int expectedQueryCount, String qrels, float expectedMAP) throws Exception
{
// Writer w = Files.writeFileWriter(ApplicationSetup.TREC_QRELS);
// System.err.println("Writing qrel files files to " + ApplicationSetup.TREC_QRELS);
// w.write(qre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void createInvertedIndex() {
if (currentIndex == null)
{
currentIndex = Index.createIndex(path,prefix);
if (currentIndex == null)
{
logger.error("No index at ("+path+","+prefix+") to build an inverted index for ");
return;
}
}
final long beginT... | #vulnerable code
public void createInvertedIndex() {
if (currentIndex == null)
{
currentIndex = Index.createIndex(path,prefix);
if (currentIndex == null)
{
logger.error("No index at ("+path+","+prefix+") to build an inverted index for ");
}
}
final long beginTimesta... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void write(String filename) throws IOException {
FileSink output = FileSinkFactory.sinkFor(filename);
if(output != null) {
write(output, filename);
} else {
throw new IOException("No sink writer for "+filename);
}
} | #vulnerable code
public void write(String filename) throws IOException {
FileSink output = FileSinkFactory.sinkFor(filename);
write(output, filename);
}
#location 3
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void checkElementStyleGroup(Element element) {
StyleGroup oldGroup = getGroup(getElementGroup(element));
// Get the old element "dynamic" status.
boolean isDyn = false;
// Get the old event set for the given element.
StyleGroup.ElementEvents events = null;
... | #vulnerable code
public void checkElementStyleGroup(Element element) {
StyleGroup oldGroup = getGroup(getElementGroup(element));
// Get the old element "dynamic" status.
boolean isDyn = oldGroup.isElementDynamic(element);
// Get the old event set for the given element.
StyleG... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void checkZIndexAndShadow(Rule oldRule, Rule newRule) {
if (oldRule != null) {
if (oldRule.selector.getId() != null
|| oldRule.selector.getClazz() != null) {
// We may accelerate things a bit when a class or id style is
// modified,
// since only ... | #vulnerable code
protected void checkZIndexAndShadow(Rule oldRule, Rule newRule) {
if (oldRule != null) {
if (oldRule.selector.getId() != null
|| oldRule.selector.getClazz() != null) {
// We may accelerate things a bit when a class or id style is
// modified,
// since... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void print(EventType type, Args args) {
if (!enable.get(type))
return;
String out = formats.get(type);
for (String k : args.keySet()) {
Object o = args.get(k);
out = out.replace(String.format("%%%s%%", k), o == null ? "null"
: o.toString());
}
... | #vulnerable code
private void print(EventType type, Args args) {
if (!enable.get(type))
return;
String out = formats.get(type);
for (String k : args.keySet()) {
Object o = args.get(k);
out = out.replace(String.format("%%%s%%", k), o == null ? "null"
: o.toString());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String... args) throws IOException {
HashMap<Option, String> options = new HashMap<Option, String>();
LinkedList<String> others = new LinkedList<String>();
for (Option option : Option.values())
if (option.defaultValue != null)
options.put(o... | #vulnerable code
public static void main(String... args) throws IOException {
HashMap<Option, String> options = new HashMap<Option, String>();
LinkedList<String> others = new LinkedList<String>();
for (Option option : Option.values())
if (option.defaultValue != null)
options... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("unchecked")
public <T extends Edge> T removeEdge(String from, String to)
throws ElementNotFoundException {
GraphicNode node0 = (GraphicNode) styleGroups.getNode(from);
GraphicNode node1 = (GraphicNode) styleGroups.getNode(to);
if (node0 != null && n... | #vulnerable code
@SuppressWarnings("unchecked")
public <T extends Edge> T removeEdge(String from, String to)
throws ElementNotFoundException {
GraphicNode node0 = (GraphicNode) styleGroups.getNode(from);
GraphicNode node1 = (GraphicNode) styleGroups.getNode(to);
if (node0 != nul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("all")
public <T extends Edge> T getEdgeToward(String id) {
List<? extends Edge> edges = mygraph.connectivity.get(this);
for (Edge edge : edges) {
if (edge.getOpposite(this).getId().equals(id))
return (T) edge;
}
return null;
} | #vulnerable code
@SuppressWarnings("all")
public <T extends Edge> T getEdgeToward(String id) {
ArrayList<? extends Edge> edges = mygraph.connectivity.get(this);
for (Edge edge : edges) {
if (edge.getOpposite(this).getId().equals(id))
return (T) edge;
}
return null;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void printConnectivity() {
Iterator<GraphicNode> keys = connectivity.keySet().iterator();
System.err.printf("Graphic graph connectivity:%n");
while (keys.hasNext()) {
GraphicNode node = keys.next();
System.err.printf(" [%s] -> ", node.getId());
Iterabl... | #vulnerable code
public void printConnectivity() {
Iterator<GraphicNode> keys = connectivity.keySet().iterator();
System.err.printf("Graphic graph connectivity:%n");
while (keys.hasNext()) {
GraphicNode node = keys.next();
System.err.printf(" [%s] -> ", node.getId());
A... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("unchecked")
public <T extends Edge> T removeEdge(String from, String to)
throws ElementNotFoundException {
GraphicNode node0 = (GraphicNode) styleGroups.getNode(from);
GraphicNode node1 = (GraphicNode) styleGroups.getNode(to);
if (node0 != null && n... | #vulnerable code
@SuppressWarnings("unchecked")
public <T extends Edge> T removeEdge(String from, String to)
throws ElementNotFoundException {
GraphicNode node0 = (GraphicNode) styleGroups.getNode(from);
GraphicNode node1 = (GraphicNode) styleGroups.getNode(to);
if (node0 != nul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void insertKeyValues(KeyValues kv) throws IOException {
if (kv.key != null) {
if (inGraph) {
if (kv.key.equals("node") || kv.key.equals("add-node")) {
handleAddNode(kv);
} else if (kv.key.equals("edge") || kv.key.equals("add-edge")) {
handleAddEd... | #vulnerable code
protected void insertKeyValues(KeyValues kv) throws IOException {
if (kv.key != null) {
if (inGraph) {
if (kv.key.equals("node") || kv.key.equals("add-node")) {
handleAddNode(kv);
} else if (kv.key.equals("edge") || kv.key.equals("add-edge")) {
handl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void savePropertyGroup(String fileName, String group, InputStream inputstream) throws IOException {
List<PropertyItemVO> items = parseInputFile(inputstream);
if (!items.isEmpty()) {
String groupFullPath = ZKPaths.makePath(ZKPaths.makePath(nodeAuth.getAuthedNode(),... | #vulnerable code
private void savePropertyGroup(String fileName, String group, InputStream inputstream) throws IOException {
Reader reader = new InputStreamReader(inputstream, Charsets.UTF_8);
Properties properties = new Properties();
properties.load(reader);
if (!properties.isEmpt... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Map<String, String> loadLocalProperties(String rootNode, String group) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(rootNode) && !Strings.isNullOrEmpty(group), "rootNode or group cannot be empty.");
Map<String, String> properties = null;
final String... | #vulnerable code
public static Map<String, String> loadLocalProperties(String rootNode, String group) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(rootNode) && !Strings.isNullOrEmpty(group), "rootNode or group cannot be empty.");
Map<String, String> properties = null;
final ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) {
String rootNode = "/projectx/modulex";
ZookeeperConfigProfile profile = new ZookeeperConfigProfile("zk.host", rootNode, true);
ZookeeperConfigGroup dbConfigs = new ZookeeperConfigGroup(null, profile, "db");
dbConfigs.setConfigLoc... | #vulnerable code
public static void main(String[] args) {
ZookeeperConfigProfile profile = new ZookeeperConfigProfile("zk.host", "/projectx/modulex", true);
profile.setLocalCacheFolder("/your/local/config/folder");
ConfigGroup dbConfigs = new ZookeeperConfigGroup(null, profile, "d... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) {
ConfigFactory configFactory = new ConfigFactory("zoo.host1:8181", "/projectx/modulex", true);
ConfigNode propertyGroup1 = configFactory.getConfigNode("property-group1");
System.out.println(propertyGroup1);
// Listen changes
pr... | #vulnerable code
public static void main(String[] args) {
ConfigFactory configFactory = new ConfigFactory("zoo.host1:8181", "/projectx/modulex");
ConfigNode propertyGroup1 = configFactory.getConfigNode("property-group1");
System.out.println(propertyGroup1);
// Listen changes
pr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@ManagedOperation
public void setProperty(String name, String value) {
if (!environment.getPropertySources().contains(MANAGER_PROPERTY_SOURCE)) {
synchronized (map) {
if (!environment.getPropertySources().contains(MANAGER_PROPERTY_SOURCE)) {
MapPropertySource sou... | #vulnerable code
@ManagedOperation
public void setProperty(String name, String value) {
if (!environment.getPropertySources().contains(MANAGER_PROPERTY_SOURCE)) {
synchronized (map) {
if (!environment.getPropertySources().contains(MANAGER_PROPERTY_SOURCE)) {
MapPropertySour... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void close() {
executorService.shutdown();
} | #vulnerable code
@Override
public void close() {
if (executorService != null) {
synchronized (InetUtils.class) {
if (executorService != null) {
executorService.shutdown();
executorService = null;
}
}
}
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private String normalizePem(String data) {
PEMKeyPair pemKeyPair = null;
try (PEMParser pemParser = new PEMParser(new StringReader(data))) {
pemKeyPair = (PEMKeyPair) pemParser.readObject();
PrivateKeyInfo privateKeyInfo = pemKeyPair.getPrivateKeyInfo();
StringWrit... | #vulnerable code
private String normalizePem(String data) {
PEMParser pemParser = new PEMParser(new StringReader(data));
PEMKeyPair pemKeyPair = null;
try {
pemKeyPair = (PEMKeyPair) pemParser.readObject();
PrivateKeyInfo privateKeyInfo = pemKeyPair.getPrivateKeyInfo();
Str... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
void shouldAutoEnableCaching() {
ApplicationContextRunner contextRunner = baseApplicationRunner();
contextRunner.run(context -> {
assertThat(context.getBeansOfType(CacheManager.class)).hasSize(1);
assertThat(((CacheManager) context.getBean("loadBalancerCacheMan... | #vulnerable code
@Test
void shouldAutoEnableCaching() {
AnnotationConfigApplicationContext context = setup("");
assertThat(context.getBeansOfType(CacheManager.class)).isNotEmpty();
assertThat(context.getBeansOfType(CacheManager.class).get("cacheManager"))
.isNotInstanceOf(NoOpCa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void newConnectionManagerWithTTL() {
HttpClientConnectionManager connectionManager = new DefaultApacheHttpClientConnectionManagerFactory()
.newConnectionManager(false, 2, 6, 56L, TimeUnit.DAYS, null);
then(((PoolingHttpClientConnectionManager) connectionMan... | #vulnerable code
@Test
public void newConnectionManagerWithTTL() throws Exception {
HttpClientConnectionManager connectionManager = new DefaultApacheHttpClientConnectionManagerFactory()
.newConnectionManager(false, 2, 6, 56L, TimeUnit.DAYS, null);
then(((PoolingHttpClientConnectio... | 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.