input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGrou... | #fixed code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGroupName)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private ByteBuffer decompressBlock(ByteBuffer block) throws IOException {
Buffers buffers = threadLocalBuffers.get();
buffers.reset();
// Decompress the block
InputStream blockInputStream =
new ByteArrayInputStream(block.array(), block.arrayOffset(... | #fixed code
private ByteBuffer decompressBlock(ByteBuffer block) throws IOException {
Local local = threadLocal.get();
local.reset();
local.getBlockDecompressor().decompress(
block.array(),
block.arrayOffset() + block.position(),
block.remaining(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGrou... | #fixed code
public void run() throws IOException {
// Add shutdown hook
addShutdownHook();
claimedRingGroupConductor = false;
LOG.info("Ring Group Conductor for ring group " + ringGroupName + " starting.");
try {
ringGroup = coordinator.getRingGroup(ringGroupName)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testGzipBlockCompression() throws Exception {
ByteArrayOutputStream s = new ByteArrayOutputStream();
MapWriter keyfileWriter = new MapWriter();
CurlyWriter writer = new CurlyWriter(s, keyfileWriter, 3, -1, BlockCompressionCodec.GZIP, 1024, 2);
... | #fixed code
public void testGzipBlockCompression() throws Exception {
ByteArrayOutputStream s = new ByteArrayOutputStream();
MapWriter keyfileWriter = new MapWriter();
CurlyWriter writer = new CurlyWriter(s, keyfileWriter, 3, -1, BlockCompressionCodec.GZIP, 1024, 2);
writer... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void aggregate(DoublePopulationStatisticsAggregator other) {
if (numValues == 0) {
// Copy deciles directly
System.arraycopy(other.deciles, 0, deciles, 0, 9);
} else if (other.numValues == 0) {
// Keep this deciles unchanged
} else {
... | #fixed code
public void aggregate(DoublePopulationStatisticsAggregator other) {
if (other.maximum > this.maximum) {
this.maximum = other.maximum;
}
if (other.minimum < this.minimum) {
this.minimum = other.minimum;
}
this.numValues += other.numValues;
thi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) throws TException {
client.getBulk(domainId, keys, resultHandler);
}
#location 2
#vulnerability type THREA... | #fixed code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) {
try {
client.getBulk(domainId, keys, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private boolean isBalanced(Ring ring, Domain domain) throws IOException {
HostDomain maxHostDomain = getMaxHostDomain(ring, domain);
HostDomain minHostDomain = getMinHostDomain(ring, domain);
int maxDistance = Math.abs(maxHostDomain.getPartitions().size()
... | #fixed code
private boolean isBalanced(Ring ring, Domain domain) throws IOException {
HostDomain maxHostDomain = getMaxHostDomain(ring, domain);
HostDomain minHostDomain = getMinHostDomain(ring, domain);
if (maxHostDomain == null || minHostDomain == null) {
// If either m... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | #fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
for (String emailTarget : emailTargets) {
String[] command = {"/bin/mail", "-s", "Hank: " + name, emailTarget};
Process process = Runtime.getRuntime()... | #fixed code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
Session session = Session.getDefaultInstance(emailSessionProperties);
Message message = new MimeMessage(session);
try {
message.setSubject("Hank: " + name... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
String configPath = args[0];
String log4jprops = args[1];
// PartDaemonConfigurator configurator = new YamlConfigurator(configPath);
PropertyConfigurator.configure(log4jprops);
new Daemon(null).... | #fixed code
public static void main(String[] args) throws Exception {
String configPath = args[0];
String log4jprops = args[1];
DataDeployerConfigurator configurator = new YamlDataDeployerConfigurator(configPath);
PropertyConfigurator.configure(log4jprops);
new Daemon(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | #fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void addTask(GetTask task) {
synchronized (getTasks) {
task.startNanoTime = System.nanoTime();
getTasks.addLast(task);
}
dispatcherThread.interrupt();
}
#location 6
#vulnerability t... | #fixed code
public void addTask(GetTask task) {
synchronized (getTasks) {
task.startNanoTime = System.nanoTime();
getTasks.addLast(task);
}
//dispatcherThread.interrupt();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String ... args) throws InterruptedException, ExecutionException, TimeoutException {
RpcServer server = createServer();
server.start();
RpcClient client = createClient();
Request request = Request.newBuilder()
... | #fixed code
public static void main(String ... args) throws InterruptedException, ExecutionException, TimeoutException {
RequestHandler handler = request -> {
String reqStr = new String(request.getBody());
return Response.newBuilder()
.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : perm... | #fixed code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : permission... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Network getWithDevicesAndDeviceClasses(@NotNull Long networkId, @NotNull HivePrincipal principal) {
if (principal.getUser() != null) {
List<Network> found = networkDAO.getNetwor... | #fixed code
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Network getWithDevicesAndDeviceClasses(@NotNull Long networkId, @NotNull HivePrincipal principal) {
if (principal.getUser() != null) {
List<Network> found = networkDAO.getNetworkList(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Action("notification/insert")
@RolesAllowed({HiveRoles.CLIENT, HiveRoles.ADMIN, HiveRoles.DEVICE, HiveRoles.KEY})
@AllowedKeyAction(action = CREATE_DEVICE_NOTIFICATION)
public WebSocketResponse processNotificationInsert(@WsParam(DEVICE_GUID) String deviceGu... | #fixed code
@Action("notification/insert")
@RolesAllowed({HiveRoles.CLIENT, HiveRoles.ADMIN, HiveRoles.DEVICE, HiveRoles.KEY})
@AllowedKeyAction(action = CREATE_DEVICE_NOTIFICATION)
public WebSocketResponse processNotificationInsert(@WsParam(DEVICE_GUID) String deviceGuid,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Action(value = "notification/unsubscribe")
public JsonObject processNotificationUnsubscribe(JsonObject message, Session session) {
logger.debug("notification/unsubscribe action. Session " + session.getId());
Gson gson = GsonFactory.createGson();
... | #fixed code
@Action(value = "notification/unsubscribe")
public JsonObject processNotificationUnsubscribe(JsonObject message, Session session) {
logger.debug("notification/unsubscribe action. Session " + session.getId());
Gson gson = GsonFactory.createGson();
L... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : perm... | #fixed code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : permission... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
BeanManager beanManager = CDI.current().getBeanManager();
Context requestScope = beanManager.getContext(RequestScoped.class);
HiveSecurityContext hiveSe... | #fixed code
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
for (String role : allowedRoles) {
if (requestContext.getSecurityContext().isUserInRole(role)) {
return;
}
}
boolean ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public DeviceNotification deviceSave(DeviceUpdate deviceUpdate,
Set<Equipment> equipmentSet) {
Network network = networkService.createOrVeriryNetwork(deviceUpdate.getNetwork());
DeviceClass deviceClass = deviceCla... | #fixed code
public DeviceNotification deviceSave(DeviceUpdate deviceUpdate,
Set<Equipment> equipmentSet) {
Network network = networkService.createOrVeriryNetwork(deviceUpdate.getNetwork());
DeviceClass deviceClass = deviceClassServ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public OAuthGrant getById(Long grantId) {
OAuthGrant grant = find(grantId);
grant = restoreRefs(grant, null, null);
return grant;
}
#location 4
#vulnerability type NULL_D... | #fixed code
@Override
public OAuthGrant getById(Long grantId) {
OAuthGrant grant = find(grantId);
if( grant != null) {
grant = restoreRefs(grant, null, null);
}
return grant;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Response get(String guid) {
logger.debug("Device get requested. Guid {}", guid);
HivePrincipal principal = (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Device device = deviceService... | #fixed code
@Override
public Response get(String guid) {
logger.debug("Device get requested. Guid {}", guid);
HivePrincipal principal = (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Device device = deviceService.getDe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void start() {
consumerWorkers = new ArrayList<>(consumerThreads);
CountDownLatch startupLatch = new CountDownLatch(consumerThreads);
for (int i = 0; i < consumerThreads; i++) {
KafkaConsumer<String, Request> cons... | #fixed code
@Override
public void start() {
disruptor.handleEventsWith(eventHandler);
disruptor.start();
RingBuffer<ServerEvent> ringBuffer = disruptor.getRingBuffer();
requestConsumer.startConsumers(ringBuffer);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler mockedHandler = request -> {
future.complete(request);
return Response.newBuilder()... | #fixed code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler handler = request -> {
future.complete(request);
return Response.newBuilder()
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public OAuthGrant getByIdAndUser(User user, Long grantId) {
OAuthGrant grant = getById(grantId);
if (grant.getUser().equals(user)) {
return grant;
} else {
return null;
}
}
... | #fixed code
@Override
public OAuthGrant getByIdAndUser(User user, Long grantId) {
OAuthGrant grant = getById(grantId);
if (grant != null && user != null && grant.getUserId() == user.getId()) {
return restoreRefs(grant, user, null);
} else {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void expirationDateTest() {
AccessKey key = new AccessKey();
CLIENT.setStatus(UserStatus.ACTIVE);
key.setUser(CLIENT);
Timestamp inPast = new Timestamp(0);
key.setExpirationDate(inPast);
HiveSecurityContex... | #fixed code
@Test
public void expirationDateTest() {
AccessKey key = new AccessKey();
CLIENT.setStatus(UserStatus.ACTIVE);
key.setUser(CLIENT);
Timestamp inPast = new Timestamp(0);
key.setExpirationDate(inPast);
HiveSecurityContext hive... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Response update(NetworkUpdate networkToUpdate, long id) {
logger.debug("Network update requested. Id : {}", id);
networkService.update(id, NetworkUpdate.convert(networkToUpdate));
logger.debug("Network has been updated succes... | #fixed code
@Override
public Response update(NetworkUpdate networkToUpdate, long id) {
logger.debug("Network update requested. Id : {}", id);
networkService.update(id, networkToUpdate);
logger.debug("Network has been updated successfully. Id : {}", id);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public User getWithNetworksById(long id) {
User user = find(id);
Set<Long> networkIds = userNetworkDao.findNetworksForUser(id);
Set<Network> networks = new HashSet<>();
for (Long networkId : networkIds) {
Networ... | #fixed code
@Override
public User getWithNetworksById(long id) {
User user = find(id);
Set<Long> networkIds = userNetworkDao.findNetworksForUser(id);
if (networkIds == null) {
return user;
}
Set<Network> networks = new HashSet<>();... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<Device> getDeviceList(List<String> guids, HivePrincipal principal) {
List<Device> deviceList = new ArrayList<>();
if (principal == null || principal.getRole().equals(HiveRoles.ADMIN)) {
for (String guid : guids) {
... | #fixed code
@Override
public List<Device> getDeviceList(List<String> guids, HivePrincipal principal) {
List<Device> deviceList = new ArrayList<>();
for (String guid : guids) {
Device device = findByUUID(guid);
if (device != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermissio... | #fixed code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : pe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void userStatusTest() throws Exception {
AccessKey key = new AccessKey();
ADMIN.setStatus(UserStatus.DISABLED);
key.setUser(ADMIN);
HiveSecurityContext hiveSecurityContext = new HiveSecurityContext();
hiveSecurity... | #fixed code
@Test
public void userStatusTest() throws Exception {
AccessKey key = new AccessKey();
ADMIN.setStatus(UserStatus.DISABLED);
key.setUser(ADMIN);
HiveSecurityContext hiveSecurityContext = new HiveSecurityContext();
hiveSecurityContex... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public List<NetworkVO> list(String name, String namePattern, String sortField, boolean sortOrderAsc, Integer take,
Integer skip, Optional<HivePrincipal> principalOptional) {
String sortFunc = sortMap.get(sortField);
... | #fixed code
@Override
public List<NetworkVO> list(String name, String namePattern, String sortField, boolean sortOrderAsc, Integer take,
Integer skip, Optional<HivePrincipal> principalOptional) {
String sortFunc = sortMap.get(sortField);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public AccessKey merge(AccessKey key) {
try {
long userId = key.getUserId();
User user = key.getUser();
Location location = new Location(USER_AND_LABEL_ACCESS_KEY_NS, String.valueOf(userId) + "n" + key.getLabel()... | #fixed code
@Override
public AccessKey merge(AccessKey key) {
try {
long userId = key.getUserId();
User user = key.getUser();
Location location = new Location(USER_AND_LABEL_ACCESS_KEY_NS, String.valueOf(userId) + "n" + key.getLabel());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermissio... | #fixed code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : pe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public User getWithNetworksById(long id) {
User user = find(id);
Set<Long> networkIds = userNetworkDao.findNetworksForUser(id);
if (networkIds == null) {
return user;
}
Set<Network> networks = new HashSe... | #fixed code
@Override
public User getWithNetworksById(long id) {
User user = find(id);
if (user == null) {
return user;
}
Set<Long> networkIds = userNetworkDao.findNetworksForUser(id);
if (networkIds == null) {
return u... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler mockedHandler = request -> {
future.complete(request);
return Response.newBuilder()... | #fixed code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler handler = request -> {
future.complete(request);
return Response.newBuilder()
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Device getDevice(UUID deviceId, User currentUser, Device currentDevice) {
Device device = deviceDAO.findByUUIDWithNetworkAndDeviceClass(deviceId);
device.getDeviceClass();//initializing properties
device.getNetwork();
if (device ... | #fixed code
public Device getDevice(UUID deviceId, User currentUser, Device currentDevice) {
Device device = deviceDAO.findByUUIDWithNetworkAndDeviceClass(deviceId);
if (device == null || !checkPermissions(device, currentUser, currentDevice)) {
throw new Hiv... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
ProtobufRPC protobufPRC = method.getAnnotation(ProtobufRPC.class);
if (protobufPRC == null) {
throw new IllegalAccessError("Target method is not marked annot... | #fixed code
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
ProtobufRPC protobufPRC = method.getAnnotation(ProtobufRPC.class);
if (protobufPRC == null) {
throw new IllegalAccessError("Target method is not marked annotation ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (instance == null) {
throw new NullPointerException("target instance is null may be not initial correct.");
}
Object result = invocation.getMethod()... | #fixed code
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
ProtobufRPC protobufPRC = method.getAnnotation(ProtobufRPC.class);
if (protobufPRC == null) {
throw new IllegalAccess... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public RpcData doHandle(RpcData data) throws Exception {
Object input = null;
Object[] param;
Object ret;
if (data.getData() != null && parseFromMethod != null) {
input = parseFromMethod.invoke(getInputClass(), new By... | #fixed code
public RpcData doHandle(RpcData data) throws Exception {
Object input = null;
Object[] param;
Object ret;
if (data.getData() != null && parseFromMethod != null) {
input = parseFromMethod.invoke(getInputClass(), new ByteArra... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void close() {
doClose(lbProxyBean, protobufRpcProxyList);
super.close();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public void close() {
Collection<List<ProtobufRpcProxy<T>>> values = protobufRpcProxyListMap.values();
for (List<ProtobufRpcProxy<T>> list : values) {
doClose(null, list);
}
Collection<LoadBalanceProxyFactoryBean> lbs = lbMap.value... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected void reInit(final String service, final List<InetSocketAddress> list) throws Exception {
// store old
LoadBalanceProxyFactoryBean oldLbProxyBean = lbMap.get(service);
List<ProtobufRpcProxy<T>> oldProtobufRpcProxyList =
... | #fixed code
@Override
protected void reInit(final String service, final List<InetSocketAddress> list) throws Exception {
// store old
LoadBalanceProxyFactoryBean oldLbProxyBean = lbMap.get(service);
List<ProtobufRpcProxy<T>> oldProtobufRpcProxyList =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void close() {
if (rpcChannel != null) {
rpcChannel.close();
}
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public void close() {
Collection<RpcChannel> rpcChannels = rpcChannelMap.values();
for (RpcChannel rpcChann : rpcChannels) {
try {
rpcChann.close();
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMess... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecuteAndFetch(){
createAndFillUserTable();
Date before = new Date();
List<User> allUsers = sql2o.createQuery("select * from User").executeAndFetch(User.class);
Date after = new Date();
long span = afte... | #fixed code
@Test
public void testExecuteAndFetch(){
createAndFillUserTable();
try (Connection con = sql2o.open()) {
Date before = new Date();
List<User> allUsers = con.createQuery("select * from User").executeAndFetch(User.class);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
... | #fixed code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
"aLon... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Query createQueryWithParams(String queryText, Object... paramValues){
return createQuery(queryText, null)
.withParams(paramValues);
}
#location 3
#vulnerability type RESOURCE_LE... | #fixed code
public Query createQueryWithParams(String queryText, Object... paramValues){
Query query = createQuery(queryText, null);
boolean destroy = true;
try {
query.withParams(paramValues);
destroy = false;
return query;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
... | #fixed code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
"aLon... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
... | #fixed code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
"aLon... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecuteAndFetch(){
createAndFillUserTable();
Date before = new Date();
List<User> allUsers = sql2o.createQuery("select * from User").executeAndFetch(User.class);
Date after = new Date();
long span = afte... | #fixed code
@Test
public void testExecuteAndFetch(){
createAndFillUserTable();
try (Connection con = sql2o.open()) {
Date before = new Date();
List<User> allUsers = con.createQuery("select * from User").executeAndFetch(User.class);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectUsingNameNotGiven() {
db() //
.select("select score from person where name=:name and name<>:name2") //
.parameter("name", "FRED") //
.parameter("name", "JOSEPH") //
.... | #fixed code
@Test
public void testSelectUsingNameNotGiven() {
try (Database db = db()) {
db //
.select("select score from person where name=:name and name<>:name2") //
.parameter("name", "FRED") //
.param... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Database fromBlocking(@Nonnull ConnectionProvider cp) {
return Database.from(new ConnectionProviderBlockingPool(cp));
}
#location 2
#vulnerability type RESOURCE_LEAK | #fixed code
public static Database fromBlocking(@Nonnull ConnectionProvider cp) {
return Database.from(new ConnectionProviderBlockingPool2(cp));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateWithParameter() {
db().update("update person set score=20 where name=?") //
.parameter("FRED").counts() //
.test().awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS) //
.assertValue(1) //
... | #fixed code
@Test
public void testUpdateWithParameter() {
try (Database db = db()) {
db.update("update person set score=20 where name=?") //
.parameter("FRED").counts() //
.test().awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInsertClobAndReadClobAsString() {
Database db = db();
db.update("insert into person_clob(name,document) values(?,?)") //
.parameters("FRED", "some text here") //
.counts() //
.test... | #fixed code
@Test
public void testInsertClobAndReadClobAsString() {
try (Database db = db()) {
db.update("insert into person_clob(name,document) values(?,?)") //
.parameters("FRED", "some text here") //
.counts() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAutoMapToInterfaceWithExplicitColumnNameThatDoesNotExist() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person4.class) //
.firstOrError() //
... | #fixed code
@Test
public void testAutoMapToInterfaceWithExplicitColumnNameThatDoesNotExist() {
try (Database db = db()) {
db //
.select("select name, score from person order by name") //
.autoMap(Person4.class) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Database from(String url, int maxPoolSize) {
return Database.from(new NonBlockingConnectionPool(Util.connectionProvider(url), maxPoolSize, 1000));
}
#location 2
#vulnerability type RESOU... | #fixed code
public static Database from(String url, int maxPoolSize) {
return Database.from( //
Pools.nonBlocking() //
.url(url) //
.maxPoolSize(maxPoolSize) //
.build());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Database create(int maxSize) {
return Database
.from(new NonBlockingConnectionPool(connectionProvider(nextUrl()), maxSize, 1000));
}
#location 3
#vulnerability type RESOU... | #fixed code
public static Database create(int maxSize) {
return Database.from(Pools.nonBlocking().connectionProvider(connectionProvider(nextUrl()))
.maxPoolSize(maxSize).build());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateTimeParameter() {
Database db = db();
Time t = new Time(1234);
db.update("update person set registered=?") //
.parameter(t) //
.counts() //
.test() //
... | #fixed code
@Test
public void testUpdateTimeParameter() {
try (Database db = db()) {
Time t = new Time(1234);
db.update("update person set registered=?") //
.parameter(t) //
.counts() //
.test... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectionPoolRecylesMany() throws SQLException {
TestScheduler s = new TestScheduler();
Database db = DatabaseCreator.create(2, s);
TestSubscriber<Connection> ts = db //
.connection() //
... | #fixed code
@Test
public void testConnectionPoolRecylesMany() throws SQLException {
TestScheduler s = new TestScheduler();
AtomicInteger count = new AtomicInteger();
Pool<Integer> pool = NonBlockingPool //
.factory(() -> count.incrementAndGet()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTuple7() {
db() //
.select("select name, score, name, score, name, score, name from person order by name") //
.getAs(String.class, Integer.class, String.class, Integer.class, String.class,
... | #fixed code
@Test
public void testTuple7() {
try (Database db = db()) {
db //
.select("select name, score, name, score, name, score, name from person order by name") //
.getAs(String.class, Integer.class, String.class, Integ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateTimestampAsZonedDateTime() {
Database db = db();
db.update("update person set registered=? where name='FRED'") //
.parameter(ZonedDateTime.ofInstant(Instant.ofEpochMilli(FRED_REGISTERED_TIME),
... | #fixed code
@Test
public void testUpdateTimestampAsZonedDateTime() {
try (Database db = db()) {
db.update("update person set registered=? where name='FRED'") //
.parameter(ZonedDateTime.ofInstant(Instant.ofEpochMilli(FRED_REGISTERED_TIME),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCreate() {
Database db = DatabaseCreator.create();
}
#location 3
#vulnerability type RESOURCE_LEAK | #fixed code
@Test
public void testCreate() {
DatabaseCreator.create(1);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInsertNullClobAndReadClobAsTuple2() {
Database db = db();
insertNullClob(db);
db.select("select document, document from person_clob where name='FRED'") //
.getAs(String.class, String.class) //
... | #fixed code
@Test
public void testInsertNullClobAndReadClobAsTuple2() {
try (Database db = db()) {
insertNullClob(db);
db.select("select document, document from person_clob where name='FRED'") //
.getAs(String.class, String.class) /... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool2 pool = Pools //
.nonBlocking() //
.connectionProvider(Dat... | #fixed code
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool pool = Pools //
.nonBlocking() //
.connectionProvider(DatabaseCr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Ignore
public void testCallableApi() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db //
.call("call getPersonCount(?,?)") //
.in(0) //
.out(Integer.class) //
... | #fixed code
@Test
@Ignore
public void testCallableApi() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db //
.call("call getPersonCount(?,?)") //
.in() //
.out(Type.INTEGER, Integer.class) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCountsInTransaction() {
db().update("update person set score = -3") //
.transacted() //
.counts() //
.doOnNext(System.out::println) //
.toList() //
.test().... | #fixed code
@Test
public void testCountsInTransaction() {
try (Database db = db()) {
db.update("update person set score = -3") //
.transacted() //
.counts() //
.doOnNext(System.out::println) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransactedCount() {
db() //
.select("select name, score, name, score, name, score, name from person where name=?") //
.parameters("FRED") //
.transacted() //
.count()... | #fixed code
@Test
public void testSelectTransactedCount() {
try (Database db = db()) {
db //
.select("select name, score, name, score, name, score, name from person where name=?") //
.parameters("FRED") //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectAutomappedAnnotatedTransacted() {
db() //
.select(Person10.class) //
.transacted() //
.valuesOnly() //
.get().test() //
.awaitDone(TIMEOUT_SECONDS, Ti... | #fixed code
@Test
public void testSelectAutomappedAnnotatedTransacted() {
try (Database db = db()) {
db //
.select(Person10.class) //
.transacted() //
.valuesOnly() //
.get().test() //... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCallableStatement() {
Database db = DatabaseCreator.createDerby(1);
db.apply(con -> {
try (Statement stmt = con.createStatement()) {
stmt.execute(
"create table app.person (nam... | #fixed code
@Test
public void testCallableStatement() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db.apply(con -> {
try (Statement stmt = con.createStatement()) {
CallableStatement st = con.prepareCall("call getPersonCoun... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransactedGetAs() {
db() //
.select("select name from person") //
.transacted() //
.getAs(String.class) //
.test() //
.awaitDone(TIMEOUT_SECONDS, Time... | #fixed code
@Test
public void testSelectTransactedGetAs() {
try (Database db = db()) {
db //
.select("select name from person") //
.transacted() //
.getAs(String.class) //
.test() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected = QueryAnnotationMissingException.class)
public void testAutoMapWithoutQueryInAnnotation() {
db().select(Person.class);
}
#location 3
#vulnerability type RESOURCE_LEAK | #fixed code
@Test(expected = QueryAnnotationMissingException.class)
public void testAutoMapWithoutQueryInAnnotation() {
try (Database db = db()) {
db.select(Person.class);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransacted() {
System.out.println("testSelectTransacted");
db() //
.select("select score from person where name=?") //
.parameters("FRED", "JOSEPH") //
.transacted() //
... | #fixed code
@Test
public void testSelectTransacted() {
try (Database db = db()) {
db //
.select("select score from person where name=?") //
.parameters("FRED", "JOSEPH") //
.transacted() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateAllWithParameterFourRuns() {
db().update("update person set score=?") //
.parameters(1, 2, 3, 4) //
.counts() //
.test().awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS) //
... | #fixed code
@Test
public void testUpdateAllWithParameterFourRuns() {
try (Database db = db()) {
db.update("update person set score=?") //
.parameters(1, 2, 3, 4) //
.counts() //
.test().awaitDone(TIMEOUT_... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransactedChained() throws Exception {
Database db = db();
db //
.select("select score from person where name=?") //
.parameters("FRED", "JOSEPH") //
.transacted() //
... | #fixed code
@Test
public void testSelectTransactedChained() throws Exception {
try (Database db = db()) {
db //
.select("select score from person where name=?") //
.parameters("FRED", "JOSEPH") //
.transa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAutoMapToInterfaceWithExplicitColumnName() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person3.class) //
.firstOrError() //
.map(Person3::... | #fixed code
@Test
public void testAutoMapToInterfaceWithExplicitColumnName() {
try (Database db = db()) {
db //
.select("select name, score from person order by name") //
.autoMap(Person3.class) //
.first... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransactedTuple4() {
Tx<Tuple4<String, Integer, String, Integer>> t = db() //
.select("select name, score, name, score from person where name=?") //
.parameters("FRED") //
.transacte... | #fixed code
@Test
public void testSelectTransactedTuple4() {
try (Database db = db()) {
Tx<Tuple4<String, Integer, String, Integer>> t = db //
.select("select name, score, name, score from person where name=?") //
.parameter... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectDependsOnCompletable() {
Database db = db();
Completable a = db.update("update person set score=100 where name=?") //
.parameter("FRED") //
.counts().ignoreElements();
db.select("sel... | #fixed code
@Test
public void testSelectDependsOnCompletable() {
try (Database db = db()) {
Completable a = db.update("update person set score=100 where name=?") //
.parameter("FRED") //
.counts().ignoreElements();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFewerColumnsMappedThanAvailable() {
db().select("select name, score from person where name='FRED'") //
.getAs(String.class) //
.test().awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS) //
.asse... | #fixed code
@Test
public void testFewerColumnsMappedThanAvailable() {
try (Database db = db()) {
db.select("select name, score from person where name='FRED'") //
.getAs(String.class) //
.test().awaitDone(TIMEOUT_SECONDS, Tim... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTuple4() {
db() //
.select("select name, score, name, score from person order by name") //
.getAs(String.class, Integer.class, String.class, Integer.class) //
.firstOrError() //
... | #fixed code
@Test
public void testTuple4() {
try (Database db = db()) {
db //
.select("select name, score, name, score from person order by name") //
.getAs(String.class, Integer.class, String.class, Integer.class) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Database test(int maxPoolSize) {
return Database.from(new NonBlockingConnectionPool(testConnectionProvider(), maxPoolSize, 1000));
}
#location 2
#vulnerability type RESOURCE_LEAK | #fixed code
public static Database test(int maxPoolSize) {
return Database.from( //
Pools.nonBlocking() //
.connectionProvider(testConnectionProvider()) //
.maxPoolSize(maxPoolSize) //
.build(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAutoMapToInterfaceWithIndex() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person5.class) //
.firstOrError() //
.map(Person5::examScore) //... | #fixed code
@Test
public void testAutoMapToInterfaceWithIndex() {
try (Database db = db()) {
db //
.select("select name, score from person order by name") //
.autoMap(Person5.class) //
.firstOrError() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateWithParameterTwoRuns() {
db().update("update person set score=20 where name=?") //
.parameters("FRED", "JOSEPH").counts() //
.test().awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS) //
.... | #fixed code
@Test
public void testUpdateWithParameterTwoRuns() {
try (Database db = db()) {
db.update("update person set score=20 where name=?") //
.parameters("FRED", "JOSEPH").counts() //
.test().awaitDone(TIMEOUT_SECONDS,... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Ignore
// TODO fix test
public void testMaxIdleTime() throws InterruptedException {
TestScheduler s = new TestScheduler();
AtomicInteger count = new AtomicInteger();
AtomicInteger disposed = new AtomicInteger();
MemberF... | #fixed code
@Test
@Ignore
// TODO fix test
public void testMaxIdleTime() throws InterruptedException {
TestScheduler s = new TestScheduler();
AtomicInteger count = new AtomicInteger();
AtomicInteger disposed = new AtomicInteger();
MemberFactory... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Ignore
public void testCallableApi() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db //
.call("call getPersonCount(?,?)") //
.in() //
.out(Type.INTEGER, Integer.class) //
... | #fixed code
@Test
@Ignore
public void testCallableApi() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db //
.call("call getPersonCount(?,?)") //
.in() //
.out(Type.INTEGER, Integer.class) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectWithFetchSize() {
db().select("select score from person order by name") //
.fetchSize(2) //
.getAs(Integer.class) //
.test() //
.awaitDone(TIMEOUT_SECONDS, TimeUnit.S... | #fixed code
@Test
public void testSelectWithFetchSize() {
try (Database db = db()) {
db.select("select score from person order by name") //
.fetchSize(2) //
.getAs(Integer.class) //
.test() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectAutomappedTransactedValuesOnly() {
db() //
.select("select name, score from person") //
.transacted() //
.valuesOnly() //
.autoMap(Person2.class) //
.... | #fixed code
@Test
public void testSelectAutomappedTransactedValuesOnly() {
try (Database db = db()) {
db //
.select("select name, score from person") //
.transacted() //
.valuesOnly() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool pool = Pools //
.nonBlocking() //
.connectionProvider(Data... | #fixed code
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool2 pool = Pools //
.nonBlocking() //
.connectionProvider(DatabaseC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransactedTuple5() {
Tx<Tuple5<String, Integer, String, Integer, String>> t = db() //
.select("select name, score, name, score, name from person where name=?") //
.parameters("FRED") //
... | #fixed code
@Test
public void testSelectTransactedTuple5() {
try (Database db = db()) {
Tx<Tuple5<String, Integer, String, Integer, String>> t = db //
.select("select name, score, name, score, name from person where name=?") //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateClobWithReader() throws FileNotFoundException {
Database db = db();
Reader reader = new FileReader(new File("src/test/resources/big.txt"));
insertNullClob(db);
db //
.update("update person_c... | #fixed code
@Test
public void testUpdateClobWithReader() throws FileNotFoundException {
try (Database db = db()) {
Reader reader = new FileReader(new File("src/test/resources/big.txt"));
insertNullClob(db);
db //
.update... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateClobWithNull() {
Database db = db();
insertNullClob(db);
db //
.update("update person_clob set document = :doc") //
.parameter("doc", Database.NULL_CLOB) //
.counts()... | #fixed code
@Test
public void testUpdateClobWithNull() {
try (Database db = db()) {
insertNullClob(db);
db //
.update("update person_clob set document = :doc") //
.parameter("doc", Database.NULL_CLOB) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInsertBlobAndReadBlobAsInputStream() {
Database db = db();
byte[] bytes = "some text here".getBytes();
db.update("insert into person_blob(name,document) values(?,?)") //
.parameters("FRED", new ByteArrayI... | #fixed code
@Test
public void testInsertBlobAndReadBlobAsInputStream() {
try (Database db = db()) {
byte[] bytes = "some text here".getBytes();
db.update("insert into person_blob(name,document) values(?,?)") //
.parameters("FRED", n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateWithBatchSize3GreaterThanNumRecords() {
db().update("update person set score=?") //
.batchSize(3) //
.parameters(1, 2, 3, 4) //
.counts() //
.test().awaitDone(TIMEOUT... | #fixed code
@Test
public void testUpdateWithBatchSize3GreaterThanNumRecords() {
try (Database db = db()) {
db.update("update person set score=?") //
.batchSize(3) //
.parameters(1, 2, 3, 4) //
.counts() /... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTuple3() {
db() //
.select("select name, score, name from person order by name") //
.getAs(String.class, Integer.class, String.class) //
.firstOrError() //
.test().awaitDon... | #fixed code
@Test
public void testTuple3() {
try (Database db = db()) {
db //
.select("select name, score, name from person order by name") //
.getAs(String.class, Integer.class, String.class) //
.firstOr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAutoMapToInterfaceWithIndexTooLarge() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person6.class) //
.firstOrError() //
.map(Person6::examS... | #fixed code
@Test
public void testAutoMapToInterfaceWithIndexTooLarge() {
try (Database db = db()) {
db //
.select("select name, score from person order by name") //
.autoMap(Person6.class) //
.firstOrErr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectUsingNamedParameterList() {
db().select("select score from person where name=:name") //
.parameters(Parameter.named("name", "FRED").value("JOSEPH").list()) //
.getAs(Integer.class) //
... | #fixed code
@Test
public void testSelectUsingNamedParameterList() {
try (Database db = db()) {
db.select("select score from person where name=:name") //
.parameters(Parameter.named("name", "FRED").value("JOSEPH").list()) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Database from(@Nonnull String url, int maxPoolSize) {
Preconditions.checkNotNull(url, "url cannot be null");
Preconditions.checkArgument(maxPoolSize > 0, "maxPoolSize must be greater than 0");
return Database.from( //
... | #fixed code
public static Database from(@Nonnull String url, int maxPoolSize) {
Preconditions.checkNotNull(url, "url cannot be null");
Preconditions.checkArgument(maxPoolSize > 0, "maxPoolSize must be greater than 0");
return Database.from( //
Pool... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testUpdateBlobWithNull() {
Database db = db();
insertPersonBlob(db);
db //
.update("update person_blob set document = :doc") //
.parameter("doc", Database.NULL_BLOB) //
.counts... | #fixed code
@Test
public void testUpdateBlobWithNull() {
try (Database db = db()) {
insertPersonBlob(db);
db //
.update("update person_blob set document = :doc") //
.parameter("doc", Database.NULL_BLOB) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testComplete() throws InterruptedException {
Database db = db(1);
Completable a = db //
.update("update person set score=-3 where name='FRED'") //
.complete();
db.update("update person set sco... | #fixed code
@Test
public void testComplete() throws InterruptedException {
try (Database db = db(1)) {
Completable a = db //
.update("update person set score=-3 where name='FRED'") //
.complete();
db.update("upda... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectTransactedTupleN() {
List<Tx<TupleN<Object>>> list = db() //
.select("select name, score from person where name=?") //
.parameters("FRED") //
.transacted() //
.getTup... | #fixed code
@Test
public void testSelectTransactedTupleN() {
try (Database db = db()) {
List<Tx<TupleN<Object>>> list = db //
.select("select name, score from person where name=?") //
.parameters("FRED") //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMoreColumnsMappedThanAvailable() {
db() //
.select("select name, score from person where name='FRED'") //
.getAs(String.class, Integer.class, String.class) //
.test().awaitDone(TIMEOUT_SEC... | #fixed code
@Test
public void testMoreColumnsMappedThanAvailable() {
try (Database db = db()) {
db //
.select("select name, score from person where name='FRED'") //
.getAs(String.class, Integer.class, String.class) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTuple6() {
db() //
.select("select name, score, name, score, name, score from person order by name") //
.getAs(String.class, Integer.class, String.class, Integer.class, String.class,
... | #fixed code
@Test
public void testTuple6() {
try (Database db = db()) {
db //
.select("select name, score, name, score, name, score from person order by name") //
.getAs(String.class, Integer.class, String.class, Integer.cla... | 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.