input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Test
public void test() {
JedisPoolConfig config = new JedisPoolConfig();
// 设置空间连接
config.setMaxIdle(20);
config.setMaxWaitMillis(1000);
JedisPool pool = new JedisPool(config, "27.126.180.210", 6379);
System.out.p... | #fixed code
@Test
public void test() {
JedisPoolConfig config = new JedisPoolConfig();
// 设置空间连接
config.setMaxIdle(20);
config.setMaxWaitMillis(1000);
// JedisPool pool = new JedisPool(config, "27.126.180.210", 6379);
// System.out.pri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public File saveAs(String path) throws IOException, InterruptedException {
Runtime rt = Runtime.getRuntime();
String command = this.commandWithParameters() + Symbol.separator + path;
Process proc = rt.exec(command);
if(htmlFromString) {
... | #fixed code
public File saveAs(String path) throws IOException, InterruptedException {
byte[] pdf = this.getPDF();
File file = new File(path);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
bufferedOutputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public byte[] getPDF() throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
if(htmlFromString && !this.params.contains(new Param("-"))) {
this.addParam(new Param("-"));
}
String command = this.com... | #fixed code
public byte[] getPDF() throws IOException, InterruptedException {
return getPDF(STDOUT);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public File saveAs(String path) throws IOException, InterruptedException {
Runtime rt = Runtime.getRuntime();
String command = this.commandWithParameters() + Symbol.separator + path;
Process proc = rt.exec(command);
if(htmlFromString) {
... | #fixed code
public File saveAs(String path) throws IOException, InterruptedException {
byte[] pdf = this.getPDF();
File file = new File(path);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
bufferedOutputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public byte[] getPDF() throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
if(htmlFromString && !this.params.contains(new Param("-"))) {
this.addParam(new Param("-"));
}
String command = this.com... | #fixed code
public byte[] getPDF() throws IOException, InterruptedException {
return getPDF(STDOUT);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public byte[] getPDF() throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(getCommandAsArray());
for (Page page : pages) {
if (page.getType().equals(PageType.htmlAsString)... | #fixed code
public byte[] getPDF() throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(getCommandAsArray());
StreamEater outputStreamEater = new StreamEater(process.getInputStream());
outputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public File saveAs(String path) throws IOException, InterruptedException {
Runtime rt = Runtime.getRuntime();
String command = this.commandWithParameters() + Symbol.separator + path;
Process proc = rt.exec(command);
if(htmlFromString) {
... | #fixed code
public File saveAs(String path) throws IOException, InterruptedException {
byte[] pdf = this.getPDF();
File file = new File(path);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
bufferedOutputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFieldPopulator()
{
Album funeral = DataGenerator.funeral();
ResultTraverser traverser = new ResultTraverser();
populatorRegistry.register( new AlbumFieldPopulator() );
YogaRequestContext requestContext = new... | #fixed code
@Test
public void testFieldPopulator()
{
Album funeral = DataGenerator.funeral();
ResultTraverser traverser = new ResultTraverser();
populatorRegistry.register( new AlbumFieldPopulator() );
YogaRequestContext requestContext = new YogaR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectUnsupportedField()
{
Album chasingProphecy = DataGenerator.chasingProphecy();
ResultTraverser traverser = new ResultTraverser();
populatorRegistry.register( new AlbumFieldPopulator() );
Map<String,Obje... | #fixed code
@Test
public void testSelectUnsupportedField()
{
Album chasingProphecy = DataGenerator.chasingProphecy();
ResultTraverser traverser = new ResultTraverser();
populatorRegistry.register( new AlbumFieldPopulator() );
Map<String,Object> ob... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testComplexCoreFields()
{
User carter = DataGenerator.carter();
carter.getFavoriteArtists().add( DataGenerator.neutralMilkHotel() );
carter.getFavoriteArtists().add( DataGenerator.arcadeFire() );
ResultTraverser ... | #fixed code
@Test
public void testComplexCoreFields()
{
User carter = DataGenerator.carter();
carter.getFavoriteArtists().add( DataGenerator.neutralMilkHotel() );
carter.getFavoriteArtists().add( DataGenerator.arcadeFire() );
ResultTraverser traver... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
@Test
// Add the MetadataLinkListener to the listener chain. The output will render an href to view the metadata
// for the album object.
public void testMetadataHref()
{
String prefixUrl = "/metadata/";
St... | #fixed code
@SuppressWarnings("unchecked")
@Test
// Add the MetadataLinkListener to the listener chain. The output will render an href to view the metadata
// for the album object.
public void testMetadataHref()
{
String prefixUrl = "/metadata/";
String f... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void init() throws IOException
{
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "sampledb.sql" );
BufferedReader reader = new BufferedReader( new InputStreamReader( is ) );
String line = null;
... | #fixed code
public void init()
{
try
{
init( Thread.currentThread().getContextClassLoader().getResourceAsStream( "sampledb.sql" ) );
}
catch ( Exception e )
{
throw new RuntimeException( e );
}
// this do... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAnnotatedModel()
{
User solomon = DataGenerator.solomon();
ResultTraverser traverser = new ResultTraverser();
YogaRequestContext requestContext = new YogaRequestContext( "test",
new DummyHttpServletR... | #fixed code
@Test
public void testAnnotatedModel()
{
User solomon = DataGenerator.solomon();
ResultTraverser traverser = new ResultTraverser();
YogaRequestContext requestContext = new YogaRequestContext( "test", new GDataSelectorParser(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testView() throws IOException {
PosixFileAttributeView view = service.getFileAttributeView(
fileSupplier(), PosixFileAttributeView.class);
assertNotNull(view);
ASSERT.that(view.name()).is("posix");
ASSERT.that(view.getOwner()).... | #fixed code
@Test
public void testView() throws IOException {
store.setAttribute("owner:owner", createUserPrincipal("user"));
PosixFileAttributeView view = provider.getView(attributeStoreSupplier());
assertNotNull(view);
ASSERT.that(view.name()).is("posix");
ASSERT.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public JimfsFileSystem newFileSystem(URI uri, Map<String, ?> env) {
checkArgument(uri.getScheme().equalsIgnoreCase(SCHEME),
"uri (%s) scheme must be '%s'", uri, SCHEME);
checkArgument(env.get(CONFIG_KEY) instanceof JimfsConfiguration,
"... | #fixed code
@Override
public JimfsFileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
checkArgument(uri.getScheme().equalsIgnoreCase(SCHEME),
"uri (%s) scheme must be '%s'", uri, SCHEME);
checkArgument(env.get(CONFIG_KEY) instanceof JimfsConfigurati... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testView() throws IOException {
AclFileAttributeView view =
service.getFileAttributeView(fileSupplier(), AclFileAttributeView.class);
assertNotNull(view);
ASSERT.that(view.name()).is("acl");
ASSERT.that(view.getAcl()).is(defau... | #fixed code
@Test
public void testView() throws IOException {
AclFileAttributeView view = provider.getView(attributeStoreSupplier());
assertNotNull(view);
ASSERT.that(view.name()).is("acl");
ASSERT.that(view.getAcl()).is(defaultAcl);
view.setAcl(ImmutableList.<AclE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testClosedChannel() throws IOException, InterruptedException {
RegularFile file = regularFile(15);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
JimfsAsynchronousFileChannel channel = channel(file, executor, R... | #fixed code
@Test
public void testClosedChannel() throws Throwable {
RegularFile file = regularFile(15);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
JimfsAsynchronousFileChannel channel = channel(file, executor, READ, WRITE);
channel.clo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testView() throws IOException {
UserDefinedFileAttributeView view =
service.getFileAttributeView(fileSupplier(), UserDefinedFileAttributeView.class);
assertNotNull(view);
ASSERT.that(view.name()).is("user");
ASSERT.that(view.li... | #fixed code
@Test
public void testView() throws IOException {
UserDefinedFileAttributeView view = provider.getView(attributeStoreSupplier());
assertNotNull(view);
ASSERT.that(view.name()).is("user");
ASSERT.that(view.list()).isEmpty();
byte[] b1 = {0, 1, 2};
byt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static FileSystem newFileSystem(String name) {
String os = System.getProperty("os.name");
Configuration config;
if (os.contains("Windows")) {
config = Configuration.windows();
} else if (os.contains("OS X")) {
config = Configuration.osX... | #fixed code
public static FileSystem newFileSystem(String name) {
return newFileSystem(name, Configuration.forCurrentPlatform());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAsynchronousClose() throws IOException, InterruptedException {
RegularFile file = regularFile(10);
final FileChannel channel = channel(file, READ, WRITE);
file.writeLock().lock(); // ensure all operations on the channel will block
... | #fixed code
@Test
public void testAsynchronousClose() throws Exception {
RegularFile file = regularFile(10);
final FileChannel channel = channel(file, READ, WRITE);
file.writeLock().lock(); // ensure all operations on the channel will block
ExecutorService executor = Ex... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public WatchService newWatchService() throws IOException {
return new PollingWatchService(defaultView, pathService, fileStore.state());
}
#location 3
#vulnerability type RESOURCE_LEAK | #fixed code
@Override
public WatchService newWatchService() throws IOException {
return watchServiceConfig.newWatchService(defaultView, pathService);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public JimfsPath toRealPath(
JimfsPath path, PathService pathService, Set<? super LinkOption> options) throws IOException {
checkNotNull(path);
checkNotNull(options);
store.readLock().lock();
try {
DirectoryEntry entry = lookUp(path, options)
... | #fixed code
public JimfsPath toRealPath(
JimfsPath path, PathService pathService, Set<? super LinkOption> options) throws IOException {
checkNotNull(path);
checkNotNull(options);
store.readLock().lock();
try {
DirectoryEntry entry = lookUp(path, options)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCloseByInterrupt() throws IOException, InterruptedException {
RegularFile file = regularFile(10);
final FileChannel channel = channel(file, READ, WRITE);
file.writeLock().lock(); // ensure all operations on the channel will block
... | #fixed code
@Test
public void testCloseByInterrupt() throws Exception {
RegularFile file = regularFile(10);
final FileChannel channel = channel(file, READ, WRITE);
file.writeLock().lock(); // ensure all operations on the channel will block
ExecutorService executor = Exe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testView() throws IOException {
DosFileAttributeView view =
service.getFileAttributeView(fileSupplier(), DosFileAttributeView.class);
assertNotNull(view);
ASSERT.that(view.name()).is("dos");
DosFileAttributes attrs = view.read... | #fixed code
@Test
public void testView() throws IOException {
DosFileAttributeView view = provider.getView(attributeStoreSupplier());
assertNotNull(view);
ASSERT.that(view.name()).is("dos");
DosFileAttributes attrs = view.readAttributes();
ASSERT.that(attrs.isHidden... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
int concurrents = Integer.parseInt(properties.getProperty("concurrents"));
int runtime = Integer.parseInt(properties.getProperty("runtime"));
String classname = properties.getProperty("classname");
... | #fixed code
public static void main(String[] args) {
loadProperties();
int concurrents = Integer.parseInt(properties.getProperty("concurrents"));
int runtime = Integer.parseInt(properties.getProperty("runtime"));
String classname = properties.getProperty("... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void register(List<URL> registryUrls, URL serviceUrl) {
for (URL url : registryUrls) {
// 根据check参数的设置,register失败可能会抛异常,上层应该知晓
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtensio... | #fixed code
private void register(List<URL> registryUrls, URL serviceUrl) {
for (URL url : registryUrls) {
// 根据check参数的设置,register失败可能会抛异常,上层应该知晓
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtension(url... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setup() throws DBException {
orientDBClient = new OrientDBClient();
Properties p = new Properties();
// TODO: Extract the property names into final variables in OrientDBClient
p.setProperty("orientdb.url", TEST_DB_URL);
orientDB... | #fixed code
@Before
public void setup() throws DBException {
orientDBClient = new OrientDBClient();
Properties p = new Properties();
// TODO: Extract the property names into final variables in OrientDBClient
p.setProperty("orientdb.url", TEST_DB_URL);
orientDBClient... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void cleanup() throws DBException
{
// Get the measurements instance as this is the only client that should
// count clean up time like an update since autoflush is off.
Measurements _measurements = Measurements.getMeasurements();
... | #fixed code
public void cleanup() throws DBException
{
// Get the measurements instance as this is the only client that should
// count clean up time like an update since autoflush is off.
Measurements _measurements = Measurements.getMeasurements();
tr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
try {
MongoCollection<Document> collection = database
.getCollection(table);
Document quer... | #fixed code
@Override
public int read(String table, String key, Set<String> fields,
HashMap<String, ByteIterator> result) {
try {
MongoCollection<Document> collection = database
.getCollection(table);
Document query = ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int update(String table, String key,
HashMap<String, ByteIterator> values) {
try {
MongoCollection<Document> collection = database
.getCollection(table);
Document query = new Document(... | #fixed code
@Override
public int update(String table, String key,
HashMap<String, ByteIterator> values) {
try {
MongoCollection<Document> collection = database
.getCollection(table);
Document query = new Document("_id",... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static RemoteCacheManager getInstance(Properties props){
if(cacheManager == null){
synchronized (RemoteCacheManager.class) {
cacheManager = new RemoteCacheManager(props);
}
}
return cacheManager;
}
#location 7
... | #fixed code
public static RemoteCacheManager getInstance(Properties props){
RemoteCacheManager result = cacheManager;
if(result == null){
synchronized (RemoteCacheManagerHolder.class) {
result = cacheManager;
if (result == null) {
cacheManager = result = new RemoteCacheM... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void init() throws DBException
{
if ( (getProperties().getProperty("debug")!=null) &&
(getProperties().getProperty("debug").compareTo("true")==0) )
{
_debug=true;
}
if (getProperties().containsKey("... | #fixed code
public void init() throws DBException
{
if ( (getProperties().getProperty("debug")!=null) &&
(getProperties().getProperty("debug").compareTo("true")==0) )
{
_debug=true;
}
if (getProperties().containsKey("client... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
try {
Statement stmt;
Select.Builder selectBuilder;
if (fields == null) {
selectBuilder... | #fixed code
@Override
public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
try {
PreparedStatement stmt = (fields == null) ? scanAllStmt.get() : scanStmts.get(fields);
// Prepare sta... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status read(String table, String key, Set<String> fields,
Map<String, ByteIterator> result) {
try {
Statement stmt;
Select.Builder selectBuilder;
if (fields == null) {
selectBuilder = QueryBuilder.select().all();
... | #fixed code
@Override
public Status read(String table, String key, Set<String> fields,
Map<String, ByteIterator> result) {
try {
PreparedStatement stmt = (fields == null) ? readAllStmt.get() : readStmts.get(fields);
// Prepare statement on demand
if (stmt == ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
MongoCursor<Document> cursor = null;
try {
MongoCollection<Document> collection = da... | #fixed code
@Override
public int scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
MongoCursor<Document> cursor = null;
try {
MongoCollection<Document> collection = database... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void init() throws DBException {
Properties props = getProperties();
String url = props.getProperty(URL_PROPERTY);
String user = props.getProperty(USER_PROPERTY, USER_PROPERTY_DEFAULT);
String password = props.getProperty(PASSWORD_PROPE... | #fixed code
@Override
public void init() throws DBException {
Properties props = getProperties();
String url = props.getProperty(URL_PROPERTY);
String user = props.getProperty(USER_PROPERTY, USER_PROPERTY_DEFAULT);
String password = props.getProperty(PASSWORD_PROPERTY, P... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
this.currentTable = this.connection.getTable(tName);
// suggestions from
// http://ryantwopointoh.blogspot.com/2009/01/
// performance-of-hbase-i... | #fixed code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
synchronized (CONNECTION_LOCK) {
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status delete(String table, String key) {
try {
Statement stmt;
stmt = QueryBuilder.delete().from(table)
.where(QueryBuilder.eq(YCSB_KEY, key));
stmt.setConsistencyLevel(writeConsistencyLevel);
if (debug) {
... | #fixed code
@Override
public Status delete(String table, String key) {
try {
PreparedStatement stmt = deleteStmt.get();
// Prepare statement on demand
if (stmt == null) {
stmt = session.prepare(QueryBuilder.delete().from(table)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setUp() throws Exception {
// check that this is Java 8+
int javaVersion = Integer.parseInt(System.getProperty("java.version").split("\\.")[1]);
Assume.assumeTrue(javaVersion >= 8);
session = cassandraUnit.getSession();
Properti... | #fixed code
@Before
public void setUp() throws Exception {
session = cassandraUnit.getSession();
Properties p = new Properties();
p.setProperty("hosts", HOST);
p.setProperty("port", Integer.toString(PORT));
p.setProperty("table", TABLE);
Measurements.setProperti... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected net.spy.memcached.MemcachedClient createMemcachedClient()
throws Exception {
ConnectionFactoryBuilder connectionFactoryBuilder =
new ConnectionFactoryBuilder();
connectionFactoryBuilder.setReadBufferSize(Integer.parseInt(
getProper... | #fixed code
protected net.spy.memcached.MemcachedClient createMemcachedClient()
throws Exception {
ConnectionFactoryBuilder connectionFactoryBuilder =
new ConnectionFactoryBuilder();
connectionFactoryBuilder.setReadBufferSize(Integer.parseInt(
getProperties()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean doTransaction(DB db, Object threadstate) {
switch (operationchooser.nextString()) {
case "UPDATE":
doTransactionUpdate(db);
break;
case "INSERT":
doTransactionInsert(db);
break;
case "DELETE":
doTran... | #fixed code
@Override
public boolean doTransaction(DB db, Object threadstate) {
String operation = operationchooser.nextString();
if (operation == null) {
return false;
}
switch (operation) {
case "UPDATE":
doTransactionUpdate(db);
break;
case "... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void cleanup() throws DBException {
// Get the measurements instance as this is the only client that should
// count clean up time like an update if client-side buffering is
// enabled.
Measurements measurements = Measurements.getMeasure... | #fixed code
@Override
public void cleanup() throws DBException {
// Get the measurements instance as this is the only client that should
// count clean up time like an update if client-side buffering is
// enabled.
Measurements measurements = Measurements.getMeasurements(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Map<String, byte[]> convertToBytearrayMap(Map<String,ByteIterator> values) {
Map<String, byte[]> retVal = new HashMap<String, byte[]>();
for (String key : values.keySet()) {
retVal.put(key, values.get(key).toArray());
}
return retVal;
}
... | #fixed code
private Map<String, byte[]> convertToBytearrayMap(Map<String,ByteIterator> values) {
Map<String, byte[]> retVal = new HashMap<String, byte[]>();
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
retVal.put(entry.getKey(), entry.getValue().toArray()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status delete(String table, String key) {
if (debug) {
System.out.println("Doing delete for key: " + key);
}
setTable(table);
final MutateRowRequest.Builder rowMutation = MutateRowRequest.newBuilder()
.setRowKey(B... | #fixed code
@Override
public Status delete(String table, String key) {
if (debug) {
System.out.println("Doing delete for key: " + key);
}
setTable(table);
final MutateRowRequest.Builder rowMutation = MutateRowRequest.newBuilder()
.setRowKey(ByteStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void cleanup() throws DBException {
if (asyncExecutor != null) {
try {
asyncExecutor.flush();
} catch (IOException e) {
throw new DBException(e);
}
}
synchronized (threadCount) {
--threadCount;
i... | #fixed code
@Override
public void cleanup() throws DBException {
if (asyncExecutor != null) {
try {
asyncExecutor.flush();
} catch (IOException e) {
throw new DBException(e);
}
}
synchronized (CONFIG) {
--threadCount;
if (threadCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void init() throws DBException {
if ("true"
.equals(getProperties().getProperty("clientbuffering", "false"))) {
this.clientSideBuffering = true;
}
if (getProperties().containsKey("writebuffersize")) {
writeBufferSize =
... | #fixed code
@Override
public void init() throws DBException {
if ("true"
.equals(getProperties().getProperty("clientbuffering", "false"))) {
this.clientSideBuffering = true;
}
if (getProperties().containsKey("writebuffersize")) {
writeBufferSize =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
synchronized (CONNECTION_LOCK) {
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p... | #fixed code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p = new BufferedMutatorParams(tName);
p.writ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
this.currentTable = this.connection.getTable(tName);
// suggestions from
// http://ryantwopointoh.blogspot.com/2009/01/
// performance-of-hbase-i... | #fixed code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
synchronized (CONNECTION_LOCK) {
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void init() throws DBException {
// initialize OrientDB driver
Properties props = getProperties();
String url;
if (System.getProperty("os.name").toLowerCase().contains("win"))
url = props.getProperty("orientdb.url", "plocal:C:/temp/databases/... | #fixed code
public void init() throws DBException {
Properties props = getProperties();
String url = props.getProperty(URL_PROPERTY);
String user = props.getProperty(USER_PROPERTY, USER_PROPERTY_DEFAULT);
String password = props.getProperty(PASSWORD_PROPERTY, PASSWORD_PROP... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void cleanup() throws DBException {
if (bulkMutation != null) {
try {
bulkMutation.flush();
} catch(RuntimeException e){
throw new DBException(e);
}
}
if (asyncExecutor != null) {
try {
asyncEx... | #fixed code
@Override
public void cleanup() throws DBException {
if (bulkMutation != null) {
try {
bulkMutation.flush();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new DBException(e);
} catch(RuntimeException... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
if (debug) {
System.out.println("Setting up put for key: " + key);
}
setTable(table);
final MutateRowRequest.Builder rowMutation = Muta... | #fixed code
@Override
public Status update(String table, String key,
HashMap<String, ByteIterator> values) {
if (debug) {
System.out.println("Setting up put for key: " + key);
}
setTable(table);
final MutateRowRequest.Builder rowMutation = MutateRowR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void acknowledge(int value)
{
if (value > limit + WINDOW_SIZE) {
throw new RuntimeException("This should be a different exception.");
}
window[value % WINDOW_SIZE] = true;
if (lock.tryLock()) {
// move a contiguous sequence from the window
// ove... | #fixed code
public void acknowledge(int value)
{
// read volatile variable to see other threads' changes
limit = limit;
if (value > limit + WINDOW_SIZE) {
throw new RuntimeException("Too many unacknowledged insertion keys.");
}
window[value % WINDOW_SIZE] = true;
if (lock... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void init() throws DBException {
Properties props = getProperties();
// Defaults the user can override if needed
CONFIG.set("google.bigtable.auth.service.account.enable", "true");
// make it easy on ourselves by copying all CLI... | #fixed code
@Override
public void init() throws DBException {
Properties props = getProperties();
// Defaults the user can override if needed
CONFIG.set("google.bigtable.auth.service.account.enable", "true");
// make it easy on ourselves by copying all CLI prope... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void init() throws DBException {
if ("true"
.equals(getProperties().getProperty("clientbuffering", "false"))) {
this.clientSideBuffering = true;
}
if (getProperties().containsKey("writebuffersize")) {
writeBufferSize =
... | #fixed code
@Override
public void init() throws DBException {
if ("true"
.equals(getProperties().getProperty("clientbuffering", "false"))) {
this.clientSideBuffering = true;
}
if (getProperties().containsKey("writebuffersize")) {
writeBufferSize =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setup() throws DBException {
orientDBClient = new OrientDBClient();
Properties p = new Properties();
// TODO: Extract the property names into final variables in OrientDBClient
p.setProperty("orientdb.url", TEST_DB_URL);
orientDB... | #fixed code
@Before
public void setup() throws DBException {
orientDBClient = new OrientDBClient();
Properties p = new Properties();
// TODO: Extract the property names into final variables in OrientDBClient
p.setProperty("orientdb.url", TEST_DB_URL);
orientDBClient... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status update(String table, String key, Map<String, ByteIterator> values) {
String documentLink = getDocumentLink(this.databaseName, table, key);
Document document = getDocumentDefinition(key, values);
RequestOptions reqOptions = getRequest... | #fixed code
@Override
public Status update(String table, String key, Map<String, ByteIterator> values) {
// Azure Cosmos does not have patch support. Until then we need to read
// the document, update in place, and then write back.
// This could actually be made more efficie... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
this.currentTable = this.connection.getTable(tName);
// suggestions from
// http://ryantwopointoh.blogspot.com/2009/01/
// performance-of-hbase-i... | #fixed code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
synchronized (CONNECTION_LOCK) {
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean doTransaction(DB db, Object threadstate) {
switch (operationchooser.nextString()) {
case "READ":
doTransactionRead(db);
break;
case "UPDATE":
doTransactionUpdate(db);
break;
case "INSERT":
doTransact... | #fixed code
@Override
public boolean doTransaction(DB db, Object threadstate) {
String operation = operationchooser.nextString();
if(operation == null) {
return false;
}
switch (operation) {
case "READ":
doTransactionRead(db);
break;
case "UPDAT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public int insert(String table, String key,
HashMap<String, ByteIterator> values) {
try {
MongoCollection<Document> collection = database
.getCollection(table);
Document toInsert = new Documen... | #fixed code
@Override
public int insert(String table, String key,
HashMap<String, ByteIterator> values) {
try {
MongoCollection<Document> collection = database
.getCollection(table);
Document toInsert = new Document("_id... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
synchronized (CONNECTION_LOCK) {
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p... | #fixed code
public void getHTable(String table) throws IOException {
final TableName tName = TableName.valueOf(table);
this.currentTable = connection.getTable(tName);
if (clientSideBuffering) {
final BufferedMutatorParams p = new BufferedMutatorParams(tName);
p.writ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Status scan(String table, String startkey, int recordcount, Set<String> fields,
Vector<HashMap<String, ByteIterator>> result) {
List<Document> documents;
FeedResponse<Document> feedResponse = null;
try {
feedRespon... | #fixed code
@Override
public Status scan(String table, String startkey, int recordcount, Set<String> fields,
Vector<HashMap<String, ByteIterator>> result) {
List<Document> documents;
FeedResponse<Document> feedResponse = null;
try {
FeedOptions feed... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void writeTo( Writer writer, WriterConfig config ) throws IOException {
WritingBuffer buffer = new WritingBuffer( writer, 128 );
write( config == null ? new JsonWriter( buffer ) : config.createWriter( buffer ) );
buffer.flush();
}
... | #fixed code
public void writeTo( Writer writer, WriterConfig config ) throws IOException {
if( writer == null ) {
throw new NullPointerException( "writer is null" );
}
if( config == null ) {
throw new NullPointerException( "config is null" );
}
WritingBuffer... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
final InputReader in = new InputReader(System.in);
V = in.readInt();
final int Q = in.readInt();
adj = new ArrayList[V + 1];
for (int i = 1; i <= V; i++) {
ad... | #fixed code
public static void main(String[] args) throws IOException {
final InputReader in = new InputReader(System.in);
V = in.readInt();
final int Q = in.readInt();
adj = new ArrayList[V + 1];
for (int i = 1; i <= V; i++) {
adj[i] =... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public long query(int end) {
end--;
final int blockIndex = end / sqrt;
final Map<Integer, Integer> map = new HashMap<>();
final int[][] elements = new int[sqrt][2];
int count = 0;
final int endIndex = end % sqrt;
f... | #fixed code
public long query(int end) {
end--;
final int blockIndex = end / sqrt;
final int freq[] = new int[powers.length];
final int queue[] = new int[sqrt];
int count = 0;
final int endIndex = end % sqrt;
for (int i = 0; i <= en... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
final InputReader in = new InputReader(System.in);
int qSZ = 0, uSZ = 0;
V = in.readInt();
int Q = in.readInt();
int E = V - 1;
Query queries[] = new Query[MAX];
... | #fixed code
public static void main(String[] args) throws IOException {
final InputReader in = new InputReader(System.in);
V = in.readInt();
final int Q = in.readInt();
final Query queries[] = new Query[MAX];
final Update updates[] = new Update[MAX... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
@CacheEvict(value={"metaCaches","metaCache"},allEntries=true,beforeInvocation=true)
public void saveMeta(String type, String name, Integer mid) {
if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(name)){
MetaCond metaCond =... | #fixed code
@Override
@CacheEvict(value={"metaCaches","metaCache"},allEntries=true,beforeInvocation=true)
public void saveMeta(String type, String name, Integer mid) {
if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(name)){
MetaCond metaCond = new M... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String indexDataset(Dataset dataset) {
logger.info("indexing dataset " + dataset.getId());
/**
* @todo should we use solrDocIdentifierDataset or
* IndexableObject.IndexableTypes.DATASET.getName() + "_" ?
*/
// Str... | #fixed code
public String indexDataset(Dataset dataset) {
logger.info("indexing dataset " + dataset.getId());
/**
* @todo should we use solrDocIdentifierDataset or
* IndexableObject.IndexableTypes.DATASET.getName() + "_" ?
*/
// String so... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String save() {
Command<Dataverse> cmd = null;
if ( editMode == EditMode.INFO ) {
dataverse.setOwner(ownerId != null ? dataverseService.find(ownerId) : null);
cmd = new CreateDataverseCommand(dataverse, session.getUser());
}... | #fixed code
public String save() {
Command<Dataverse> cmd = null;
//TODO change to Create - for now the page is expecting INFO instead.
if (dataverse.getId() == null){
dataverse.setOwner(ownerId != null ? dataverseService.find(ownerId... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void init() {
if (dataset.getId() != null) { // view mode for a dataset
dataset = datasetService.find(dataset.getId());
editVersion = dataset.getLatestVersion();
editValues = editVersion.getDatasetFieldValues... | #fixed code
public void init() {
if (dataset.getId() != null) { // view mode for a dataset
dataset = datasetService.find(dataset.getId());
editVersion = dataset.getLatestVersion();
editVersion.setDatasetFieldValues(editVersion.initDa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void writeTo(DownloadInstance di, Class<?> clazz, Type type, Annotation[] annotation, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream outstream) throws IOException, WebApplicationException {
if (di.getDownloadI... | #fixed code
@Override
public void writeTo(DownloadInstance di, Class<?> clazz, Type type, Annotation[] annotation, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream outstream) throws IOException, WebApplicationException {
if (di.getDownloadInfo() ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String indexDataset(Dataset dataset) {
logger.info("indexing dataset " + dataset.getId());
Collection<SolrInputDocument> docs = new ArrayList<>();
List<String> dataversePathSegmentsAccumulator = new ArrayList<>();
// List<String> da... | #fixed code
public String indexDataset(Dataset dataset) {
logger.info("indexing dataset " + dataset.getId());
Collection<SolrInputDocument> docs = new ArrayList<>();
List<String> dataversePathSegmentsAccumulator = new ArrayList<>();
List<String> dataverseS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String releaseDraft() {
if (releaseRadio == 1) {
dataset.getEditVersion().setVersionNumber(new Long(dataset.getReleasedVersion().getVersionNumber().intValue() + 1));
dataset.getEditVersion().setMinorVersionNumber(new Long(0));
... | #fixed code
public String releaseDraft() {
if (releaseRadio == 1) {
return releaseDataset(false);
} else {
return releaseDataset(true);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void init() {
if (dataset.getId() != null) { // view mode for a dataset
dataset = datasetService.find(dataset.getId());
editVersion = dataset.getLatestVersion();
editValues = editVersion.getDatasetFieldValues... | #fixed code
public void init() {
if (dataset.getId() != null) { // view mode for a dataset
dataset = datasetService.find(dataset.getId());
editVersion = dataset.getLatestVersion();
editVersion.setDatasetFieldValues(editVersion.initDa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String releaseDraft() {
if (releaseRadio == 1) {
dataset.getEditVersion().setVersionNumber(new Long(dataset.getReleasedVersion().getVersionNumber().intValue() + 1));
dataset.getEditVersion().setMinorVersionNumber(new Long(0));
... | #fixed code
public String releaseDraft() {
if (releaseRadio == 1) {
return releaseDataset(false);
} else {
return releaseDataset(true);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void deleteContainer(String uri, AuthCredentials authCredentials, SwordConfiguration sc) throws SwordError, SwordServerException, SwordAuthException {
// swordConfiguration = (SwordConfigurationImpl) sc;
DataverseUser vdcUser = swordA... | #fixed code
@Override
public void deleteContainer(String uri, AuthCredentials authCredentials, SwordConfiguration sc) throws SwordError, SwordServerException, SwordAuthException {
// swordConfiguration = (SwordConfigurationImpl) sc;
DataverseUser vdcUser = swordAuth.au... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String indexDataset(Dataset dataset) {
logger.info("indexing dataset " + dataset.getId());
Collection<SolrInputDocument> docs = new ArrayList<>();
List<String> dataversePathSegmentsAccumulator = new ArrayList<>();
List<String> data... | #fixed code
public String indexDataset(Dataset dataset) {
logger.info("indexing dataset " + dataset.getId());
String solrIdDraftStudy = "dataset_" + dataset.getId() + "_draft";
String solrIdPublishedStudy = "dataset_" + dataset.getId();
StringBuilder sb = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public synchronized String CalculateMD5 (String datafile) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
Fil... | #fixed code
public synchronized String CalculateMD5 (String datafile) {
FileInputStream fis = null;
try {
fis = new FileInputStream(datafile);
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String save() {
dataset.setOwner(dataverseService.find(ownerId));
//TODO get real application-wide protocol/authority
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("5555");
... | #fixed code
public String save() {
// Validate
boolean dontSave = false;
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
for (DatasetField dsf : editVersion.getFlatDatasetFields()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void init() {
if (dataset.getId() != null) { // view mode for a dataset
dataset = datasetService.find(dataset.getId());
editVersion = dataset.getLatestVersion();
ownerId = dataset.getOwner().getId();
... | #fixed code
public void init() {
if (dataset.getId() != null) { // view mode for a dataset
dataset = datasetService.find(dataset.getId());
editVersion = dataset.getLatestVersion();
ownerId = dataset.getOwner().getId();
e... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void handleDropBoxUpload(ActionEvent e) {
// Read JSON object from the output of the DropBox Chooser:
JsonReader dbJsonReader = Json.createReader(new StringReader(dropBoxSelection));
JsonArray dbArray = dbJsonReader.readArray();
d... | #fixed code
public void handleDropBoxUpload(ActionEvent e) {
// Read JSON object from the output of the DropBox Chooser:
JsonReader dbJsonReader = Json.createReader(new StringReader(dropBoxSelection));
JsonArray dbArray = dbJsonReader.readArray();
dbJsonR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getCitation(boolean isOnlineVersion, DatasetVersion version) {
String str = "";
boolean includeAffiliation = false;
String authors = version.getAuthorsStr(includeAffiliation);
if (!StringUtil.isEmpty(authors)) {
... | #fixed code
public String getCitation(boolean isOnlineVersion, DatasetVersion version) {
return version.getCitation(isOnlineVersion);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public DepositReceipt getEntry(String uri, Map<String, String> map, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordServerException, SwordError, SwordAuthException {
DataverseUser dataverseUser = swordAuth.auth(a... | #fixed code
@Override
public DepositReceipt getEntry(String uri, Map<String, String> map, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordServerException, SwordError, SwordAuthException {
DataverseUser dataverseUser = swordAuth.auth(authCre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String save() {
dataset.setOwner(dataverseService.find(ownerId));
//TODO get real application-wide protocol/authority
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("5555");
/... | #fixed code
public String save() {
dataset.setOwner(dataverseService.find(ownerId));
//TODO get real application-wide protocol/authority
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("5555");
//TODO ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Path("dsPreview/{datasetId}")
@GET
@Produces({ "image/png" })
public InputStream dsPreview(@PathParam("datasetId") Long datasetId, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, Ser... | #fixed code
@Path("dsPreview/{datasetId}")
@GET
@Produces({ "image/png" })
public InputStream dsPreview(@PathParam("datasetId") Long datasetId, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUn... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Statement getStatement(String editUri, Map<String, String> map, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordServerException, SwordError, SwordAuthException {
this.swordConfiguration = (SwordConfigurati... | #fixed code
@Override
public Statement getStatement(String editUri, Map<String, String> map, AuthCredentials authCredentials, SwordConfiguration swordConfiguration) throws SwordServerException, SwordError, SwordAuthException {
this.swordConfiguration = (SwordConfigurationImpl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String save() {
dataset.setOwner(dataverseService.find(ownerId));
//TODO get real application-wide protocol/authority
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("5555");
/... | #fixed code
public String save() {
dataset.setOwner(dataverseService.find(ownerId));
//TODO get real application-wide protocol/authority
dataset.setProtocol("doi");
dataset.setAuthority("10.5072/FK2");
dataset.setIdentifier("5555");
/*
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private DatasetVersion createNewDatasetVersion() {
DatasetVersion dsv = new DatasetVersion();
dsv.setVersionState(DatasetVersion.VersionState.DRAFT);
DatasetVersion latestVersion = getLatestVersion();
//if the latest version has values g... | #fixed code
private DatasetVersion createNewDatasetVersion() {
DatasetVersion dsv = new DatasetVersion();
dsv.setVersionState(DatasetVersion.VersionState.DRAFT);
DatasetVersion latestVersion = getLatestVersion();
//if the latest version has values get the... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
DepositReceipt replaceOrAddFiles(String uri, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration, boolean shouldReplace) throws SwordError, SwordAuthException, SwordServerException {
DataverseUser vdcUser = swordAuth.auth(auth... | #fixed code
DepositReceipt replaceOrAddFiles(String uri, Deposit deposit, AuthCredentials authCredentials, SwordConfiguration swordConfiguration, boolean shouldReplace) throws SwordError, SwordAuthException, SwordServerException {
DataverseUser vdcUser = swordAuth.auth(authCreden... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public synchronized String CalculateMD5 (String datafile) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
Fil... | #fixed code
public synchronized String CalculateMD5 (String datafile) {
FileInputStream fis = null;
try {
fis = new FileInputStream(datafile);
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public DataModel getDatasetFieldsDataModel() {
List values = new ArrayList();
int i = 0;
for (DatasetFieldValue dsfv : dataset.getEditVersion().getDatasetFieldValues()){
DatasetField datasetField = dsfv.getDatasetField(); ... | #fixed code
public DataModel getDatasetFieldsDataModel() {
List values = new ArrayList();
int i = 0;
for (DatasetFieldValue dsfv : editVersion.getDatasetFieldValues()){
DatasetField datasetField = dsfv.getDatasetField();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithLoops() throws Exception {
URI resource = getClass().getResource("/yaml/loops/simple_loop.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<SlangSource> path = Sets.newHa... | #fixed code
@Test
public void testFlowWithLoops() throws Exception {
URI resource = getClass().getResource("/yaml/loops/simple_loop.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<SlangSource> path = Sets.newHashSet(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ReturnValues getExecutionReturnValues(){
if(StringUtils.isEmpty(result)){
throw new RuntimeException("Result of executing the test " + testCaseName + " cannot be empty");
}
if (outputs == null){
outputs = new HashMa... | #fixed code
public ReturnValues getExecutionReturnValues(){
// if(StringUtils.isEmpty(result)){
// throw new RuntimeException("Result of executing the test " + testCaseName + " cannot be empty");
// }
return new ReturnValues(outputs, result);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidStatementAndTrim() throws Exception {
ForLoopStatement statement = transformer.transform(" min in collection ");
Assert.assertEquals(ForLoopStatement.Type.LIST, statement.getType());
Assert.assertEquals("min", s... | #fixed code
@Test
public void testValidStatementAndTrim() throws Exception {
ForLoopStatement statement = transformer.transform(" min in collection ");
ListForLoopStatement listForLoopStatement = validateListForLoopStatement(statement);
Assert.assertEqual... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidMapStatement() throws Exception {
ForLoopStatement statement = transformer.transform("k, v in collection");
Assert.assertEquals(ForLoopStatement.Type.MAP, statement.getType());
Assert.assertEquals("k v", statement.g... | #fixed code
@Test
public void testValidMapStatement() throws Exception {
ForLoopStatement statement = transformer.transform("k, v in collection");
MapForLoopStatement mapForLoopStatement = validateMapForLoopStatement(statement);
Assert.assertEquals("k", mapFo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidStatement() throws Exception {
ForLoopStatement statement = transformer.transform("x in collection");
Assert.assertEquals(ForLoopStatement.Type.LIST, statement.getType());
Assert.assertEquals("x", statement.getVarNa... | #fixed code
@Test
public void testValidStatement() throws Exception {
ForLoopStatement statement = transformer.transform("x in collection");
ListForLoopStatement listForLoopStatement = validateListForLoopStatement(statement);
Assert.assertEquals("x", listForL... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
String repositoryPath = System.getProperty("path");
String testsPath = System.getProperty("testPath");
String testSuitsArg = System.getProperty("testSuits");
Validate.notNull(repositoryPath, "You m... | #fixed code
public static void main(String[] args) {
String repositoryPath = System.getProperty("path");
String testsPath = System.getProperty("testPath");
String testSuitsArg = System.getProperty("testSuits");
Validate.notNull(repositoryPath, "You must pa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<RuntimeException> validateModelWithDependencies(
Executable executable,
Map<String, Executable> dependencies,
Set<Executable> verifiedExecutables,
List<RuntimeException> errors) {
//validate that all r... | #fixed code
private List<RuntimeException> validateModelWithDependencies(
Executable executable,
Map<String, Executable> dependencies,
Set<Executable> verifiedExecutables,
List<RuntimeException> errors) {
//validate that all require... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<Value> bindAsyncLoopList(
AsyncLoopStatement asyncLoopStatement,
Context flowContext,
Set<SystemProperty> systemProperties,
String nodeName) {
Validate.notNull(asyncLoopStatement, "async loop statement ... | #fixed code
public List<Value> bindAsyncLoopList(
AsyncLoopStatement asyncLoopStatement,
Context flowContext,
Set<SystemProperty> systemProperties,
String nodeName) {
Validate.notNull(asyncLoopStatement, "async loop statement cannot... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValues() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI();
URI operation1 = getClass().getResource("/yaml/formats/values_op.sl").toURI();
URI operation2 ... | #fixed code
@Test
public void testValues() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI();
URI operation1 = getClass().getResource("/yaml/formats/values_op.sl").toURI();
URI operation2 = getC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMultipleInsAreTrimmed() throws Exception {
ForLoopStatement statement = transformer.transform(" in in in ");
Assert.assertEquals("in", statement.getVarName());
Assert.assertEquals("in", statement.getCollectionExpressio... | #fixed code
@Test
public void testMultipleInsAreTrimmed() throws Exception {
ForLoopStatement statement = transformer.transform(" in in in ");
ListForLoopStatement listForLoopStatement = validateListForLoopStatement(statement);
Assert.assertEquals("in", lis... | 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.