input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#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) {
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
... | #fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
... | #fixed code
@Override
public void onResponse(SearchResponse response) {
long timeTaken = System.currentTimeMillis() - timeLastQuery;
Aggregations aggregs = response.getAggregations();
if (aggregs == null) {
isInQuery.set(false);
retur... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 =... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute(Tuple input) {
_collector.ack(input);
// this bolt can be connected to anything
// we just want to trigger a new search when the input is a tick tuple
if (!TupleUtils.isTick(input)) {
return;... | #fixed code
@Override
public void execute(Tuple input) {
_collector.ack(input);
// this bolt can be connected to anything
// we just want to trigger a new search when the input is a tick tuple
if (!TupleUtils.isTick(input)) {
return;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#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)"
... | #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)"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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).... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<RegexRule> readRules(String rulesFile) {
List<RegexRule> rules = new ArrayList<RegexRule>();
try {
InputStream regexStream = getClass().getClassLoader()
.getResourceAsStream(rulesFile);
Reader re... | #fixed code
private List<RegexRule> readRules(String rulesFile) {
List<RegexRule> rules = new ArrayList<RegexRule>();
try {
InputStream regexStream = getClass().getClassLoader()
.getResourceAsStream(rulesFile);
Reader reader =... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<RegexRule> readRules(String rulesFile) {
List<RegexRule> rules = new ArrayList<RegexRule>();
try {
InputStream regexStream = getClass().getClassLoader()
.getResourceAsStream(rulesFile);
Reader re... | #fixed code
private List<RegexRule> readRules(String rulesFile) {
List<RegexRule> rules = new ArrayList<RegexRule>();
try {
InputStream regexStream = getClass().getClassLoader()
.getResourceAsStream(rulesFile);
Reader reader = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void populateBuffer() {
if (lastDate == null) {
lastDate = new Date();
}
String formattedLastDate = ISODateTimeFormat.dateTimeNoMillis().print(
lastDate.getTime());
LOG.info("{} Popul... | #fixed code
@Override
protected void populateBuffer() {
if (queryDate == null) {
queryDate = new Date();
lastTimeResetToNOW = Instant.now();
}
String formattedLastDate = ISODateTimeFormat.dateTimeNoMillis().print(
quer... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static String getCharsetFromBOM(final byte[] byteData) {
BOMInputStream bomIn = new BOMInputStream(new ByteArrayInputStream(
byteData));
try {
ByteOrderMark bom = bomIn.getBOM();
if (bom != null) {
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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()) {
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void populateBuffer() {
if (lastDate == null) {
lastDate = String.format(DATEFORMAT, new Date());
}
LOG.info("{} Populating buffer with nextFetchDate <= {}", logIdprefix,
lastDate);
Q... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
partitionField = ConfUtils.getString(stormConf,
ESStatusRoutingFieldParamName);
bucketSortField = ConfUtils.getString(stormCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
indexName = ConfUtils.getString(stormConf, ESStatusIndexNameParamName,
"status");
docType = ConfUtils.getString(stormCon... | #fixed code
@Override
public void open(Map stormConf, TopologyContext context,
SpoutOutputCollector collector) {
maxInFlightURLsPerBucket = ConfUtils.getInt(stormConf,
ESStatusMaxInflightParamName, 1);
maxBufferSize = ConfUtils.getInt(stor... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void parseXml_empty() {
Result<IntegerProperty> result = parseXCalProperty("", marshaller);
IntegerProperty prop = result.getValue();
assertNull(prop.getValue());
assertWarnings(0, result.getWarnings());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void writeXml() {
DateTimePropertyImpl prop = new DateTimePropertyImpl(datetime);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<date-time>2013-0... | #fixed code
@Test
public void writeXml() {
DateTimePropertyImpl prop = new DateTimePropertyImpl(datetime);
assertWriteXml("<date-time>2013-06-11T13:43:02Z</date-time>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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,... | #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);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void writeXml_missing_both() {
Geo prop = new Geo(null, null);
assertWriteXml("", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void basic() throws Exception {
ICalendar ical = new ICalendar();
VEvent event = new VEvent();
event.setSummary("summary");
ical.addEvent(event);
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.write(ical);... | #fixed code
@Test
public void basic() throws Exception {
ICalendar ical = new ICalendar();
VEvent event = new VEvent();
event.setSummary("summary");
ical.addEvent(event);
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw);
writer.write(ical);
wri... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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(), ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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>");
... | #fixed code
@Test
public void writeXml_missing_longitude() {
Geo prop = new Geo(12.34, null);
assertWriteXml("<latitude>12.34</latitude>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void writeXml() {
IntegerProperty prop = new IntegerProperty(5);
assertWriteXml("<integer>5</integer>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void writeXml() {
TextPropertyImpl prop = new TextPropertyImpl("text");
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<text>text</text>");
asse... | #fixed code
@Test
public void writeXml() {
TextPropertyImpl prop = new TextPropertyImpl("text");
assertWriteXml("<text>text</text>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected = CannotParseException.class)
public void parseXml_bad_latitude() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<latitude>bad</latitude><longitude>56.78</longitude>");
marshaller.parseXml(element, ... | #fixed code
@Test(expected = CannotParseException.class)
public void parseXml_bad_latitude() {
parseXCalProperty("<latitude>bad</latitude><longitude>56.78</longitude>", marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void writeXml_data_type() {
TextPropertyMarshallerImpl marshaller = new TextPropertyMarshallerImpl(Value.CAL_ADDRESS);
TextPropertyImpl prop = new TextPropertyImpl("mailto:[email protected]");
Document actual = xcalProperty(marshaller);
marshaller.... | #fixed code
@Test
public void writeXml_data_type() {
TextPropertyMarshallerImpl marshaller = new TextPropertyMarshallerImpl(Value.CAL_ADDRESS);
TextPropertyImpl prop = new TextPropertyImpl("mailto:[email protected]");
assertWriteXml("<cal-address>mailto:[email protected]</cal-add... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
}
... | #fixed code
@Test(expected = CannotParseException.class)
public void parseXml_invalid() {
parseXCalProperty("<integer>invalid</integer>", marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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(... | #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.... | Below is the vulnerable code, please generate the patch based on the following information. |
#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.... | #fixed code
@Test
public void parseXml_data_type() {
TextPropertyMarshallerImpl marshaller = new TextPropertyMarshallerImpl(Value.CAL_ADDRESS);
Result<TextPropertyImpl> result = parseXCalProperty("<cal-address>mailto:[email protected]</cal-address>", marshaller);
TextPropertyImpl ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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();
//@... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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,... | #fixed code
@Test(expected = CannotParseException.class)
public void parseXml_bad_longitude() {
parseXCalProperty("<latitude>12.34</latitude><longitude>bad</longitude>", marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void writeXml_missing_latitude() {
Geo prop = new Geo(null, 56.78);
Document actual = xcalProperty(marshaller);
marshaller.writeXml(prop, XmlUtils.getRootElement(actual));
Document expected = xcalProperty(marshaller, "<longitude>56.78</longitude>");... | #fixed code
@Test
public void writeXml_missing_latitude() {
Geo prop = new Geo(null, 56.78);
assertWriteXml("<longitude>56.78</longitude>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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()... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void writeXml_null() {
TextPropertyImpl prop = new TextPropertyImpl(null);
assertWriteXml("<text></text>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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()... | #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();
/... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void writeXml_null() {
DateTimePropertyImpl prop = new DateTimePropertyImpl(null);
assertWriteXml("", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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(... | #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());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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(... | #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);... | Below is the vulnerable code, please generate the patch based on the following information. |
#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());
{
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #fixed code
@Test
public void writeXml_null() {
IntegerProperty prop = new IntegerProperty(null);
assertWriteXml("", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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, ... | #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("... | Below is the vulnerable code, please generate the patch based on the following information. |
#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>" ... | #fixed code
@Test
public void writeXml_data() {
Attachment prop = new Attachment("image/png", "data".getBytes());
assertWriteXml("<binary>" + Base64.encodeBase64String("data".getBytes()) + "</binary>", prop, marshaller);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void parseXml() {
ICalParameters params = new ICalParameters();
Element element = xcalPropertyElement(marshaller, "<text>text</text>");
Result<TextPropertyImpl> result = marshaller.parseXml(element, params);
TextPropertyImpl prop = result.getValue()... | #fixed code
@Test
public void parseXml() {
Result<TextPropertyImpl> result = parseXCalProperty("<text>text</text>", marshaller);
TextPropertyImpl prop = result.getValue();
assertEquals("text", prop.getValue());
assertWarnings(0, result.getWarnings());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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())... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 + "... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void write(String filename) throws IOException {
FileSink output = FileSinkFactory.sinkFor(filename);
write(output, filename);
}
#location 3
#vulnerability type NULL_DEREFERENCE | #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);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void sendAttributeChangedEvent(String eltId, ElementType eltType, String attribute,
AttributeChangeEvent event, Object oldValue, Object newValue) {
//
// Attributes with name beginnig with a dot are hidden.
//
if (passYourWay || attribute.charAt(0) == '.'... | #fixed code
public void sendAttributeChangedEvent(String eltId, ElementType eltType, String attribute,
AttributeChangeEvent event, Object oldValue, Object newValue) {
//
// Attributes with name beginnig with a dot are hidden.
//
if (passYourWay || attribute.charAt(0) == '.')
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#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());
... | #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());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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;
}
... | #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;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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(),... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 ... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void close() {
if (executorService != null) {
synchronized (InetUtils.class) {
if (executorService != null) {
executorService.shutdown();
executorService = null;
}
}
}
}
#location 3
... | #fixed code
@Override
public void close() {
executorService.shutdown();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | 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.