input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
void delete(byte[] key) throws IOException {
writeLock.lock();
try {
InMemoryIndexMetaData metaData = inMemoryIndex.get(key);
if (metaData != null) {
//TODO: implement a getAndRemove method in InMemoryIndex.
... | #fixed code
void close() throws IOException {
writeLock.lock();
try {
if (isClosing) {
// instance already closed.
return;
}
isClosing = true;
try {
if(!compactionManager.stop... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
long getSequenceNumber() {
return sequenceNumber;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
DBMetaData(String dbDirectory) {
this.dbDirectory = dbDirectory;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean stopCompactionThread() throws IOException {
isRunning = false;
if (compactionThread != null) {
try {
// We don't want to call interrupt on compaction thread as it
// may interrupt IO operations and leav... | #fixed code
CompactionManager(HaloDBInternal dbInternal) {
this.dbInternal = dbInternal;
this.compactionRateLimiter = RateLimiter.create(dbInternal.options.getCompactionJobRate());
this.compactionQueue = new LinkedBlockingQueue<>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void mergeTombstoneFiles() throws IOException {
if (!options.isCleanUpTombstonesDuringOpen()) {
logger.info("CleanUpTombstonesDuringOpen is not enabled, returning");
return;
}
File[] tombStoneFiles = dbDirectory.listTombs... | #fixed code
void close() throws IOException {
writeLock.lock();
try {
if (isClosing) {
// instance already closed.
return;
}
isClosing = true;
try {
if(!compactionManager.stop... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean isMergeComplete() {
if (compactionQueue.isEmpty()) {
try {
stopCompactionThread();
} catch (IOException e) {
logger.error("Error in isMergeComplete", e);
}
return true;
... | #fixed code
CompactionManager(HaloDBInternal dbInternal) {
this.dbInternal = dbInternal;
this.compactionRateLimiter = RateLimiter.create(dbInternal.options.compactionJobRate);
this.compactionQueue = new LinkedBlockingQueue<>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testReOpenDBAfterMerge() throws IOException, InterruptedException {
String directory = "/tmp/HaloDBTestWithMerge/testReOpenDBAfterMerge";
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = recordsPerFile * r... | #fixed code
@Test
public void testReOpenDBAfterMerge() throws IOException, InterruptedException {
String directory = "/tmp/HaloDBTestWithMerge/testReOpenDBAfterMerge";
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = recordsPerFile * recordS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean isCompactionComplete() {
if (dbInternal.options.isCompactionDisabled())
return true;
if (compactionQueue.isEmpty()) {
try {
submitFileForCompaction(STOP_SIGNAL);
compactionThread.join();
... | #fixed code
CompactionManager(HaloDBInternal dbInternal) {
this.dbInternal = dbInternal;
this.compactionRateLimiter = RateLimiter.create(dbInternal.options.getCompactionJobRate());
this.compactionQueue = new LinkedBlockingQueue<>();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRepairDB() throws IOException {
String directory = Paths.get("tmp", "DBRepairTest", "testRepairDB").toString();
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = 1024 * 1024;
HaloDB db = getTes... | #fixed code
@Test
public void testRepairDB() throws IOException {
String directory = Paths.get("tmp", "DBRepairTest", "testRepairDB").toString();
HaloDBOptions options = new HaloDBOptions();
options.maxFileSize = 1024 * 1024;
HaloDB db = getTestDB(di... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
RecordMetaDataForCache writeRecord(Record record) throws IOException {
long start = System.nanoTime();
writeToChannel(record.serialize(), writeChannel);
int recordSize = record.getRecordSize();
long recordOffset = writeOffset;
writeOffset += recordSize;
Inde... | #fixed code
long getWriteOffset() {
return writeOffset;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static int sizeof(Class<? extends Pointer> type) {
// Should we synchronize that?
return memberOffsets.get(type).get("sizeof");
}
#location 3
#vulnerability type NULL_DEREFERENCE | #fixed code
public static int sizeof(Class<? extends Pointer> type) {
return offsetof(type, "sizeof");
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
String translate(String text) {
int namespace = text.lastIndexOf("::");
if (namespace >= 0) {
Info info2 = infoMap.getFirst(text.substring(0, namespace));
text = text.substring(namespace + 2);
if (info2.pointerTypes !=... | #fixed code
Parser(Parser p, String text) {
this.logger = p.logger;
this.properties = p.properties;
this.infoMap = p.infoMap;
this.tokens = new TokenIndexer(infoMap, new Tokenizer(text).tokenize());
this.lineSeparator = p.lineSeparator;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public BytePointer putString(String s) {
byte[] bytes = s.getBytes();
//capacity(bytes.length+1);
asBuffer().put(bytes).put((byte)0);
return this;
}
#location 4
#vulnerability ... | #fixed code
public BytePointer putString(String s) {
byte[] bytes = s.getBytes();
return put(bytes).put(bytes.length, (byte)0);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean generate(Class<?> ... classes) throws FileNotFoundException {
// first pass using a null writer to fill up the LinkedListRegister objects
out = new PrintWriter(new Writer() {
@Override public void close() { }
@Overr... | #fixed code
public boolean generate(Class<?> ... classes) throws FileNotFoundException {
// first pass using a null writer to fill up the LinkedListRegister objects
out = new PrintWriter(new Writer() {
@Override public void close() { }
@Override pu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
Main main = new Main();
for (int i = 0; i < args.length; i++) {
if ("-help".equals(args[i]) || "--help".equals(args[i])) {
printHelp();
System.exit(0);
... | #fixed code
public static void main(String[] args) throws Exception {
Main main = new Main();
for (int i = 0; i < args.length; i++) {
if ("-help".equals(args[i]) || "--help".equals(args[i])) {
printHelp();
System.exit(0);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void parse(File outputFile, Context context, String[] includePath, String ... includes) throws IOException, ParserException {
ArrayList<Token> tokenList = new ArrayList<Token>();
for (String include : includes) {
File file = null;
... | #fixed code
Parser(Parser p, String text) {
this.logger = p.logger;
this.properties = p.properties;
this.infoMap = p.infoMap;
this.tokens = new TokenIndexer(infoMap, new Tokenizer(text).tokenize());
this.lineSeparator = p.lineSeparator;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean generate(Class<?> ... classes) throws FileNotFoundException {
// first pass using a null writer to fill up the LinkedListRegister objects
out = new PrintWriter(new Writer() {
@Override public void close() { }
@Overr... | #fixed code
public boolean generate(Class<?> ... classes) throws FileNotFoundException {
// first pass using a null writer to fill up the LinkedListRegister objects
out = new PrintWriter(new Writer() {
@Override public void close() { }
@Override pu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void parse(File outputFile, Context context, String[] includePath, String ... includes) throws IOException, ParserException {
ArrayList<Token> tokenList = new ArrayList<Token>();
for (String include : includes) {
File file = null;
... | #fixed code
Parser(Parser p, String text) {
this.logger = p.logger;
this.properties = p.properties;
this.infoMap = p.infoMap;
this.tokens = new TokenIndexer(infoMap, new Tokenizer(text).tokenize());
this.lineSeparator = p.lineSeparator;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String load(Class cls, Properties properties, boolean pathsFirst) {
if (!isLoadLibraries() || cls == null) {
return null;
}
// Find the top enclosing class, to match the library filename
cls = getEnclosingClass(... | #fixed code
public static String load(Class cls, Properties properties, boolean pathsFirst) {
if (!isLoadLibraries() || cls == null) {
return null;
}
// Find the top enclosing class, to match the library filename
cls = getEnclosingClass(cls);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void init(long allocatedAddress, int allocatedCapacity, long deallocatorAddress) {
address = allocatedAddress;
position = 0;
limit = allocatedCapacity;
capacity = allocatedCapacity;
deallocator(new NativeDeallocator(this, dealloca... | #fixed code
void init(long allocatedAddress, int allocatedCapacity, long ownerAddress, long deallocatorAddress) {
address = allocatedAddress;
position = 0;
limit = allocatedCapacity;
capacity = allocatedCapacity;
deallocator(new NativeDeallocator(t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean generate(String sourceFilename, String headerFilename, String loadSuffix,
String baseLoadSuffix, String classPath, Class<?> ... classes) throws IOException {
try {
// first pass using a null writer to fill up the IndexedSet... | #fixed code
public boolean generate(String sourceFilename, String headerFilename, String loadSuffix,
String baseLoadSuffix, String classPath, Class<?> ... classes) throws IOException {
try {
// first pass using a null writer to fill up the IndexedSet objec... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Token[] expand(Token[] array, int index) {
if (index < array.length && infoMap.containsKey(array[index].value)) {
// if we hit a token whose info.cppText starts with #define (a macro), expand it
int startIndex = index;
Info in... | #fixed code
TokenIndexer(InfoMap infoMap, Token[] array, boolean isCFile) {
this.infoMap = infoMap;
this.array = array;
this.isCFile = isCFile;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static File cacheResource(URL resourceURL, String target) throws IOException {
// Find appropriate subdirectory in cache for the resource ...
File urlFile = new File(resourceURL.getPath());
String name = urlFile.getName();
long siz... | #fixed code
public static File cacheResource(URL resourceURL, String target) throws IOException {
// Find appropriate subdirectory in cache for the resource ...
File urlFile = new File(resourceURL.getPath());
String name = urlFile.getName();
long size, tim... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public File parse(File outputDirectory, String[] classPath, Class cls) throws IOException, Exception {
Loader.ClassProperties allProperties = Loader.loadProperties(cls, properties, true);
Loader.ClassProperties clsProperties = Loader.loadProperties(cls, ... | #fixed code
public File parse(File outputDirectory, String[] classPath, Class cls) throws IOException, Exception {
Loader.ClassProperties allProperties = Loader.loadProperties(cls, properties, true);
Loader.ClassProperties clsProperties = Loader.loadProperties(cls, proper... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static int offsetof(Class<? extends Pointer> type, String member) {
// Should we synchronize that?
return memberOffsets.get(type).get(member);
}
#location 3
#vulnerability type NULL_DER... | #fixed code
public static int offsetof(Class<? extends Pointer> type, String member) {
// Should we synchronize that?
HashMap<String,Integer> offsets = memberOffsets.get(type);
while (offsets == null && type.getSuperclass() != null) {
type = type.getSu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static File extractResource(URL resourceURL, File directory,
String prefix, String suffix) throws IOException {
InputStream is = resourceURL != null ? resourceURL.openStream() : null;
if (is == null) {
return null;
... | #fixed code
public static File extractResource(URL resourceURL, File directory,
String prefix, String suffix) throws IOException {
InputStream is = resourceURL != null ? resourceURL.openStream() : null;
OutputStream os = null;
if (is == null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ByteBuffer asByteBuffer() {
if (isNull()) {
return null;
}
if (limit > 0 && limit < position) {
throw new IllegalArgumentException("limit < position: (" + limit + " < " + position + ")");
}
int value... | #fixed code
public ByteBuffer asByteBuffer() {
if (isNull()) {
return null;
}
if (limit > 0 && limit < position) {
throw new IllegalArgumentException("limit < position: (" + limit + " < " + position + ")");
}
int size = size... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override public void execute() throws MojoExecutionException {
final Log log = getLog();
try {
log.info("Executing JavaCPP Builder");
if (log.isDebugEnabled()) {
log.debug("classPath: " + classPath);
... | #fixed code
@Override public void execute() throws MojoExecutionException {
final Log log = getLog();
try {
log.info("Executing JavaCPP Builder");
if (log.isDebugEnabled()) {
log.debug("classPath: " + classPath);
log... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static File cacheResource(URL resourceURL, String target) throws IOException {
// Find appropriate subdirectory in cache for the resource ...
File urlFile;
try {
urlFile = new File(new URI(resourceURL.toString().split("#")[0]))... | #fixed code
public static File cacheResource(URL resourceURL, String target) throws IOException {
// Find appropriate subdirectory in cache for the resource ...
File urlFile;
try {
urlFile = new File(new URI(resourceURL.toString().split("#")[0]));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String load(Class cls) {
if (!loadLibraries || cls == null) {
return null;
}
// Find the top enclosing class, to match the library filename
Properties p = (Properties)getProperties().clone();
cls = appen... | #fixed code
public static String load(Class cls) {
if (!loadLibraries || cls == null) {
return null;
}
// Find the top enclosing class, to match the library filename
Properties p = (Properties)getProperties().clone();
String pathSepara... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
boolean checkPlatform(Platform platform, String[] defaultNames) {
if (platform == null) {
return true;
}
if (defaultNames == null) {
defaultNames = new String[0];
}
String platform2 = properties.getProperty... | #fixed code
boolean classes(boolean handleExceptions, boolean defineAdapters, boolean convertStrings,
String loadSuffix, String baseLoadSuffix, String classPath, Class<?> ... classes) {
String version = Generator.class.getPackage().getImplementationVersion();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected <P extends Pointer> P deallocator(Deallocator deallocator) {
if (this.deallocator != null) {
if (logger.isDebugEnabled()) {
logger.debug("Predeallocating " + this);
}
this.deallocator.deallocate();
... | #fixed code
protected <P extends Pointer> P deallocator(Deallocator deallocator) {
if (this.deallocator != null) {
if (logger.isDebugEnabled()) {
logger.debug("Predeallocating " + this);
}
this.deallocator.deallocate();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override public void execute() throws MojoExecutionException {
final Log log = getLog();
try {
log.info("Executing JavaCPP Builder");
if (log.isDebugEnabled()) {
log.debug("classPath: " + classPath);
... | #fixed code
@Override public void execute() throws MojoExecutionException {
final Log log = getLog();
try {
log.info("Executing JavaCPP Builder");
if (log.isDebugEnabled()) {
log.debug("classPath: " + classPath);
log... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean generate(String sourceFilename, String headerFilename,
String classPath, Class<?> ... classes) throws FileNotFoundException {
// first pass using a null writer to fill up the IndexedSet objects
out = new PrintWriter(new Writer(... | #fixed code
public boolean generate(String sourceFilename, String headerFilename,
String classPath, Class<?> ... classes) throws IOException {
// first pass using a null writer to fill up the IndexedSet objects
out = new PrintWriter(new Writer() {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Token[] expand(Token[] array, int index) {
if (index < array.length && infoMap.containsKey(array[index].value)) {
// if we hit a token whose info.cppText starts with #define (a macro), expand it
int startIndex = index;
Info in... | #fixed code
TokenIndexer(InfoMap infoMap, Token[] array, boolean isCFile) {
this.infoMap = infoMap;
this.array = array;
this.isCFile = isCFile;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public BytePointer putString(String s, String charsetName)
throws UnsupportedEncodingException {
byte[] bytes = s.getBytes(charsetName);
//capacity(bytes.length+1);
asBuffer().put(bytes).put((byte)0);
return this;
}
... | #fixed code
public BytePointer putString(String s, String charsetName)
throws UnsupportedEncodingException {
byte[] bytes = s.getBytes(charsetName);
//capacity(bytes.length+1);
put(bytes).put(bytes.length, (byte)0);
return this;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<Task> assignTasks(TaskTracker taskTracker)
throws IOException {
HttpHost tracker = new HttpHost(taskTracker.getStatus().getHost(),
taskTracker.getStatus().getHttpPort());
if (!mesosTrackers.containsKey(tracker)) {
LOG.i... | #fixed code
@Override
public List<Task> assignTasks(TaskTracker taskTracker)
throws IOException {
HttpHost tracker = new HttpHost(taskTracker.getStatus().getHost(),
taskTracker.getStatus().getHttpPort());
if (!mesosTrackers.containsKey(tracker)) {
LOG.info("U... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> T get(String claimName, Class<T> requiredType) {
Object value = get(claimName);
if (value == null) { return null; }
if (Claims.EXPIRATION.equals(claimName) ||
Claims.ISSUED_AT.equals(claimName) ||
... | #fixed code
@Override
public <T> T get(String claimName, Class<T> requiredType) {
Object value = get(claimName);
if (value == null) { return null; }
if (Claims.EXPIRATION.equals(claimName) ||
Claims.ISSUED_AT.equals(claimName) ||
Claim... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected byte[] doDecompress(byte[] compressed) throws IOException {
byte[] buffer = new byte[512];
ByteArrayOutputStream outputStream = null;
GZIPInputStream gzipInputStream = null;
ByteArrayInputStream inputStream = null... | #fixed code
@Override
protected byte[] doDecompress(byte[] compressed) throws IOException {
return readAndClose(new GZIPInputStream(new ByteArrayInputStream(compressed)));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public boolean updateRule(@PathVariable String id, @RequestBody RouteDTO routeDTO, @PathVariable String env) {
Route route = routeService.findRoute(id);
if (route == null) {
//T... | #fixed code
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public boolean updateRule(@PathVariable String id, @RequestBody RouteDTO routeDTO, @PathVariable String env) {
Route route = routeService.findRoute(id);
if (route == null) {
throw new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public RouteDTO detailRoute(@PathVariable String id, @PathVariable String env) {
Route route = routeService.findRoute(id);
if (route == null) {
// TODO throw exception
}... | #fixed code
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public RouteDTO detailRoute(@PathVariable String id, @PathVariable String env) {
Route route = routeService.findRoute(id);
if (route == null) {
// TODO throw exception
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public RouteDTO detailRoute(@PathVariable String id, @PathVariable String env) {
Route route = routeService.findRoute(id);
if (route == null) {
// TODO throw exception
}... | #fixed code
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public RouteDTO detailRoute(@PathVariable String id, @PathVariable String env) {
Route route = routeService.findRoute(id);
if (route == null) {
throw new ResourceNotFoundException("Un... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public OverrideDTO detailOverride(@PathVariable String id, @PathVariable String env) {
Override override = overrideService.findById(id);
if (override == null) {
//TODO throw exc... | #fixed code
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public OverrideDTO detailOverride(@PathVariable String id, @PathVariable String env) {
Override override = overrideService.findById(id);
if (override == null) {
throw new ResourceNotF... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void addToWindow(Datum newDatum) {
if (window.size() == 0) {
// We don't know what weight to use for the first datum, so we wait
// until we have the second one to actually process it.
window.add(new Datum... | #fixed code
@Override
public void addToWindow(Datum newDatum) {
if (window.size() == 0) {
// We don't know what weight to use for the first datum, so we wait
// until we have the second one to actually process it.
window.add(new DatumWithIn... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDumpSmall() throws Exception {
MacroBaseConf conf = new MacroBaseConf();
ArrayList<Integer> attrs = new ArrayList<>();
attrs.add(1);
attrs.add(2);
OutlierClassifier dummy = new OutlierClassifier() {
... | #fixed code
@Test
public void testDumpSmall() throws Exception {
MacroBaseConf conf = new MacroBaseConf();
ArrayList<Integer> attrs = new ArrayList<>();
attrs.add(1);
attrs.add(2);
OutlierClassifier dummy = new OutlierClassifier() {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ColumnValue getAttribute(int encodedAttr) {
int matchingColumn = integerToColumn.get(encodedAttr);
String columnName = attributeDimensionNameMap.get(matchingColumn);
String columnValue = integerEncoding.get(matchingColumn).inverse().get(e... | #fixed code
public ColumnValue getAttribute(int encodedAttr) {
int matchingColumn = integerToColumn.get(encodedAttr);
String columnName = attributeDimensionNameMap.get(matchingColumn);
Map<String, Integer> columnEncoding = integerEncoding.get(matchingColumn);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<AnalysisResult> run() throws Exception {
final int batchSize = conf.getInt(MacroBaseConf.TUPLE_BATCH_SIZE,
MacroBaseDefaults.TUPLE_BATCH_SIZE);
Stopwatch sw = Stopwatch.createStarted();... | #fixed code
@Override
public List<AnalysisResult> run() throws Exception {
final int batchSize = conf.getInt(MacroBaseConf.TUPLE_BATCH_SIZE,
MacroBaseDefaults.TUPLE_BATCH_SIZE);
Stopwatch sw = Stopwatch.createStarted();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@POST
@Consumes(MediaType.APPLICATION_JSON)
public FormattedRowSetResponse getRowsFormatted(RowSetRequest request) {
FormattedRowSetResponse response = new FormattedRowSetResponse();
try {
conf.set(MacroBaseConf.DB_URL, request.pgUrl... | #fixed code
@POST
@Consumes(MediaType.APPLICATION_JSON)
public FormattedRowSetResponse getRowsFormatted(RowSetRequest request) {
FormattedRowSetResponse response = new FormattedRowSetResponse();
try {
conf.set(MacroBaseConf.DB_URL, request.pgUrl);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@POST
@Consumes(MediaType.APPLICATION_JSON)
public FormattedRowSetResponse getRowsFormatted(RowSetRequest request) {
FormattedRowSetResponse response = new FormattedRowSetResponse();
try {
conf.set(MacroBaseConf.DB_URL, request.pgUrl... | #fixed code
@POST
@Consumes(MediaType.APPLICATION_JSON)
public FormattedRowSetResponse getRowsFormatted(RowSetRequest request) {
FormattedRowSetResponse response = new FormattedRowSetResponse();
try {
conf.set(MacroBaseConf.DB_URL, request.pgUrl);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public AnalysisResult run() throws Exception {
long startMs = System.currentTimeMillis();
DataIngester ingester = conf.constructIngester();
List<Datum> data = ingester.getStream().drain();
long loadEndMs = System.currentTime... | #fixed code
@Override
public AnalysisResult run() throws Exception {
long startMs = System.currentTimeMillis();
DataIngester ingester = conf.constructIngester();
List<Datum> data = ingester.getStream().drain();
long loadEndMs = System.currentTimeMillis... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldHandleErrorResponse() throws Exception {
//given
final HttpResponse errorResponse = new HttpResponse(401, "{\n" +
" \"error\": {\n" +
" \"message\": \"Invalid OAuth access token.\",\n" +
... | #fixed code
@Test
public void shouldHandleErrorResponse() throws Exception {
//given
final HttpResponse errorResponse = new HttpResponse(401, "{\n" +
" \"error\": {\n" +
" \"message\": \"Invalid OAuth access token.\",\n" +
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
if (args.length < 1){
System.out.println("usage: <index location> <command> <command args>");
System.exit(1);
}
String idxLocation = args[0];
ClueApplication app = null;
... | #fixed code
public static void main(String[] args) throws Exception {
if (args.length < 1){
System.out.println("usage: <index location> <command> <command args>");
System.exit(1);
}
String idxLocation = args[0];
ClueApplication app = null;
if ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));
while(true){
System.out.print("> ");
String line = inReader.readLine();
if (line == null || line.isEmpty()) continue;
lin... | #fixed code
public void run() throws IOException {
while(true){
System.out.print("> ");
String line = ctx.readCommand();
if (line == null || line.isEmpty()) continue;
line = line.trim();
String[] parts = line.split("\\s");
if (parts.length > 0){
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute(String[] args, PrintStream out) throws Exception {
String field = null;
String termVal = null;
try{
field = args[0];
}
catch(Exception e){
field = null;
}
if (field != null){
String[] parts... | #fixed code
@Override
public void execute(String[] args, PrintStream out) throws Exception {
String field = null;
String termVal = null;
try{
field = args[0];
}
catch(Exception e){
field = null;
}
if (field != null){
String[] parts = fie... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
if (args.length < 1){
System.out.println("usage: <index location> <command> <command args>");
System.exit(1);
}
ClueConfiguration config = ClueConfiguration.load();
String idxL... | #fixed code
public static void main(String[] args) throws Exception {
if (args.length < 1){
System.out.println("usage: <index location> <command> <command args>");
System.exit(1);
}
String idxLocation = args[0];
ClueApplication app = null;
if ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
if (args.length < 1){
System.out.println("usage: <index location> <command> <command args>");
System.exit(1);
}
String idxLocation = args[0];
ClueApplication app = null;
... | #fixed code
public static void main(String[] args) throws Exception {
if (args.length < 1){
System.out.println("usage: <index location> <command> <command args>");
System.exit(1);
}
String idxLocation = args[0];
ClueApplication app = null;
if ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void printScreen() {
if (error != null && error) {
printScreenWithOld();
} else {
try {
String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
... | #fixed code
public static void printScreen() {
if (error == null || error || !error) {
printScreenWithOld();
} else {
try {
String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void printScreen() {
if (error != null && error) {
printScreenWithOld();
} else {
try {
String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
... | #fixed code
public static void printScreen() {
if (error == null || error || !error) {
printScreenWithOld();
} else {
try {
String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void printScreen() {
if (error != null && error) {
printScreenWithOld();
} else {
try {
String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
... | #fixed code
public static void printScreen() {
if (error == null || error || !error) {
printScreenWithOld();
} else {
try {
String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void buildSysGenProfilingFile() {
long startMills = System.currentTimeMillis();
String filePath = ProfilingConfig.getInstance().getSysProfilingParamsFile();
String tempFilePath = filePath + "_tmp";
File tempFile = new File(t... | #fixed code
public static void buildSysGenProfilingFile() {
long startMills = System.currentTimeMillis();
String filePath = ProfilingConfig.getInstance().getSysProfilingParamsFile();
String tempFilePath = filePath + "_tmp";
File tempFile = new File(tempFil... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
void authenticationStepsShouldAuthenticatePushModeWithProvidedSecretId() {
String roleId = getRoleId("with-secret-id");
String secretId = "hello_world_two";
VaultResponse customSecretIdResponse = getVaultOperations().write(
"auth/approle/role/with-secret... | #fixed code
@Test
void authenticationStepsShouldAuthenticatePushModeWithProvidedSecretId() {
String roleId = getRoleId("with-secret-id");
String secretId = "hello_world_two";
VaultResponse customSecretIdResponse = getVaultOperations().write(
"auth/approle/role/with-secret-id/cu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
private Lease renew(Lease lease) {
HttpEntity<Object> leaseRenewalEntity = getLeaseRenewalBody(lease);
ResponseEntity<Map<String, Object>> entity = operations
.doWithSession(restOperations -> (ResponseEntity) restOperations
.... | #fixed code
@SuppressWarnings("unchecked")
private Lease renew(Lease lease) {
return operations.doWithSession(restOperations -> leaseEndpoints.renew(lease,
restOperations));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
@SuppressWarnings("unchecked")
public boolean isInitialized() {
return requireResponse(vaultOperations.doWithVault(restOperations -> {
try {
Map<String, Boolean> body = restOperations.getForObject("sys/init",
Map.class);
Assert.state(body ... | #fixed code
@Override
@SuppressWarnings("unchecked")
public boolean isInitialized() {
return requireResponse(vaultOperations.doWithSession(restOperations -> {
try {
ResponseEntity<Map<String, Boolean>> body = (ResponseEntity) restOperations
.exchange("sys/init", HttpMetho... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
void shouldAuthenticatePullModeWithGeneratedSecretId() {
String roleId = getRoleId("with-secret-id");
String secretId = (String) getVaultOperations()
.write(String.format("auth/approle/role/%s/secret-id", "with-secret-id"),
null).getRequiredData().get... | #fixed code
@Test
void shouldAuthenticatePullModeWithGeneratedSecretId() {
String roleId = getRoleId("with-secret-id");
String secretId = (String) getVaultOperations()
.write(String.format("auth/approle/role/%s/secret-id", "with-secret-id"),
null).getRequiredData().get("secr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean initForceBatchStatementsOrdering(TypedMap configMap) {
return configMap.getTypedOr(FORCE_BATCH_STATEMENTS_ORDERING, true);
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public boolean initForceBatchStatementsOrdering(TypedMap configMap) {
return configMap.getTypedOr(FORCE_BATCH_STATEMENTS_ORDERING, DEFAULT_FORCE_BATCH_STATEMENTS_ORDERING);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private TypeParsingResult parseComputedType(AnnotationTree annotationTree, FieldParsingContext context, TypeName sourceType) {
final CodecInfo codecInfo = codecFactory.createCodec(sourceType, annotationTree, context);
final TypeName rawTargetType = getRa... | #fixed code
private TypeParsingResult parseComputedType(AnnotationTree annotationTree, FieldParsingContext context, TypeName sourceType) {
final CodecInfo codecInfo = codecFactory.createCodec(sourceType, annotationTree, context, Optional.empty());
final TypeName rawTarget... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public PreparedStatement prepareUpdateFields(Session session, EntityMeta entityMeta, List<PropertyMeta> pms) {
log.trace("Generate prepared statement for UPDATE properties {}", pms);
PropertyMeta idMeta = entityMeta.getIdMeta();
Update update = update(entityMeta.ge... | #fixed code
public PreparedStatement prepareUpdateFields(Session session, EntityMeta entityMeta, List<PropertyMeta> pms) {
log.trace("Generate prepared statement for UPDATE properties {}", pms);
PropertyMeta idMeta = entityMeta.getIdMeta();
Update update = update(entityMeta.getTable... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void addInterceptorsToEntityMetas(List<Interceptor<?>> interceptors, Map<Class<?>,
EntityMeta> entityMetaMap) {
for (Interceptor<?> interceptor : interceptors) {
Class<?> entityClass = propertyParser.inferEntityClassFromInterceptor... | #fixed code
public void addInterceptorsToEntityMetas(List<Interceptor<?>> interceptors, Map<Class<?>,
EntityMeta> entityMetaMap) {
for (Interceptor<?> interceptor : interceptors) {
Class<?> parentEntityClass = propertyParser.inferEntityClassFromInterceptor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Map<CQLQueryType, PreparedStatement> prepareClusteredCounterQueryMap(Session session, EntityMeta meta) {
PropertyMeta idMeta = meta.getIdMeta();
PropertyMeta counterMeta = meta.getFirstMeta();
String tableName = meta.getTableName();
String counterName = coun... | #fixed code
public Map<CQLQueryType, PreparedStatement> prepareClusteredCounterQueryMap(Session session, EntityMeta meta) {
PropertyMeta idMeta = meta.getIdMeta();
PropertyMeta counterMeta = meta.getFirstMeta();
String tableName = meta.getTableName();
String counterName = counterMet... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
final boolean kubernetesEnabled = environment
.getProperty("spring.cloud.kubernetes.enabled", Boolean.class, true);
if (!kubernetesEnabled) {
... | #fixed code
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
final boolean kubernetesEnabled = environment
.getProperty("spring.cloud.kubernetes.enabled", Boolean.class, true);
if (!kubernetesEnabled) {
return... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeWithMessageIdAndAck() throws IOException {
Packet packet = decoder.decodePacket("5:1+::{\"name\":\"tobi\"}", null);
Assert.assertEquals(PacketType.EVENT, packet.getType());
// Assert.assertEquals(1, (long)packet.get... | #fixed code
@Test
public void testDecodeWithMessageIdAndAck() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:1+::{\"name\":\"tobi\"}", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.EVENT, packet.getType());
// As... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) {
FullHttpRequest req = (FullHttpRequest) msg;
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
File resource... | #fixed code
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) {
FullHttpRequest req = (FullHttpRequest) msg;
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
String resource = r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void disconnect() {
ChannelFuture future = send(new Packet(PacketType.DISCONNECT));
future.addListener(ChannelFutureListener.CLOSE);
onChannelDisconnect();
}
#location 3
#vulne... | #fixed code
public void disconnect() {
ChannelFuture future = send(new Packet(PacketType.DISCONNECT));
if(future != null) {
future.addListener(ChannelFutureListener.CLOSE);
}
onChannelDisconnect();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void doReconnect(Channel channel, HttpRequest req) {
isKeepAlive = isKeepAlive(req);
this.channel = channel;
this.connected = true;
sendPayload();
}
#location 5
#vulnerability... | #fixed code
public void doReconnect(Channel channel, HttpRequest req) {
this.isKeepAlive = HttpHeaders.isKeepAlive(req);
this.origin = req.getHeader(HttpHeaders.Names.ORIGIN);
this.channel = channel;
this.connected = true;
sendPayload();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePacket("5:::{\"name\":\"woot\"}", null);
Assert.assertEquals(PacketType.EVENT, packet.getType());
Assert.assertEquals("woot", packet.getName());
}
... | #fixed code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("5:::{\"name\":\"woot\"}", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.EVENT, packet.getType());
Assert.assertEquals("woot... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void encodePacket(Packet packet, ByteBuf buffer, ByteBufAllocator allocator, boolean binary, boolean jsonp) throws IOException {
ByteBuf buf = buffer;
if (!binary) {
buf = allocateBuffer(allocator);
}
byte type = toChar... | #fixed code
public void encodePacket(Packet packet, ByteBuf buffer, ByteBufAllocator allocator, boolean binary, boolean jsonp) throws IOException {
ByteBuf buf = buffer;
if (!binary) {
buf = allocateBuffer(allocator);
}
byte type = toChar(packe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeDisconnection() throws IOException {
Packet packet = decoder.decodePacket("0::/woot", null);
Assert.assertEquals(PacketType.DISCONNECT, packet.getType());
Assert.assertEquals("/woot", packet.getNsp());
}
... | #fixed code
@Test
public void testDecodeDisconnection() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("0::/woot", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.DISCONNECT, packet.getType());
Assert.assertEquals("/... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePacket("3:::woot", null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
Assert.assertEquals("woot", packet.getData());
}
... | #fixed code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:::woot", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
Assert.assertEquals("woot", packet.get... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeWithData() throws IOException {
JacksonJsonSupport jsonSupport = new JacksonJsonSupport();
jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class);
PacketDecoder decoder = new PacketDe... | #fixed code
@Test
public void testDecodeWithData() throws IOException {
JacksonJsonSupport jsonSupport = new JacksonJsonSupport();
jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class);
PacketDecoder decoder = new PacketDecoder(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeWithMessageIdAndAckData() throws IOException {
Packet packet = decoder.decodePacket("4:1+::{\"a\":\"b\"}", null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
// Assert.assertEquals(1, (long)packet.getI... | #fixed code
@Test
public void testDecodeWithMessageIdAndAckData() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("4:1+::{\"a\":\"b\"}", CharsetUtil.UTF_8), null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
// Ass... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeWithArgs() throws IOException {
initExpectations();
Packet packet = decoder.decodePacket("6:::12+[\"woot\",\"wa\"]", null);
Assert.assertEquals(PacketType.ACK, packet.getType());
Assert.assertEquals(12, (l... | #fixed code
@Test
public void testDecodeWithArgs() throws IOException {
initExpectations();
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("6:::12+[\"woot\",\"wa\"]", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.ACK, packet.getType()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUTF8Decode() throws IOException {
Packet packet = decoder.decodePacket("4:::\"Привет\"", null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
Assert.assertEquals("Привет", packet.getData());
}
... | #fixed code
@Test
public void testUTF8Decode() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("4:::\"Привет\"", CharsetUtil.UTF_8), null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
Assert.assertEquals("Привет",... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeId() throws IOException {
Packet packet = decoder.decodePacket("3:1::asdfasdf", null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
// Assert.assertEquals(1, (long)packet.getId());
// Assert.ass... | #fixed code
@Test
public void testDecodeId() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:1::asdfasdf", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
// Assert.assertEquals(1, (long)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeWithQueryString() throws IOException {
Packet packet = decoder.decodePacket("1::/test:?test=1", null);
Assert.assertEquals(PacketType.CONNECT, packet.getType());
Assert.assertEquals("/test", packet.getNsp());
// ... | #fixed code
@Test
public void testDecodeWithQueryString() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("1::/test:?test=1", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.CONNECT, packet.getType());
Assert.assertEq... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePacket("6:::140", null);
Assert.assertEquals(PacketType.ACK, packet.getType());
Assert.assertEquals(140, (long)packet.getAckId());
// Assert.assertTrue(p... | #fixed code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("6:::140", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.ACK, packet.getType());
Assert.assertEquals(140, (long)packet.getAc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodingNewline() throws IOException {
Packet packet = decoder.decodePacket("3:::\n", null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
Assert.assertEquals("\n", packet.getData());
}
... | #fixed code
@Test
public void testDecodingNewline() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:::\n", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
Assert.assertEquals("\n", packe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePacket("4:::\"2\"", null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
Assert.assertEquals("2", packet.getData());
}
... | #fixed code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("4:::\"2\"", CharsetUtil.UTF_8), null);
// Assert.assertEquals(PacketType.JSON, packet.getType());
Assert.assertEquals("2", packet.getDat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePacket("1::/tobi", null);
Assert.assertEquals(PacketType.CONNECT, packet.getType());
Assert.assertEquals("/tobi", packet.getNsp());
}
... | #fixed code
@Test
public void testDecode() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("1::/tobi", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.CONNECT, packet.getType());
Assert.assertEquals("/tobi", packet.ge... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testDecodeWithIdAndEndpoint() throws IOException {
Packet packet = decoder.decodePacket("3:5:/tobi", null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
// Assert.assertEquals(5, (long)packet.getId());
// ... | #fixed code
@Test
public void testDecodeWithIdAndEndpoint() throws IOException {
Packet packet = decoder.decodePackets(Unpooled.copiedBuffer("3:5:/tobi", CharsetUtil.UTF_8), null);
Assert.assertEquals(PacketType.MESSAGE, packet.getType());
// Assert.assertEqual... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) {
FullHttpRequest req = (FullHttpRequest) msg;
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
File resource... | #fixed code
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) {
FullHttpRequest req = (FullHttpRequest) msg;
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
String resource = r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testBench1() throws Exception {
if (System.getProperty("skipBenchmark") != null && System.getProperty("skipBenchmark").equals("true")) {
System.out.println(":: skipping naive benchmarks...");
return;
}
System.out.println(":: running naive ben... | #fixed code
@Test
public void testBench1() throws Exception {
if (System.getProperty("skipBenchmark") != null) {
System.out.println(":: skipping naive benchmarks...");
return;
}
System.out.println(":: running naive benchmarks, set -DskipBenchmark to skip");
String expr = "foo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canUpsertWithWriteConcern() throws Exception {
WriteConcern writeConcern = spy(WriteConcern.SAFE);
/* when */
WriteResult writeResult = collection.upsert("{}", "{$set:{name:'John'}}", writeConcern);
/* then */
... | #fixed code
@Test
public void canUpsertWithWriteConcern() throws Exception {
/* when */
WriteResult writeResult = collection.update("{}").upsert().concern(WriteConcern.SAFE).with("{$set:{name:'John'}}");
/* then */
People john = collection.findOne("{... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canModifyAlreadySavedEntity() throws Exception {
/* given */
String idAsString = collection.save(new People("John", "21 Jump Street"));
ObjectId id = new ObjectId(idAsString);
People people = collection.findOne(id).a... | #fixed code
@Test
public void canModifyAlreadySavedEntity() throws Exception {
/* given */
People john = new People("John", "21 Jump Street");
collection.save(john);
john.setAddress("new address");
/* when */
collection.save(john);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canFindOne() throws Exception {
/* given */
String id = collection.save(this.people);
/* when */
People people = collection.findOne("{name:#}", "John").as(People.class);
/* then */
assertThat(people... | #fixed code
@Test
public void canFindOne() throws Exception {
/* given */
String id = collection.save(new People("John", new Coordinate(1, 1)));
/* when */
People result = collection.findOne("{name:#}", "John").as(People.class);
/* then */
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canModifyAlreadySavedEntity() throws Exception {
/* given */
String idAsString = collection.save(new People("John", "21 Jump Street"));
ObjectId id = new ObjectId(idAsString);
People people = collection.findOne(id).a... | #fixed code
@Test
public void canModifyAlreadySavedEntity() throws Exception {
/* given */
People john = new People("John", "21 Jump Street");
collection.save(john);
john.setAddress("new address");
/* when */
collection.save(john);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
//https://groups.google.com/forum/?fromgroups#!topic/jongo-user/p9CEKnkKX9Q
public void canUpdateIntoAnArray() throws Exception {
collection.insert("{friends:[{name:'Robert'},{name:'Peter'}]}");
collection.update("{ 'friends.name' : 'Pete... | #fixed code
@Test
//https://groups.google.com/forum/?fromgroups#!topic/jongo-user/p9CEKnkKX9Q
public void canUpdateIntoAnArray() throws Exception {
collection.insert("{friends:[{name:'Robert'},{name:'Peter'}]}");
collection.update("{ 'friends.name' : 'Peter' }")... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canFindOneWithObjectId() throws Exception {
/* given */
People john = new People("John", "22 Wall Street Avenue");
collection.save(john);
People foundPeople = collection.findOne(john.getId()).as(People.class);
... | #fixed code
@Test
public void canFindOneWithObjectId() throws Exception {
/* given */
Friend john = new Friend("John", "22 Wall Street Avenue");
collection.save(john);
Friend foundFriend = collection.findOne(john.getId()).as(Friend.class);
/*... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canFindOneWithEmptyQuery() throws Exception {
/* given */
collection.save(new People("John", "22 Wall Street Avenue"));
/* when */
People people = collection.findOne().as(People.class);
/* then */
a... | #fixed code
@Test
public void canFindOneWithEmptyQuery() throws Exception {
/* given */
collection.save(new Friend("John", "22 Wall Street Avenue"));
/* when */
Friend friend = collection.findOne().as(Friend.class);
/* then */
assertT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canSaveAnObjectWithAnObjectId() throws Exception {
People john = new People(new ObjectId("47cc67093475061e3d95369d"), "John");
String id = collection.save(john);
People result = collection.findOne(new ObjectId(id)).as(Peo... | #fixed code
@Test
public void canSaveAnObjectWithAnObjectId() throws Exception {
People john = new People(new ObjectId("47cc67093475061e3d95369d"), "John");
collection.save(john);
People result = collection.findOne(new ObjectId("47cc67093475061e3d95369d")).... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canFindOne() throws Exception {
/* given */
collection.save(new People("John", "22 Wall Street Avenue"));
/* when */
People people = collection.findOne("{name:'John'}").as(People.class);
/* then */
... | #fixed code
@Test
public void canFindOne() throws Exception {
/* given */
collection.save(new Friend("John", "22 Wall Street Avenue"));
/* when */
Friend friend = collection.findOne("{name:'John'}").as(Friend.class);
/* then */
assert... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void canUpsert() throws Exception {
/* when */
WriteResult writeResult = collection.upsert("{}", "{$set:{name:'John'}}");
/* then */
People john = collection.findOne("{name:'John'}").as(People.class);
assertThat... | #fixed code
@Test
public void canUpsert() throws Exception {
/* when */
WriteResult writeResult = collection.update("{}").upsert().with("{$set:{name:'John'}}");
/* then */
People john = collection.findOne("{name:'John'}").as(People.class);
as... | 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.