output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
public final void send() {
if (packet == null) {
packet = outqueue.poll();
if (packet == null) {
return;
}
}
try {
for (;;) {
while (packet.writeLength < packet.totalLength... | #vulnerable code
public final void send() {
if (packet == null) {
packet = outqueue.poll();
if (packet == null) {
return;
}
}
try {
for (;;) {
while (packet.writeLength < packet.total... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public final void send() {
if (packet == null) {
packet = outqueue.poll();
if (packet == null) {
return;
}
}
try {
for (;;) {
while (packet.writeLength < packet.totalLength... | #vulnerable code
public final void send() {
if (packet == null) {
packet = outqueue.poll();
if (packet == null) {
return;
}
}
try {
for (;;) {
while (packet.writeLength < packet.total... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public final void send() {
if (packet == null) {
packet = outqueue.poll();
if (packet == null) {
return;
}
}
try {
for (;;) {
while (packet.writeLength < packet.totalLength... | #vulnerable code
public final void send() {
if (packet == null) {
packet = outqueue.poll();
if (packet == null) {
return;
}
}
try {
for (;;) {
while (packet.writeLength < packet.total... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<String, String> filterInfo(Map<String, String> info) {
Map<String, String> newInfo = Maps.newHashMap(info);
String limitLine = newInfo.remove(PUSH_PROPERTIES_LIMIT);
Set<String> limitKeys = getLimitKeys(limitLine);
if (limitKeys.isE... | #vulnerable code
private Map<String, String> filterInfo(Map<String, String> info) {
HashMap<String, String> newInfo = Maps.newHashMap(info);
String limit = newInfo.get(PUSH_PROPERTIES_LIMIT);
if (Strings.isNullOrEmpty(limit)) {
newInfo.remove(PUSH_P... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public T blpopObject(int timeout, String key, Class clazz) {
this.setSchema(clazz);
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
List<byte[]> bytes = jedis.blpop(timeout, key.getBytes());
if (bytes == n... | #vulnerable code
public T blpopObject(int timeout, String key, Class clazz) {
this.setSchema(clazz);
Jedis jedis = null;
try {
List<byte[]> bytes = jedis.blpop(timeout, key.getBytes());
if (bytes == null || bytes.size() == 0) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPostMultipleFiles() throws JSONException, URISyntaxException {
HttpResponse<JsonNode> response = Unirest.post(MockServer.POST)
.field("param3", "wot")
.field("file1", new File(getClass().getResource("/test").to... | #vulnerable code
@Test
public void testPostMultipleFiles() throws JSONException, URISyntaxException {
HttpResponse<JsonNode> response = Unirest.post("http://httpbin.org/post").field("param3", "wot").field("file1", new File(getClass().getResource("/test").toURI())).field("fil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCustomUserAgent() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GETJSON)
.header("user-agent", "hello-world")
.asJson();
RequestCapture json = parse(response);
... | #vulnerable code
@Test
public void testCustomUserAgent() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get?name=mark").header("user-agent", "hello-world").asJson();
assertEquals("hello-world", response.getBody().getObject().... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testAsync() throws JSONException, InterruptedException, ExecutionException {
// Future<HttpResponse<JsonNode>> future = Unirest.post("http://httpbin.org/post")
// .header("accept", "application/json")
// .field("param1", "value1")
// .field("param... | #vulnerable code
@Test
public void testAsync() throws JSONException, InterruptedException, ExecutionException {
Future<HttpResponse<JsonNode>> future = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.field("param1", "value1")
.field("param2"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T> MashapeResponse<T> doRequest (Class<T> clazz, HttpMethod httpMethod, String url, Map<String, Object> parameters, ContentType contentType, ResponseType responseType, List<Authentication> authenticationHandlers) {
if (authenticationHandlers == null) authenticat... | #vulnerable code
public static <T> MashapeResponse<T> doRequest (Class<T> clazz, HttpMethod httpMethod, String url, Map<String, Object> parameters, ContentType contentType, ResponseType responseType, List<Authentication> authenticationHandlers) {
if (authenticationHandlers == null) authe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPostRawBody() {
String sourceString = "'\"@こんにちは-test-123-" + Math.random();
byte[] sentBytes = sourceString.getBytes();
HttpResponse<JsonNode> response = Unirest.post(MockServer.POST)
.body(sentBytes)
.asJson();
RequestCapture json = par... | #vulnerable code
@Test
public void testPostRawBody() {
String sourceString = "'\"@こんにちは-test-123-" + Math.random();
byte[] sentBytes = sourceString.getBytes();
HttpResponse<JsonNode> response = Unirest.post("http://httpbin.org/post").body(sentBytes).asJson();
assertEquals(source... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testMultipartAsync() throws JSONException, InterruptedException, ExecutionException, URISyntaxException, UnirestException {
Unirest.post("http://httpbin.org/post")
.field("name", "Mark")
.field("file", new File(getClass().getResource("/test").toURI())).a... | #vulnerable code
@Test
public void testMultipartAsync() throws JSONException, InterruptedException, ExecutionException, URISyntaxException, UnirestException {
Future<HttpResponse<JsonNode>> future = Unirest.post("http://httpbin.org/post")
.field("file", new File(getClass().getResource... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testMultipartInputStreamContentType() throws JSONException, URISyntaxException, FileNotFoundException {
FileInputStream stream = new FileInputStream(new File(getClass().getResource("/image.jpg").toURI()));
MultipartBody request = Unirest.post(MockServer.HO... | #vulnerable code
@Test
public void testMultipartInputStreamContentType() throws JSONException, URISyntaxException, FileNotFoundException {
FileInputStream stream = new FileInputStream(new File(getClass().getResource("/image.jpg").toURI()));
MultipartBody request = Unirest.post(MockSer... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDeleteBody() throws JSONException, UnirestException {
String body = "{\"jsonString\":{\"members\":\"members1\"}}";
HttpResponse<JsonNode> response = Unirest.delete(MockServer.DELETE)
.body(body)
.asJson();
assertEquals(200, response.getStatu... | #vulnerable code
@Test
public void testDeleteBody() throws JSONException, UnirestException {
String body = "{\"jsonString\":{\"members\":\"members1\"}}";
HttpResponse<JsonNode> response = Unirest.delete("http://httpbin.org/delete").body(body).asJson();
assertEquals(200, response.get... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetMultiple() throws JSONException, UnirestException {
for (int i = 1; i <= 20; i++) {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GETJSON + "?try=" + i).asJson();
parse(response).assertQuery("try", String.valueOf(i));
}
... | #vulnerable code
@Test
public void testGetMultiple() throws JSONException, UnirestException {
for (int i = 1; i <= 20; i++) {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get?try=" + i).asJson();
assertEquals(response.getBody().getObject().getJSONObject("args"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPostCollection() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.post(MockServer.POST)
.field("name", Arrays.asList("Mark", "Tom"))
.asJson();
parse(response)
... | #vulnerable code
@Test
public void testPostCollection() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.post("http://httpbin.org/post").field("name", Arrays.asList("Mark", "Tom")).asJson();
JSONArray names = response.getBody().getO... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetArray() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GET)
.queryString("name", Arrays.asList("Mark", "Tom"))
.asJson();
parse(response)
... | #vulnerable code
@Test
public void testGetArray() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get").queryString("name", Arrays.asList("Mark", "Tom")).asJson();
JSONArray names = response.getBody().getObj... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testQueryStringEncoding() throws JSONException, UnirestException {
String testKey = "email2=someKey&email";
String testValue = "hello@hello.com";
HttpResponse<JsonNode> response = Unirest.get(MockServer.GETJSON)
.queryString(testKey, tes... | #vulnerable code
@Test
public void testQueryStringEncoding() throws JSONException, UnirestException {
String testKey = "email2=someKey&email";
String testValue = "hello@hello.com";
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get").queryString(testKey, testValue... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetUTF8() {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GETJSON)
.header("accept", "application/json")
.queryString("param3", "こんにちは")
.asJson();
FormCapture json = TestUtils.read(response, FormCapture.class);
json.assertQue... | #vulnerable code
@Test
public void testGetUTF8() {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get").queryString("param3", "こんにちは").asJson();
assertEquals(response.getBody().getObject().getJSONObject("args").getString("param3"), "こんにちは");
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testObjectMapperWrite() {
Unirest.setObjectMapper(new JacksonObjectMapper());
GetResponse postResponseMock = new GetResponse();
postResponseMock.setUrl(MockServer.POST);
HttpResponse<JsonNode> postResponse = Unirest.post... | #vulnerable code
@Test
public void testObjectMapperWrite() {
Unirest.setObjectMapper(new JacksonObjectMapper());
GetResponse postResponseMock = new GetResponse();
postResponseMock.setUrl("http://httpbin.org/post");
HttpResponse<JsonNode> postRespons... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetQuerystringArray() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GET)
.queryString("name", "Mark")
.queryString("name", "Tom")
.asJson();
... | #vulnerable code
@Test
public void testGetQuerystringArray() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get").queryString("name", "Mark").queryString("name", "Tom").asJson();
JSONArray names = response.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDelete() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.delete(MockServer.DELETE).asJson();
assertEquals(200, response.getStatus());
response = Unirest.delete(MockServer.DELETE)
.field("name", "mark")
.fie... | #vulnerable code
@Test
public void testDelete() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.delete("http://httpbin.org/delete").asJson();
assertEquals(200, response.getStatus());
response = Unirest.delete("http://httpbin.org/delete").field("na... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPostBinaryUTF8() throws URISyntaxException {
HttpResponse<JsonNode> response = Unirest.post(MockServer.POST)
.header("Accept", ContentType.MULTIPART_FORM_DATA.getMimeType())
.field("param3", "こんにちは")
.field("file", new File(getClass().getReso... | #vulnerable code
@Test
public void testPostBinaryUTF8() throws URISyntaxException {
HttpResponse<JsonNode> response = Unirest.post("http://httpbin.org/post").field("param3", "こんにちは").field("file", new File(getClass().getResource("/test").toURI())).asJson();
assertEquals("This is a te... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCaseInsensitiveHeaders() {
GetRequest request = Unirest.get(MockServer.GET)
.header("Name", "Marco");
assertEquals(1, request.getHeaders().size());
assertEquals("Marco", request.getHeaders().get("name").get(0)... | #vulnerable code
@Test
public void testCaseInsensitiveHeaders() {
GetRequest request = Unirest.get("http://httpbin.org/headers").header("Name", "Marco");
assertEquals(1, request.getHeaders().size());
assertEquals("Marco", request.getHeaders().get("name").get(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testMultipartInputStreamContentType() throws JSONException, InterruptedException, ExecutionException, URISyntaxException, UnirestException, FileNotFoundException {
FileInputStream stream = new FileInputStream(new File(getClass().getResource("/image.jpg").toU... | #vulnerable code
@Test
public void testMultipartInputStreamContentType() throws JSONException, InterruptedException, ExecutionException, URISyntaxException, UnirestException, FileNotFoundException {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post").field("nam... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testAsync() throws JSONException, InterruptedException, ExecutionException {
Future<HttpResponse<JsonNode>> future = Unirest.post(MockServer.POST)
.header("accept", "application/json")
.field("param1", "value1")
.field("param2", "bye")
.asJso... | #vulnerable code
@Test
public void testAsync() throws JSONException, InterruptedException, ExecutionException {
Future<HttpResponse<JsonNode>> future = Unirest.post("http://httpbin.org/post").header("accept", "application/json").field("param1", "value1").field("param2", "bye").asJsonAsy... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetFields2() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GETJSON)
.queryString("email", "hello@hello.com")
.asJson();
parse(response).assertQuery("email", "hel... | #vulnerable code
@Test
public void testGetFields2() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/get").queryString("email", "hello@hello.com").asJson();
assertEquals("hello@hello.com", response.getBody().getObject().getJSON... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPostUTF8() {
HttpResponse response = Unirest.post(MockServer.POSTJSON)
.header("accept", "application/json")
.field("param3", "こんにちは")
.asJson();
FormCapture json = TestUtils.read(response, FormCapture.class);
json.assertQuery("param3", ... | #vulnerable code
@Test
public void testPostUTF8() {
HttpResponse<JsonNode> response = Unirest.post("http://httpbin.org/post").field("param3", "こんにちは").asJson();
assertEquals(response.getBody().getObject().getJSONObject("form").getString("param3"), "こんにちは");
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBasicAuth() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get(MockServer.GETJSON)
.basicAuth("user", "test")
.asJson();
parse(response).assertHeader("Authorization", "Basic dXNlcjp0ZXN0");
} | #vulnerable code
@Test
public void testBasicAuth() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/headers").basicAuth("user", "test").asJson();
assertEquals("Basic dXNlcjp0ZXN0", response.getBody().getObject().getJSONObject("... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPostArray() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.post(MockServer.POST)
.field("name", "Mark")
.field("name", "Tom")
.asJson();
parse(respon... | #vulnerable code
@Test
public void testPostArray() throws JSONException, UnirestException {
HttpResponse<JsonNode> response = Unirest.post("http://httpbin.org/post").field("name", "Mark").field("name", "Tom").asJson();
JSONArray names = response.getBody().getObject(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testRequests() throws JSONException {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.field("param1", "value1")
.field("param2","bye")
... | #vulnerable code
@Test
public void testRequests() throws Exception {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.field("param1", "value1")
.field("param2","bye")
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean isStarted() {
try {
lock.lock();
return client.getState() == CuratorFrameworkState.STARTED;
} finally {
lock.unlock();
}
} | #vulnerable code
public boolean isStarted() {
return client.getState() == CuratorFrameworkState.STARTED;
}
#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 void postEvent(ApplicationType applicationType, ActionType actionType, ProtocolType protocolType, ProtocolMessage message) {
if (message.getException() == null) {
return;
}
ProtocolEvent protocolEvent = new ProtocolEvent(appl... | #vulnerable code
public static void postEvent(ApplicationType applicationType, ActionType actionType, ProtocolType protocolType, ProtocolMessage message) {
if (message.getException() == null) {
return;
}
ProtocolEvent protocolEvent = new ProtocolEven... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void onEvent(PathChildrenCacheEvent event, InstanceEventType instanceEventType) throws Exception {
String childPath = event.getData().getPath();
String applicationJson = childPath.substring(childPath.lastIndexOf("/") + 1);
ApplicationEntity app... | #vulnerable code
private void onEvent(PathChildrenCacheEvent event, InstanceEventType instanceEventType) throws Exception {
String childPath = event.getData().getPath();
String applicationJson = childPath.substring(childPath.lastIndexOf("/") + 1);
ApplicationEnti... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSourceSinkStartResumeRollingEverySecond() throws Exception {
//This is the config that is required to make the VanillaChronicle roll every second
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkB... | #vulnerable code
@Test
public void testSourceSinkStartResumeRollingEverySecond() throws Exception {
//This is the config that is required to make the VanillaChronicle roll every second
final String sourceBasePath = getVanillaTestPath("-source");
final String... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPricePublishing1() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = ChronicleQueueBuilde... | #vulnerable code
@Test
public void testPricePublishing1() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = new ChronicleS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testOverTCP() throws IOException, InterruptedException {
String baseDir = System.getProperty("java.io.tmpdir");
String srcBasePath = baseDir + "/IPCT.testOverTCP.source";
ChronicleTools.deleteOnExit(srcBasePath);
// NOTE: ... | #vulnerable code
@Test
public void testOverTCP() throws IOException, InterruptedException {
String baseDir = System.getProperty("java.io.tmpdir");
String srcBasePath = baseDir + "/IPCT.testOverTCP.source";
ChronicleTools.deleteOnExit(srcBasePath);
// ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String... ignored) throws IOException {
String basePath = TMP + "/ExampleCacheMain";
ChronicleTools.deleteOnExit(basePath);
CachePerfMain map = new CachePerfMain(basePath, 64);
buildkeylist(keys);
long duration;
for (int i = 0; i < 2; i++) {... | #vulnerable code
public static void main(String... ignored) throws IOException {
String basePath = TMP + "/ExampleCacheMain";
ChronicleTools.deleteOnExit(basePath);
CachePerfMain map = new CachePerfMain(basePath, 32);
long start = System.nanoTime();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPricePublishing1() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = ChronicleQueueBuilde... | #vulnerable code
@Test
public void testPricePublishing1() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = new ChronicleS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldBeAbleToDumpReadOnlyQueueFile() throws Exception {
if (OS.isWindows())
return;
final File dataDir = DirectoryUtils.tempDir(DumpQueueMainTest.class.getSimpleName());
try (final SingleChronicleQueue queue = Single... | #vulnerable code
@Test
public void shouldBeAbleToDumpReadOnlyQueueFile() throws Exception {
if (OS.isWindows())
return;
final File dataDir = DirectoryUtils.tempDir(DumpQueueMainTest.class.getSimpleName());
final SingleChronicleQueue queue = Singl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldDetermineQueueDirectoryFromQueueFile() throws Exception {
final Path path = Paths.get(OS.USER_DIR, TEST_QUEUE_FILE);
try (final SingleChronicleQueue queue =
SingleChronicleQueueBuilder.binary(path)
... | #vulnerable code
@Test
public void shouldDetermineQueueDirectoryFromQueueFile() throws Exception {
final File queuePath = DirectoryUtils.tempDir(getClass().getSimpleName());
try (final SingleChronicleQueue queue =
SingleChronicleQueueBuilder.bina... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static long getCurrentQueueFileLength(final Path dataDir) throws IOException {
try (RandomAccessFile file = new RandomAccessFile(
Files.list(dataDir).filter(p -> p.toString().endsWith("cq4")).findFirst().
orElseThrow(Ass... | #vulnerable code
private static long getCurrentQueueFileLength(final Path dataDir) throws IOException {
return new RandomAccessFile(
Files.list(dataDir).filter(p -> p.toString().endsWith("cq4")).findFirst().
orElseThrow(AssertionError::new... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public VanillaFile dataForLast(int cycle, int threadId) throws IOException {
String cycleStr = dateCache.formatFor(cycle);
String cyclePath = basePath + "/" + cycleStr;
String dataPrefix = "data-" + threadId + "-";
if (lastCycle != cycle) {
... | #vulnerable code
public VanillaFile dataForLast(int cycle, int threadId) throws IOException {
String cycleStr = dateCache.formatFor(cycle);
String dataPrefix = basePath + "/" + cycleStr + "/data-" + threadId + "-";
if (lastCycle != cycle) {
int maxCou... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testOverTCP() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
// NOTE: the sink and source must have different chron... | #vulnerable code
@Test
public void testOverTCP() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
// NOTE: the sink and source must have different... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPersistedLocalVanillaSink_001() throws Exception {
final int port = BASE_PORT + 301;
final String basePath = getVanillaTestPath();
final Chronicle chronicle = ChronicleQueueBuilder.vanilla(basePath).build();
final Ch... | #vulnerable code
@Test
public void testPersistedLocalVanillaSink_001() throws Exception {
final int port = BASE_PORT + 301;
final String basePath = getVanillaTestPath();
final Chronicle chronicle = ChronicleQueueBuilder.vanilla(basePath).build();
fin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void init() {
tableStore.doWithExclusiveLock(ts -> {
maxCycleValue = ts.acquireValueFor(HIGHEST_CREATED_CYCLE);
minCycleValue = ts.acquireValueFor(LOWEST_CREATED_CYCLE);
lock = ts.acquireValueFor(LOCK);
... | #vulnerable code
@Override
public void init() {
final long timeoutAt = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(20L);
boolean warnedOnFailure = false;
while (System.currentTimeMillis() < timeoutAt) {
try (final FileChannel channel = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPricePublishing2() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = ChronicleQueueBuilde... | #vulnerable code
@Test
public void testPricePublishing2() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = new ChronicleS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void writeBytesInternal(final long index, @NotNull final BytesStore bytes, boolean metadata) {
final int cycle = queue.rollCycle().toCycle(index);
if (wire == null)
setCycle2(cycle, true);
else if (queue.rollCycle().toCycle(wire.... | #vulnerable code
protected void writeBytesInternal(final long index, @NotNull final BytesStore bytes, boolean metadata) {
final int cycle = queue.rollCycle().toCycle(index);
long headerNumber = wire.headerNumber();
if (wire == null) {
setCycle2(cycle... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSimpledSingleThreadedWriteRead() throws Exception {
try (DirectStore allocate = DirectStore.allocate(150)) {
final BytesRingBuffer bytesRingBuffer = new BytesRingBuffer(allocate.bytes());
bytesRingBuffer.offer(outpu... | #vulnerable code
@Test
public void testSimpledSingleThreadedWriteRead() throws Exception {
try (DirectStore allocate = DirectStore.allocate(150)) {
final BytesQueue bytesRingBuffer = new BytesQueue(allocate.bytes());
bytesRingBuffer.offer(output.c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSourceSinkStartResumeRollingEverySecond() throws Exception {
//This is the config that is required to make the VanillaChronicle roll every second
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkB... | #vulnerable code
@Test
public void testSourceSinkStartResumeRollingEverySecond() throws Exception {
//This is the config that is required to make the VanillaChronicle roll every second
final String sourceBasePath = getVanillaTestPath("-source");
final String... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPricePublishing3() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = ChronicleQueueBuilde... | #vulnerable code
@Test
public void testPricePublishing3() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = new ChronicleS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testReplication1() throws Exception {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final ChronicleSource source = new Chronic... | #vulnerable code
@Test
public void testReplication1() throws IOException {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final ChronicleSource source = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testFlowAroundSingleThreadedWriteDiffrentSizeBuffers() throws Exception {
for (int j = 23 + 34; j < 100; j++) {
try (DirectStore allocate = DirectStore.allocate(j)) {
final BytesRingBuffer bytesRingBuffer = new Bytes... | #vulnerable code
@Test
public void testFlowAroundSingleThreadedWriteDiffrentSizeBuffers() throws Exception {
for (int j = 23 + 34; j < 100; j++) {
try (DirectStore allocate = DirectStore.allocate(j)) {
final BytesQueue bytesRingBuffer = new Byte... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testReplication1() throws Exception {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final Chronicle source = ChronicleQueueBui... | #vulnerable code
@Test
public void testReplication1() throws Exception {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final ChronicleSource source = new C... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPricePublishing2() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = ChronicleQueueBuilde... | #vulnerable code
@Test
public void testPricePublishing2() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = new ChronicleS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@NotNull
private WireStore acquireStore(final long cycle, final long epoch) {
@NotNull final RollCycle rollCycle = builder.rollCycle();
@NotNull final String cycleFormat = this.dateCache.formatFor(cycle);
@NotNull final File cycleFile = new File(th... | #vulnerable code
@NotNull
private WireStore acquireStore(final long cycle, final long epoch) {
@NotNull final RollCycle rollCycle = builder.rollCycle();
@NotNull final String cycleFormat = this.dateCache.formatFor(cycle);
@NotNull final File cycleFile = new F... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPersistedLocalIndexedSink_001() throws Exception {
final int port = BASE_PORT + 201;
final String basePath = getIndexedTestPath();
final Chronicle chronicle = ChronicleQueueBuilder.indexed(basePath).build();
final Ch... | #vulnerable code
@Test
public void testPersistedLocalIndexedSink_001() throws Exception {
final int port = BASE_PORT + 201;
final String basePath = getIndexedTestPath();
final Chronicle chronicle = ChronicleQueueBuilder.indexed(basePath).build();
fin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testOverTCP() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
// NOTE: the sink and source must have different chron... | #vulnerable code
@Test
public void testOverTCP() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
// NOTE: the sink and source must have different... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@NotNull
private WireStore acquireStore(final long cycle, final long epoch) {
@NotNull final RollCycle rollCycle = builder.rollCycle();
@NotNull final String cycleFormat = this.dateCache.formatFor(cycle);
@NotNull final File cycleFile = new File(th... | #vulnerable code
@NotNull
private WireStore acquireStore(final long cycle, final long epoch) {
@NotNull final RollCycle rollCycle = builder.rollCycle();
@NotNull final String cycleFormat = this.dateCache.formatFor(cycle);
@NotNull final File cycleFile = new F... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testWriteAndRead() throws Exception {
try (DirectStore allocate = DirectStore.allocate(150)) {
final BytesRingBuffer bytesRingBuffer = new BytesRingBuffer(allocate.bytes());
bytesRingBuffer.offer(output.clear());
... | #vulnerable code
@Test
public void testWriteAndRead() throws Exception {
try (DirectStore allocate = DirectStore.allocate(150)) {
final BytesQueue bytesRingBuffer = new BytesQueue(allocate.bytes());
bytesRingBuffer.offer(output.clear());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long exceptsPerCycle(int cycle) {
StoreTailer tailer = acquireTailer();
try {
long index = rollCycle.toIndex(cycle, 0);
if (tailer.moveToIndex(index)) {
assert tailer.store != null && tailer.store.refCount() > 0;
... | #vulnerable code
public long exceptsPerCycle(int cycle) {
StoreTailer tailer = acquireTailer();
try {
long index = rollCycle.toIndex(cycle, 0);
if (tailer.moveToIndex(index)) {
assert tailer.store.refCount() > 0;
re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testReplication1() throws Exception {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final ChronicleSource source = new Chronic... | #vulnerable code
@Test
public void testReplication1() throws IOException {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final ChronicleSource source = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testReplication1() throws Exception {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final Chronicle source = ChronicleQueueBui... | #vulnerable code
@Test
public void testReplication1() throws Exception {
final int RUNS = 100;
final String sourceBasePath = getVanillaTestPath("-source");
final String sinkBasePath = getVanillaTestPath("-sink");
final ChronicleSource source = new C... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPricePublishing3() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = ChronicleQueueBuilde... | #vulnerable code
@Test
public void testPricePublishing3() throws IOException, InterruptedException {
final String basePathSource = getIndexedTestPath("-source");
final String basePathSink = getIndexedTestPath("-sink");
final Chronicle source = new ChronicleS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
int lastIndexFile(int cycle) {
return lastIndexFile(cycle, 0);
} | #vulnerable code
int lastIndexFile(int cycle, int defaultCycle) {
int maxIndex = -1;
final File cyclePath = new File(baseFile, dateCache.formatFor(cycle));
final File[] files = cyclePath.listFiles();
if (files != null) {
for (final File file ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public synchronized LongValue acquireValueFor(CharSequence key) {
StringBuilder sb = Wires.acquireStringBuilder();
mappedBytes.reserve();
try {
mappedBytes.readPosition(0);
mappedBytes.readLimit(mappedBytes.realCap... | #vulnerable code
@Override
public synchronized LongValue acquireValueFor(CharSequence key) {
StringBuilder sb = Wires.acquireStringBuilder();
mappedBytes.reserve();
try {
mappedBytes.readPosition(0);
mappedBytes.readLimit(mappedBytes.r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void unlock(@NotNull String dir) {
File path = new File(dir);
if (!path.isDirectory()) {
System.err.println("Path argument must be a queue directory");
System.exit(1);
}
File storeFilePath = new File(path... | #vulnerable code
private static void unlock(@NotNull String dir) {
File path = new File(dir);
if (!path.isDirectory()) {
System.err.println("Path argument must be a queue directory");
System.exit(1);
}
File storeFilePath = new Fil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPersistedLocalVanillaSink_001() throws Exception {
final int port = BASE_PORT + 301;
final String basePath = getVanillaTestPath();
final Chronicle chronicle = ChronicleQueueBuilder.vanilla(basePath).build();
final Ch... | #vulnerable code
@Test
public void testPersistedLocalVanillaSink_001() throws Exception {
final int port = BASE_PORT + 301;
final String basePath = getVanillaTestPath();
final Chronicle chronicle = ChronicleQueueBuilder.vanilla(basePath).build();
fin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Before
public void setup() {
final Bytes out = ByteBufferBytes.wrap(ByteBuffer.allocate(22));
out.writeUTF(EXPECTED);
output = out.flip().slice();
} | #vulnerable code
@Before
public void setup() {
final Bytes out = new ByteBufferBytes(ByteBuffer.allocate(22));
out.writeUTF(EXPECTED);
output = out.flip().slice();
}
#location 5
#vulnerability type... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testOneAtATime() throws IOException {
ChronicleConfig config = ChronicleConfig.TEST.clone();
config.indexBlockSize(128); // very small
config.dataBlockSize(128); // very small
final String basePath = TMP + "/testOneAtATim... | #vulnerable code
@Test
public void testOneAtATime() throws IOException {
ChronicleConfig config = ChronicleConfig.TEST.clone();
config.indexBlockSize(128); // very small
config.dataBlockSize(128); // very small
final String basePath = TMP + "/testOne... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testWrite3read3SingleThreadedWrite() throws Exception {
try (DirectStore allocate = DirectStore.allocate(40 * 3)) {
final BytesRingBuffer bytesRingBuffer = new BytesRingBuffer(allocate.bytes());
for (int i = 0; i < 100; i... | #vulnerable code
@Test
public void testWrite3read3SingleThreadedWrite() throws Exception {
try (DirectStore allocate = DirectStore.allocate(40 * 3)) {
final BytesQueue bytesRingBuffer = new BytesQueue(allocate.bytes());
for (int i = 0; i < 100; i++) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public synchronized void release(@NotNull CommonStore store) {
store.release();
long refCount = store.refCount();
assert refCount >= 0;
if (refCount == 0) {
for (Map.Entry<RollDetails, WeakReference<WireStore>> entry : stores.entry... | #vulnerable code
public synchronized void release(@NotNull CommonStore store) {
store.release();
long refCount = store.refCount();
assert refCount >= 0;
if (refCount == 0) {
for (Map.Entry<RollDetails, WeakReference<WireStore>> entry : stores... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
try {
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
r... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
LOG.info("Receive RequestVote request from server {} " +
"in term {} (my term was {})",
request.getServerId(), request.getTerm(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void appendEntries(Peer peer) {
long firstLogIndex = raftLog.getFirstLogIndex();
if (peer.getNextIndex() < firstLogIndex) {
installSnapshot(peer);
return;
}
long prevLogIndex = peer.getNextIndex() - 1;
lo... | #vulnerable code
public void appendEntries(Peer peer) {
long startLogIndex = raftLog.getStartLogIndex();
if (peer.getNextIndex() < startLogIndex) {
this.installSnapshot(peer);
return;
}
long lastLogIndex = this.raftLog.getLastLogI... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
responseBuilder.setTerm(raf... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
if (request.getTerm() > raftNode.getCurrentTerm()) {
LOG.info("Received RequestVote request from server {} " +
"in term {} (this server's term was {})"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
responseBuilder.setTerm(raf... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
if (request.getTerm() > raftNode.getCurrentTerm()) {
LOG.info("Received RequestVote request from server {} " +
"in term {} (this server's term was {})"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
responseBuilder.setTerm(raf... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
if (request.getTerm() > raftNode.getCurrentTerm()) {
LOG.info("Received RequestVote request from server {} " +
"in term {} (this server's term was {})"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
raftNode.getLock().lock();
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode... | #vulnerable code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
responseBuilder.setTerm(raf... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
if (request.getTerm() > raftNode.getCurrentTerm()) {
LOG.info("Received RequestVote request from server {} " +
"in term {} (this server's term was {})"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
raftNode.getLock().lock();
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode... | #vulnerable code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void replicate(byte[] data) {
lock.lock();
Raft.LogEntry logEntry = Raft.LogEntry.newBuilder()
.setTerm(currentTerm)
.setType(Raft.EntryType.ENTRY_TYPE_DATA)
.setData(ByteString.copyFrom(data)).build();
... | #vulnerable code
public void replicate(byte[] data) {
Raft.LogEntry logEntry = Raft.LogEntry.newBuilder()
.setTerm(currentTerm)
.setType(Raft.EntryType.ENTRY_TYPE_DATA)
.setData(ByteString.copyFrom(data)).build();
List<Raft... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void appendEntries(Peer peer) {
long firstLogIndex = raftLog.getFirstLogIndex();
if (peer.getNextIndex() < firstLogIndex) {
installSnapshot(peer);
return;
}
long prevLogIndex = peer.getNextIndex() - 1;
lo... | #vulnerable code
public void appendEntries(Peer peer) {
long startLogIndex = raftLog.getStartLogIndex();
if (peer.getNextIndex() < startLogIndex) {
this.installSnapshot(peer);
return;
}
long lastLogIndex = this.raftLog.getLastLogI... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void advanceCommitIndex(RaftMessage.AppendEntriesRequest request) {
long newCommitIndex = Math.min(request.getCommitIndex(),
request.getPrevLogIndex() + request.getEntriesCount());
raftNode.setCommitIndex(newCommitIndex);
if (ra... | #vulnerable code
private void advanceCommitIndex(RaftMessage.AppendEntriesRequest request) {
long newCommitIndex = Math.min(request.getCommitIndex(),
request.getPrevLogIndex() + request.getEntriesCount());
raftNode.setCommitIndex(newCommitIndex);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
raftNode.getLock().lock();
try {
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBu... | #vulnerable code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
LOG.info("Receive AppendEntries request from server {} " +
"in term {} (my term was {})",
request.getServerId(), request.ge... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void installSnapshot(Peer peer) {
Raft.InstallSnapshotRequest.Builder requestBuilder = Raft.InstallSnapshotRequest.newBuilder();
requestBuilder.setServerId(localServer.getServerId());
requestBuilder.setTerm(currentTerm);
// send snapshot... | #vulnerable code
public void installSnapshot(Peer peer) {
Raft.InstallSnapshotRequest.Builder requestBuilder = Raft.InstallSnapshotRequest.newBuilder();
requestBuilder.setServerId(localServer.getServerId());
requestBuilder.setTerm(currentTerm);
// send sn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
raftNode.getLock().lock();
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode... | #vulnerable code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.InstallSnapshotResponse installSnapshot(Raft.InstallSnapshotRequest request) {
raftNode.getLock().lock();
Raft.InstallSnapshotResponse.Builder responseBuilder = Raft.InstallSnapshotResponse.newBuilder();
responseBuilder.setTer... | #vulnerable code
@Override
public Raft.InstallSnapshotResponse installSnapshot(Raft.InstallSnapshotRequest request) {
Raft.InstallSnapshotResponse.Builder responseBuilder = Raft.InstallSnapshotResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void advanceCommitIndex() {
// 获取quorum matchIndex
int peerNum = peers.size();
long[] matchIndexes = new long[peerNum + 1];
for (int i = 0; i < peerNum - 1; i++) {
matchIndexes[i] = peers.get(i).getMatchIndex();
}
... | #vulnerable code
public void advanceCommitIndex() {
// 获取quorum matchIndex
int peerNum = peers.size();
long[] matchIndexes = new long[peerNum + 1];
for (int i = 0; i < peerNum - 1; i++) {
matchIndexes[i] = peers.get(i).getMatchIndex();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void takeSnapshot() {
if (raftLog.getTotalSize() < RaftOption.snapshotMinLogSize) {
return;
}
if (lastAppliedIndex <= snapshot.getMetaData().getLastIncludedIndex()) {
return;
}
long lastAppliedTerm = 0;
... | #vulnerable code
public void takeSnapshot() {
if (raftLog.getTotalSize() < RaftOption.snapshotMinLogSize) {
return;
}
if (lastAppliedIndex <= lastSnapshotIndex) {
return;
}
long lastAppliedTerm = 0;
if (lastAppliedI... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
raftNode.getLock().lock();
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode... | #vulnerable code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
responseBuilder.setTerm(raf... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
if (request.getTerm() > raftNode.getCurrentTerm()) {
LOG.info("Received RequestVote request from server {} " +
"in term {} (this server's term was {})"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.InstallSnapshotResponse installSnapshot(Raft.InstallSnapshotRequest request) {
raftNode.getLock().lock();
Raft.InstallSnapshotResponse.Builder responseBuilder = Raft.InstallSnapshotResponse.newBuilder();
responseBuilder.setTer... | #vulnerable code
@Override
public Raft.InstallSnapshotResponse installSnapshot(Raft.InstallSnapshotRequest request) {
Raft.InstallSnapshotResponse.Builder responseBuilder = Raft.InstallSnapshotResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void installSnapshot(Peer peer) {
Raft.InstallSnapshotRequest.Builder requestBuilder = Raft.InstallSnapshotRequest.newBuilder();
requestBuilder.setServerId(localServer.getServerId());
requestBuilder.setTerm(currentTerm);
// send snapshot... | #vulnerable code
public void installSnapshot(Peer peer) {
Raft.InstallSnapshotRequest.Builder requestBuilder = Raft.InstallSnapshotRequest.newBuilder();
requestBuilder.setServerId(localServer.getServerId());
requestBuilder.setTerm(currentTerm);
// send sn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
raftNode.getLock().lock();
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode... | #vulnerable code
@Override
public Raft.AppendEntriesResponse appendEntries(Raft.AppendEntriesRequest request) {
Raft.AppendEntriesResponse.Builder responseBuilder = Raft.AppendEntriesResponse.newBuilder();
responseBuilder.setTerm(raftNode.getCurrentTerm());
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void replicate(byte[] data) {
lock.lock();
Raft.LogEntry logEntry = Raft.LogEntry.newBuilder()
.setTerm(currentTerm)
.setType(Raft.EntryType.ENTRY_TYPE_DATA)
.setData(ByteString.copyFrom(data)).build();
... | #vulnerable code
public void replicate(byte[] data) {
Raft.LogEntry logEntry = Raft.LogEntry.newBuilder()
.setTerm(currentTerm)
.setType(Raft.EntryType.ENTRY_TYPE_DATA)
.setData(ByteString.copyFrom(data)).build();
List<Raft... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.InstallSnapshotResponse installSnapshot(Raft.InstallSnapshotRequest request) {
raftNode.getLock().lock();
try {
Raft.InstallSnapshotResponse.Builder responseBuilder = Raft.InstallSnapshotResponse.newBuilder();
... | #vulnerable code
@Override
public Raft.InstallSnapshotResponse installSnapshot(Raft.InstallSnapshotRequest request) {
LOG.info("Receive installSnapshot request from server {} " +
"in term {} (my term was {})",
request.getServerId(), re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
raftNode.getLock().lock();
Raft.VoteResponse.Builder responseBuilder = Raft.VoteResponse.newBuilder();
responseBuilder.setGranted(false);
responseBuilder.setTerm(raf... | #vulnerable code
@Override
public Raft.VoteResponse requestVote(Raft.VoteRequest request) {
if (request.getTerm() > raftNode.getCurrentTerm()) {
LOG.info("Received RequestVote request from server {} " +
"in term {} (this server's term was {})"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) {
String pipelinePath = new ZhihuConfiguration().getFolloweePath();
int crawlSize = 1000000;
Spider.create(new ZhihuFolloweePageProcessor())
.setScheduler(//new QueueScheduler()
... | #vulnerable code
public static void main(String[] args) {
String pipelinePath = new ZhihuConfiguration().getFolloweePath();
int crawlSize = 1000000;
Spider.create(new ZhihuFolloweePageProcessor())
.setScheduler(//new QueueScheduler()
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Set<String> getURLTokens(String path) {
List<String> tokens = FileHelper.processFile(path, br -> {
List<String> ts = new ArrayList<>();
String s;
while ((s = br.readLine()) != null) {
ts.add(s);
}
... | #vulnerable code
public Set<String> getURLTokens(String path) {
Set<String> urlTokens = new HashSet<>();
BufferedReader in;
try {
in = new BufferedReader(
new FileReader(new File(path))
);
String s;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) {
ElasticsearchUploader esUploader = new ElasticsearchUploader();
ElasticsearchUploader.logger.info("aaa");
} | #vulnerable code
public static void main(String[] args) {
TransportClient client = null;
try {
// on startup
client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.g... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static String readFollowees(File inItem) {
List<String> followees = FileHelper.processFile(inItem, br -> {
br.readLine();//pass first line
String s = br.readLine();
if (!StringUtils.isEmpty(s)) {
s = s.substri... | #vulnerable code
public static String readFollowees(File inItem) {
BufferedReader in = null;
try {
in = new BufferedReader(
new FileReader(inItem)
);
String s;
in.readLine();//pass first line
... | 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.