output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
public void run() throws IOException {
LOG.info("Data Deployer Daemon for ring group " + ringGroupName + " starting.");
boolean claimedDataDeployer = false;
try {
ringGroup = coord.getRingGroup(ringGroupName);
// attempt to claim the data deployer title... | #vulnerable code
public void run() throws IOException {
LOG.info("Data Deployer Daemon for ring group " + ringGroupName + " starting.");
boolean claimedDataDeployer = false;
try {
ringGroupConfig = coord.getRingGroup(ringGroupName);
// attempt to claim the data de... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) {
try {
client.getBulk(domainId, keys, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | #vulnerable code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) throws TException {
client.getBulk(domainId, keys, resultHandler);
}
#location 2
#vulnerability type THREA... | Below is the vulnerable code, please generate the patch based on the following information. |
#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(),
... | #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(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) {
try {
client.get(domainId, key, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | #vulnerable code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) throws TException {
client.get(domainId, key, resultHandler);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void addTask(GetTask task) {
try {
// TODO: remove trace
//LOG.trace("Adding task with state " + task.state);
if (task.startNanoTime == null) {
task.startNanoTime = System.nanoTime();
}
getTasks.put(task);
//LOG.trace("Get ... | #vulnerable code
public void addTask(GetTask task) {
synchronized (getTasks) {
task.startNanoTime = System.nanoTime();
getTasks.addLast(task);
}
dispatcherThread.interrupt();
}
#location 6
#vulnerability t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() throws IOException {
hostConfig.setState(HostState.IDLE);
processCommands();
while (!goingDown) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOG.debug("Interrupted in run loop. Exiting.");
brea... | #vulnerable code
public void run() throws IOException {
hostConfig.setState(HostState.IDLE);
if (hostConfig.getCurrentCommand() != null) {
processCurrentCommand(hostConfig, hostConfig.getCurrentCommand());
}
while (!goingDown) {
try {
Thread.sleep(1000... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void commitFiles(File sourceRoot, String destinationRoot) throws IOException {
File[] files = sourceRoot.listFiles();
if (files == null) {
throw new IOException("Failed to commit files from " + sourceRoot + " to " + destinationRoot + " since source is no... | #vulnerable code
protected void commitFiles(File sourceRoot, String destinationRoot) throws IOException {
for (File file : sourceRoot.listFiles()) {
// Skip non files
if (!file.isFile()) {
continue;
}
File targetFile = new File(destinationRoot + "/" + f... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Ring addRing(int ringNum) throws IOException {
try {
Ring rc = ZkRing.create(zk, ringGroupPath, ringNum, this,
isUpdating() ? getUpdatingToVersion() : getCurrentVersion());
ringsByNumber.put(rc.getRingNumber(), rc);
return rc;
... | #vulnerable code
@Override
public Ring addRing(int ringNum) throws IOException {
try {
Ring rc = ZkRing.create(zk, ringGroupPath, ringNum, this, isUpdating() ? getUpdatingToVersion() : getCurrentVersion());
ringsByNumber.put(rc.getRingNumber(), rc);
return rc;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static DomainGroupVersion createNewFastForwardVersion(DomainGroup domainGroup) throws IOException {
Map<Domain, Integer> domainNameToVersion = new HashMap<Domain, Integer>();
// find the latest domain group version
DomainGroupVersion dgv = DomainGroups.getLa... | #vulnerable code
public static DomainGroupVersion createNewFastForwardVersion(DomainGroup domainGroup) throws IOException {
Map<Domain, Integer> domainNameToVersion = new HashMap<Domain, Integer>();
// find the latest domain group version
DomainGroupVersion dgv = DomainGroups... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) {
try {
client.get(domainId, key, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | #vulnerable code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) throws TException {
client.get(domainId, key, resultHandler);
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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)... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
LOG.info("Sending Monitor email to " + emailTargets.size() + " targets: " + emailTargets + " Email body: " + body);
for (String emailTarget : emailTargets) {
... | #vulnerable code
private void sendEmails(Set<String> emailTargets, String body) throws IOException {
File temporaryEmailBody = File.createTempFile("_tmp_" + getClass().getSimpleName(), null);
BufferedWriter writer = new BufferedWriter(new FileWriter(temporaryEmailBody, false));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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(),
... | #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(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException {
Path source = new Path(getAbsoluteRemotePath(remoteSourceRelativePath));
File destination = new File(localDestinationRoot + "/" + new Path(remoteSo... | #vulnerable code
@Override
public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException {
Path source = new Path(getAbsoluteRemotePath(remoteSourceRelativePath));
File destination = new File(localDestinationRoot + "/" + new Path(re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stop() {
stopping = true;
} | #vulnerable code
public void stop() {
goingDown = true;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
Host getHost() {
return host;
} | #vulnerable code
boolean isAvailable() {
return state != HostConnectionState.STANDBY;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testBlockCompressionSnappy() throws Exception {
doTestBlockCompression(BlockCompressionCodec.SNAPPY, EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_SNAPPY);
} | #vulnerable code
public void testBlockCompressionSnappy() throws Exception {
new File(TMP_TEST_CURLY_READER).mkdirs();
OutputStream s = new FileOutputStream(TMP_TEST_CURLY_READER + "/00000.base.curly");
s.write(EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_SNAPPY);
s.flush();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean isDeletable() throws IOException {
Boolean result;
if (deletable != null) {
result = deletable.get();
} else {
try {
result = WatchedBoolean.get(zk, ZkPath.append(path, DELETABLE_PATH_SEGMENT));
} catch (Exception... | #vulnerable code
@Override
public boolean isDeletable() throws IOException {
if (deletable != null) {
return deletable.get();
} else {
try {
return WatchedBoolean.get(zk, ZkPath.append(path, DELETABLE_PATH_SEGMENT));
} catch (Exception e) {
thro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
Host getHost() {
return host;
} | #vulnerable code
boolean isAvailable() {
return state != HostConnectionState.STANDBY;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait for st... | #vulnerable code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to claim the ... | #vulnerable code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to clai... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | #vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | Below is the vulnerable code, please generate the patch based on the following information. |
#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)... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testBlockCompressionGzip() throws Exception {
doTestBlockCompression(BlockCompressionCodec.GZIP, EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_GZIP);
} | #vulnerable code
public void testBlockCompressionGzip() throws Exception {
new File(TMP_TEST_CURLY_READER).mkdirs();
OutputStream s = new FileOutputStream(TMP_TEST_CURLY_READER + "/00000.base.curly");
s.write(EXPECTED_RECORD_FILE_BLOCK_COMPRESSED_GZIP);
s.flush();
s.cl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ZkRingGroup create(ZooKeeperPlus zk, String path, ZkDomainGroup domainGroup, Coordinator coordinator) throws KeeperException, InterruptedException, IOException {
if (domainGroup.getVersions().isEmpty()) {
throw new IllegalStateException(
"You c... | #vulnerable code
public static ZkRingGroup create(ZooKeeperPlus zk, String path, ZkDomainGroup domainGroup, Coordinator coordinator) throws KeeperException, InterruptedException, IOException {
if (domainGroup.getVersions().isEmpty()) {
throw new IllegalStateException(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void updateComplete() throws IOException {
try {
currentVersionNumber.set(getUpdatingToVersionNumber());
updatingToVersionNumber.set(null);
} catch (Exception e) {
throw new IOException(e);
}
} | #vulnerable code
@Override
public void updateComplete() throws IOException {
try {
if (zk.exists(ringPath + CURRENT_VERSION_PATH_SEGMENT, false) != null) {
zk.setData(ringPath + CURRENT_VERSION_PATH_SEGMENT, getUpdatingToVersionNumber().toString().getBytes(), -1);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void runUpdateCore(DomainVersion currentVersion,
DomainVersion updatingToVersion,
IncrementalUpdatePlan updatePlan,
String updateWorkRoot) throws IOException {
... | #vulnerable code
@Override
protected void runUpdateCore(DomainVersion currentVersion,
DomainVersion updatingToVersion,
IncrementalUpdatePlan updatePlan,
String updateWorkRoot) throws IOException... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait for st... | #vulnerable code
public void run() throws IOException, InterruptedException {
// Add shutdown hook
addShutdownHook();
// Initialize and process commands
setStateSynchronized(HostState.IDLE); // In case of exception, server will stop and state will be coherent.
// Wait ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Flow build(Properties cascasdingProperties,
TapOrTapMap sources) throws IOException {
pipe = new DomainBuilderAssembly(properties.getDomainName(), pipe, keyFieldName, valueFieldName);
// Open new version and check for success
openNewVe... | #vulnerable code
private Flow build(Properties cascasdingProperties,
TapOrTapMap sources) throws IOException {
pipe = new DomainBuilderAssembly(properties.getDomainName(), pipe, keyFieldName, valueFieldName);
// Open new version and check for success
ope... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | #vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to claim the ... | #vulnerable code
public void run() throws IOException {
LOG.info("Ring Group Conductor Daemon for ring group " + ringGroupName + " starting.");
boolean claimedRingGroupConductor = false;
try {
ringGroup = coordinator.getRingGroup(ringGroupName);
// attempt to clai... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void updateComplete() throws IOException {
try {
currentVersionNumber.set(getUpdatingToVersionNumber());
updatingToVersionNumber.set(null);
} catch (Exception e) {
throw new IOException(e);
}
} | #vulnerable code
@Override
public void updateComplete() throws IOException {
try {
if (zk.exists(ringPath + CURRENT_VERSION_PATH_SEGMENT, false) != null) {
zk.setData(ringPath + CURRENT_VERSION_PATH_SEGMENT, getUpdatingToVersionNumber().toString().getBytes(), -1);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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)... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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(),
... | #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(... | Below is the vulnerable code, please generate the patch based on the following information. |
#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)... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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 {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) {
try {
client.getBulk(domainId, keys, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | #vulnerable code
public void getBulk(int domainId, List<ByteBuffer> keys, HostConnectionGetBulkCallback resultHandler) throws TException {
client.getBulk(domainId, keys, resultHandler);
}
#location 2
#vulnerability type THREA... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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()
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | #vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | Below is the vulnerable code, please generate the patch based on the following information. |
#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(... | #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).... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer transform... | #vulnerable code
public void merge(final CueballFilePath base,
final List<CueballFilePath> deltas,
final String newBasePath,
final int keyHashSize,
final int valueSize,
ValueTransformer tra... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void addTask(GetTask task) {
synchronized (getTasks) {
task.startNanoTime = System.nanoTime();
getTasks.addLast(task);
}
//dispatcherThread.interrupt();
} | #vulnerable code
public void addTask(GetTask task) {
synchronized (getTasks) {
task.startNanoTime = System.nanoTime();
getTasks.addLast(task);
}
dispatcherThread.interrupt();
}
#location 6
#vulnerability t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String ... args) throws InterruptedException, ExecutionException, TimeoutException {
RequestHandler handler = request -> {
String reqStr = new String(request.getBody());
return Response.newBuilder()
.... | #vulnerable code
public static void main(String ... args) throws InterruptedException, ExecutionException, TimeoutException {
RpcServer server = createServer();
server.start();
RpcClient client = createClient();
Request request = Request.newBuilder()
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : permission... | #vulnerable code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : perm... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Network getWithDevicesAndDeviceClasses(@NotNull Long networkId, @NotNull HivePrincipal principal) {
if (principal.getUser() != null) {
List<Network> found = networkDAO.getNetworkList(... | #vulnerable code
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Network getWithDevicesAndDeviceClasses(@NotNull Long networkId, @NotNull HivePrincipal principal) {
if (principal.getUser() != null) {
List<Network> found = networkDAO.getNetwor... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : permission... | #vulnerable code
public static void filterActions(AccessKeyAction allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : perm... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
for (String role : allowedRoles) {
if (requestContext.getSecurityContext().isUserInRole(role)) {
return;
}
}
boolean ... | #vulnerable code
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
BeanManager beanManager = CDI.current().getBeanManager();
Context requestScope = beanManager.getContext(RequestScoped.class);
HiveSecurityContext hiveSe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public DeviceNotification deviceSave(DeviceUpdate deviceUpdate,
Set<Equipment> equipmentSet) {
Network network = networkService.createOrVeriryNetwork(deviceUpdate.getNetwork());
DeviceClass deviceClass = deviceClassServ... | #vulnerable code
public DeviceNotification deviceSave(DeviceUpdate deviceUpdate,
Set<Equipment> equipmentSet) {
Network network = networkService.createOrVeriryNetwork(deviceUpdate.getNetwork());
DeviceClass deviceClass = deviceCla... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public OAuthGrant getById(Long grantId) {
OAuthGrant grant = find(grantId);
if( grant != null) {
grant = restoreRefs(grant, null, null);
}
return grant;
} | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void start() {
disruptor.handleEventsWith(eventHandler);
disruptor.start();
RingBuffer<ServerEvent> ringBuffer = disruptor.getRingBuffer();
requestConsumer.startConsumers(ringBuffer);
} | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler handler = request -> {
future.complete(request);
return Response.newBuilder()
... | #vulnerable code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler mockedHandler = request -> {
future.complete(request);
return Response.newBuilder()... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 {
... | #vulnerable code
@Override
public OAuthGrant getByIdAndUser(User user, Long grantId) {
OAuthGrant grant = getById(grantId);
if (grant.getUser().equals(user)) {
return grant;
} else {
return null;
}
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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<>();... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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) {
... | #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) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : pe... | #vulnerable code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermissio... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void userStatusTest() throws Exception {
AccessKey key = new AccessKey();
ADMIN.setStatus(UserStatus.DISABLED);
key.setUser(ADMIN);
HiveSecurityContext hiveSecurityContext = new HiveSecurityContext();
hiveSecurityContex... | #vulnerable code
@Test
public void userStatusTest() throws Exception {
AccessKey key = new AccessKey();
ADMIN.setStatus(UserStatus.DISABLED);
key.setUser(ADMIN);
HiveSecurityContext hiveSecurityContext = new HiveSecurityContext();
hiveSecurity... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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());
... | #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()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermission : pe... | #vulnerable code
public static void filterActions(AllowedKeyAction.Action allowedAction,
Set<AccessKeyPermission> permissions) {
Set<AccessKeyPermission> permissionsToRemove = new HashSet<>();
for (AccessKeyPermission currentPermissio... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler handler = request -> {
future.complete(request);
return Response.newBuilder()
... | #vulnerable code
@Test
public void shouldSendRequestToServer() throws Exception {
CompletableFuture<Request> future = new CompletableFuture<>();
RequestHandler mockedHandler = request -> {
future.complete(request);
return Response.newBuilder()... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
public Device getDevice(UUID deviceId, User currentUser, Device currentDevice) {
Device device = deviceDAO.findByUUIDWithNetworkAndDeviceClass(deviceId);
device.getDeviceClass();//initializing properties
device.getNetwork();
if (device ... | Below is the vulnerable code, please generate the patch based on the following information. |
#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 ... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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()... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
public void close() {
doClose(lbProxyBean, protobufRpcProxyList);
super.close();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#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 =
... | #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 =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
"aLon... | #vulnerable code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
"aLon... | #vulnerable code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
"aLon... | #vulnerable code
@Test
public void testExecuteAndFetchWithNulls(){
String sql =
"create table testExecWithNullsTbl (" +
"id int identity primary key, " +
"text varchar(255), " +
"aNumber int, " +
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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);
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
@Test
public void testSelectUsingNameNotGiven() {
db() //
.select("select score from person where name=:name and name<>:name2") //
.parameter("name", "FRED") //
.parameter("name", "JOSEPH") //
.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Database fromBlocking(@Nonnull ConnectionProvider cp) {
return Database.from(new ConnectionProviderBlockingPool2(cp));
} | #vulnerable code
public static Database fromBlocking(@Nonnull ConnectionProvider cp) {
return Database.from(new ConnectionProviderBlockingPool(cp));
}
#location 2
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#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)... | #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) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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() //
... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testAutoMapToInterfaceWithExplicitColumnNameThatDoesNotExist() {
try (Database db = db()) {
db //
.select("select name, score from person order by name") //
.autoMap(Person4.class) //
... | #vulnerable code
@Test
public void testAutoMapToInterfaceWithExplicitColumnNameThatDoesNotExist() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person4.class) //
.firstOrError() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Database from(String url, int maxPoolSize) {
return Database.from( //
Pools.nonBlocking() //
.url(url) //
.maxPoolSize(maxPoolSize) //
.build());
} | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Database create(int maxSize) {
return Database.from(Pools.nonBlocking().connectionProvider(connectionProvider(nextUrl()))
.maxPoolSize(maxSize).build());
} | #vulnerable code
public static Database create(int maxSize) {
return Database
.from(new NonBlockingConnectionPool(connectionProvider(nextUrl()), maxSize, 1000));
}
#location 3
#vulnerability type RESOU... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #vulnerable code
@Test
public void testUpdateTimeParameter() {
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. |
#fixed code
@Test
public void testConnectionPoolRecylesMany() throws SQLException {
TestScheduler s = new TestScheduler();
AtomicInteger count = new AtomicInteger();
Pool<Integer> pool = NonBlockingPool //
.factory(() -> count.incrementAndGet()... | #vulnerable code
@Test
public void testConnectionPoolRecylesMany() throws SQLException {
TestScheduler s = new TestScheduler();
Database db = DatabaseCreator.create(2, s);
TestSubscriber<Connection> ts = db //
.connection() //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#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),
... | #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),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreate() {
DatabaseCreator.create(1);
} | #vulnerable code
@Test
public void testCreate() {
Database db = DatabaseCreator.create();
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#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) /... | #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) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool pool = Pools //
.nonBlocking() //
.connectionProvider(DatabaseCr... | #vulnerable code
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool2 pool = Pools //
.nonBlocking() //
.connectionProvider(Dat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
@Ignore
public void testCallableApi() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db //
.call("call getPersonCount(?,?)") //
.in() //
.out(Type.INTEGER, Integer.class) //
... | #vulnerable code
@Test
@Ignore
public void testCallableApi() {
Database db = DatabaseCreator.createDerbyWithStoredProcs(1);
db //
.call("call getPersonCount(?,?)") //
.in(0) //
.out(Integer.class) //
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCountsInTransaction() {
try (Database db = db()) {
db.update("update person set score = -3") //
.transacted() //
.counts() //
.doOnNext(System.out::println) //
... | #vulnerable code
@Test
public void testCountsInTransaction() {
db().update("update person set score = -3") //
.transacted() //
.counts() //
.doOnNext(System.out::println) //
.toList() //
.test().... | Below is the vulnerable code, please generate the patch based on the following information. |
#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") //
... | #vulnerable code
@Test
public void testSelectTransactedCount() {
db() //
.select("select name, score, name, score, name, score, name from person where name=?") //
.parameters("FRED") //
.transacted() //
.count()... | Below is the vulnerable code, please generate the patch based on the following information. |
#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... | #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... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSelectTransactedGetAs() {
try (Database db = db()) {
db //
.select("select name from person") //
.transacted() //
.getAs(String.class) //
.test() //
... | #vulnerable code
@Test
public void testSelectTransactedGetAs() {
db() //
.select("select name from person") //
.transacted() //
.getAs(String.class) //
.test() //
.awaitDone(TIMEOUT_SECONDS, Time... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSelectTransacted() {
try (Database db = db()) {
db //
.select("select score from person where name=?") //
.parameters("FRED", "JOSEPH") //
.transacted() //
... | #vulnerable code
@Test
public void testSelectTransacted() {
System.out.println("testSelectTransacted");
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. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.