input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
public void testSimpleHttpPostsContentNotConsumed() throws Exception {
HttpRequestHandler requestHandler = new HttpRequestHandler() {
public void handle(
final HttpRequest request,
final HttpResponse response,... | #fixed code
public void testSimpleHttpPostsContentNotConsumed() throws Exception {
HttpRequestHandler requestHandler = new HttpRequestHandler() {
public void handle(
final HttpRequest request,
final HttpResponse response,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String toString(
final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
if (entity == null) {
throw new IllegalArgumentException("HTTP entity may not be null");
}
InputStre... | #fixed code
public static String toString(
final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
if (entity == null) {
throw new IllegalArgumentException("HTTP entity may not be null");
}
InputStream ins... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void processEvent(final SelectionKey key) {
SessionHandle handle = (SessionHandle) key.attachment();
IOSession session = handle.getSession();
try {
if (key.isAcceptable()) {
acceptable(key);
}
... | #fixed code
protected void processEvent(final SelectionKey key) {
IOSessionImpl session = (IOSessionImpl) key.attachment();
try {
if (key.isAcceptable()) {
acceptable(key);
}
if (key.isConnectable()) {
co... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEmptyChunkedInputStream() throws IOException {
final String input = "0\r\n";
final InputStream in = new ChunkedInputStream(
new SessionInputBufferMock(input, Consts.ISO_8859_1));
final byte[] buffer = new... | #fixed code
@Test
public void testEmptyChunkedInputStream() throws IOException {
final String input = "0\r\n";
final InputStream in = new ChunkedInputStream(
new SessionInputBufferMock(input, Consts.ISO_8859_1));
final byte[] buffer = new byte[... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void onRequestReceived(final HttpRequest request) throws IOException {
this.request = request;
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) this.request).getEnt... | #fixed code
@Override
protected void onRequestReceived(final HttpRequest request) throws IOException {
this.request = request;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEndOfStreamConditionReadingLastChunk() throws Exception {
String s = "10\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345";
ReadableByteChannel channel = new ReadableByteChannelMockup(
new Str... | #fixed code
@Test
public void testEndOfStreamConditionReadingLastChunk() throws Exception {
String s = "10\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf ... | #fixed code
@Test
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf = new Se... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void processEvent(final SelectionKey key) {
SessionHandle handle = (SessionHandle) key.attachment();
IOSession session = handle.getSession();
try {
if (key.isAcceptable()) {
acceptable(key);
}
... | #fixed code
protected void processEvent(final SelectionKey key) {
IOSessionImpl session = (IOSessionImpl) key.attachment();
try {
if (key.isAcceptable()) {
acceptable(key);
}
if (key.isConnectable()) {
co... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
... | #fixed code
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
final String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
final InputStream in = new ChunkedInputStream(
n... | #fixed code
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
final String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
final InputStream in = new ChunkedInputStream(
new Ses... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionIn... | #fixed code
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testChunkedConsistence() throws IOException {
final String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final OutputStream out = ne... | #fixed code
@Test
public void testChunkedConsistence() throws IOException {
final String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final OutputStream out = new Chun... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTooLongChunkHeader() throws IOException {
final String input = "5; and some very looooong commend\r\n12345\r\n0\r\n";
final InputStream in1 = new ChunkedInputStream(
new SessionInputBufferMock(input, MessageConst... | #fixed code
@Test
public void testTooLongChunkHeader() throws IOException {
final String input = "5; and some very looooong commend\r\n12345\r\n0\r\n";
final InputStream in1 = new ChunkedInputStream(
new SessionInputBufferMock(input, MessageConstraints... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void onResponseReceived(final HttpResponse response) throws IOException {
this.response = response;
HttpEntity entity = this.response.getEntity();
if (entity != null) {
long len = entity.getContentLength();
... | #fixed code
@Override
protected void onResponseReceived(final HttpResponse response) throws IOException {
this.response = response;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInputBufferOperations() throws IOException {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
ContentDecoder decoder = new MockupDecoder(channel);
... | #fixed code
@Test
public void testInputBufferOperations() throws IOException {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
ContentDecoder decoder = new ContentDecoderMock(channel);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConstructor() throws Exception {
final SessionInputBuffer receiver = new SessionInputBufferMock(new byte[] {});
new IdentityInputStream(receiver);
try {
new IdentityInputStream(null);
Assert.fail(... | #fixed code
@Test
public void testConstructor() throws Exception {
final SessionInputBuffer receiver = new SessionInputBufferMock(new byte[] {});
final IdentityInputStream in = new IdentityInputStream(receiver);
in.close();
try {
new Identi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testChunkedConsistence() throws IOException {
final String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final OutputStream out = ne... | #fixed code
@Test
public void testChunkedConsistence() throws IOException {
final String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final OutputStream out = new Chun... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected=MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamMissingCRLF() throws IOException {
final String s = "5\r\n012345\r\n56789\r\n0\r\n";
final InputStream in = new ChunkedInputStream(
new Sessi... | #fixed code
@Test(expected=MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamMissingCRLF() throws IOException {
final String s = "5\r\n012345\r\n56789\r\n0\r\n";
final InputStream in = new ChunkedInputStream(
new SessionInpu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConstructor() throws Exception {
final SessionOutputBufferMock transmitter = new SessionOutputBufferMock();
new IdentityOutputStream(transmitter);
try {
new IdentityOutputStream(null);
Assert.fail... | #fixed code
@Test
public void testConstructor() throws Exception {
final SessionOutputBufferMock transmitter = new SessionOutputBufferMock();
new IdentityOutputStream(transmitter).close();
try {
new IdentityOutputStream(null);
Assert.fa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testSimpleHttpPostsWithContentLength() throws Exception {
HttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
... | #fixed code
public void testSimpleHttpPostsWithContentLength() throws Exception {
HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(Job testjob) {
String s... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFoldedFooters() throws Exception {
String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n \r\n fghij\r\n\r\n";
ReadableByteChannel channel = new ReadableBy... | #fixed code
@Test
public void testFoldedFooters() throws Exception {
String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n \r\n fghij\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChan... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithInvalidContentLength() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams().s... | #fixed code
@Test
public void testEntityWithInvalidContentLength() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams().setBool... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAvailable() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final SessionInputBufferMock receiver = new SessionInputBufferMock(input);
final IdentityInputStream instream = new IdentityInputStream(rece... | #fixed code
@Test
public void testAvailable() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final SessionInputBufferMock receiver = new SessionInputBufferMock(input);
final IdentityInputStream instream = new IdentityInputStream(receiver);... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public DefaultNHttpClientConnection createConnection(final IOSession iosession) {
final SSLIOSession ssliosession = createSSLIOSession(iosession, this.sslcontext, this.sslHandler);
CharsetDecoder chardecoder = null;
CharsetEncoder charencoder = n... | #fixed code
public DefaultNHttpClientConnection createConnection(final IOSession iosession) {
final SSLIOSession ssliosession = createSSLIOSession(iosession, this.sslcontext, this.sslHandler);
return new DefaultNHttpClientConnection(
ssliosession,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
final String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
final InputStream in = new ChunkedInputStream(
new SessionInputBufferMock(
... | #fixed code
@Test
public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
final String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
final InputStream in = new ChunkedInputStream(
new SessionInputBufferMock(
Enc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCodingCompletedFromFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
HttpParams params = new BasicHttpParams();
SessionOutputBuffer outbuf ... | #fixed code
public void testCodingCompletedFromFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
HttpParams params = new BasicHttpParams();
SessionOutputBuffer outbuf = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testSimpleHttpHeads() throws Exception {
int connNo = 3;
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
jobs[i] = new TestJob();
}
Queue<TestJo... | #fixed code
public void testSimpleHttpHeads() throws Exception {
int connNo = 3;
int reqNo = 20;
Job[] jobs = new Job[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
jobs[i] = new Job();
}
Queue<Job> queue = new Concurr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void handleRequest(
final ServerConnState connState,
final HttpContext context) throws HttpException, IOException {
HttpRequest request = connState.getRequest();
context.setAttribute(HttpExecutionContext.HTTP_REQUEST, req... | #fixed code
private void handleRequest(
final ServerConnState connState,
final HttpContext context) throws HttpException, IOException {
HttpRequest request = connState.getRequest();
context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getP... | #fixed code
@Test
public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void doShutdown() throws InterruptedIOException {
if (this.status.compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0) {
return;
}
this.status = IOReactorStatus.SHUTTING_DOWN;
try {
cancelRequests();
... | #fixed code
protected void doShutdown() throws InterruptedIOException {
if (this.status.compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0) {
return;
}
this.status = IOReactorStatus.SHUTTING_DOWN;
try {
cancelRequests();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void connected(final IOSession session) {
SSLIOSession sslSession = new SSLIOSession(
session,
this.sslcontext,
this.sslHandler);
NHttpClientIOTarget conn = createConnection(
... | #fixed code
public void connected(final IOSession session) {
SSLIOSession sslSession = createSSLIOSession(
session,
this.sslcontext,
this.sslHandler);
NHttpClientIOTarget conn = createConnection(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void onRequestReceived(final HttpRequest request) throws IOException {
this.request = request;
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) this.request).getEnt... | #fixed code
@Override
protected void onRequestReceived(final HttpRequest request) throws IOException {
this.request = request;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConstructors() throws Exception {
new ContentLengthInputStream(new SessionInputBufferMock(new byte[] {}), 10);
try {
new ContentLengthInputStream(null, 10);
Assert.fail("IllegalArgumentException should ha... | #fixed code
@Test
public void testConstructors() throws Exception {
final ContentLengthInputStream in = new ContentLengthInputStream(
new SessionInputBufferMock(new byte[] {}), 0);
in.close();
try {
new ContentLengthInputStream(null... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff;", "more stuff"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionIn... | #fixed code
public void testBasicDecodingFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testBasicDecoding() throws Exception {
String s = "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {s}, "US-ASCII");
HttpParams... | #fixed code
@Test
public void testBasicDecoding() throws Exception {
String s = "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s}, "US-ASCII");
HttpParams params ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInvalidInput() throws Exception {
String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMockup(
... | #fixed code
@Test
public void testInvalidInput() throws Exception {
String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testBasicDecodingFile() throws Exception {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
final SessionInputBuffer inbuf ... | #fixed code
@Test
public void testBasicDecodingFile() throws Exception {
final ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
final SessionInputBuffer inbuf = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testComplexDecoding() throws Exception {
String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\nFooter2: fghij\r\n\r\n";
ReadableByteChannel channel = new Readable... | #fixed code
@Test
public void testComplexDecoding() throws Exception {
String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
"5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\nFooter2: fghij\r\n\r\n";
ReadableByteChannel channel = new ReadableByteCh... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String toString(
final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
if (entity == null) {
throw new IllegalArgumentException("HTTP entity may not be null");
}
InputStre... | #fixed code
public static String toString(
final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
if (entity == null) {
throw new IllegalArgumentException("HTTP entity may not be null");
}
InputStream ins... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCodingBeyondContentLimitFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {
"stuff;",
"more stuff; and a lot more stuff"},... | #fixed code
@Test
public void testCodingBeyondContentLimitFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {
"stuff;",
"more stuff; and a lot more stuff"}, "US-ASC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testReadingWitSmallBuffer() throws Exception {
String s = "10\r\n1234567890123456\r\n" +
"40\r\n12345678901234561234567890123456" +
"12345678901234561234567890123456\r\n0\r\n";
ReadableByteChannel cha... | #fixed code
@Test
public void testReadingWitSmallBuffer() throws Exception {
String s = "10\r\n1234567890123456\r\n" +
"40\r\n12345678901234561234567890123456" +
"12345678901234561234567890123456\r\n0\r\n";
ReadableByteChannel channel =... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void onRequestReceived(final HttpRequest request) throws IOException {
this.request = request;
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) this.request).getEnt... | #fixed code
@Override
protected void onRequestReceived(final HttpRequest request) throws IOException {
this.request = request;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodingWithSmallBuffer() throws Exception {
String s1 = "5\r\n01234\r\n5\r\n5678";
String s2 = "9\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {... | #fixed code
@Test
public void testDecodingWithSmallBuffer() throws Exception {
String s1 = "5\r\n01234\r\n5\r\n5678";
String s2 = "9\r\n6\r\nabcdef\r\n0\r\n\r\n";
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {s1, s2},... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamInvalidFooter() throws IOException {
final String s = "1\r\n0\r\n0\r\nstuff\r\n";
final InputStream in = new ChunkedInputStream(
new Sessio... | #fixed code
@Test(expected = MalformedChunkCodingException.class)
public void testCorruptChunkedInputStreamInvalidFooter() throws IOException {
final String s = "1\r\n0\r\n0\r\nstuff\r\n";
final InputStream in = new ChunkedInputStream(
new SessionInput... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getP... | #fixed code
@Test
public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testHttpPostsWithExpectationVerification() throws Exception {
TestJob[] jobs = new TestJob[3];
jobs[0] = new TestJob("AAAAA", 10);
jobs[1] = new TestJob("AAAAA", 10);
jobs[2] = new TestJob("BBBBB", 20);
Queue<TestJob> ... | #fixed code
public void testHttpPostsWithExpectationVerification() throws Exception {
Job[] jobs = new Job[3];
jobs[0] = new Job("AAAAA", 10);
jobs[1] = new Job("AAAAA", 10);
jobs[2] = new Job("BBBBB", 20);
Queue<Job> queue = new ConcurrentLinkedQu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() {
HttpResponse response = null;
BenchmarkConnection conn = new BenchmarkConnection(this.stats);
String scheme = targetHost.getSchemeName();
String hostname = targetHost.getHostName();
int port = targetHost.getP... | #fixed code
public void run() {
HttpResponse response = null;
BenchmarkConnection conn = new BenchmarkConnection(this.stats);
String scheme = targetHost.getSchemeName();
String hostname = targetHost.getHostName();
int port = targetHost.getPort();... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testInputThrottling() throws Exception {
HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
public void initalizeContext(final HttpContext context, final Object attachment) {
context... | #fixed code
public void testInputThrottling() throws Exception {
HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
public void initalizeContext(final HttpContext context, final Object attachment) {
context.setAt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithMultipleContentLength() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams().... | #fixed code
@Test
public void testEntityWithMultipleContentLength() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams().setBoo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTooLongChunkHeader() throws IOException {
final String input = "5; and some very looooong commend\r\n12345\r\n0\r\n";
final InputStream in1 = new ChunkedInputStream(
new SessionInputBufferMock(input, MessageConst... | #fixed code
@Test
public void testTooLongChunkHeader() throws IOException {
final String input = "5; and some very looooong commend\r\n12345\r\n0\r\n";
final InputStream in1 = new ChunkedInputStream(
new SessionInputBufferMock(input, MessageConstraints... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf ... | #fixed code
@Test
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMock(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf = new Se... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCodingBeyondContentLimitFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {
"stuff;",
"more stuff; and a lot more stuff"}, "US-ASCI... | #fixed code
public void testCodingBeyondContentLimitFile() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {
"stuff;",
"more stuff; and a lot more stuff"}, "US-ASCII");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf =... | #fixed code
public void testWriteBeyondFileSize() throws Exception {
ReadableByteChannel channel = new ReadableByteChannelMockup(
new String[] {"a"}, "US-ASCII");
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuf = new S... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void validate(final Set keys) {
long currentTime = System.currentTimeMillis();
if( (currentTime - this.lastTimeoutCheck) >= this.timeoutCheckInterval) {
this.lastTimeoutCheck = currentTime;
if (keys != null) {
... | #fixed code
protected void validate(final Set keys) {
long currentTime = System.currentTimeMillis();
if( (currentTime - this.lastTimeoutCheck) >= this.timeoutCheckInterval) {
this.lastTimeoutCheck = currentTime;
if (keys != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpClientConnection create(final HttpHost host) throws IOException {
final String scheme = host.getSchemeName();
Socket socket = null;
if ("http".equalsIgnoreCase(scheme)) {
socket = this.plainfactory != null ? this.plainfacto... | #fixed code
public HttpClientConnection create(final HttpHost host) throws IOException {
final String scheme = host.getSchemeName();
Socket socket = null;
if ("http".equalsIgnoreCase(scheme)) {
socket = this.plainfactory != null ? this.plainfactory.cre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Future<BasicNIOPoolEntry> lease(
final HttpHost route,
final Object state) {
int connectTimeout = Config.getInt(params, CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
return super.lease(route, state, connectTime... | #fixed code
@Override
public Future<BasicNIOPoolEntry> lease(
final HttpHost route,
final Object state) {
return super.lease(route, state, this.connectTimeout, this.tunit, null);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithMultipleContentLengthSomeWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.get... | #fixed code
@Test
public void testEntityWithMultipleContentLengthSomeWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void doShutdown() throws InterruptedIOException {
if (this.status.compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0) {
return;
}
this.status = IOReactorStatus.SHUTTING_DOWN;
try {
cancelRequests();
... | #fixed code
protected void doShutdown() throws InterruptedIOException {
synchronized (this.statusLock) {
if (this.status.compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0) {
return;
}
this.status = IOReactorStatus.SHUTTING_DOWN;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testHttpPostsWithExpectationVerification() throws Exception {
TestJob[] jobs = new TestJob[3];
jobs[0] = new TestJob("AAAAA", 10);
jobs[1] = new TestJob("AAAAA", 10);
jobs[2] = new TestJob("BBBBB", 20);
Queue<TestJob> ... | #fixed code
public void testHttpPostsWithExpectationVerification() throws Exception {
Job[] jobs = new Job[3];
jobs[0] = new Job("AAAAA", 10);
jobs[1] = new Job("AAAAA", 10);
jobs[2] = new Job("BBBBB", 20);
Queue<Job> queue = new ConcurrentLinkedQu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getP... | #fixed code
@Test
public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testEntityWithMultipleContentLength() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams().... | #fixed code
@Test
public void testEntityWithMultipleContentLength() throws Exception {
SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
HttpMessage message = new DummyHttpMessage();
// lenient mode
message.getParams().setBoo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testResponseContentOverwriteHeaders() throws Exception {
ResponseContent interceptor = new ResponseContent(true);
HttpContext context = new BasicHttpContext(null);
HttpResponse response = new BasicHttpResponse(HttpVersion.HT... | #fixed code
@Test
public void testResponseContentOverwriteHeaders() throws Exception {
ResponseContent interceptor = new ResponseContent(true);
HttpContext context = new BasicHttpContext(null);
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() {
long appId = 6666;
long versionId = 100;
long releaseId = 11111;
VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
ReleaseSnapshotDTO[] someReleaseSnapShots = ne... | #fixed code
@Test
public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() {
long appId = 6666;
long versionId = 100;
long releaseId = 11111;
VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
ReleaseSnapshotDTO[] someReleaseSnapShots = new Rele... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private boolean isServiceUndeployed(int environmentId, int serviceId){
Date latestDeploymentDate = getLatestDeploymentDateByServiceIdInEnvironment(environmentId, serviceId);
Date latestUpdatedDate = getLatestDeployableVersionDateByServiceId(serviceId);
... | #fixed code
private boolean isServiceUndeployed(int environmentId, int serviceId){
Date latestDeploymentDate = getLatestDeploymentDateByServiceIdInEnvironment(environmentId, serviceId);
Date latestUpdatedDate = getLatestDeployableVersionDateByServiceId(serviceId);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() {
long appId = 6666;
long versionId = 100;
long releaseId = 11111;
VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
ReleaseSnapshotDTO[] someReleaseSnapShots ... | #fixed code
@Test
public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() {
long appId = 6666;
long versionId = 100;
long releaseId = 11111;
VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
ReleaseSnapshotDTO[] someReleaseSnapShots = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testBlockByAvailabilityOnAllServices() throws Exception {
ApolloTestClient apolloTestClient = Common.signupAndLogin();
ApolloTestAdminClient apolloTestAdminClient = Common.getAndLoginApolloTestAdminClient();
String availabi... | #fixed code
@Test
public void testBlockByAvailabilityOnAllServices() throws Exception {
ApolloTestClient apolloTestClient = Common.signupAndLogin();
ApolloTestAdminClient apolloTestAdminClient = Common.getAndLoginApolloTestAdminClient();
String availability =... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void onWhenRequested() throws Exception {
setup("server.port=7000", "spring.cloud.config.discovery.enabled=true",
"spring.cloud.consul.discovery.port:7001",
"spring.cloud.consul.discovery.hostname:foo",
"spring.cloud.config.discovery.service-id:... | #fixed code
@Test
public void onWhenRequested() throws Exception {
setup("server.port=0", "spring.cloud.config.discovery.enabled=true",
"logging.level.org.springframework.cloud.config.client=DEBUG",
"spring.cloud.consul.discovery.test.enabled:true",
"spring.application.name=d... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void propertySourcesFound() throws Exception {
String foo = this.environment.getProperty("foo");
assertThat(foo).as("foo was wrong").isEqualTo("bar-app-dev");
String myBaz = this.environment.getProperty("my.baz");
assertThat(myBaz).as("my.baz was wro... | #fixed code
@Test
public void propertySourcesFound() throws Exception {
String foo = this.environment.getProperty("foo");
assertThat(foo).as("foo was wrong").isEqualTo("bar-app-dev");
String myBaz = this.environment.getProperty("my.baz");
assertThat(myBaz).as("my.baz was wrong").i... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> T get(Class<? extends T> clazz, long id) throws EntityNotFoundException
{
// The cast gets rid of "no unique maximal instance exists" compiler error
return (T)this.get(this.factory.createKey(clazz, id));
}
#location ... | #fixed code
@Override
public <T> T get(Class<? extends T> clazz, long id) throws EntityNotFoundException
{
// The cast gets rid of "no unique maximal instance exists" compiler error
return (T)this.get(new OKey<T>(clazz, id));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> T get(Class<? extends T> clazz, String name) throws EntityNotFoundException
{
// The cast gets rid of "no unique maximal instance exists" compiler error
return (T)this.get(this.factory.createKey(clazz, name));
}
#loc... | #fixed code
@Override
public <T> T get(Class<? extends T> clazz, String name) throws EntityNotFoundException
{
// The cast gets rid of "no unique maximal instance exists" compiler error
return (T)this.get(new OKey<T>(clazz, name));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void tooDeeplyNestedObjects() throws IOException {
Object root = Boolean.TRUE;
for (int i = 0; i < 32; i++) {
root = singletonMap("a", root);
}
JsonReader reader = new JsonValueReader(root);
for (int i = 0; i < 31; i++) {
reade... | #fixed code
@Test public void tooDeeplyNestedObjects() throws IOException {
Object root = Boolean.TRUE;
for (int i = 0; i < MAX_DEPTH + 1; i++) {
root = singletonMap("a", root);
}
JsonReader reader = new JsonValueReader(root);
for (int i = 0; i < MAX_DEPTH; i++) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerNullValue() throws Exception {
JsonReader reader = newReader("{\"null\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.null");
assertThat(reader.peek()).isEqualTo(JsonReader.To... | #fixed code
@Test public void readerNullValue() throws Exception {
JsonReader reader = factory.newReader("{\"null\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.null");
assertThat(reader.peek()).isEqualTo(JsonReader.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readingDoesNotBuffer() throws IOException {
Buffer buffer = new Buffer().writeUtf8("{}{}");
JsonReader reader1 = new JsonReader(buffer);
reader1.beginObject();
reader1.endObject();
assertThat(buffer.size()).isEqualTo(2);
JsonRea... | #fixed code
@Test public void readingDoesNotBuffer() throws IOException {
Buffer buffer = new Buffer().writeUtf8("{}{}");
JsonReader reader1 = JsonReader.of(buffer);
reader1.beginObject();
reader1.endObject();
assertThat(buffer.size()).isEqualTo(2);
JsonReader rea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readObjectSource() throws IOException {
Buffer buffer = new Buffer().writeUtf8("{\"a\": \"android\", \"b\": \"banana\"}");
JsonReader reader = new JsonReader(buffer);
reader.beginObject();
assertThat(reader.nextName()).isEqualTo("a");
... | #fixed code
@Test public void readObjectSource() throws IOException {
Buffer buffer = new Buffer().writeUtf8("{\"a\": \"android\", \"b\": \"banana\"}");
JsonReader reader = JsonReader.of(buffer);
reader.beginObject();
assertThat(reader.nextName()).isEqualTo("a");
assert... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerUnusedPromotionDoesntPersist() throws Exception {
JsonReader reader = new JsonReader(new Buffer().writeUtf8("[{},{\"a\":5}]"));
reader.beginArray();
reader.beginObject();
reader.promoteNameToValue();
reader.endObject();
read... | #fixed code
@Test public void readerUnusedPromotionDoesntPersist() throws Exception {
JsonReader reader = newReader("[{},{\"a\":5}]");
reader.beginArray();
reader.beginObject();
reader.promoteNameToValue();
reader.endObject();
reader.beginObject();
try {
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerLongValue() throws Exception {
JsonReader reader = newReader("{\"5\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.5");
assertThat(reader.peek()).isEqualTo(JsonReader.Token.ST... | #fixed code
@Test public void readerLongValue() throws Exception {
JsonReader reader = factory.newReader("{\"5\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.5");
assertThat(reader.peek()).isEqualTo(JsonReader.Token.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readObjectBuffer() throws IOException {
Buffer buffer = new Buffer().writeUtf8("{\"a\": \"android\", \"b\": \"banana\"}");
JsonReader reader = new JsonReader(buffer);
reader.beginObject();
assertThat(reader.nextName()).isEqualTo("a");
... | #fixed code
@Test public void readObjectBuffer() throws IOException {
Buffer buffer = new Buffer().writeUtf8("{\"a\": \"android\", \"b\": \"banana\"}");
JsonReader reader = JsonReader.of(buffer);
reader.beginObject();
assertThat(reader.nextName()).isEqualTo("a");
assert... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerBooleanValue() throws Exception {
JsonReader reader = newReader("{\"true\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.true");
assertThat(reader.peek()).isEqualTo(JsonReader... | #fixed code
@Test public void readerBooleanValue() throws Exception {
JsonReader reader = factory.newReader("{\"true\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.true");
assertThat(reader.peek()).isEqualTo(JsonRead... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerUnquotedDoubleValue() throws Exception {
JsonReader reader = newReader("{5:1}");
reader.setLenient(true);
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.nextDouble()).isEqualTo(5d);
assertThat(reader.ne... | #fixed code
@Test public void readerUnquotedDoubleValue() throws Exception {
JsonReader reader = factory.newReader("{5:1}");
reader.setLenient(true);
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.nextDouble()).isEqualTo(5d);
assertThat(reader.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerMultipleValueObject() throws Exception {
JsonReader reader = newReader("{\"a\":1,\"b\":2}");
reader.beginObject();
assertThat(reader.nextName()).isEqualTo("a");
assertThat(reader.nextInt()).isEqualTo(1);
reader.promoteNameToValu... | #fixed code
@Test public void readerMultipleValueObject() throws Exception {
JsonReader reader = factory.newReader("{\"a\":1,\"b\":2}");
reader.beginObject();
assertThat(reader.nextName()).isEqualTo("a");
assertThat(reader.nextInt()).isEqualTo(1);
reader.promoteNameToVa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerUnquotedIntegerValue() throws Exception {
JsonReader reader = newReader("{5:1}");
reader.setLenient(true);
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.nextInt()).isEqualTo(5);
assertThat(reader.nextI... | #fixed code
@Test public void readerUnquotedIntegerValue() throws Exception {
JsonReader reader = factory.newReader("{5:1}");
reader.setLenient(true);
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.nextInt()).isEqualTo(5);
assertThat(reader.nex... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerStringValue() throws Exception {
JsonReader reader = newReader("{\"a\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.a");
assertThat(reader.peek()).isEqualTo(JsonReader.Token.... | #fixed code
@Test public void readerStringValue() throws Exception {
JsonReader reader = factory.newReader("{\"a\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.a");
assertThat(reader.peek()).isEqualTo(JsonReader.Toke... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static JsonWriter of(BufferedSink sink) {
return new JsonUt8Writer(sink);
}
#location 2
#vulnerability type RESOURCE_LEAK | #fixed code
public static JsonWriter of(BufferedSink sink) {
return new JsonUtf8Writer(sink);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerEmptyValueObject() throws Exception {
JsonReader reader = newReader("{}");
reader.beginObject();
assertThat(reader.peek()).isEqualTo(JsonReader.Token.END_OBJECT);
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqual... | #fixed code
@Test public void readerEmptyValueObject() throws Exception {
JsonReader reader = factory.newReader("{}");
reader.beginObject();
assertThat(reader.peek()).isEqualTo(JsonReader.Token.END_OBJECT);
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerUnquotedLongValue() throws Exception {
JsonReader reader = newReader("{5:1}");
reader.setLenient(true);
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.nextLong()).isEqualTo(5L);
assertThat(reader.nextIn... | #fixed code
@Test public void readerUnquotedLongValue() throws Exception {
JsonReader reader = factory.newReader("{5:1}");
reader.setLenient(true);
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.nextLong()).isEqualTo(5L);
assertThat(reader.next... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerDoubleValue() throws Exception {
JsonReader reader = newReader("{\"5.5\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.5.5");
assertThat(reader.peek()).isEqualTo(JsonReader.To... | #fixed code
@Test public void readerDoubleValue() throws Exception {
JsonReader reader = factory.newReader("{\"5.5\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.5.5");
assertThat(reader.peek()).isEqualTo(JsonReader.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override void promoteNameToValue() throws IOException {
Map.Entry<?, ?> peeked = require(Map.Entry.class, Token.NAME);
push(peeked.getKey());
stack[stackSize - 2] = peeked.getValue();
}
#location 4
... | #fixed code
@Override void promoteNameToValue() throws IOException {
if (hasNext()) {
String name = nextName();
push(name);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static JsonWriter of(BufferedSink sink) {
return new BufferedSinkJsonWriter(sink);
}
#location 2
#vulnerability type RESOURCE_LEAK | #fixed code
public static JsonWriter of(BufferedSink sink) {
return new JsonUt8Writer(sink);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerUnusedPromotionDoesntPersist() throws Exception {
JsonReader reader = newReader("[{},{\"a\":5}]");
reader.beginArray();
reader.beginObject();
reader.promoteNameToValue();
reader.endObject();
reader.beginObject();
try {
... | #fixed code
@Test public void readerUnusedPromotionDoesntPersist() throws Exception {
JsonReader reader = factory.newReader("[{},{\"a\":5}]");
reader.beginArray();
reader.beginObject();
reader.promoteNameToValue();
reader.endObject();
reader.beginObject();
try {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerIntegerValue() throws Exception {
JsonReader reader = newReader("{\"5\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.5");
assertThat(reader.peek()).isEqualTo(JsonReader.Token... | #fixed code
@Test public void readerIntegerValue() throws Exception {
JsonReader reader = factory.newReader("{\"5\":1}");
reader.beginObject();
reader.promoteNameToValue();
assertThat(reader.getPath()).isEqualTo("$.5");
assertThat(reader.peek()).isEqualTo(JsonReader.Tok... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static JsonReader of(BufferedSource source) {
return new BufferedSourceJsonReader(source);
}
#location 2
#vulnerability type RESOURCE_LEAK | #fixed code
public static JsonReader of(BufferedSource source) {
return new JsonUtf8Reader(source);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test public void readerUnusedPromotionDoesntPersist() throws Exception {
JsonReader reader = new JsonReader(new Buffer().writeUtf8("[{},{\"a\":5}]"));
reader.beginArray();
reader.beginObject();
reader.promoteNameToValue();
reader.endObject();
read... | #fixed code
@Test public void readerUnusedPromotionDoesntPersist() throws Exception {
JsonReader reader = newReader("[{},{\"a\":5}]");
reader.beginArray();
reader.beginObject();
reader.promoteNameToValue();
reader.endObject();
reader.beginObject();
try {
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean addOrReplace(byte[] key, V old, V value)
{
KeyBuffer keyBuffer = keySource(key);
byte[] data = value(value);
byte[] oldData = value(old);
if (maxEntrySize > 0L && CheckSegment.sizeOf(keyBuffer, data) > maxEntrySize)
... | #fixed code
public boolean addOrReplace(byte[] key, V old, V value)
{
KeyBuffer keyBuffer = keySource(key);
byte[] data = value(value);
byte[] oldData = value(old);
CheckSegment segment = segment(keyBuffer.hash());
return segment.put(keyBuffer... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
FileChannel getWriteChannel() {
return writeChannel;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
long getWriteOffset() {
return writeOffset;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDeleteAndMerge() throws Exception {
String directory = "/tmp/HaloDBDeletionTest/testDeleteAndMerge";
HaloDBOptions options = new HaloDBOptions();
options.mergeJobIntervalInSeconds = 1;
options.maxFileSize = 10 * ... | #fixed code
@Test
public void testDeleteAndMerge() throws Exception {
String directory = "/tmp/HaloDBDeletionTest/testDeleteAndMerge";
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = 10 * 1024;
options.mergeThresholdPerFile = 0.10;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMerge() throws Exception {
File directory = new File("/tmp/HaloDBTestWithMerge/testMerge");
TestUtils.deleteDirectory(directory);
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = recordsPerFile... | #fixed code
@Test
public void testMerge() throws Exception {
File directory = new File("/tmp/HaloDBTestWithMerge/testMerge");
TestUtils.deleteDirectory(directory);
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = recordsPerFile * rec... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean put(byte[] key, V value)
{
KeyBuffer keyBuffer = keySource(key);
byte[] data = value(value);
if (maxEntrySize > 0L && CheckSegment.sizeOf(keyBuffer, data) > maxEntrySize)
{
remove(key);
putFailC... | #fixed code
public boolean put(byte[] key, V value)
{
KeyBuffer keyBuffer = keySource(key);
byte[] data = value(value);
CheckSegment segment = segment(keyBuffer.hash());
return segment.put(keyBuffer, data, false, null);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDeleteInsertCloseAndOpen() throws IOException {
String directory = "/tmp/HaloDBTest/testDeleteInsertCloseAndOpen";
HaloDBOptions options = new HaloDBOptions();
options.isMergeDisabled = true;
options.maxFileSize... | #fixed code
@Test
public void testDeleteInsertCloseAndOpen() throws IOException {
String directory = "/tmp/HaloDBTest/testDeleteInsertCloseAndOpen";
HaloDBOptions options = new HaloDBOptions();
options.isMergeDisabled = true;
options.maxFileSize = 10*... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void close() throws IOException {
isClosing = true;
try {
if(!compactionManager.stopCompactionThread())
setIOErrorFlag();
} catch (IOException e) {
logger.error("Error while stopping compaction thread. Set... | #fixed code
void close() throws IOException {
writeLock.lock();
try {
isClosing = true;
try {
if(!compactionManager.stopCompactionThread())
setIOErrorFlag();
} catch (IOException e) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean putIfAbsent(byte[] key, V v)
{
KeyBuffer keyBuffer = keySource(key);
byte[] data = value(v);
if (maxEntrySize > 0L && CheckSegment.sizeOf(keyBuffer, data) > maxEntrySize)
{
remove(key);
putFailC... | #fixed code
public boolean putIfAbsent(byte[] key, V v)
{
KeyBuffer keyBuffer = keySource(key);
byte[] data = value(v);
CheckSegment segment = segment(keyBuffer.hash());
return segment.put(keyBuffer, data, true, null);
} | 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.