output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
@Test
public void findWhere() {
class Book {
public final String title;
public final String author;
public final Integer year;
public Book(final String title, final String author, final Integer year) {
... | #vulnerable code
@Test
public void findWhere() {
class Book {
public final String title;
public final String author;
public final Integer year;
public Book(final String title, final String author, final Integer year) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void singleOrNull() {
U<Integer> uWithMoreElement = new U<>(asList(1, 2, 3));
U<Integer> uWithOneElement = new U<>(singletonList(1));
final Integer result1 = U.singleOrNull(asList(1, 2, 3));
assertNull(result1);
final int r... | #vulnerable code
@Test
public void singleOrNull() {
U<Integer> uWithMoreElement = new U<>(asList(1, 2, 3));
U<Integer> uWithOneElement = new U<>(asList(1));
final Integer result1 = U.singleOrNull(asList(1, 2, 3));
assertNull(result1);
final int re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <E, F extends Number> Double average(final Iterable<E> iterable, final Function<E, F> func) {
F sum = sum(iterable, func);
if (sum == null) {
return null;
}
return sum.doubleValue() / size(iterable);
} | #vulnerable code
public static <E, F extends Number> Double average(final Iterable<E> iterable, final Function<E, F> func) {
F sum = sum(iterable, func);
return sum.doubleValue() / size(iterable);
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void firstOrNull() {
final Integer result = $.firstOrNull(asList(5, 4, 3, 2, 1));
assertEquals("5", result.toString());
final Integer resultObj = new $<Integer>(asList(5, 4, 3, 2, 1)).firstOrNull();
assertEquals("5", resultObj.... | #vulnerable code
@Test
public void firstOrNull() {
final Integer result = $.firstOrNull(asList(5, 4, 3, 2, 1));
assertEquals("5", result.toString());
final Integer resultObj = new $<Integer>(asList(5, 4, 3, 2, 1)).firstOrNull();
assertEquals("5", resu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T extends Number> double mean(final Iterable<T> iterable) {
T result = null;
int count = 0;
for (final T item : iterable) {
result = add(result, item);
count += 1;
}
if (result == null) {
... | #vulnerable code
public static <T extends Number> double mean(final Iterable<T> iterable) {
T result = null;
int count = 0;
for (final T item : iterable) {
result = add(result, item);
count += 1;
}
return result.doubleValue... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void detect() {
final Optional<Integer> result = _.detect(asList(1, 2, 3, 4, 5, 6),
new Predicate<Integer>() {
public Boolean apply(Integer item) {
return item % 2 == 0;
}
});
assertE... | #vulnerable code
@Test
public void detect() {
final Integer result = _.detect(asList(1, 2, 3, 4, 5, 6),
new Predicate<Integer>() {
public Boolean apply(Integer item) {
return item % 2 == 0;
}
});
assertEqua... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadingLocalTime() throws Exception {
Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalTime.now());
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
//noinspection Duplicates
try (Sq... | #vulnerable code
@Test
public void testLoadingLocalTime() throws Exception {
Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalTime.now());
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
//noinspection Duplicates
t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
this.sql... | #vulnerable code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBatchUpdatePersistentVertices() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b");
this.sqlgGraph.tx().commit();
assertEqual... | #vulnerable code
@Test
public void testBatchUpdatePersistentVertices() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b");
this.sqlgGraph.tx().commit();
asser... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBatchUpdatePersistentVerticesAllTypes() {
Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues());
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this.sqlgG... | #vulnerable code
@Test
public void testBatchUpdatePersistentVerticesAllTypes() {
Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues());
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadVertexProperties() {
Vertex marko = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko");
this.sqlgGraph.tx().commit();
marko = this.sqlgGraph.traversal().V(marko.id()).next();
Assert.assertEquals("marko", ... | #vulnerable code
@Test
public void testLoadVertexProperties() {
Vertex marko = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko");
this.sqlgGraph.tx().commit();
marko = this.sqlgGraph.v(marko.id());
Assert.assertEquals("marko", marko.propert... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
this.sqlgGr... | #vulnerable code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
this.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void loadResultSet(ResultSet resultSet, List<VertexLabel> inForeignKeys, List<VertexLabel> outForeignKeys) throws SQLException {
SchemaTable inVertexColumnName = null;
SchemaTable outVertexColumnName = null;
ResultSetMetaData resultSetMetaData ... | #vulnerable code
private void loadResultSet(ResultSet resultSet, List<VertexLabel> inForeignKeys, List<VertexLabel> outForeignKeys) throws SQLException {
SchemaTable inVertexColumnName = null;
SchemaTable outVertexColumnName = null;
ResultSetMetaData resultSetMet... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBatchUpdatePersistentVertices() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b");
this.sqlgGraph.tx().commit();
assertEqual... | #vulnerable code
@Test
public void testBatchUpdatePersistentVertices() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b");
this.sqlgGraph.tx().commit();
asser... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
this.sqlgGr... | #vulnerable code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
this.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testMultipleReferencesToSameVertex2Instances() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
this.sqlgGraph.tx().commit();
//_v1 is in the transaction cache
//v1 is not
Vertex _v1 = thi... | #vulnerable code
@Test
public void testMultipleReferencesToSameVertex2Instances() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
this.sqlgGraph.tx().commit();
//_v1 is in the transaction cache
//v1 is not
Vertex _v1... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
this.sql... | #vulnerable code
@Test
public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter");
th... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@BeforeClass
public static void beforeClass() throws Exception {
URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
configuration = new PropertiesConfiguration(sqlProperties);
if (!configuration.conta... | #vulnerable code
@BeforeClass
public static void beforeClass() throws ClassNotFoundException, IOException, PropertyVetoException, NamingException, ConfigurationException {
URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadingJson() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsJson());
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode json = new ObjectNode(objectMapper.getNodeFactory());
json.... | #vulnerable code
@Test
public void testLoadingJson() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsJson());
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode json = new ObjectNode(objectMapper.getNodeFactory());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testVertexTransactionalCache2() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person");
Edge e1 = v1.addE... | #vulnerable code
@Test
public void testVertexTransactionalCache2() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person");
Edge e1 = v... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBatchUpdateDifferentPropertiesDifferentRows() {
Vertex sqlgVertex1 = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a1", "property2", "b1", "property3", "c1");
Vertex sqlgVertex2 = this.sqlgGraph.addVertex(T.label, "Person... | #vulnerable code
@Test
public void testBatchUpdateDifferentPropertiesDifferentRows() {
Vertex sqlgVertex1 = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a1", "property2", "b1", "property3", "c1");
Vertex sqlgVertex2 = this.sqlgGraph.addVertex(T.label, "... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadingDatasourceFromJndi() throws Exception {
SqlgGraph g = SqlgGraph.open(configuration);
assertNotNull(g.getSqlDialect());
assertEquals(configuration.getString("jdbc.url"), g.getJdbcUrl());
assertNotNull(g.getConnec... | #vulnerable code
@Test
public void testLoadingDatasourceFromJndi() throws Exception {
SqlgGraph g = SqlgGraph.open(configuration);
assertNotNull(g.getSqlDialect());
assertNotNull(g.getSqlgDataSource().get(configuration.getString("jdbc.url")));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadPropertiesOnUpdate() {
Vertex vertex = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a", "property2", "b");
this.sqlgGraph.tx().commit();
vertex = this.sqlgGraph.traversal().V(vertex.id()).next();
vert... | #vulnerable code
@Test
public void testLoadPropertiesOnUpdate() {
Vertex vertex = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a", "property2", "b");
this.sqlgGraph.tx().commit();
vertex = this.sqlgGraph.v(vertex.id());
vertex.property("... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Map<String, Set<IndexRef>> extractIndices(Connection conn, String catalog, String schema) throws SQLException{
// copied and simplified from the postgres JDBC driver class (PgDatabaseMetaData)
String sql = "SELECT NULL AS TABLE_CAT, n.nspname... | #vulnerable code
@Override
public Map<String, Set<IndexRef>> extractIndices(Connection conn, String catalog, String schema) throws SQLException{
// copied and simplified from the postgres JDBC driver class (PgDatabaseMetaData)
String sql = "SELECT NULL AS TABLE_CAT, n.n... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testMultipleReferencesToSameVertex() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
this.sqlgGraph.tx().commit();
Assert.assertEquals("john", v1.value("name"));
//_v1 is in the transaction cache... | #vulnerable code
@Test
public void testMultipleReferencesToSameVertex() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john");
this.sqlgGraph.tx().commit();
Assert.assertEquals("john", v1.value("name"));
//_v1 is in the transaction... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@BeforeClass
public static void beforeClass() throws Exception {
URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
configuration = new PropertiesConfiguration(sqlProperties);
if (!configuration.conta... | #vulnerable code
@BeforeClass
public static void beforeClass() throws Exception {
URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
configuration = new PropertiesConfiguration(sqlProperties);
if (!configuration... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@BeforeClass
public static void beforeClass() throws Exception {
URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
configuration = new PropertiesConfiguration(sqlProperties);
if (!configuration.conta... | #vulnerable code
@BeforeClass
public static void beforeClass() throws ClassNotFoundException, IOException, PropertyVetoException, NamingException, ConfigurationException {
URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBatchUpdatePersistentVerticesAllTypes() {
Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues());
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this.sqlgG... | #vulnerable code
@Test
public void testBatchUpdatePersistentVerticesAllTypes() {
Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues());
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
Vertex v2 = this... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadingLocalDateTime() throws Exception {
Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalDateTime.now());
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
//noinspection Duplicates
... | #vulnerable code
@Test
public void testLoadingLocalDateTime() throws Exception {
Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalDateTime.now());
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
//noinspection Duplicates
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testVertexTransactionalCache() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person");
v1.addEdge("friend... | #vulnerable code
@Test
public void testVertexTransactionalCache() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person");
v1.addEdge("... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreateEdgeBetweenVertices() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person");
this.sqlgGraph.tx().commit();
person1 = this.sqlgGraph.traversal... | #vulnerable code
@Test
public void testCreateEdgeBetweenVertices() {
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person");
this.sqlgGraph.tx().commit();
person1 = this.sqlgGraph.v(p... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testPropertiesNotBeingCachedOnVertexOut() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "a");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Car", "name", ... | #vulnerable code
@Test
public void testPropertiesNotBeingCachedOnVertexOut() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "a");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Car", "n... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testIdNotLoadedAsProperty() throws Exception {
Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configura... | #vulnerable code
@Test
public void testIdNotLoadedAsProperty() throws Exception {
Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "name", "a");
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(con... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLoadingDatasourceFromJndi() throws Exception {
SqlgGraph g = SqlgGraph.open(configuration);
assertNotNull(g.getSqlDialect());
assertEquals(configuration.getString("jdbc.url"), g.getJdbcUrl());
assertNotNull(g.getConnec... | #vulnerable code
@Test
public void testLoadingDatasourceFromJndi() throws Exception {
SqlgGraph g = SqlgGraph.open(configuration);
assertNotNull(g.getSqlDialect());
assertNotNull(g.getSqlgDataSource().get(configuration.getString("jdbc.url")));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@POST
@Path(value = "test")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> test(@Context Repository repository,
@FormParam(Notifier.JENKINS_BASE) String jenkinsBase,
@FormParam(Notifier.CLONE_TYPE) String cloneType,
@FormParam(Not... | #vulnerable code
@POST
@Path(value = "test")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> test(@Context Repository repository,
@FormParam(Notifier.JENKINS_BASE) String jenkinsBase,
@FormParam(Notifier.CLONE_TYPE) String cloneType,
@FormPar... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws Exception {
try (MongoClient client = new MongoClient(Connection.URI)) {
MongoCollection<Document> eventCollection =
client.getDatabase("test").getCollection("events");
long i = 0;
while (tru... | #vulnerable code
public static void main(String[] args) throws Exception {
MongoCollection<Document> eventCollection =
new MongoClient(
new MongoClientURI("mongodb://localhost:27001,localhost:27002,localhost:27003/test?replicatSet=demo-dev")
).getDatabase("test").getColle... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws Exception {
try (MongoClient client = new MongoClient(Connection.URI)) {
MongoCollection<Document> eventCollection =
client.getDatabase("test").getCollection("events");
ChangeStreamIterable<Document> chang... | #vulnerable code
public static void main(String[] args) throws Exception {
MongoCollection<Document> eventCollection =
new MongoClient(
new MongoClientURI("mongodb://localhost:27001,localhost:27002,localhost:27003/test?replicatSet=demo-dev")
).getD... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void invertLookupTable() {
int nImages = getStackSize();
ip.invertLut();
if (nImages==1)
ip.invert();
else {
ImageStack stack2 = getStack();
for (int i=1; i<=nImages; i++)
stack2.getProcessor(i).invert();
stack2.setColorModel(ip.getColorModel());
}
} | #vulnerable code
void undoFilter() {
if (ip!=null) {
ip.reset();
updateAndDraw();
}
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void setPixels(Object pixels)
{
setImagePlanePixels(this.imageData, getPlanePosition(), pixels);
} | #vulnerable code
@Override
public void setPixels(Object pixels)
{
int[] position = Index.create(0, 0, getPlanePosition());
setImagePlanePixels(this.imageData, position, pixels);
}
#location 4
#vulnerability type NULL_DEREF... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public AttributeBuilder nodeAttributes(String groupId, String artifactId, String version, String scopes, String effectiveScope) {
AbstractNode node = this.scopeStyles.containsKey(effectiveScope) ? this.scopeStyles.get(effectiveScope) : this.defaultNode;
return node.crea... | #vulnerable code
public AttributeBuilder nodeAttributes(String groupId, String artifactId, String version, String scopes, String effectiveScope) {
Map<String, ? extends AbstractNode> scopedNodes = getScopedNodes();
AbstractNode node = scopedNodes.containsKey(effectiveScope) ? scop... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private String downloadNzb(SearchResultEntity result) throws IOException {
Request request = new Request.Builder().url(result.getLink()).build();
Indexer indexerByName = searchModuleProvider.getIndexerByName(result.getIndexer().getName());
Integer time... | #vulnerable code
private String downloadNzb(SearchResultEntity result) throws IOException {
Request request = new Request.Builder().url(result.getLink()).build();
Indexer indexerByName = searchModuleProvider.getIndexerByName(result.getIndexer().getName());
Intege... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@PreDestroy
public void destroy() {
boolean isOsWindows = isOsWindows();
if (isOsWindows) {
logger.debug("Initiating removal of windows tray icon (if it exists)");
try {
WindowsTrayIcon.remove();
} catch ... | #vulnerable code
@PreDestroy
public void destroy() {
String osName = System.getProperty("os.name");
boolean isOsWindows = osName.toLowerCase().contains("windows");
if (isOsWindows) {
logger.debug("Initiating removal of windows tray icon (if it exi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testExecute() throws Exception {
MockWebServer server = getMockWebServer();
HttpUrl url = server.url("/repos/theotherp/nzbhydra2/releases");
//Here the magic happens
File pom = getTestFile("/src/test/resources/org/nzbhydra/github/m... | #vulnerable code
public void testExecute() throws Exception {
MockWebServer server = new MockWebServer();
Release draftReleaseResponse = new Release();
draftReleaseResponse.setUploadUrl(server.url("/repos/theotherp/nzbhydra2/releases/1/assets").toString());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@PostConstruct
private void addTrayIconIfApplicable() {
boolean isOsWindows = isOsWindows();
if (isOsWindows) {
logger.info("Adding windows system tray icon");
try {
new WindowsTrayIcon();
} catch (Headle... | #vulnerable code
@PostConstruct
private void addTrayIconIfApplicable() {
String osName = System.getProperty("os.name");
boolean isOsWindows = osName.toLowerCase().contains("windows");
if (isOsWindows) {
logger.info("Adding windows system tray icon... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldSetEnabledOnDownloadEvent() {
testee.queueCheckEnabled = false;
testee.lastDownload = null;
testee.onNzbDownloadEvent(new FileDownloadEvent(new FileDownloadEntity(), new SearchResultEntity()));
assertThat(testee.qu... | #vulnerable code
@Test
public void shouldSetEnabledOnDownloadEvent() {
testee.queueCheckEnabled = false;
testee.lastDownload = null;
testee.onNzbDownloadEvent(new FileDownloadEvent(null, null));
assertThat(testee.queueCheckEnabled).isTrue();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldMigrate() {
BaseConfig input = new BaseConfig();
input.getMain().setConfigVersion(1);
BaseConfig afterMigration = new BaseConfig();
afterMigration.getMain().setConfigVersion(2);
when(configMigrationStepMock.... | #vulnerable code
@Test
public void shouldMigrate() {
HashMap<String, Object> input = new HashMap<>(ImmutableMap.of("main", new HashMap<>(ImmutableMap.of("configVersion", 1))));
HashMap<String, Object> afterMigration = new HashMap<>(ImmutableMap.of("main", new HashMap... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping(value = {"/api", "/dognzb/api"}, produces = MediaType.TEXT_XML_VALUE)
public ResponseEntity<? extends Object> api(NewznabParameters params, HttpServletRequest request) throws Exception {
if (params.getT() == ActionAttribute.CAPS) {
//t... | #vulnerable code
@RequestMapping(value = {"/api", "/dognzb/api"}, produces = MediaType.TEXT_XML_VALUE)
public ResponseEntity<? extends Object> api(NewznabParameters params, HttpServletRequest request) throws Exception {
if (params.getT() == ActionAttribute.CAPS) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void migrateIndexerApiAccesses(Map<Integer, IndexerEntity> oldIdToIndexersMap) throws SQLException {
Statement statement = connection.createStatement();
int countIndexerApiAccesses = getCount(statement, "INDEXERAPIACCESS");
logger.info("Migrati... | #vulnerable code
private void migrateIndexerApiAccesses(Map<Integer, IndexerEntity> oldIdToIndexersMap) throws SQLException {
Statement statement = connection.createStatement();
int countIndexerApiAccesses = getCount(statement, "INDEXERAPIACCESS");
logger.info("M... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void buildVariablesFor(AbstractBuild build, Map<String, String> variables) {
final Executor executor = build.getExecutor();
if (executor != null && executor.getOwner() instanceof DockerComputer) {
final DockerComputer dockerCom... | #vulnerable code
@Override
public void buildVariablesFor(AbstractBuild build, Map<String, String> variables) {
final Executor executor = build.getExecutor();
if (executor != null && executor.getOwner() instanceof DockerComputer) {
final DockerComputer doc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testAddingVmargsInBeforeContainerCreated() throws IOException, InterruptedException {
// Given
final String vmargs = "-Dhttp.proxyPort=8080";
final DockerComputerJNLPConnector connector = new DockerComputerJNLPConnector(new JNLPLa... | #vulnerable code
@Test
public void testAddingVmargsInBeforeContainerCreated() throws IOException, InterruptedException {
String vmargs = "-Dhttp.proxyPort=8080";
DockerComputerJNLPConnector connector = new DockerComputerJNLPConnector(new JNLPLauncher(null, vmargs));... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testKeepingEvnInBeforeContainerCreated() throws IOException, InterruptedException {
// Given
final String env1 = "ENV1=val1";
final String vmargs = "-Dhttp.proxyPort=8080";
final DockerComputerJNLPConnector connector = new... | #vulnerable code
@Test
public void testKeepingEvnInBeforeContainerCreated() throws IOException, InterruptedException {
String env1 = "ENV1=val1";
DockerComputerJNLPConnector connector = new DockerComputerJNLPConnector(new JNLPLauncher(null, "-Dhttp.proxyPort=8080"))... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void pullImage(DockerTemplate dockerTemplate) throws IOException {
final String imageName = dockerTemplate.getDockerTemplateBase().getImage();
if (shouldPullImage(imageName, dockerTemplate.getPullStrategy())) {
LOGGER.info("Pulling image... | #vulnerable code
private void pullImage(DockerTemplate dockerTemplate) throws IOException {
final String imageName = dockerTemplate.getDockerTemplateBase().getImage();
if (shouldPullImage(imageName, dockerTemplate.getPullStrategy())) {
LOGGER.info("Pulling... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public RpcResponse send(RpcRequest request) throws Exception {
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioSocketChannel.class)
... | #vulnerable code
public RpcResponse send(RpcRequest request) throws Exception {
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDecompressionWithZLIB() throws Exception {
// Build a datagram packet.
DatagramPacket gelfMessage = GELFTestHelper.buildZLIBCompressedDatagramPacket(this.originalMessage);
// Let the decompression take place.
SimpleGE... | #vulnerable code
@Test
public void testDecompressionWithZLIB() throws Exception {
// ZLIB compress message.
byte[] compressMe = this.originalMessage.getBytes();
byte[] compressedMessage = new byte[compressMe.length];
Deflater compressor = new Deflater... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static double heightDegrees(int n) {
if (hashHeightCache[n - 1] == null) {
double a;
if (n % 2 == 0)
a = -1;
else
a = -0.5;
double result = 90 / Math.pow(2, 2.5 * n + a);
hashHeightCache[n - 1] = result;
}
return hashHeightCache[n - 1];
} | #vulnerable code
public static double heightDegrees(int n) {
if (hashHeightCache.get(n) == null) {
double a;
if (n % 2 == 0)
a = -1;
else
a = -0.5;
double result = 90 / Math.pow(2, 2.5 * n + a);
hashHeightCache.put(n, result);
}
return hashHeightCache.get(n);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void add(double lat, double lon, long time, T t, long expiryTime) {
String hash = GeoHash.encodeHash(lat, lon);
// full hash length is 12 so this will insert 12 entries
for (int i = 1; i <= hash.length(); i++) {
long key = Base32.dec... | #vulnerable code
public void add(double lat, double lon, long time, T t, long expiryTime) {
String hash = GeoHash.encodeHash(lat, lon);
for (int i = 1; i <= hash.length(); i++) {
String key = hash.substring(0, i);
if (map.get(key) == null) {
map.put(key, Maps.<Long, T> newTre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDeleteViewIndexSequences() throws Exception {
createBaseTable(tableName, false, null, null);
Connection conn1 = getConnection();
Connection conn2 = getConnection();
String viewName = schemaName + "." + VIEW_NAME;
... | #vulnerable code
@Test
public void testDeleteViewIndexSequences() throws Exception {
createBaseTable(tableName, false, null, null);
Connection conn1 = getConnection();
Connection conn2 = getConnection();
conn1.createStatement().execute("CREATE VIEW " ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static Object[] coerceToNewLength(PDataType baseType, Object[] elements, int maxLength) {
Object[] resizedElements = new Object[elements.length];
for (int i = 0; i < elements.length; i++) {
Integer length = baseType.getMaxLength(elements[i]);
... | #vulnerable code
private static Object[] coerceToNewLength(PDataType baseType, Object[] elements, int maxLength) {
Object[] resizedElements = new Object[elements.length];
for (int i = 0; i < elements.length; i++) {
int length = baseType.getMaxLength(elements[i])... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private PTable doGetTable(byte[] tenantId, byte[] schemaName, byte[] tableName,
long clientTimeStamp, RowLock rowLock, int clientVersion, boolean skipAddingIndexes,
boolean skipAddingParentColumns, PTable lockedAncestorTable) throws IOException, SQLExc... | #vulnerable code
private PTable doGetTable(byte[] tenantId, byte[] schemaName, byte[] tableName,
long clientTimeStamp, RowLock rowLock, int clientVersion, boolean skipAddingIndexes,
boolean skipAddingParentColumns, PTable lockedAncestorTable) throws IOException, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void close() throws SQLException {
if (closed) {
return;
}
synchronized (this) {
if (closed) {
return;
}
closed = true;
SQLException sqlE = null;
... | #vulnerable code
@Override
public void close() throws SQLException {
SQLException sqlE = null;
try {
// Attempt to return any unused sequences.
returnAllSequences(this.sequenceMap);
} catch (SQLException e) {
sqlE = e;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Expression visitLeave(ArrayConstructorNode node, List<Expression> children) throws SQLException {
boolean isChildTypeUnknown = false;
Expression arrayElemChild = null;
PDataType arrayElemDataType = children.get(0).getDataType();
... | #vulnerable code
@Override
public Expression visitLeave(ArrayConstructorNode node, List<Expression> children) throws SQLException {
boolean isChildTypeUnknown = false;
Expression arrayElemChild = null;
PDataType arrayElemDataType = children.get(0).getDataType... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean next(List<Cell> results) throws IOException {
if (indexRowKey != null &&
singleRowRebuildReturnCode == GlobalIndexChecker.RebuildReturnCode.NO_DATA_ROW.getValue()) {
byte[] rowCountBytes =
PL... | #vulnerable code
@Override
public boolean next(List<Cell> results) throws IOException {
if (indexRowKey != null &&
singleRowRebuildReturnCode == GlobalIndexChecker.RebuildReturnCode.NO_DATA_ROW.getValue()) {
byte[] rowCountBytes =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int executeStatements(Reader reader, List<Object> binds, PrintStream out) throws IOException, SQLException {
int bindsOffset = 0;
int nStatements = 0;
PhoenixStatementParser parser = new PhoenixStatementParser(reader);
try {
... | #vulnerable code
public int executeStatements(Reader reader, List<Object> binds, PrintStream out) throws IOException, SQLException {
int bindsOffset = 0;
int nStatements = 0;
PhoenixStatementParser parser = new PhoenixStatementParser(reader);
try {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException,
InterruptedException, TimeoutException {
try (HBaseAdmin admin = new HBaseAdmin(config)) {
if (!allowOnlineTableSchemaUpdate()) {
admin.disableTable(tab... | #vulnerable code
@Override
public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException,
InterruptedException, TimeoutException {
HBaseAdmin admin = new HBaseAdmin(config);
if (!allowOnlineTableSchemaUpdate()) {
admin.di... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSystemCatalogWALEntryFilter() throws Exception {
//now create WAL.Entry objects that refer to cells in those view rows in System.Catalog
Get tenantViewGet = getTenantViewGet(catalogTable, TENANT_BYTES, TENANT_VIEW_NAME);
Get nonTenantViewGe... | #vulnerable code
@Test
public void testSystemCatalogWALEntryFilter() throws Exception {
//now create WAL.Entry objects that refer to cells in those view rows in System.Catalog
Get tenantGet = getGet(catalogTable, TENANT_BYTES, TENANT_VIEW_NAME);
Get nonTenantGet = getGet(c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSelectUpsertWithNewClient() throws Exception {
// Insert data with old client and read with new client
executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
executeQueriesWithCurrentVersion(QUERY);
assert... | #vulnerable code
@Test
public void testSelectUpsertWithNewClient() throws Exception {
checkForPreConditions();
// Insert data with old client and read with new client
executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
executeQueriesWi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testUpsertSelectSameBatchConcurrently() throws Exception {
try (Connection conn = driver.connect(url, props)) {
int numUpsertSelectRunners = 5;
ExecutorService exec = Executors.newFixedThreadPool(numUpsertSelectRunners);
Complet... | #vulnerable code
@Test
public void testUpsertSelectSameBatchConcurrently() throws Exception {
final String dataTable = generateUniqueName();
final String index = "IDX_" + dataTable;
// create the table and ensure its empty
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected static void setupTxManager() throws SQLException, IOException {
TransactionFactory.getTransactionProvider().getTransactionContext().setupTxManager(config, getUrl());
} | #vulnerable code
protected static void setupTxManager() throws SQLException, IOException {
TransactionFactory.getTransactionFactory().getTransactionContext().setupTxManager(config, getUrl());
}
#location 2
#vulnerabil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testUpsertDeleteWithNewClient() throws Exception {
// Insert data with old client and read with new client
executeQueriesWithCurrentVersion(CREATE_ADD);
executeQueryWithClientVersion(compatibleClientVersion, QUERY);
assert... | #vulnerable code
@Test
public void testUpsertDeleteWithNewClient() throws Exception {
checkForPreConditions();
// Insert data with old client and read with new client
executeQueriesWithCurrentVersion(CREATE_ADD);
executeQueryWithClientVersion(compatib... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Expression visitLeave(ArrayConstructorNode node, List<Expression> children) throws SQLException {
boolean isChildTypeUnknown = false;
Expression arrayElemChild = null;
PDataType arrayElemDataType = children.get(0).getDataType();
... | #vulnerable code
@Override
public Expression visitLeave(ArrayConstructorNode node, List<Expression> children) throws SQLException {
boolean isChildTypeUnknown = false;
Expression arrayElemChild = null;
PDataType arrayElemDataType = children.get(0).getDataType... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testIndexRebuildTask() throws Throwable {
String baseTable = generateUniqueName();
String viewName = generateUniqueName();
Connection conn = null;
Connection tenantConn = null;
try {
conn = DriverManage... | #vulnerable code
@Test
public void testIndexRebuildTask() throws Throwable {
String baseTable = generateUniqueName();
Connection conn = null;
Connection viewConn = null;
try {
conn = DriverManager.getConnection(getUrl());
conn.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException,
InterruptedException, TimeoutException {
try (HBaseAdmin admin = new HBaseAdmin(config)) {
if (!allowOnlineTableSchemaUpdate()) {
admin.disableTable(tab... | #vulnerable code
@Override
public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException,
InterruptedException, TimeoutException {
HBaseAdmin admin = new HBaseAdmin(config);
if (!allowOnlineTableSchemaUpdate()) {
admin.di... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void reduce(TableRowkeyPair key, Iterable<ImmutableBytesWritable> values,
Reducer<TableRowkeyPair, ImmutableBytesWritable, TableRowkeyPair, KeyValue>.Context context)
throws IOException, InterruptedException {
... | #vulnerable code
@Override
protected void reduce(TableRowkeyPair key, Iterable<ImmutableBytesWritable> values,
Reducer<TableRowkeyPair, ImmutableBytesWritable, TableRowkeyPair, KeyValue>.Context context)
throws IOException, InterruptedException ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static Object[] coerceToEqualLength(PDataType baseType, Object[] elements) {
if (elements == null || elements.length == 0) {
return elements;
}
int maxLength = 0;
boolean resizeElements = false;
for (int i = 0; i < elements.leng... | #vulnerable code
private static Object[] coerceToEqualLength(PDataType baseType, Object[] elements) {
if (elements == null || elements.length == 0) {
return elements;
}
Object element = elements[0];
int maxLength = baseType.getMaxLength(element);
boolean r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private DeleteType getDeleteTypeOrNull(Collection<? extends Cell> pendingUpdates, int nCFs) {
int nDeleteCF = 0;
int nDeleteVersionCF = 0;
for (Cell kv : pendingUpdates) {
if (kv.getTypeByte() == KeyValue.Type.DeleteFamilyVersion.getCode()) {
... | #vulnerable code
private DeleteType getDeleteTypeOrNull(Collection<? extends Cell> pendingUpdates, int nCFs) {
int nDeleteCF = 0;
int nDeleteVersionCF = 0;
for (Cell kv : pendingUpdates) {
if (kv.getTypeByte() == KeyValue.Type.DeleteFamilyVersion.getCode... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testIndexQos() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = driver.connect(getUrl(), props);
try {
// create the table
createTable(conn, dataTableFullNa... | #vulnerable code
@Test
public void testIndexQos() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = driver.connect(getUrl(), props);
try {
// create the table
conn.createStatement().exe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected RegionScanner doPostScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c, final Scan scan, final RegionScanner s) throws IOException {
RegionCoprocessorEnvironment env = c.getEnvironment();
Region region = env.getRegion();
... | #vulnerable code
@Override
protected RegionScanner doPostScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c, final Scan scan, final RegionScanner s) throws IOException {
RegionCoprocessorEnvironment env = c.getEnvironment();
Region region = env.getRegi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testUpsertDeleteWithOldClient() throws Exception {
// Insert data with old client and read with new client
executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
executeQueriesWithCurrentVersion(QUERY);
assert... | #vulnerable code
@Test
public void testUpsertDeleteWithOldClient() throws Exception {
checkForPreConditions();
// Insert data with old client and read with new client
executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
executeQueriesWi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean isFilterDone() { return false; } | #vulnerable code
@Override
public boolean isFilterDone() { return hasMore; }
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("unchecked")
protected QueryPlan compileJoinQuery(StatementContext context, List<Object> binds, JoinTable joinTable, boolean asSubquery, boolean projectPKColumns, List<OrderByNode> orderBy) throws SQLException {
byte[] emptyByteArray = new byte[0... | #vulnerable code
@SuppressWarnings("unchecked")
protected QueryPlan compileJoinQuery(StatementContext context, List<Object> binds, JoinTable joinTable, boolean asSubquery, boolean projectPKColumns, List<OrderByNode> orderBy) throws SQLException {
byte[] emptyByteArray = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDeleteRowFromTableWithImmutableIndex() throws SQLException {
testDeleteRowFromTableWithImmutableIndex(false);
} | #vulnerable code
@Test
public void testDeleteRowFromTableWithImmutableIndex() throws SQLException {
Connection con = null;
try {
boolean autoCommit = false;
con = DriverManager.getConnection(getUrl());
con.setAutoCommit(autoCommit)... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void writeMetrics() throws Exception {
Connection conn = getConnectionWithoutTracing();
latch = new CountDownLatch(1);
testTraceWriter.start();
// create a simple metrics record
long traceid = 987654;
String d... | #vulnerable code
@Test
public void writeMetrics() throws Exception {
Connection conn = getConnectionWithoutTracing();
String tableName = generateUniqueName();
TraceSpanReceiver traceSpanReceiver = new TraceSpanReceiver();
latch = new CountDownLatch(1... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean next(List<Cell> results) throws IOException {
if (indexRowKey != null &&
singleRowRebuildReturnCode == GlobalIndexChecker.RebuildReturnCode.NO_DATA_ROW.getValue()) {
byte[] rowCountBytes =
PL... | #vulnerable code
@Override
public boolean next(List<Cell> results) throws IOException {
if (indexRowKey != null &&
singleRowRebuildReturnCode == GlobalIndexChecker.RebuildReturnCode.NO_DATA_ROW.getValue()) {
byte[] rowCountBytes =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public byte[] buildRowKey(ValueGetter valueGetter, ImmutableBytesWritable rowKeyPtr, byte[] regionStartKey, byte[] regionEndKey, long ts) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean prependRegionStartKey = isLocalIndex && regionStartK... | #vulnerable code
public byte[] buildRowKey(ValueGetter valueGetter, ImmutableBytesWritable rowKeyPtr, byte[] regionStartKey, byte[] regionEndKey, long ts) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean prependRegionStartKey = isLocalIndex && region... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCSVCommonsUpsert_WithArray() throws Exception {
CSVParser parser = null;
PhoenixConnection conn = null;
try {
// Create table
String statements = "CREATE TABLE IF NOT EXISTS ARRAY_TABLE "
... | #vulnerable code
@Test
public void testCSVCommonsUpsert_WithArray() throws Exception {
CSVParser parser = null;
PhoenixConnection conn = null;
try {
// Create table
String statements = "CREATE TABLE IF NOT EXISTS ARRAY_TABLE "
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private String makeQueryString(JobConf jobConf, String tableName, List<String>
readColumnList, String whereClause, String queryTemplate, String hints, Map<String,
TypeInfo> columnTypeMap) throws IOException {
StringBuilder sql = new StringBuild... | #vulnerable code
private String makeQueryString(JobConf jobConf, String tableName, List<String>
readColumnList, String whereClause, String queryTemplate, String hints, Map<String,
TypeInfo> columnTypeMap) throws IOException {
StringBuilder sql = new Strin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void initTxServiceClient() {
txZKClientService = TransactionFactory.getTransactionProvider().getTransactionContext().setTransactionClient(config, props, connectionInfo);
} | #vulnerable code
private void initTxServiceClient() {
txZKClientService = TransactionFactory.getTransactionFactory().getTransactionContext().setTransactionClient(config, props, connectionInfo);
}
#location 2
#vulnerab... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testUpsertWithOldClient() throws Exception {
// Insert data with old client and read with new client
executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
executeQueriesWithCurrentVersion(QUERY);
assertExpect... | #vulnerable code
@Test
public void testUpsertWithOldClient() throws Exception {
checkForPreConditions();
// Insert data with old client and read with new client
executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
executeQueriesWithCurr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean next(List<Cell> results) throws IOException {
if (indexRowKey != null &&
singleRowRebuildReturnCode == GlobalIndexChecker.RebuildReturnCode.NO_DATA_ROW.getValue()) {
byte[] rowCountBytes =
PL... | #vulnerable code
@Override
public boolean next(List<Cell> results) throws IOException {
if (indexRowKey != null &&
singleRowRebuildReturnCode == GlobalIndexChecker.RebuildReturnCode.NO_DATA_ROW.getValue()) {
byte[] rowCountBytes =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public DataValue getDataForRule(Scenario scenario, Column phxMetaColumn) throws Exception {
// TODO Make a Set of Rules that have already been applied so that so we don't generate for every value
List<Scenario> scenarios = parser.getScenarios();
DataV... | #vulnerable code
public DataValue getDataForRule(Scenario scenario, Column phxMetaColumn) throws Exception {
// TODO Make a Set of Rules that have already been applied so that so we don't generate for every value
List<Scenario> scenarios = parser.getScenarios();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLocalIndexTableRegionSplitPolicyAndSplitKeys() throws Exception {
createBaseTable(DATA_TABLE_NAME, null,"('e','i','o')");
Connection conn1 = DriverManager.getConnection(getUrl());
Connection conn2 = DriverManager.getConnection... | #vulnerable code
@Test
public void testLocalIndexTableRegionSplitPolicyAndSplitKeys() throws Exception {
createBaseTable(DATA_TABLE_NAME, null,"('e','i','o')");
Connection conn1 = DriverManager.getConnection(getUrl());
Connection conn2 = DriverManager.getConn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testUpsertSelectSameBatchConcurrently() throws Exception {
try (Connection conn = driver.connect(url, props)) {
int numUpsertSelectRunners = 5;
ExecutorService exec = Executors.newFixedThreadPool(numUpsertSelectRunners);
Complet... | #vulnerable code
@Test
public void testUpsertSelectSameBatchConcurrently() throws Exception {
final String dataTable = generateUniqueName();
final String index = "IDX_" + dataTable;
// create the table and ensure its empty
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public byte[] buildRowKey(ValueGetter valueGetter, ImmutableBytesWritable rowKeyPtr, byte[] regionStartKey, byte[] regionEndKey, long ts) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean prependRegionStartKey = isLocalIndex && regionStartK... | #vulnerable code
public byte[] buildRowKey(ValueGetter valueGetter, ImmutableBytesWritable rowKeyPtr, byte[] regionStartKey, byte[] regionEndKey, long ts) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean prependRegionStartKey = isLocalIndex && region... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testIndexHalfStoreFileReader() throws Exception {
Connection conn1 = getConnection();
ConnectionQueryServices connectionQueryServices = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES);
HBaseAdmin admin = connection... | #vulnerable code
@Test
public void testIndexHalfStoreFileReader() throws Exception {
Connection conn1 = getConnection();
ConnectionQueryServices connectionQueryServices = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES);
HBaseAdmin admin = conn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean seekOrReseek(Cell cell, boolean isSeek) throws IOException{
Cell keyToSeek = cell;
KeyValue splitKeyValue = new KeyValue.KeyOnlyKeyValue(reader.getSplitkey());
if (reader.isTop()) {
if(this.comparator.compare(cell, splitKeyVa... | #vulnerable code
public boolean seekOrReseek(Cell cell, boolean isSeek) throws IOException{
KeyValue kv = PhoenixKeyValueUtil.maybeCopyCell(cell);
KeyValue keyToSeek = kv;
KeyValue splitKeyValue = KeyValueUtil.createKeyValueFromKey(reader.getSplitkey());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(timeout=300000)
public void testWriteFailureDisablesIndex() throws Exception {
testWriteFailureDisablesIndex(false);
} | #vulnerable code
@Test(timeout=300000)
public void testWriteFailureDisablesIndex() throws Exception {
String query;
ResultSet rs;
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = driver.connect(url, props);
conn.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCSVCommonsUpsert_WithTimestamp() throws Exception {
CSVParser parser = null;
PhoenixConnection conn = null;
try {
// Create table
String statements = "CREATE TABLE IF NOT EXISTS TS_TABLE "
... | #vulnerable code
@Test
public void testCSVCommonsUpsert_WithTimestamp() throws Exception {
CSVParser parser = null;
PhoenixConnection conn = null;
try {
// Create table
String statements = "CREATE TABLE IF NOT EXISTS TS_TABLE "
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLocalIndexTableRegionSplitPolicyAndSplitKeys() throws Exception {
createBaseTable(DATA_TABLE_NAME, null,"('e','i','o')");
Connection conn1 = DriverManager.getConnection(getUrl());
Connection conn2 = DriverManager.getConnection... | #vulnerable code
@Test
public void testLocalIndexTableRegionSplitPolicyAndSplitKeys() throws Exception {
createBaseTable(DATA_TABLE_NAME, null,"('e','i','o')");
Connection conn1 = DriverManager.getConnection(getUrl());
Connection conn2 = DriverManager.getConn... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static long convertToMilliseconds(long serverTimeStamp) {
return serverTimeStamp / TransactionFactory.getTransactionProvider().getTransactionContext().getMaxTransactionsPerSecond();
} | #vulnerable code
public static long convertToMilliseconds(long serverTimeStamp) {
return serverTimeStamp / TransactionFactory.getTransactionFactory().getTransactionContext().getMaxTransactionsPerSecond();
}
#location 2
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSelectUpsertWithOldClient() throws Exception {
// Insert data with new client and read with old client
executeQueriesWithCurrentVersion(CREATE_ADD);
executeQueryWithClientVersion(compatibleClientVersion, QUERY);
assert... | #vulnerable code
@Test
public void testSelectUpsertWithOldClient() throws Exception {
checkForPreConditions();
// Insert data with new client and read with old client
executeQueriesWithCurrentVersion(CREATE_ADD);
executeQueryWithClientVersion(compatib... | 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.