output stringlengths 79 30.1k | instruction stringclasses 1
value | input stringlengths 216 28.9k |
|---|---|---|
#fixed code
public void reputation(final String uid, final int rep)
throws IOException {
this.checkExisting(uid);
try (final Item item = this.item()) {
new Xocument(item.path()).modify(
new Directives().xpath(
String... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void reputation(final String uid, final int rep)
throws IOException {
if (!this.exists(uid)) {
throw new IllegalArgumentException(
new Par("Person @%s doesn't exist").say(uid)
);
}
try (final... |
#fixed code
@Test
public void rendersDebts() throws Exception {
final Farm farm = FkFarm.props();
final Debts debts = new Debts(farm).bootstrap();
final String uid = "yegor256";
final String first = "details 1";
final String second = "details 2... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void rendersDebts() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final Debts debts = new Debts(farm).bootstrap();
final String uid = "yegor256";
final String first = "details 1";
final String ... |
#fixed code
@Test
public void receiveMessages() throws Exception {
final Project project = new FkProject();
final Farm farm = new PropsFarm(new FkFarm(project));
final AmazonSQS sqs = new ExtSqs(farm).value();
final String queue = new ClaimsQueueUrl(fa... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void receiveMessages() throws Exception {
final Project project = new FkProject();
final Farm farm = new PropsFarm(new FkFarm(project));
final AmazonSQS sqs = new ExtSqs(farm).value();
final String queue = new ClaimsQueue... |
#fixed code
public boolean published(final String pid) throws IOException {
this.checkExist(pid);
try (final Item item = this.item()) {
return Boolean.parseBoolean(
new Xocument(item).xpath(
String.format(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public boolean published(final String pid) throws IOException {
if (!this.exists(pid)) {
throw new IllegalArgumentException(
new Par(
"Project \"%s\" doesn't exist, can't check publish"
).say(pid)
... |
#fixed code
Model(Matrix wi,
Matrix wo,
Args args,
int seed) {
hidden_ = new Vector(args.dim);
output_ = new Vector(wo.m_);
grad_ = new Vector(args.dim);
random = new Random(seed);
wi_ = wi;
wo_ = wo;
a... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
float binaryLogistic(int target, boolean label, float lr) {
float score = sigmoid(wo_.dotRow(hidden_, target));
float alpha = lr * (label ? 1f : 0f - score);
grad_.addRow(wo_, target, alpha);
synchronized (this) {
wo_.addRow(h... |
#fixed code
Model(Matrix wi,
Matrix wo,
Args args,
int seed) {
hidden_ = new Vector(args.dim);
output_ = new Vector(wo.m_);
grad_ = new Vector(args.dim);
random = new Random(seed);
wi_ = wi;
wo_ = wo;
a... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
int getNegative(int target) {
int negative;
do {
negative = negatives[negpos];
negpos = (negpos + 1) % negatives.length;
} while (target == negative);
return negative;
}
#location 5... |
#fixed code
Model(Matrix wi,
Matrix wo,
Args args,
int seed) {
hidden_ = new Vector(args.dim);
output_ = new Vector(wo.m_);
grad_ = new Vector(args.dim);
random = new Random(seed);
wi_ = wi;
wo_ = wo;
a... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void update(int[] input, int target, float lr) {
assert (target >= 0);
assert (target < osz_);
if (input.length == 0) return;
computeHidden(input, hidden_);
if (args_.loss == Args.loss_name.ns) {
loss_ += negativeSampl... |
#fixed code
void internalClose() throws IOException {
if (!closed) {
closed = true;
backend.rrdClose();
}
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void realClose() throws IOException {
if (!closed) {
closed = true;
backend.rrdClose();
}
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
private void testFile(String file, String version) throws IOException {
URL url = getClass().getResource(file);
RRDatabase rrd = new RRDatabase(url.getFile());
Assert.assertEquals("Invalid date", new Date(920808900000L), rrd.getLastUpdate());
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void testFile(String file, String version) throws IOException {
URL url = getClass().getResource(file);
RRDatabase rrd = new RRDatabase(url.getFile());
Assert.assertEquals("Invalid date", new Date(920808900000L), rrd.getLastUpdate());
... |
#fixed code
public RrdDb requestRrdDb(String path) throws IOException {
RrdEntry ref = null;
try {
ref = getEntry(path, true);
} catch (InterruptedException e) {
throw new RuntimeException("request interrupted for " + path, e);
}
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public RrdDb requestRrdDb(String path) throws IOException {
RrdEntry ref = null;
try {
ref = getEntry(path, true);
} catch (InterruptedException e) {
throw new RuntimeException("request interrupted for " + path, e);
... |
#fixed code
@Test
public void testBackendFactory() throws IOException {
File rrdfile = testFolder.newFile("testfile");
try(RrdSafeFileBackendFactory factory = new RrdSafeFileBackendFactory()) {
super.testBackendFactory(factory,rrdfile.getCanonicalPath());
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testBackendFactory() throws IOException {
RrdRandomAccessFileBackendFactory factory = (RrdRandomAccessFileBackendFactory) RrdBackendFactory.getFactory("SAFE");
File rrdfile = testFolder.newFile("testfile");
RrdBackend be = ... |
#fixed code
@Test
public void testEntriesNeg50To0InRrd() throws IOException, FontFormatException {
createGaugeRrd(100);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<50; i++) {
long timestamp = startTime + 1 + (i * 60... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testEntriesNeg50To0InRrd() throws IOException, FontFormatException {
createGaugeRrd(100);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<50; i++) {
long timestamp = startTime + 1 + (i * 60);
Samp... |
#fixed code
@Test
public void testTwoEntriesInRrd() throws IOException, FontFormatException {
createGaugeRrd(100);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<2; i++) {
long timestamp = startTime + 1 + (i * 60);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testTwoEntriesInRrd() throws IOException, FontFormatException {
createGaugeRrd(100);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<2; i++) {
long timestamp = startTime + 1 + (i * 60);
Sample sam... |
#fixed code
@Test
public void testEntriesZeroTo100InRrd() throws IOException, FontFormatException {
createGaugeRrd(105); //Make sure all entries are recorded (5 is just a buffer for consolidation)
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
f... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testEntriesZeroTo100InRrd() throws IOException, FontFormatException {
createGaugeRrd(105); //Make sure all entries are recorded (5 is just a buffer for consolidation)
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<100; ... |
#fixed code
@Test
public void testBackendFactoryDefaults() throws IOException {
try (RrdNioBackendFactory factory = new RrdNioBackendFactory(0)) {
File rrdfile = testFolder.newFile("testfile");
super.testBackendFactory(factory,rrdfile.getCanonicalPath(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testBackendFactoryDefaults() throws IOException {
// Don't close a default NIO, it will close the background sync threads executor
@SuppressWarnings("resource")
RrdNioBackendFactory factory = new RrdNioBackendFactory();
... |
#fixed code
public void testXhtmlParsing() throws Exception {
String path = "/test-documents/testXHTML.html";
Metadata metadata = new Metadata();
String content = Tika.parseToString(
HtmlParserTest.class.getResourceAsStream(path), metadata);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testXhtmlParsing() throws Exception {
Parser parser = new AutoDetectParser(); // Should auto-detect!
ContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
InputStream stream = HtmlParserTest.c... |
#fixed code
@Before
public void before() throws Throwable {
save(new Properties() {{
setProperty("someValue", "10");
}});
reloadableConfig = ConfigFactory.create(ReloadableConfig.class);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Before
public void before() throws Throwable {
synchronized (target) {
save(new Properties() {{
setProperty("someValue", "10");
}});
reloadableConfig = ConfigFactory.create(ReloadableConfig.class);
... |
#fixed code
@Test
public void testReload() throws Throwable {
assertEquals(Integer.valueOf(10), reloadableConfig.someValue());
save(new Properties() {{
setProperty("someValue", "20");
}});
reloadableConfig.reload();
assertEquals(I... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testReload() throws Throwable {
assertEquals(Integer.valueOf(10), reloadableConfig.someValue());
synchronized (target) {
save(new Properties() {{
setProperty("someValue", "20");
}});
... |
#fixed code
public static void save(File target, Properties p) throws IOException {
File parent = target.getParentFile();
parent.mkdirs();
if (isWindows()) {
store(target, p);
} else {
File tempFile = createTempFile(target.getName()... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void save(File target, Properties p) throws IOException {
File parent = target.getParentFile();
parent.mkdirs();
if (isWindows()) {
store(new FileOutputStream(target), p);
} else {
File tempFile = cre... |
#fixed code
LoadersManager() {
registerLoader(new PropertiesLoader());
registerLoader(new XMLLoader());
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
InputStream getInputStream(URL url) throws IOException {
URLConnection conn = url.openConnection();
if (conn == null)
return null;
return conn.getInputStream();
}
#location 5
... |
#fixed code
@Override
public Object execute() {
// Configure command before execution
introspector.getHystrixProperties()
.entrySet()
.forEach(entry -> setProperty(entry.getKey(), entry.getValue()));
// Ensure our inter... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public Object execute() {
// Configure command before execution
introspector.getHystrixProperties()
.entrySet()
.forEach(entry -> setProperty(entry.getKey(), entry.getValue()));
// Ensure our... |
#fixed code
@Override
protected Optional<Instant> dataStamp() {
// the URL may not be an HTTP URL
try {
URLConnection urlConnection = url.openConnection();
if (urlConnection instanceof HttpURLConnection) {
HttpURLConnection conn... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
protected Optional<Instant> dataStamp() {
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(HEAD_METHOD);
if (connection.getLastModified() != 0) {
... |
#fixed code
@Override
public Object execute() {
boolean lockRemoved = false;
try {
// Configure command before execution
introspector.getHystrixProperties()
.entrySet()
.forEach(entry -> setProperty(entr... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public Object execute() {
// Configure command before execution
introspector.getHystrixProperties()
.entrySet()
.forEach(entry -> setProperty(entry.getKey(), entry.getValue()));
// Ensure our... |
#fixed code
static String checkModelForParametrizedValue(String seleniumVersion, Model model) {
String version = getNamePropertyName(seleniumVersion);
if (nonNull(model.getProperties())) {
return model.getProperties().getProperty(version);
} else if ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
static String checkModelForParametrizedValue(String seleniumVersion, Model model) {
String version = getNamePropertyName(seleniumVersion);
String versionProp = null;
if (nonNull(seleniumVersion) && nonNull(model.getProperties())) {
v... |
#fixed code
@Test
public void testGetTypeMap() {
Result result = new Result(false, false, 1000, 2000, new BranchTrace(), vector, "unittest.id");
rule.onApply(result);
vector.addModification(new AddMessageModification(new ServerHelloDoneMessage(), new SendAction()));
rule.onApply(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testGetTypeMap() {
Result result = new Result(false, false, 1000, 2000, new BranchTrace(), vector, "unittest.id");
rule.onApply(result);
vector.addModification(new AddMessageModification(new ServerHelloDoneMessage(), new SendAction()));
rule.on... |
#fixed code
public void startTlsServer(TlsConfig config) {
TlsContext tlsContext = new TlsContext(config);
WorkflowExecutor workflowExecutor = WorkflowExecutorFactory.createWorkflowExecutor(config.getExecutorType(),
tlsContext);
try {
w... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void startTlsServer(TlsConfig config) {
TlsContext tlsContext = new TlsContext(config);
WorkflowExecutor workflowExecutor = WorkflowExecutorFactory.createWorkflowExecutor(config.getExecutorType(),
tlsContext);
try {
... |
#fixed code
private boolean testExecuteWorkflow(TlsConfig config) {
// TODO ugly
ConfigHandler configHandler = new ConfigHandler();
TransportHandler transportHandler = configHandler.initializeTransportHandler(config);
TlsContext tlsContext = configHandle... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private boolean testExecuteWorkflow(TlsConfig config) {
// TODO ugly
ConfigHandler configHandler = new ConfigHandler();
TransportHandler transportHandler = configHandler.initializeTransportHandler(config);
TlsContext tlsContext = config... |
#fixed code
@Override
public void handle(Message<JsonObject> message) {
String action = getMandatoryString("action", message);
if (action == null) {
sendError(message, "No action specified.");
return;
}
switch (action) {
case "receive":
doRecei... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void handle(Message<JsonObject> message) {
String action = getMandatoryString("action", message);
if (action == null) {
sendError(message, "No action specified.");
}
switch (action) {
case "receive":
doReceive(messag... |
#fixed code
@Test
public void testFieldsSelector() {
Selector selector = new FieldsSelector("test");
JsonMessage test1 = DefaultJsonMessage.create(new JsonObject().putString("test", "a"), "auditor");
List<Connection> connections1 = selector.select(test1, testConnections);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testFieldsSelector() {
Selector selector = new FieldsSelector("test");
JsonMessage test1 = DefaultJsonMessage.create(new JsonObject().putString("test", "a"), "auditor");
List<Connection> connections1 = selector.select(test1, testConnection... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.