input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Override
public void contextPrepared(ConfigurableApplicationContext context) {
System.out.printf("Log files: %s/logs/%n", NACOS_HOME);
System.out.printf("Conf files: %s/conf/%n", NACOS_HOME);
System.out.printf("Data files: %s/data/%n", NACOS... | #fixed code
@Override
public void contextPrepared(ConfigurableApplicationContext context) {
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void checkLocalConfig(CacheData cacheData) {
final String dataId = cacheData.dataId;
final String group = cacheData.group;
final String tenant = cacheData.tenant;
File path = LocalConfigInfoProcessor.getFailoverFile(agent.getName(... | #fixed code
private void checkLocalConfig(CacheData cacheData) {
final String dataId = cacheData.dataId;
final String group = cacheData.group;
final String tenant = cacheData.tenant;
File path = LocalConfigInfoProcessor.getFailoverFile(agent.getName(), dat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException {
Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral));
... | #fixed code
public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException {
Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");... | #fixed code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void update(SwitchDomain newSwitchDomain) {
switchDomain.setMasters(newSwitchDomain.getMasters());
switchDomain.setAdWeightMap(newSwitchDomain.getAdWeightMap());
switchDomain.setDefaultPushCacheMillis(newSwitchDomain.getDefaultPushCacheMil... | #fixed code
public void update(SwitchDomain newSwitchDomain) {
switchDomain.setMasters(newSwitchDomain.getMasters());
switchDomain.setAdWeightMap(newSwitchDomain.getAdWeightMap());
switchDomain.setDefaultPushCacheMillis(newSwitchDomain.getDefaultPushCacheMillis())... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@NeedAuth
@RequestMapping("/remvIP4Dom")
public String remvIP4Dom(HttpServletRequest request) throws Exception {
String dom = WebUtils.required(request, "dom");
String ipListString = WebUtils.required(request, "ipList");
Loggers.DEBUG_LO... | #fixed code
@NeedAuth
@RequestMapping("/remvIP4Dom")
public String remvIP4Dom(HttpServletRequest request) throws Exception {
String dom = WebUtils.required(request, "dom");
String ipListString = WebUtils.required(request, "ipList");
Map<String, String> pr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");... | #fixed code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException {
if (subscribe) {
return Balancer.RandomByWeight.selectHost(
hostReactor.ge... | #fixed code
@Override
public Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException {
if (subscribe) {
return Balancer.RandomByWeight.selectHost(
hostReactor.getServi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException {
Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral));
... | #fixed code
public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException {
Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");... | #fixed code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void initNamespace(Properties properties) {
String namespaceTmp = null;
String isUseCloudNamespaceParsing =
properties.getProperty(PropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
System.getProperty(SystemPropertyKeyC... | #fixed code
private void initNamespace(Properties properties) {
namespace = ParamUtil.parseNamespace(properties);
properties.put(PropertyKeyConst.NAMESPACE, namespace);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("... | #fixed code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("X-DOOR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void evolutionVCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("John_Doe_EVOLUTION.vcf")));
reader.setCompatibilityMode(CompatibilityMode.EVOLUTION);
VCard vcard = reader.readNext();
... | #fixed code
@Test
public void evolutionVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_EVOLUTION.vcf"));
reader.setCompatibilityMode(CompatibilityMode.EVOLUTION);
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("... | #fixed code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("X-DOOR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setFamily("Angstadt");
n.setGiven("Michael");
n.addPrefix("Mr");
vcard.setStructuredName(n);
vcard.setFormattedName(new F... | #fixed code
public static void main(String[] args) throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setFamily("Angstadt");
n.setGiven("Michael");
n.addPrefix("Mr");
vcard.setStructuredName(n);
vcard.setFormattedName(new Formatt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void test() throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setGiven("Michael");
n.setFamily("Angstadt");
vcard.setStructuredName(n);
FormattedNameType fn = new FormattedNameType("Michael Angstadt... | #fixed code
@Test
public void test() throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setGiven("Michael");
n.setFamily("Angstadt");
vcard.setStructuredName(n);
FormattedNameType fn = new FormattedNameType("Michael Angstadt");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void doUnmarshalValue() throws Exception {
//Note: Marshalling of 2.1 AGENT types is tested in VCardWriterTest
VCardVersion version = VCardVersion.V3_0;
List<String> warnings = new ArrayList<String>();
CompatibilityMode compatibilityMode = Compatibil... | #fixed code
@Test
public void doUnmarshalValue() throws Exception {
VCardVersion version = VCardVersion.V3_0;
List<String> warnings = new ArrayList<String>();
CompatibilityMode compatibilityMode = CompatibilityMode.RFC;
VCardSubTypes subTypes;
AgentType t;
//with URL
t = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void msOutlookVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_MS_OUTLOOK.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
St... | #fixed code
@Test
public void msOutlookVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_MS_OUTLOOK.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
Structur... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void lotusNotesVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_LOTUS_NOTES.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//PRODID
... | #fixed code
@Test
public void lotusNotesVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_LOTUS_NOTES.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//PRODID
{
P... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public T find(V value) {
return find(value, false, false);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public T find(V value) {
checkInit();
for (T obj : preDefined) {
if (matches(obj, value)) {
return obj;
}
}
return null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("... | #fixed code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("X-DOOR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void doUnmarshalValue(String value, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) {
value = VCardStringUtils.unescape(value);
if (subTypes.getValue() != null) {
url = value;
} else {
VCardReader reader =... | #fixed code
@Override
protected void doUnmarshalValue(String value, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) {
if (subTypes.getValue() != null) {
setUrl(VCardStringUtils.unescape(value));
} else {
//instruct the marshaller to look for an e... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void outlook2007VCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("outlook-2007.vcf")));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion())... | #fixed code
@Test
public void outlook2007VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2007.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
StructuredNam... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void outlook2007VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2007.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
Structu... | #fixed code
@Test
public void outlook2007VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2007.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
StructuredNam... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void gmailVCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("John_Doe_GMAIL.vcf")));
reader.setCompatibilityMode(CompatibilityMode.GMAIL);
VCard vcard = reader.readNext();
//VERSION
... | #fixed code
@Test
public void gmailVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_GMAIL.vcf"));
reader.setCompatibilityMode(CompatibilityMode.GMAIL);
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public T get(V value) {
return find(value, true, true);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public T get(V value) {
T found = find(value);
if (found != null) {
return found;
}
synchronized (runtimeDefined) {
for (T obj : runtimeDefined) {
if (matches(obj, value)) {
return obj;
}
}
T created = create(value);
runtimeDefined.add(creat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void labels() throws Exception {
VCard vcard = new VCard();
//address with label
AddressType adr = new AddressType();
adr.setStreetAddress("123 Main St.");
adr.setLocality("Austin");
adr.setRegion("TX");
adr.setPostalCode("12345");
adr.setLab... | #fixed code
@Test
public void labels() throws Exception {
VCard vcard = new VCard();
//address with label
AddressType adr = new AddressType();
adr.setStreetAddress("123 Main St.");
adr.setLocality("Austin");
adr.setRegion("TX");
adr.setPostalCode("12345");
adr.setLabel("12... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("... | #fixed code
@Test
public void subTypes() throws Exception {
VCard vcard = new VCard();
//one sub type
AddressType adr = new AddressType();
adr.getSubTypes().put("X-DOORMAN", "true");
vcard.addAddress(adr);
//two types
adr = new AddressType();
adr.getSubTypes().put("X-DOOR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void lotusNotesVCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("John_Doe_LOTUS_NOTES.vcf")));
reader.setCompatibilityMode(CompatibilityMode.MAC_ADDRESS_BOOK);
VCard vcard = reader.read... | #fixed code
@Test
public void lotusNotesVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_LOTUS_NOTES.vcf"));
reader.setCompatibilityMode(CompatibilityMode.MAC_ADDRESS_BOOK);
VCard vcard = reader.readNext();
//VERSION
assert... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setFamily("Angstadt");
n.setGiven("Michael");
n.addPrefix("Mr");
vcard.setStructuredName(n);
vcard.setFormattedName(new F... | #fixed code
public static void main(String[] args) throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setFamily("Angstadt");
n.setGiven("Michael");
n.addPrefix("Mr");
vcard.setStructuredName(n);
vcard.setFormattedName(new Formatt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void evolutionVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_EVOLUTION.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//URL
{
I... | #fixed code
@Test
public void evolutionVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_EVOLUTION.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//URL
{
Iterato... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void thunderbird() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("thunderbird-MoreFunctionsForAddressBook-extension.vcf")));
reader.setCompatibilityMode(CompatibilityMode.MAC_ADDRESS_BOOK);
... | #fixed code
@Test
public void thunderbird() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("thunderbird-MoreFunctionsForAddressBook-extension.vcf"));
reader.setCompatibilityMode(CompatibilityMode.MAC_ADDRESS_BOOK);
VCard vcard = reader.readNext... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void gmailSingle() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("gmail-single.vcf")));
reader.setCompatibilityMode(CompatibilityMode.GMAIL);
VCard vcard = reader.readNext();
//VERSION
... | #fixed code
@Test
public void gmailSingle() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("gmail-single.vcf"));
reader.setCompatibilityMode(CompatibilityMode.GMAIL);
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void gmailSingle() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("gmail-single.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//FN
{
FormattedNa... | #fixed code
@Test
public void gmailSingle() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("gmail-single.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//FN
{
FormattedNameType... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void msOutlookVCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("John_Doe_MS_OUTLOOK.vcf")));
reader.setCompatibilityMode(CompatibilityMode.MS_OUTLOOK);
VCard vcard = reader.readNext();
... | #fixed code
@Test
public void msOutlookVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_MS_OUTLOOK.vcf"));
reader.setCompatibilityMode(CompatibilityMode.MS_OUTLOOK);
VCard vcard = reader.readNext();
//VERSION
assertEquals(V... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void doMarshalValue(StringBuilder sb, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) {
//VCardWriter handles 2.1 AGENT types that have an embedded vCard.
//this method will not be called for these instances
if ... | #fixed code
@Override
protected void doMarshalValue(StringBuilder sb, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) {
if (url != null) {
sb.append(url);
} else if (vcard != null) {
throw new EmbeddedVCardException(vcard);
} else {
throw ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void iPhoneVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_IPHONE.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//PRODID
{
Prod... | #fixed code
@Test
public void iPhoneVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_IPHONE.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//PRODID
{
ProdIdType... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void labels() throws Exception {
VCard vcard = new VCard();
//address with label
AddressType adr = new AddressType();
adr.setStreetAddress("123 Main St.");
adr.setLocality("Austin");
adr.setRegion("TX");
adr.setPostalCode("12345");
adr.setLab... | #fixed code
@Test
public void labels() throws Exception {
VCard vcard = new VCard();
//address with label
AddressType adr = new AddressType();
adr.setStreetAddress("123 Main St.");
adr.setLocality("Austin");
adr.setRegion("TX");
adr.setPostalCode("12345");
adr.setLabel("12... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void thunderbird() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("thunderbird-MoreFunctionsForAddressBook-extension.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getV... | #fixed code
@Test
public void thunderbird() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("thunderbird-MoreFunctionsForAddressBook-extension.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void doUnmarshalValue(Element element, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) throws VCardException {
Element ele = XCardUtils.getFirstElement(element.getChildNodes());
value = ele.getTextContent();
if (... | #fixed code
@Override
protected void doUnmarshalValue(Element element, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) throws VCardException {
String value = XCardUtils.getFirstChildText(element, "text", "uri");
if (value != null) {
parseValue(value... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void outlook2003VCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("outlook-2003.vcf")));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion())... | #fixed code
@Test
public void outlook2003VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2003.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
StructuredNam... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void iPhoneVCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("John_Doe_IPHONE.vcf")));
reader.setCompatibilityMode(CompatibilityMode.I_PHONE);
VCard vcard = reader.readNext();
//VERSI... | #fixed code
@Test
public void iPhoneVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_IPHONE.vcf"));
reader.setCompatibilityMode(CompatibilityMode.I_PHONE);
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersio... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setFamily("Angstadt");
n.setGiven("Michael");
n.addPrefix("Mr");
vcard.setStructuredName(n);
vcard.setFormattedName(new F... | #fixed code
public static void main(String[] args) throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setFamily("Angstadt");
n.setGiven("Michael");
n.addPrefix("Mr");
vcard.setStructuredName(n);
vcard.setFormattedName(new Formatt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void macAddressBookVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_MAC_ADDRESS_BOOK.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//... | #fixed code
@Test
public void macAddressBookVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_MAC_ADDRESS_BOOK.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//N
{
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void macAddressBookVCard() throws Exception {
VCardReader reader = new VCardReader(new InputStreamReader(getClass().getResourceAsStream("John_Doe_MAC_ADDRESS_BOOK.vcf")));
reader.setCompatibilityMode(CompatibilityMode.MAC_ADDRESS_BOOK);
VCard vcard = re... | #fixed code
@Test
public void macAddressBookVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_MAC_ADDRESS_BOOK.vcf"));
reader.setCompatibilityMode(CompatibilityMode.MAC_ADDRESS_BOOK);
VCard vcard = reader.readNext();
//VERSION... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void embeddedVCard() throws Exception {
VCard vcard = new VCard();
FormattedNameType fn = new FormattedNameType("Michael Angstadt");
vcard.setFormattedName(fn);
VCard agentVcard = new VCard();
agentVcard.setFormattedName(new FormattedNameType("Age... | #fixed code
@Test
public void embeddedVCard() throws Exception {
VCard vcard = new VCard();
FormattedNameType fn = new FormattedNameType("Michael Angstadt");
vcard.setFormattedName(fn);
VCard agentVcard = new VCard();
agentVcard.setFormattedName(new FormattedNameType("Agent 007... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void test() throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setGiven("Michael");
n.setFamily("Angstadt");
vcard.setStructuredName(n);
FormattedNameType fn = new FormattedNameType("Michael Angstadt... | #fixed code
@Test
public void test() throws Exception {
VCard vcard = new VCard();
StructuredNameType n = new StructuredNameType();
n.setGiven("Michael");
n.setFamily("Angstadt");
vcard.setStructuredName(n);
FormattedNameType fn = new FormattedNameType("Michael Angstadt");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void gmailVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_GMAIL.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//FN
{
FormattedN... | #fixed code
@Test
public void gmailVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_GMAIL.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//FN
{
FormattedNameTyp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void outlook2003VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2003.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
Structu... | #fixed code
@Test
public void outlook2003VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2003.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
StructuredNam... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> execute(TsLintExecutorConfig config, List<String> files) {
if (config == null) {
throw new IllegalArgumentException("config");
}
if (files == null) {
throw new IllegalArgumentException("files")... | #fixed code
public List<String> execute(TsLintExecutorConfig config, List<String> files) {
if (config == null) {
throw new IllegalArgumentException("config");
}
else if (files == null) {
throw new IllegalArgumentException("files");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String getCommandOutput(Command thisCommand, StreamConsumer stdOutConsumer, StreamConsumer stdErrConsumer, File tslintOutputFile, Integer timeoutMs) {
LOG.debug("Executing TsLint with command: " + thisCommand.toCommandLine());
// Timeout is spec... | #fixed code
private String getCommandOutput(Command thisCommand, StreamConsumer stdOutConsumer, StreamConsumer stdErrConsumer, File tslintOutputFile, Integer timeoutMs) {
LOG.debug("Executing TsLint with command: " + thisCommand.toCommandLine());
// Timeout is specified ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
@RedisCache(flush = true)
public Comment comment(Comment comment) throws ZhydCommentException {
if (StringUtils.isEmpty(comment.getNickname())) {
throw new ZhydCommentException("必须输入昵称哦~~");
}
String content = commen... | #fixed code
@Override
@RedisCache(flush = true)
public Comment comment(Comment comment) throws ZhydCommentException {
if (StringUtils.isEmpty(comment.getNickname())) {
throw new ZhydCommentException("必须输入昵称哦~~");
}
String content = comment.getC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String template2String(String templateContent, Map<String, Object> map,
boolean isNeedFilter) {
if (StringUtils.isEmpty(templateContent)) {
return null;
}
if (map == null) {
... | #fixed code
public static String template2String(String templateContent, Map<String, Object> map,
boolean isNeedFilter) {
if (StringUtils.isEmpty(templateContent)) {
return null;
}
if (map == null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void sendEmails(Set<String> emailTargets, String body) throws IOException {
File temporaryEmailBody = File.createTempFile("_tmp_" + getClass().getSimpleName(), null);
BufferedWriter writer = new BufferedWriter(new FileWriter(temporaryEmailBody, false));
... | #fixed code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
LOG.info("Sending Monitor email to " + emailTargets.size() + " targets: " + emailTargets + " Email body: " + body);
for (String emailTarget : emailTargets) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
LOG.info("Data Deployer Daemon for ring group " + ringGroupName + " starting.");
boolean claimedDataDeployer = false;
try {
ringGroupConfig = coord.getRingGroup(ringGroupName);
// attempt to claim the data de... | #fixed code
public void run() throws IOException {
LOG.info("Data Deployer Daemon for ring group " + ringGroupName + " starting.");
boolean claimedDataDeployer = false;
try {
ringGroup = coord.getRingGroup(ringGroupName);
// attempt to claim the data deployer title... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException {
Path source = new Path(getAbsoluteRemotePath(remoteSourceRelativePath));
File destination = new File(localDestinationRoot + "/" + new Path(re... | #fixed code
@Override
public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException {
Path source = new Path(getAbsoluteRemotePath(remoteSourceRelativePath));
File destination = new File(localDestinationRoot + "/" + new Path(remoteSo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int decompress(byte[] src, int srcOffset, int srcLength, byte[] dst, int dstOff) {
if (srcLength - srcOffset == 0) {
return 0;
}
try {
ByteArrayInputStream bytesIn = new ByteArrayInputStream(src, srcOffset, srcLength);
GZIP... | #fixed code
@Override
public int decompress(byte[] src, int srcOffset, int srcLength, byte[] dst, int dstOff) {
if (srcLength - srcOffset == 0) {
return 0;
}
try {
ByteArrayInputStream bytesIn = new ByteArrayInputStream(src, srcOffset, srcLength);
GZIPInputS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void assign(RingGroup ringGroup, int ringNum, Domain domain) throws IOException {
ring = ringGroup.getRing(ringNum);
domainGroup = ringGroup.getDomainGroup();
domainId = domainGroup.getDomainId(domain.getName());
version = domainGroup.ge... | #fixed code
@Override
public void assign(RingGroup ringGroup, int ringNum, Domain domain) throws IOException {
ring = ringGroup.getRing(ringNum);
domainGroup = ringGroup.getDomainGroup();
domainId = domainGroup.getDomainId(domain.getName());
version = domainGroup.getLates... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBlockCompressionSnappy() throws Exception {
new File(TMP_TEST_CURLY_READER).mkdirs();
OutputStream s = new FileOutputStream(TMP_TEST_CURLY_READER + "/00000.base.curly");
s.write(EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_SNAPPY);
s.flush();
... | #fixed code
public void testBlockCompressionSnappy() throws Exception {
doTestBlockCompression(BlockCompressionCodec.SNAPPY, EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_SNAPPY);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
String configPath = args[0];
String log4jprops = args[1];
PropertyConfigurator.configure(log4jprops);
new UpdateDaemon(null, HostUtils.getHostName()).run();
}
#loc... | #fixed code
public static void main(String[] args) throws IOException {
String configPath = args[0];
String log4jprops = args[1];
PropertyConfigurator.configure(log4jprops);
UpdateDaemonConfigurator conf = new YamlConfigurator(configPath);
new UpdateDaemon(conf, HostU... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
LOG.info("Data Deployer Daemon for ring group " + ringGroupName + " starting.");
boolean claimedDataDeployer = false;
try {
ringGroupConfig = coord.getRingGroup(ringGroupName);
// attempt to claim the data de... | #fixed code
public void run() throws IOException {
LOG.info("Data Deployer Daemon for ring group " + ringGroupName + " starting.");
boolean claimedDataDeployer = false;
try {
ringGroup = coord.getRingGroup(ringGroupName);
// attempt to claim the data deployer title... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) throws TException {
client.getBulk(domainId, keys, resultHandler);
}
#location 2
#vulnerability type THREA... | #fixed code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) {
try {
client.getBulk(domainId, keys, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private ByteBuffer decompressBlock(ByteBuffer block) throws IOException {
Buffers buffers = threadLocalBuffers.get();
buffers.reset();
// Decompress the block
InputStream blockInputStream =
new ByteArrayInputStream(block.array(), block.arrayOffset(... | #fixed code
private ByteBuffer decompressBlock(ByteBuffer block) throws IOException {
Local local = threadLocal.get();
local.reset();
local.getBlockDecompressor().decompress(
block.array(),
block.arrayOffset() + block.position(),
block.remaining(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) throws TException {
client.get(domainId, key, resultHandler);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) {
try {
client.get(domainId, key, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void aggregate(DoublePopulationStatisticsAggregator other) {
if (numValues == 0) {
// Copy deciles directly
System.arraycopy(other.deciles, 0, deciles, 0, 9);
} else if (other.numValues == 0) {
// Keep this deciles unchanged
} else {
... | #fixed code
public void aggregate(DoublePopulationStatisticsAggregator other) {
if (other.maximum > this.maximum) {
this.maximum = other.maximum;
}
if (other.minimum < this.minimum) {
this.minimum = other.minimum;
}
this.numValues += other.numValues;
thi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void addTask(GetTask task) {
synchronized (getTasks) {
task.startNanoTime = System.nanoTime();
getTasks.addLast(task);
}
dispatcherThread.interrupt();
}
#location 6
#vulnerability t... | #fixed code
public void addTask(GetTask task) {
try {
// TODO: remove trace
//LOG.trace("Adding task with state " + task.state);
if (task.startNanoTime == null) {
task.startNanoTime = System.nanoTime();
}
getTasks.put(task);
//LOG.trace("Get ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBlockCompressionGzip() throws Exception {
new File(TMP_TEST_CURLY_READER).mkdirs();
OutputStream s = new FileOutputStream(TMP_TEST_CURLY_READER + "/00000.base.curly");
s.write(EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_GZIP);
s.flush();
s.cl... | #fixed code
public void testBlockCompressionGzip() throws Exception {
doTestBlockCompression(BlockCompressionCodec.GZIP, EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_GZIP);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
hostConfig.setState(HostState.IDLE);
if (hostConfig.getCurrentCommand() != null) {
processCurrentCommand(hostConfig, hostConfig.getCurrentCommand());
}
while (!goingDown) {
try {
Thread.sleep(1000... | #fixed code
public void run() throws IOException {
hostConfig.setState(HostState.IDLE);
processCommands();
while (!goingDown) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOG.debug("Interrupted in run loop. Exiting.");
brea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void commitFiles(File sourceRoot, String destinationRoot) throws IOException {
for (File file : sourceRoot.listFiles()) {
// Skip non files
if (!file.isFile()) {
continue;
}
File targetFile = new File(destinationRoot + "/" + f... | #fixed code
protected void commitFiles(File sourceRoot, String destinationRoot) throws IOException {
File[] files = sourceRoot.listFiles();
if (files == null) {
throw new IOException("Failed to commit files from " + sourceRoot + " to " + destinationRoot + " since source is no... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Ring addRing(int ringNum) throws IOException {
try {
Ring rc = ZkRing.create(zk, ringGroupPath, ringNum, this, isUpdating() ? getUpdatingToVersion() : getCurrentVersion());
ringsByNumber.put(rc.getRingNumber(), rc);
return rc;
... | #fixed code
@Override
public Ring addRing(int ringNum) throws IOException {
try {
Ring rc = ZkRing.create(zk, ringGroupPath, ringNum, this,
isUpdating() ? getUpdatingToVersion() : getCurrentVersion());
ringsByNumber.put(rc.getRingNumber(), rc);
return rc;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static DomainGroupVersion createNewFastForwardVersion(DomainGroup domainGroup) throws IOException {
Map<Domain, Integer> domainNameToVersion = new HashMap<Domain, Integer>();
// find the latest domain group version
DomainGroupVersion dgv = DomainGroups... | #fixed code
public static DomainGroupVersion createNewFastForwardVersion(DomainGroup domainGroup) throws IOException {
Map<Domain, Integer> domainNameToVersion = new HashMap<Domain, Integer>();
// find the latest domain group version
DomainGroupVersion dgv = DomainGroups.getLa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) throws TException {
client.get(domainId, key, resultHandler);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) {
try {
client.get(domainId, key, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException, InterruptedException {
setState(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
processCurrentCommand();
while (!stopping) {
try {
Thread.sleep(MAIN_THREAD_STEP_SLEEP_M... | #fixed code
public void run() throws IOException, InterruptedException {
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
processCommandOnStartup();
while (!stopping) {
try {
Thread.sleep(MAIN_THREAD_STEP... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGrou... | #fixed code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGroupName)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
for (String emailTarget : emailTargets) {
String[] command = {"/bin/mail", "-s", "Hank: " + name, emailTarget};
Process process = Runtime.getRuntime()... | #fixed code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
Session session = Session.getDefaultInstance(emailSessionProperties);
Message message = new MimeMessage(session);
try {
message.setSubject("Hank: " + name... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void sendEmails(Set<String> emailTargets, String body) throws IOException {
File temporaryEmailBody = File.createTempFile("_tmp_" + getClass().getSimpleName(), null);
BufferedWriter writer = new BufferedWriter(new FileWriter(temporaryEmailBody, false));
... | #fixed code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
LOG.info("Sending Monitor email to " + emailTargets.size() + " targets: " + emailTargets + " Email body: " + body);
for (String emailTarget : emailTargets) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private ByteBuffer decompressBlock(ByteBuffer block) throws IOException {
Buffers buffers = threadLocalBuffers.get();
buffers.reset();
// Decompress the block
InputStream blockInputStream =
new ByteArrayInputStream(block.array(), block.arrayOffset(... | #fixed code
private ByteBuffer decompressBlock(ByteBuffer block) throws IOException {
Local local = threadLocal.get();
local.reset();
local.getBlockDecompressor().decompress(
block.array(),
block.arrayOffset() + block.position(),
block.remaining(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException {
Path source = new Path(getAbsoluteRemotePath(remoteSourceRelativePath));
File destination = new File(localDestinationRoot + "/" + new Path(re... | #fixed code
@Override
public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException {
Path source = new Path(getAbsoluteRemotePath(remoteSourceRelativePath));
File destination = new File(localDestinationRoot + "/" + new Path(remoteSo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void stop() {
goingDown = true;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public void stop() {
stopping = true;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void assign(RingGroup ringGroup, int ringNum, Domain domain) throws IOException {
ring = ringGroup.getRing(ringNum);
domainGroup = ringGroup.getDomainGroup();
domainId = domainGroup.getDomainId(domain.getName());
version = domainGroup.ge... | #fixed code
@Override
public void assign(RingGroup ringGroup, int ringNum, Domain domain) throws IOException {
ring = ringGroup.getRing(ringNum);
domainGroup = ringGroup.getDomainGroup();
domainId = domainGroup.getDomainId(domain.getName());
version = domainGroup.getLates... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean isAvailable() {
return state != HostConnectionState.STANDBY;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
Host getHost() {
return host;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBlockCompressionSnappy() throws Exception {
new File(TMP_TEST_CURLY_READER).mkdirs();
OutputStream s = new FileOutputStream(TMP_TEST_CURLY_READER + "/00000.base.curly");
s.write(EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_SNAPPY);
s.flush();
... | #fixed code
public void testBlockCompressionSnappy() throws Exception {
doTestBlockCompression(BlockCompressionCodec.SNAPPY, EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_SNAPPY);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean isDeletable() throws IOException {
if (deletable != null) {
return deletable.get();
} else {
try {
return WatchedBoolean.get(zk, ZkPath.append(path, DELETABLE_PATH_SEGMENT));
} catch (Exception e) {
thro... | #fixed code
@Override
public boolean isDeletable() throws IOException {
Boolean result;
if (deletable != null) {
result = deletable.get();
} else {
try {
result = WatchedBoolean.get(zk, ZkPath.append(path, DELETABLE_PATH_SEGMENT));
} catch (Exception... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean isAvailable() {
return state != HostConnectionState.STANDBY;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
Host getHost() {
return host;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait ... | #fixed code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait for st... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to clai... | #fixed code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to claim the ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | #fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGrou... | #fixed code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGroupName)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testGzipBlockCompression() throws Exception {
ByteArrayOutputStream s = new ByteArrayOutputStream();
MapWriter keyfileWriter = new MapWriter();
CurlyWriter writer = new CurlyWriter(s, keyfileWriter, 3, -1, BlockCompressionCodec.GZIP, 1024, 2);
... | #fixed code
public void testGzipBlockCompression() throws Exception {
ByteArrayOutputStream s = new ByteArrayOutputStream();
MapWriter keyfileWriter = new MapWriter();
CurlyWriter writer = new CurlyWriter(s, keyfileWriter, 3, -1, BlockCompressionCodec.GZIP, 1024, 2);
writer... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBlockCompressionGzip() throws Exception {
new File(TMP_TEST_CURLY_READER).mkdirs();
OutputStream s = new FileOutputStream(TMP_TEST_CURLY_READER + "/00000.base.curly");
s.write(EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_GZIP);
s.flush();
s.cl... | #fixed code
public void testBlockCompressionGzip() throws Exception {
doTestBlockCompression(BlockCompressionCodec.GZIP, EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_GZIP);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static ZkRingGroup create(ZooKeeperPlus zk, String path, ZkDomainGroup domainGroup, Coordinator coordinator) throws KeeperException, InterruptedException, IOException {
if (domainGroup.getVersions().isEmpty()) {
throw new IllegalStateException(
... | #fixed code
public static ZkRingGroup create(ZooKeeperPlus zk, String path, ZkDomainGroup domainGroup, Coordinator coordinator) throws KeeperException, InterruptedException, IOException {
if (domainGroup.getVersions().isEmpty()) {
throw new IllegalStateException(
"You c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void updateComplete() throws IOException {
try {
if (zk.exists(ringPath + CURRENT_VERSION_PATH_SEGMENT, false) != null) {
zk.setData(ringPath + CURRENT_VERSION_PATH_SEGMENT, getUpdatingToVersionNumber().toString().getBytes(), -1);
... | #fixed code
@Override
public void updateComplete() throws IOException {
try {
currentVersionNumber.set(getUpdatingToVersionNumber());
updatingToVersionNumber.set(null);
} catch (Exception e) {
throw new IOException(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void runUpdateCore(DomainVersion currentVersion,
DomainVersion updatingToVersion,
IncrementalUpdatePlan updatePlan,
String updateWorkRoot) throws IOException... | #fixed code
@Override
protected void runUpdateCore(DomainVersion currentVersion,
DomainVersion updatingToVersion,
IncrementalUpdatePlan updatePlan,
String updateWorkRoot) throws IOException {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait ... | #fixed code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait for st... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
for (String emailTarget : emailTargets) {
String[] command = {"/bin/mail", "-s", "Hank: " + name, emailTarget};
Process process = Runtime.getRuntime()... | #fixed code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
Session session = Session.getDefaultInstance(emailSessionProperties);
Message message = new MimeMessage(session);
try {
message.setSubject("Hank: " + name... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void addCompleteTask(GetTask task) {
synchronized (getTasksComplete) {
getTasksComplete.addLast(task);
}
dispatcherThread.interrupt();
}
#location 5
#vulnerability type THREAD_SAFETY_VIOL... | #fixed code
public void addCompleteTask(GetTask task) {
synchronized (getTasksComplete) {
getTasksComplete.addLast(task);
}
//dispatcherThread.interrupt();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Flow build(Properties cascasdingProperties,
TapOrTapMap sources) throws IOException {
pipe = new DomainBuilderAssembly(properties.getDomainName(), pipe, keyFieldName, valueFieldName);
// Open new version and check for success
ope... | #fixed code
private Flow build(Properties cascasdingProperties,
TapOrTapMap sources) throws IOException {
pipe = new DomainBuilderAssembly(properties.getDomainName(), pipe, keyFieldName, valueFieldName);
// Open new version and check for success
openNewVe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | #fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to clai... | #fixed code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to claim the ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void updateComplete() throws IOException {
try {
if (zk.exists(ringPath + CURRENT_VERSION_PATH_SEGMENT, false) != null) {
zk.setData(ringPath + CURRENT_VERSION_PATH_SEGMENT, getUpdatingToVersionNumber().toString().getBytes(), -1);
... | #fixed code
@Override
public void updateComplete() throws IOException {
try {
currentVersionNumber.set(getUpdatingToVersionNumber());
updatingToVersionNumber.set(null);
} catch (Exception e) {
throw new IOException(e);
}
} | 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.