output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
public void apply(final String uid, final Date when) throws IOException {
this.checkExisting(uid);
try (final Item item = this.item()) {
new Xocument(item.path()).modify(
new Directives().xpath(
String.format("//... | #vulnerable code
public void apply(final String uid, final Date when) throws IOException {
if (!this.exists(uid)) {
throw new IllegalArgumentException(
new Par("Person @%s doesn't exist").say(uid)
);
}
try (final Item item ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void givesNoBonus() throws Exception {
final Speed speed = new Speed(
new FkFarm(new FkProject()), "other"
).bootstrap();
final String job = "gh:bonus/slow#1";
speed.add("TST100009", job, Duration.ofDays(Tv.THREE).t... | #vulnerable code
@Test
public void givesNoBonus() throws Exception {
final FkProject project = new FkProject();
final FkFarm farm = new FkFarm(project);
final Speed speed = new Speed(farm, "other").bootstrap();
final String job = "gh:bonus/slow#1";
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void unlink(final String pid, final String rel, final String href)
throws IOException {
this.checkExist(pid);
try (final Item item = this.item()) {
new Xocument(item.path()).modify(
new Directives()
... | #vulnerable code
public void unlink(final String pid, final String rel, final String href)
throws IOException {
if (!this.exists(pid)) {
throw new IllegalArgumentException(
new Par(
"Project %s doesn't exist, can't unlink"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean applied(final String uid) throws IOException {
this.checkExisting(uid);
try (final Item item = this.item()) {
return !new Xocument(item).nodes(
String.format("//people/person[@id ='%s']/applied", uid)
).i... | #vulnerable code
public boolean applied(final String uid) throws IOException {
if (!this.exists(uid)) {
throw new IllegalArgumentException(
new Par("Person @%s doesn't exist").say(uid)
);
}
try (final Item item = this.item(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersVacanciesPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | #vulnerable code
@Test
public void rendersVacanciesPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void dontRepeatErrorClaims() throws Exception {
final FkProject project = new FkProject();
new ClaimOut().type("Error").postTo(project);
final int before = new LengthOf(new Claims(project).iterate())
.intValue();
ne... | #vulnerable code
@Test
public void dontRepeatErrorClaims() throws Exception {
final FkProject project = new FkProject();
new ClaimOut().type("Error").postTo(project);
final XML claim = new Claims(project).iterate().iterator().next();
new StkSafe(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersSingleArtifact() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | #vulnerable code
@Test
public void rendersSingleArtifact() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void setsJobs() throws Exception {
final People people =
new People(new FkFarm(new FkProject())).bootstrap();
final String uid = "jobs";
people.invite(uid, uid);
final int jobs = Tv.TEN;
people.jobs(uid, job... | #vulnerable code
@Test
public void setsJobs() throws Exception {
final FkFarm farm = new FkFarm(new FkProject());
final People people = new People(farm).bootstrap();
final String uid = "jobs";
people.invite(uid, uid);
final int jobs = Tv.TEN;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
@SuppressWarnings("unchecked")
public void showsThatUserAlreadyHasMentor() throws IOException {
final Farm farm = new PropsFarm(new FkFarm());
final People people = new People(farm).bootstrap();
final String mentor = "yoda";
final... | #vulnerable code
@Test
@SuppressWarnings("unchecked")
public void showsThatUserAlreadyHasMentor() throws IOException {
final Farm farm = FkFarm.props();
final People people = new People(farm).bootstrap();
final String mentor = "yoda";
final String... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersProfilePageWithoutRateInFirefox() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final String uid = "yegor256";
MatcherAssert.assertThat(
new View(farm, String.format("/u/%s", uid)).html(),
... | #vulnerable code
@Test
public void rendersProfilePageWithoutRateInFirefox() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final People people = new People(farm).bootstrap();
final String uid = "yegor256";
people.wallet(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersHomePage() throws Exception {
final Farm farm = FkFarm.props();
final String uid = "yegor";
new Awards(farm, uid).bootstrap().add(
new FkProject(), 1, "gh:test/test#1", "reason"
);
new Agenda(far... | #vulnerable code
@Test
public void rendersHomePage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final String uid = "yegor";
new Awards(farm, uid).bootstrap().add(
new FkProject(), 1, "gh:test/test#1", "reason"
);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersHomePage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
n... | #vulnerable code
@Test
public void rendersHomePage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void speed(final String uid, final double speed)
throws IOException {
this.checkExisting(uid);
try (final Item item = this.item()) {
new Xocument(item.path()).modify(
new Directives().xpath(
String... | #vulnerable code
public void speed(final String uid, final double speed)
throws IOException {
if (!this.exists(uid)) {
throw new IllegalArgumentException(
new Par("Person @%s doesn't exist").say(uid)
);
}
try (f... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void setsEstimatesOnAssign() throws Exception {
final Project project = new FkProject();
final PropsFarm farm = new PropsFarm();
new Ledger(farm, project).bootstrap().add(
new Ledger.Transaction(
new Cash.S(... | #vulnerable code
@Test
public void setsEstimatesOnAssign() throws Exception {
final Project project = new FkProject();
final PropsFarm farm = new PropsFarm();
new Ledger(farm, project).bootstrap().add(
new Ledger.Transaction(
new C... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersHomePageViaHttp() throws Exception {
final Take app = new TkApp(FkFarm.props());
new FtRemote(app).exec(
home -> new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.ass... | #vulnerable code
@Test
public void rendersHomePageViaHttp() throws Exception {
final Take app = new TkApp(new PropsFarm(new FkFarm()));
new FtRemote(app).exec(
home -> new JdkRequest(home)
.fetch()
.as(RestResponse.class)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
@Ignore
public void redirectOnError() throws Exception {
final Take take = new TkApp(FkFarm.props());
final String message = "Internal application error";
MatcherAssert.assertThat(
"Could not redirect on error",
ne... | #vulnerable code
@Test
@Ignore
public void redirectOnError() throws Exception {
final Take take = new TkApp(new PropsFarm(new FkFarm()));
final String message = "Internal application error";
MatcherAssert.assertThat(
"Could not redirect on err... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersProfilePageInFirefoxWithReputation() throws Exception {
final Farm farm = FkFarm.props();
final String user = "yegor256";
MatcherAssert.assertThat(
new View(farm, String.format("/u/%s", user)).html(),
... | #vulnerable code
@Test
public void rendersProfilePageInFirefoxWithReputation() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final String user = "yegor256";
MatcherAssert.assertThat(
new View(farm, String.format("/u/%s", user))... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void votesHighIfMaxJobsReached() throws Exception {
final Project project = new FkProject();
final String user = "g4s8";
final int total = 10;
final Pmo pmo = new Pmo(new FkFarm());
new Options(pmo, user).bootstrap().ma... | #vulnerable code
@Test
public void votesHighIfMaxJobsReached() throws Exception {
final Project project = new FkProject();
final FkFarm farm = new FkFarm();
final String user = "g4s8";
final int total = 10;
final Pmo pmo = new Pmo(farm);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersProjectPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | #vulnerable code
@Test
public void rendersProjectPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final Catalog catalog = new Catalog(new Pmo(farm)).bootstrap();
final String pid = "A1B2C3D4F";
catalog.add(pid, String.format("2... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Input pdf(final String login) throws IOException {
final double share = this.share(login);
if (share == 0.0d) {
throw new IllegalArgumentException(
new Par(
"@%s doesn't have any share in %s"
... | #vulnerable code
public Input pdf(final String login) throws IOException {
final double share = this.share(login);
if (share == 0.0d) {
throw new IllegalArgumentException(
new Par(
"@%s doesn't have any share in %s"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
@SuppressWarnings("unchecked")
public void showsThatUserAlreadyHasMentor() throws IOException {
final Farm farm = FkFarm.props();
final People people = new People(farm).bootstrap();
final String mentor = "yoda";
final String appli... | #vulnerable code
@Test
@SuppressWarnings("unchecked")
public void showsThatUserAlreadyHasMentor() throws IOException {
final Farm farm = new PropsFarm(new FkFarm());
final People people = new People(farm).bootstrap();
final String mentor = "yoda";
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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(
... | #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)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rechargeIsRequiredIfCashBalanceIsLessThanLocked()
throws Exception {
final Project project = new FkProject();
final String job = "gh:test/test#1";
new Wbs(project).bootstrap().add(job);
final PropsFarm farm = new P... | #vulnerable code
@Test
public void rechargeIsRequiredIfCashBalanceIsLessThanLocked()
throws Exception {
final Project project = new FkProject();
final String job = "gh:test/test#1";
new Wbs(project).bootstrap().add(job);
final PropsFarm farm =... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Response act(final RqRegex req) throws IOException {
final Project project = new RqAnonProject(this.farm, req);
return new RsWithHeaders(
new RsWithType(
new RsWithBody(
this.getClass().getRe... | #vulnerable code
@Override
public Response act(final RqRegex req) throws IOException {
final String pid = req.matcher().group(1);
final Catalog catalog = new Catalog(this.farm).bootstrap();
if (!catalog.exists(pid)) {
throw new RsForward(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void parsesJson() throws Exception {
MatcherAssert.assertThat(
new TkGithub(
new PropsFarm(),
new Rebound.Fake("nothing")
).act(
new RqWithBody(
new RqFake("PO... | #vulnerable code
@Test
public void parsesJson() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final Take take = new TkGithub(
farm, (frm, github, event) -> "nothing"
);
MatcherAssert.assertThat(
take.act(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void payZold() throws Exception {
final Farm farm = new PropsFarm();
final String target = "yegor256";
new Roles(new Pmo(farm)).bootstrap().assign(target, "PO");
MatcherAssert.assertThat(
new Zold(farm).pay(
... | #vulnerable code
@Test
public void payZold() throws Exception {
MatcherAssert.assertThat(
new Zold(new PropsFarm()).pay(
"yegor256",
new Cash.S("$0.01"),
"ZoldITCase#payZold",
"none"
),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rendersHomePage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
n... | #vulnerable code
@Test
public void rendersHomePage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<Dependency> dependencies(final Resource resource,
final Properties properties) {
if ("true".equals(properties.getProperty("computed", "false"))) {
log.info("Dependencies are pre-computed in properties");
Model model = new Model();
model = ThinProperties... | #vulnerable code
public List<Dependency> dependencies(final Resource resource,
final Properties properties) {
if ("true".equals(properties.getProperty("computed", "false"))) {
log.info("Dependencies are pre-computed in properties");
Model model = new Model();
model = ThinProp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<Dependency> dependencies(final Resource resource,
final Properties properties) {
if ("true".equals(properties.getProperty("computed", "false"))) {
log.info("Dependencies are pre-computed in properties");
Model model = new Model();
model = ThinProperties... | #vulnerable code
public List<Dependency> dependencies(final Resource resource,
final Properties properties) {
if ("true".equals(properties.getProperty("computed", "false"))) {
log.info("Dependencies are pre-computed in properties");
Model model = new Model();
model = ThinProp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<Dependency> dependencies(final Resource resource,
final Properties properties) {
if ("true".equals(properties.getProperty("computed", "false"))) {
log.info("Dependencies are pre-computed in properties");
Model model = new Model();
model = ThinProperties... | #vulnerable code
public List<Dependency> dependencies(final Resource resource,
final Properties properties) {
if ("true".equals(properties.getProperty("computed", "false"))) {
log.info("Dependencies are pre-computed in properties");
Model model = new Model();
model = ThinProp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static String getStreamContents(InputStream is) {
Preconditions.checkNotNull(is, "Cannot get String from a null object");
try {
final char[] buffer = new char[0x10000];
final StringBuilder out = new StringBuilder();
t... | #vulnerable code
public static String getStreamContents(InputStream is) {
Preconditions.checkNotNull(is, "Cannot get String from a null object");
try {
final char[] buffer = new char[0x10000];
final StringBuilder out = new StringBuilder();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
void findKBest(int k, PriorityQueue<Pair> heap,
Vector hidden, Vector output) {
computeOutputSoftmax(hidden, output);
for (int i = 0; i < osz_; i++) {
if (heap.size() == k && log(output.data_[i]) < heap.peek().first) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float negativeSampling(int target, float lr) {
float loss = 0.0f;
grad_.zero();
for (int n = 0; n <= args_.neg; n++) {
if (n == 0) {
loss += binaryLogistic(target, true, lr);
} else {
loss +... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
int getNegative(int target) {
int negative;
do {
negative = negatives.get(negpos);
negpos = (negpos + 1) % negatives.size();
} while (target == negative);
return negative;
}
#locati... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void setInfo() {
setLevel(Level.INFO);
} | #vulnerable code
public static void setInfo() {
setLevel(Level.INFO);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float negativeSampling(int target, float lr) {
float loss = 0.0f;
grad_.zero();
for (int n = 0; n <= args_.neg; n++) {
if (n == 0) {
loss += binaryLogistic(target, true, lr);
} else {
loss +... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float softmax(int target, float lr) {
grad_.zero();
computeOutputSoftmax();
for (int i = 0; i < osz_; i++) {
float label = (i == target) ? 1.0f : 0.0f;
float alpha = lr * (label - output_.data_[i]);
grad_.addRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float hierarchicalSoftmax(int target, float lr) {
float loss = 0.0f;
grad_.zero();
IntVector binaryCode = codes.get(target);
IntVector pathToRoot = paths.get(target);
for (int i = 0; i < pathToRoot.size(); i++) {
loss ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float getLoss() {
return loss_ / nexamples_;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
void dfs(int k, int node, float score,
PriorityQueue<Pair> heap,
Vector hidden) {
if (heap.size() == k && score < heap.peek().first) {
return;
}
if (tree[node].left == -1 && tree[node].right == -1) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float softmax(int target, float lr) {
grad_.zero();
computeOutputSoftmax();
for (int i = 0; i < osz_; i++) {
float label = (i == target) ? 1.0f : 0.0f;
float alpha = lr * (label - output_.data_[i]);
grad_.addRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
List<Pair> predict(int[] input,
int k,
Vector hidden,
Vector output) {
assert (k > 0);
computeHidden(input, hidden);
PriorityQueue<Pair> heap = new PriorityQueue<>(k+1, PAIR_COMPARATOR);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
Stri... | #vulnerable code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
void computeHidden(int[] input, Vector hidden) {
assert (hidden.size() == hsz_);
hidden.zero();
for (int i : input) {
hidden.addRow(wi_, i);
}
hidden.mul(1.0f / input.length);
}
#locati... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
void computeOutputSoftmax(Vector hidden, Vector output) {
output.mul(wo_, hidden);
float max = output.data_[0], z = 0.0f;
for (int i = 0; i < osz_; i++) {
max = Math.max(output.data_[i], max);
}
for (int i = 0; i < osz... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
List<Pair> predict(int[] input, int k) {
return predict(input, k, hidden_, output_);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
Stri... | #vulnerable code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float softmax(int target, float lr) {
grad_.zero();
computeOutputSoftmax();
for (int i = 0; i < osz_; i++) {
float label = (i == target) ? 1.0f : 0.0f;
float alpha = lr * (label - output_.data_[i]);
grad_.addRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
int getNegative(int target) {
int negative;
do {
negative = negatives[negpos];
negpos = (negpos + 1) % negatives.length;
} while (target == negative);
return negative;
}
#location 5... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
float softmax(int target, float lr) {
grad_.zero();
computeOutputSoftmax();
for (int i = 0; i < osz_; i++) {
float label = (i == target) ? 1.0f : 0.0f;
float alpha = lr * (label - output_.data_[i]);
grad_.addRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
void computeOutputSoftmax() {
computeOutputSoftmax(hidden_, output_);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
Stri... | #vulnerable code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void stemEndingTest1() throws IOException {
TurkishMorphology morphology = TurkishMorphology.builder().addDictionaryLines("bakmak", "gelmek").build();
List<String> endings = Lists.newArrayList("acak", "ecek");
StemEndingGraph graph = n... | #vulnerable code
@Test
public void stemEndingTest1() throws IOException {
TurkishMorphology morphology = TurkishMorphology.builder().addDictionaryLines("bakmak", "gelmek").build();
List<String> endings = Lists.newArrayList("acak", "ecek");
StemEndingGraph gra... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
@Ignore("Slow test. Uses actual data.")
public void suggestWordTest() throws IOException, URISyntaxException {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
TurkishSpellChecker spellChecker = new TurkishSpellChecker(morph... | #vulnerable code
@Test
@Ignore("Slow test. Uses actual data.")
public void suggestWordTest() throws IOException, URISyntaxException {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
TurkishSpellChecker spellChecker = new TurkishSpellChecker... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
Stri... | #vulnerable code
public static WebDocument fromText(String meta, List<String> pageData) {
String url = Regexps.firstMatch(urlPattern, meta, 2);
String id = url.replaceAll("http://|https://", "");
String source = Regexps.firstMatch(sourcePattern, meta, 2);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public List<WordAnalysis> analyzeWithoutCache(String word) {
String s = normalize(word); // TODO: this may cause problem for some foreign words.
if (s.length() == 0) {
return Collections.emptyList();
}
List<WordAnalysis> res = wordA... | #vulnerable code
public List<WordAnalysis> analyzeWithoutCache(String word) {
String s = normalize(word); // TODO: this may cause problem for some foreign words.
if (s.length() == 0) {
return Collections.emptyList();
}
List<WordAnalysis> res =... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
List<Pair> predict(int[] input,
int k,
Vector hidden,
Vector output) {
assert (k > 0);
computeHidden(input, hidden);
PriorityQueue<Pair> heap = new PriorityQueue<>(k+1, PAIR_COMPARATOR);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
}
... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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());
... | #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());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void release(RrdDb rrdDb) throws IOException {
// null pointer should not kill the thread, just ignore it
if (rrdDb == null) {
return;
}
String canonicalPath = rrdDb.getCanonicalPath();
RrdEntry ref;
try {
... | #vulnerable code
public void release(RrdDb rrdDb) throws IOException {
// null pointer should not kill the thread, just ignore it
if (rrdDb == null) {
return;
}
String canonicalPath = rrdDb.getCanonicalPath();
RrdEntry ref;
tr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBackendFactoryWithExecutor() throws IOException {
RrdNioBackendFactory factory = (RrdNioBackendFactory) RrdBackendFactory.getFactory("NIO");
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
factory.setS... | #vulnerable code
@Test
public void testBackendFactoryWithExecutor() throws IOException {
RrdNioBackendFactory factory = (RrdNioBackendFactory) RrdBackendFactory.getFactory("NIO");
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
factor... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
}
... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEntriesNeg55To105InRrd() throws IOException, FontFormatException {
createGaugeRrd(165);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<160; i++) {
long timestamp = startTime + 1 + (i *... | #vulnerable code
@Test
public void testEntriesNeg55To105InRrd() throws IOException, FontFormatException {
createGaugeRrd(165);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<160; i++) {
long timestamp = startTime + 1 + (i * 60);
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEntriesNeg50To100InRrd() throws IOException, FontFormatException {
createGaugeRrd(155);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<150; i++) {
long timestamp = startTime + 1 + (i *... | #vulnerable code
@Test
public void testEntriesNeg50To100InRrd() throws IOException, FontFormatException {
createGaugeRrd(155);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<150; i++) {
long timestamp = startTime + 1 + (i * 60);
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#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());
... | #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());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBackendFactory() throws IOException {
File rrdfile = testFolder.newFile("testfile");
try(RrdSafeFileBackendFactory factory = new RrdSafeFileBackendFactory()) {
super.testBackendFactory(factory,rrdfile.getCanonicalPath());
... | #vulnerable code
@Test
public void testBackendFactory() throws IOException {
RrdRandomAccessFileBackendFactory factory = (RrdRandomAccessFileBackendFactory) RrdBackendFactory.getFactory("SAFE");
File rrdfile = testFolder.newFile("testfile");
RrdBackend be = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
}
... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 * 6... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEntriesNeg50To100InRrd() throws IOException, FontFormatException {
createGaugeRrd(155);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<150; i++) {
long timestamp = startTime + 1 + (i ... | #vulnerable code
@Test
public void testEntriesNeg50To100InRrd() throws IOException, FontFormatException {
createGaugeRrd(155);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<150; i++) {
long timestamp = startTime + 1 + (i * 60);
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void copyFile(String sourcePath, String destPath, boolean saveBackup)
throws IOException {
File source = new File(sourcePath);
File dest = new File(destPath);
if (saveBackup) {
String backupPath = getBackupPath(de... | #vulnerable code
private static void copyFile(String sourcePath, String destPath, boolean saveBackup)
throws IOException {
File source = new File(sourcePath);
File dest = new File(destPath);
if (saveBackup) {
String backupPath = getBackupP... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
}
... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEntriesNeg80To80InRrd() throws IOException, FontFormatException {
createGaugeRrd(180);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<160; i++) {
long timestamp = startTime + 1 + (i *... | #vulnerable code
@Test
public void testEntriesNeg80To80InRrd() throws IOException, FontFormatException {
createGaugeRrd(180);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<160; i++) {
long timestamp = startTime + 1 + (i * 60);
Sa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void internalClose() throws IOException {
if (!closed) {
closed = true;
backend.rrdClose();
}
} | #vulnerable code
void realClose() throws IOException {
if (!closed) {
closed = true;
backend.rrdClose();
}
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
}
... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBackendFactory() throws IOException {
File rrdfile = testFolder.newFile("testfile");
try(RrdRandomAccessFileBackendFactory factory = new RrdRandomAccessFileBackendFactory()) {
super.testBackendFactory(factory,rrdfile.getCa... | #vulnerable code
@Test
public void testBackendFactory() throws IOException {
RrdRandomAccessFileBackendFactory factory = (RrdRandomAccessFileBackendFactory) RrdBackendFactory.getFactory("FILE");
File rrdfile = testFolder.newFile("testfile");
RrdBackend be = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void release(RrdDb rrdDb) throws IOException {
// null pointer should not kill the thread, just ignore it
if (rrdDb == null) {
return;
}
RrdEntry ref;
try {
ref = getEntry(rrdDb.getPath(), false);
... | #vulnerable code
public void release(RrdDb rrdDb) throws IOException {
// null pointer should not kill the thread, just ignore it
if (rrdDb == null) {
return;
}
RrdEntry ref;
try {
ref = getEntry(rrdDb.getPath(), false);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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; ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEntriesNeg80To90InRrd() throws IOException, FontFormatException {
createGaugeRrd(180);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<170; i++) {
long timestamp = startTime + 1 + (i *... | #vulnerable code
@Test
public void testEntriesNeg80To90InRrd() throws IOException, FontFormatException {
createGaugeRrd(180);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<170; i++) {
long timestamp = startTime + 1 + (i * 60);
Sa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBackendFactoryDefaults() throws IOException {
try (RrdNioBackendFactory factory = new RrdNioBackendFactory(0)) {
File rrdfile = testFolder.newFile("testfile");
super.testBackendFactory(factory,rrdfile.getCanonicalPath(... | #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();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Archive findMatchingArchive(FetchRequest request) throws IOException {
ConsolFun consolFun = request.getConsolFun();
long fetchStart = request.getFetchStart();
long fetchEnd = request.getFetchEnd();
long resolution = request.getResolutio... | #vulnerable code
public Archive findMatchingArchive(FetchRequest request) throws IOException {
ConsolFun consolFun = request.getConsolFun();
long fetchStart = request.getFetchStart();
long fetchEnd = request.getFetchEnd();
long resolution = request.getRes... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void release(RrdDb rrdDb) throws IOException {
// null pointer should not kill the thread, just ignore it
if (rrdDb == null) {
return;
}
RrdEntry ref;
try {
ref = getEntry(rrdDb.getPath(), false);
... | #vulnerable code
public void release(RrdDb rrdDb) throws IOException {
// null pointer should not kill the thread, just ignore it
if (rrdDb == null) {
return;
}
RrdEntry ref;
try {
ref = getEntry(rrdDb.getPath(), false);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEntriesNeg80To90InRrd() throws IOException, FontFormatException {
createGaugeRrd(180);
RrdDb rrd = RrdDb.getBuilder().setPath(jrbFileName).build();
for(int i=0; i<170; i++) {
long timestamp = startTime + 1 + (i * ... | #vulnerable code
@Test
public void testEntriesNeg80To90InRrd() throws IOException, FontFormatException {
createGaugeRrd(180);
RrdDb rrd = new RrdDb(jrbFileName);
for(int i=0; i<170; i++) {
long timestamp = startTime + 1 + (i * 60);
Sa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void basicUsage() throws IOException {
// OSGi metadata is only added for Java8+, so skip this test on Java 7
String javaVersion = System.getProperty("java.version");
assumeThat(javaVersion, not(startsWith((("1.7")))));
RrdDe... | #vulnerable code
@Test
public void basicUsage() throws IOException {
// OSGi metadata is only added for Java8+, so skip this test on Java 7
String javaVersion = System.getProperty("java.version");
assumeThat(javaVersion, not(startsWith((("1.7")))));
... | 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.