output stringlengths 79 30.1k | instruction stringclasses 1
value | input stringlengths 216 28.9k |
|---|---|---|
#fixed code
@Test
public void testGarbageCollectorExports() {
assertEquals(
100L,
registry.getSampleValue(
"jvm_gc_collection_seconds_count",
new String[]{"gc"},
new String[]{"MyGC1"}),
.0000001);
assertEquals(
1... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testGarbageCollectorExports() {
assertEquals(
100L,
registry.getSampleValue(
GarbageCollectorExports.COLLECTIONS_COUNT_METRIC,
new String[]{"gc"},
new String[]{"MyGC1"}),
.0000001);
as... |
#fixed code
private static void main(Config config, boolean taq) throws IOException {
NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
InetAddress multicastGroup = Configs.getInetAddress(config, "market... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static void main(Config config, boolean taq) throws IOException {
NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
InetAddress multicastGroup = Configs.getInetAddress(config, "... |
#fixed code
private static void main(Config config, boolean taq) throws IOException {
NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
InetAddress multicastGroup = Configs.getInetAddress(config, "market... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static void main(Config config, boolean taq) throws IOException {
NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
InetAddress multicastGroup = Configs.getInetAddress(config, "... |
#fixed code
public void run() throws IOException {
LineReader reader = LineReaderBuilder.builder()
.completer(new StringsCompleter(Commands.names().castToList()))
.build();
printf("Type 'help' for help.\n");
while (!closed) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void run() throws IOException {
ConsoleReader reader = new ConsoleReader();
reader.addCompleter(new StringsCompleter(Commands.names().castToList()));
printf("Type 'help' for help.\n");
while (!closed) {
String line =... |
#fixed code
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
return loadPlugin(file, false);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
JavaPlugin result = null;
PluginDescriptionFile description = null;
if (!file.exists()) {
throw new InvalidP... |
#fixed code
int shared_cache(boolean enable) throws SQLException
{
// The shared cache is per-process, so it is useless as
// each nested connection is its own process.
return -1;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
int enable_load_extension(boolean enable) throws SQLException
{
return call("sqlite3_enable_load_extension", handle, enable ? 1 : 0);
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
public static String getArchName() {
String osArch = System.getProperty("os.arch");
if(osArch.startsWith("arm")) {
osArch = resolveArmArchType();
}
else {
String lc = osArch.toLowerCase(Locale.US);
if(archMap... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static String getArchName() {
String osArch = System.getProperty("os.arch");
if(osArch.startsWith("arm")) {
// Java 1.8 introduces a system property to determine armel or armhf
if(System.getProperty("sun.arch.abi") != null ... |
#fixed code
public boolean execute(String sql) throws SQLException {
internalClose();
SQLExtension ext = ExtendedCommand.parse(sql);
if (ext != null) {
ext.execute(db);
return false;
}
this.sql = sql;
db.prepare... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public boolean execute(String sql) throws SQLException {
internalClose();
SQLExtension ext = ExtendedCommand.parse(sql);
if (ext != null) {
ext.execute(db);
return false;
}
this.sql = sql;
bool... |
#fixed code
@Test
public void TestEscSlashLast() throws Exception {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc3.json", 0, 44)));
Assert.assertArrayEquals(n... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestEscSlashLast() throws IOException {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc3.json", 0, 44)));
Assert.assertArray... |
#fixed code
@Test
public void TestGeomFirst() throws Exception {
Assert.assertArrayEquals(new int[] { 1 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-geom-first.json", 32, 54)));
Assert.assertArrayEquals(new int[] { 1 }, getRecordIndexesInReader(getReaderFor("unenclosed-jso... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestGeomFirst() throws IOException {
Assert.assertArrayEquals(new int[] { 1 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-geom-first.json", 32, 54)));
Assert.assertArrayEquals(new int[] { 1 }, getRecordIndexesInReader(getReaderFor("unencl... |
#fixed code
@Test
public void TestEscPoints() throws Exception {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc-points.json", 0, 74), true));
Assert.assertArra... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestEscPoints() throws IOException {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc-points.json", 0, 74), true));
Assert.as... |
#fixed code
@Test
public void TestArbitrarySplitLocations() throws Exception {
//int totalSize = 415;
//int [] recordBreaks = new int[] { 0, 40, 80, 120, 160, 200, 240, 280, 320, 372 };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestArbitrarySplitLocations() throws IOException {
//int totalSize = 415;
//int [] recordBreaks = new int[] { 0, 40, 80, 120, 160, 200, 240, 280, 320, 372 };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor... |
#fixed code
@Test
public void TestEscAposLast() throws Exception {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc2.json", 0, 44)));
Assert.assertArrayEquals(ne... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestEscAposLast() throws IOException {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc2.json", 0, 44)));
Assert.assertArrayE... |
#fixed code
@Test
public void TestNullGeom() throws Exception {
ArrayList<Object> stuff = new ArrayList<Object>();
Properties proptab = new Properties();
proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMNS, "shape");
proptab.setProperty(HiveShims.serdeConstants.LIST_COL... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestNullGeom() throws Exception {
Configuration config = new Configuration();
Text value = new Text();
SerDe jserde = new GeoJsonSerDe();
Properties proptab = new Properties();
proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMNS, "shape"... |
#fixed code
@Test
public void TestEscOpenLast() throws Exception {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc5.json", 0, 44)));
Assert.assertArrayEquals(ne... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void TestEscOpenLast() throws IOException {
//int [] recordBreaks = new int[] { 0, 75, 146, 218, 290, 362, , , };
Assert.assertArrayEquals(new int[] { 0 }, getRecordIndexesInReader(getReaderFor("unenclosed-json-esc5.json", 0, 44)));
Assert.assertArrayE... |
#fixed code
public SmsAlphabet getAlphabet()
{
switch (getGroup())
{
case GENERAL_DATA_CODING:
// General Data Coding Indication
if (dcs_ == 0x00)
{
return SmsAlphabet.ASCII;
}
switch... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public SmsAlphabet getAlphabet()
{
switch (getGroup())
{
case GENERAL_DATA_CODING:
// General Data Coding Indication
if (dcs_ == 0x00)
{
return SmsAlphabet.ASCII;
}
... |
#fixed code
void startRebalancingTimer(long period, HelixManager manager) {
if (period != _timerPeriod) {
logger.info("Controller starting timer at period " + period);
if (_rebalanceTimer != null) {
_rebalanceTimer.cancel();
}
_rebalanceTimer = new Timer... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void stopRebalancingTimer() {
if (_rebalanceTimer != null) {
_rebalanceTimer.cancel();
_rebalanceTimer = null;
}
_timerPeriod = Integer.MAX_VALUE;
}
#location 6
#vulnerability type THREAD_... |
#fixed code
public boolean waitForKeeperState(KeeperState keeperState, long time, TimeUnit timeUnit)
throws ZkInterruptedException {
validateCurrentThread();
Date timeout = new Date(System.currentTimeMillis() + timeUnit.toMillis(time));
LOG.debug("Waiting for keeper stat... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public boolean waitForKeeperState(KeeperState keeperState, long time, TimeUnit timeUnit)
throws ZkInterruptedException {
if (_zookeeperEventThread != null && Thread.currentThread() == _zookeeperEventThread) {
throw new IllegalArgumentException("Must not be... |
#fixed code
@Override
public void disconnect()
{
if (!isConnected())
{
logger.error("ClusterManager " + _instanceName + " already disconnected");
return;
}
disconnectInternal();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void disconnect()
{
if (!isConnected())
{
logger.warn("ClusterManager " + _instanceName + " already disconnected");
return;
}
logger.info("disconnect " + _instanceName + "(" + _instanceType + ") from "
+ _clusterN... |
#fixed code
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) {
if (_zkClientForRoutingDataListener == null || _zkClientForRoutingDataListener.isClosed()) {
return;
}
// Resubscribe
_zkClientForRoutingDataListener.unsubscribeAll(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) {
if (_zkClientForListener == null || _zkClientForListener.isClosed()) {
return;
}
// Resubscribe
_zkClientForListener.unsubscribeAll();
_zkClientForListener... |
#fixed code
protected static Set<String> getExpiredJobs(HelixDataAccessor dataAccessor,
HelixPropertyStore propertyStore, WorkflowConfig workflowConfig,
WorkflowContext workflowContext) {
Set<String> expiredJobs = new HashSet<String>();
if (workflowContext != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected static Set<String> getExpiredJobs(HelixDataAccessor dataAccessor,
HelixPropertyStore propertyStore, WorkflowConfig workflowConfig,
WorkflowContext workflowContext) {
Set<String> expiredJobs = new HashSet<String>();
if (workflowContext != nul... |
#fixed code
void addControllerMessageListener(MessageListener listener)
{
addListener(listener, new Builder(_clusterName).controllerMessages(), ChangeType.MESSAGES_CONTROLLER,
new EventType[] { EventType.NodeChildrenChanged, EventType.NodeDeleted, EventType.NodeCreated });
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void disconnectInternal()
{
// This function can be called when the connection are in bad state(e.g. flapping),
// in which isConnected() could be false and we want to disconnect from cluster.
logger.info("disconnect " + _instanceName + "(" + _instanceType ... |
#fixed code
@Override
public void handleNewSession(String sessionId) {
if (_zkClientForRoutingDataListener == null || _zkClientForRoutingDataListener.isClosed()) {
return;
}
// Resubscribe
_zkClientForRoutingDataListener.unsubscribeAll();
_zkClientForRoutingData... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public void handleNewSession(String sessionId) {
if (_zkClientForListener == null || _zkClientForListener.isClosed()) {
return;
}
// Resubscribe
_zkClientForListener.unsubscribeAll();
_zkClientForListener.subscribeRoutingDataChanges(t... |
#fixed code
@Test
public void testConsumerStartWithInterval() {
int msgSize = 100;
String originMsgDCName = RandomUtils.getStringByUUID();
String msgBodyDCName = RandomUtils.getStringByUUID();
RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, t... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testConsumerStartWithInterval() {
String tag = "jueyin";
int msgSize = 100;
String originMsgDCName = RandomUtils.getStringByUUID();
String msgBodyDCName = RandomUtils.getStringByUUID();
RMQNormalConsumer con... |
#fixed code
public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
SendMessageContext context) {
if (hasSendMessageHook()) {
for (SendMessageHook hook : this.sendMessageHook... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
SendMessageContext context) {
if (hasSendMessageHook()) {
for (SendMessageHook hook : this.sendMessa... |
#fixed code
@Test
public void testIPv6Check() throws UnknownHostException {
InetAddress nonInternal = InetAddress.getByName("2408:4004:0180:8100:3FAA:1DDE:2B3F:898A");
InetAddress internal = InetAddress.getByName("FE80:0000:0000:0000:0000:0000:0000:FFFF");
ass... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testIPv6Check() {
byte[] nonInternalIp = UtilAll.string2bytes("24084004018081003FAA1DDE2B3F898A");
byte[] internalIp = UtilAll.string2bytes("FEC0000000000000000000000000FFFF");
assertThat(UtilAll.isInternalV6IP(nonInternalIp... |
#fixed code
public void threadDumpIfNeed(String reasonMsg) {
if (!enable) {
return;
}
synchronized (this) {
if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) {
return;
} else {
lastThreadDumpTime = System.currentTimeMillis();
}
}
logge... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void threadDumpIfNeed(String reasonMsg) {
if (!enable) {
return;
}
synchronized (this) {
if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) {
return;
} else {
lastThreadDumpTime = System.currentTimeMillis();
}
}
... |
#fixed code
private void printCounter(CounterMetric counter) {
output.printf(" last count = %d%n", counter.lastCount);
output.printf(" total count = %d%n", counter.totalCount);
output.printf(" last rate = %d%n", counter.lastRate);
output.printf(" mean ra... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void printCounter(CounterMetric counter) {
output.printf(" last count = %d%n", counter.lastCount);
output.printf(" total count = %d%n", counter.totalCount);
output.printf(" last rate = %2.2f/s%n", counter.lastRate);
output.printf(" ... |
#fixed code
public OutputStream writeBoolean(boolean value) throws IOException {
write(value ? booleanTrue : booleanFalse);
return this;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public OutputStream writeBoolean(boolean value) throws IOException {
write(getIsoBytes(String.valueOf(value)));
return this;
}
#location 2
#vulnerability type NULL_DEREFERENCE |
#fixed code
@Test
public void outlinesTest() throws IOException, PdfException {
PdfReader reader = new PdfReader(new FileInputStream(sourceFolder+"iphone_user_guide.pdf"));
PdfDocument pdfDoc = new PdfDocument(reader);
PdfOutline outlines = pdfDoc.getOutlines... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void outlinesTest() throws IOException, PdfException {
PdfReader reader = new PdfReader(new FileInputStream(sourceFolder+"iphone_user_guide.pdf"));
PdfDocument pdfDoc = new PdfDocument(reader);
PdfOutline outlines = pdfDoc.getCa... |
#fixed code
@Test
public void imageTest05() throws IOException, InterruptedException {
String outFileName = destinationFolder + "imageTest05.pdf";
String cmpFileName = sourceFolder + "cmp_imageTest05.pdf";
FileOutputStream file = new FileOutputStream(outFile... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void imageTest05() throws IOException, InterruptedException {
String outFileName = destinationFolder + "imageTest05.pdf";
String cmpFileName = sourceFolder + "cmp_imageTest05.pdf";
FileOutputStream file = new FileOutputStream(o... |
#fixed code
@Override
public LayoutResult layout(LayoutContext layoutContext) {
LayoutArea area = layoutContext.getArea();
Rectangle layoutBox = area.getBBox();
occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public LayoutResult layout(LayoutContext layoutContext) {
LayoutArea area = layoutContext.getArea();
Rectangle layoutBox = area.getBBox();
occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox... |
#fixed code
protected int writeXRefTable() throws IOException, PdfException {
int strtxref = currentPos;
if (fullCompression) {
PdfStream stream = new PdfStream(pdfDocument);
stream.put(PdfName.Type, PdfName.XRef);
stream.put(PdfName.Si... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected int writeXRefTable() throws IOException, PdfException {
int strtxref = currentPos;
if (fullCompression) {
PdfStream stream = new PdfStream(pdfDocument);
stream.put(PdfName.Type, PdfName.XRef);
stream.put(PdfN... |
#fixed code
@Test
public void imageTest04() throws IOException, InterruptedException {
String outFileName = destinationFolder + "imageTest04.pdf";
String cmpFileName = sourceFolder + "cmp_imageTest04.pdf";
FileOutputStream file = new FileOutputStream(outFile... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void imageTest04() throws IOException, InterruptedException {
String outFileName = destinationFolder + "imageTest04.pdf";
String cmpFileName = sourceFolder + "cmp_imageTest04.pdf";
FileOutputStream file = new FileOutputStream(o... |
#fixed code
public OutputStream writeInteger(int value) throws IOException {
writeInteger(value, 8);
return this;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public OutputStream writeInteger(int value) throws IOException {
write(getIsoBytes(String.valueOf(value)));
return this;
}
#location 2
#vulnerability type NULL_DEREFERENCE |
#fixed code
public static NSObject parse(File f) throws Exception {
FileInputStream fis = new FileInputStream(f);
return parse(fis);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static NSObject parse(File f) throws Exception {
FileInputStream fis = new FileInputStream(f);
byte[] magic = new byte[8];
fis.read(magic);
String magic_string = new String(magic);
fis.close();
if (magic_string.star... |
#fixed code
public void runTagger() throws IOException, ClassNotFoundException {
tagger = new Tagger();
if (!justTokenize) {
tagger.loadModel(modelFilename);
}
if (inputFormat.equals("conll")) {
runTaggerInEvalMode();
return;
}
assert (inputFormat.equals("json... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void runTagger() throws IOException, ClassNotFoundException {
tagger = new Tagger();
if (!justTokenize) {
tagger.loadModel(modelFilename);
}
if (inputFormat.equals("conll")) {
runTaggerInEvalMode();
return;
}
assert (inputFormat.equals... |
#fixed code
public static ArrayList<Sentence> readFile(String filename) throws IOException {
BufferedReader reader = BasicFileIO.openFileToReadUTF8(filename);
ArrayList sentences = new ArrayList<String>();
ArrayList<String> curLines = new ArrayList<String>();
String line;
while (... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static ArrayList<Sentence> readFile(String filename) throws IOException {
BufferedReader reader = BasicFileIO.openFileToRead(filename);
ArrayList sentences = new ArrayList<String>();
ArrayList<String> curLines = new ArrayList<String>();
String line;
while... |
#fixed code
public void cacheInterceptor(String cacheName, Long timeToLive, List<String> headers, List<String> queryParams) {
RedissonClient redisson = (RedissonClient) BeanManager.getBean(RedissonClient.class);
RequestContext context = RequestContext.getCurrentContext(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void cacheInterceptor(String cacheName, Long timeToLive, List<String> headers, List<String> queryParams) {
Helper helper = new HelperImpl();
RedissonClient redisson = (RedissonClient) BeanManager.getBean(RedissonClient.class);
RequestCo... |
#fixed code
private void load() throws IOException
{
if ( !knownHosts.exists() )
{
return;
}
assertKnownHostFileReadable();
try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) )
{
S... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void load() throws IOException
{
if ( !knownHosts.exists() )
{
return;
}
assertKnownHostFileReadable();
BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) );
String line;
... |
#fixed code
@Test
void shouldSaveNewCert() throws Throwable
{
// Given
int newPort = 200;
BoltServerAddress address = new BoltServerAddress( knownServerIp, newPort );
Logger logger = mock(Logger.class);
TrustOnFirstUseTrustManager manager =... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
void shouldSaveNewCert() throws Throwable
{
// Given
int newPort = 200;
BoltServerAddress address = new BoltServerAddress( knownServerIp, newPort );
Logger logger = mock(Logger.class);
TrustOnFirstUseTrustManager man... |
#fixed code
@SuppressWarnings( "ConstantConditions" )
@Test
public void shouldHandleNullAuthToken() throws Throwable
{
// Given
AuthToken token = null;
try ( Driver driver = GraphDatabase.driver( neo4j.address(), token ) )
{
Session... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@SuppressWarnings( "ConstantConditions" )
@Test
public void shouldHandleNullAuthToken() throws Throwable
{
// Given
AuthToken token = null;
Driver driver = GraphDatabase.driver( neo4j.address(), token);
Session session = drive... |
#fixed code
public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException
{
try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) )
{
CertificateFactory certFac... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException
{
BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) );
CertificateFactory certFactory = Certific... |
#fixed code
@Test
void shouldNotSendWriteAccessModeInStatementMetadata() throws Exception
{
StubServer server = StubServer.start( "hello_run_exit.script", 9001 );
try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG );
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
void shouldNotSendWriteAccessModeInStatementMetadata() throws Exception
{
StubServer server = StubServer.start( "hello_run_exit.script", 9001 );
Config config = Config.builder()
.withoutEncryption()
.build()... |
#fixed code
public static String read(File file) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
String ret = new String(new byte[0], "UTF-8");
String line;
while ((line = in.readLine()) != null) {
ret +=... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static String read(File file) throws IOException {
// BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
InputStream inStream = new FileInputStream(file);
BufferedReader in = new BufferedReader(inputStreamToReader... |
#fixed code
void findTarget(final String patFilename, final Location initOffset) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Region screenUnion = Region.create(0, 0, 1, 1);
Finder f = new Finder(_simg, screenUnion);
try {
f.find(p... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void paintLoading(Graphics2D g2d) {
int w = getWidth(), h = getHeight();
g2d.setColor(new Color(0, 0, 0, 200));
g2d.fillRect(0, 0, w, h);
BufferedImage spinner = _loading.getFrame();
g2d.drawImage(spinner, null, w / 2 - spinner.getWidth() / 2, h / 2 - spinner.get... |
#fixed code
public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed {
lastMatches = null;
Image img = null;
String targetStr = target.toString();
if (target instanceof String) {
targetStr = targetStr.trim();
}
while (true) {
try {
if (... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed {
lastMatches = null;
Image img = null;
String targetStr = target.toString();
if (target instanceof String) {
targetStr = targetStr.trim();
}
while (true) {
try {
... |
#fixed code
public static void main(String[] args) throws FindFailed {
System.out.println("********** Running Sikulix.main");
if (args.length > 1 && args[0].toLowerCase().startsWith("runserver")) {
if (args[1].toLowerCase().contains("start")) {
RunServer.run(nul... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void main(String[] args) throws FindFailed {
System.out.println("********** Running Sikulix.main");
int dl = RunTime.checkArgs(args, RunTime.Type.API);
if (dl > -1 && dl < 999) {
testNumber = dl;
Debug.on(3);
} else {
test... |
#fixed code
@Deprecated
public static boolean addHotkey(char key, int modifiers, HotkeyListener listener) {
return Key.addHotkey(key, modifiers, listener);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Deprecated
public static boolean addHotkey(char key, int modifiers, HotkeyListener listener) {
return HotkeyManager.getInstance().addHotkey(key, modifiers, listener);
}
#location 3
#vulnerability type NULL... |
#fixed code
public static List<Object[]> queryGenericObjectArrayListSQL(String poolName, String sql, Object[] params) {
List<Object[]> returnList = null;
try {
ArrayListHandler resultSetHandler = new ArrayListHandler();
// returnList = new QueryRunner().query(con, sq... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static List<Object[]> queryGenericObjectArrayListSQL(String poolName, String sql, Object[] params) {
List<Object[]> returnList = null;
Connection con = null;
try {
con = DB_CONNECTION_MANAGER.getConnection(poolName);
if (con == null) {
... |
#fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... |
#fixed code
void onRpcReturned(Status status, GetFileResponse response) {
this.lock.lock();
try {
if (this.finished) {
return;
}
if (!status.isOk()) {
// Reset count to make next rpc retry the previous on... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
void sendNextRpc() {
this.timer = null;
final long offset = requestBuilder.getOffset() + requestBuilder.getCount();
final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE;
this.requestBuilder ... |
#fixed code
private ClassLoader getDriverClassLoader() {
File localDriverPath = getCustomDriverPath();
if (driverClassLoader != null) {
return driverClassLoader;
} else if (localDriverPath.exists()) {
try {
List<URL> urlList = new ArrayList<>();
File... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private ClassLoader getDriverClassLoader() {
File localDriverPath = getCustomDriverPath();
if (driverClassLoader != null) {
return driverClassLoader;
} else if (localDriverPath.exists()) {
try {
List<URL> urlList = new ArrayList<URL>();
... |
#fixed code
private void verifyNode(Node node) {
if (node == null)
return;
// Pre-order traversal.
verifyNodes(node.children());
if (node instanceof Call) {
Call call = (Call) node;
// Skip resolving property derefs.
if (call.isJavaStatic() || cal... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void verifyNode(Node node) {
if (node == null)
return;
// Pre-order traversal.
verifyNodes(node.children());
if (node instanceof Call) {
Call call = (Call) node;
// Skip resolving property derefs.
if (call.isJavaStatic() ... |
#fixed code
public void testToArray() throws SQLException {
Object[] a = null;
assertTrue(this.rs.next());
a = processor.toArray(this.rs);
assertEquals(COLS, a.length);
assertEquals("1", a[0]);
assertEquals("2", a[1]);
assertEquals... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void testToArray() throws SQLException {
int rowCount = 0;
Object[] a = null;
while (this.rs.next()) {
a = processor.toArray(this.rs);
assertEquals(COLS, a.length);
rowCount++;
}
assert... |
#fixed code
@Override
@SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine")
public synchronized void launch(SlaveComputer computer, TaskListener listener) {
if (!(computer instanceof KubernetesComputer)) {
throw new IllegalArg... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
@SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine")
public synchronized void launch(SlaveComputer computer, TaskListener listener) {
if (!(computer instanceof KubernetesComputer)) {
throw new Ille... |
#fixed code
private Pod getPodTemplate(KubernetesSlave slave, Label label) {
DockerTemplate template = getTemplate(label);
String id = getIdForLabel(label);
Pod podTemplate = new Pod();
podTemplate.setId(slave.getNodeName());
// labels
pod... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private Pod getPodTemplate(KubernetesSlave slave, Label label) {
DockerTemplate template = getTemplate(label);
String id = getIdForLabel(label);
Pod podTemplate = new Pod();
podTemplate.setId(slave.getNodeName());
// labels
... |
#fixed code
@Override
@SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine")
public synchronized void launch(SlaveComputer computer, TaskListener listener) {
if (!(computer instanceof KubernetesComputer)) {
throw new IllegalArg... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
@SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine")
public synchronized void launch(SlaveComputer computer, TaskListener listener) {
if (!(computer instanceof KubernetesComputer)) {
throw new Ille... |
#fixed code
private static boolean userHasAdministerPermission() {
return Jenkins.get().hasPermission(Jenkins.ADMINISTER);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private static boolean userHasAdministerPermission() {
return Jenkins.getInstance().getACL().hasPermission(Jenkins.ADMINISTER);
}
#location 2
#vulnerability type NULL_DEREFERENCE |
#fixed code
@Override
public boolean start() throws Exception {
Cloud cloud = Jenkins.get().getCloud(cloudName);
if (cloud == null) {
throw new AbortException(String.format("Cloud does not exist: %s", cloudName));
}
if (!(cloud instanceof ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public boolean start() throws Exception {
Cloud cloud = Jenkins.getInstance().getCloud(cloudName);
if (cloud == null) {
throw new AbortException(String.format("Cloud does not exist: %s", cloudName));
}
if (!(clo... |
#fixed code
protected void deleteNode(Handle handle) throws IOException {
if (cachesize != 0) {
Node n = (Node) cache.get(handle);
if (n != null) synchronized (cache) {
cacheScore.deleteScore(handle);
cache.remove(handle);
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
protected void deleteNode(Handle handle) throws IOException {
if (cachesize != 0) {
Node n = (Node) cache.get(handle);
if (n != null) {
cacheScore.deleteScore(handle);
cache.remove(handle);
}
... |
#fixed code
private void respondError(OutputStream respond, String origerror, int errorcase, String url) {
FileInputStream fis = null;
try {
// set rewrite values
serverObjects tp = new serverObjects();
tp.put("errormessage", errorcase)... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void respondError(OutputStream respond, String origerror, int errorcase, String url) {
try {
// set rewrite values
serverObjects tp = new serverObjects();
tp.put("errormessage", errorcase);
tp.put("httperro... |
#fixed code
public static void copy(File source, OutputStream dest) throws IOException {
InputStream fis = null;
try {
fis = new FileInputStream(source);
copy(fis, dest);
} finally {
if (fis != null) try { fis.close(); } catch (Exception e) {}
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static void copy(File source, OutputStream dest) throws IOException {
InputStream fis = new FileInputStream(source);
copy(fis, dest);
fis.close();
}
#location 5
#vulnerability type RESOURCE_L... |
#fixed code
@Override
public Health health() {
boolean allPassed = true;
Health.Builder builder = new Health.Builder();
for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) {
Biz biz = DynamicJvmServiceProxyFinder.getBiz(sofa... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
public Health health() {
boolean allPassed = true;
Health.Builder builder = new Health.Builder();
for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) {
if (!sofaRuntimeManager.isLivenessHealth()) ... |
#fixed code
@Test
public void testReadinessCheckFailedHttpCode() {
ResponseEntity<String> response = restTemplate.getForEntity("/health/readiness",
String.class);
Assert.assertEquals(HttpStatus.SERVICE_UNAVAILABLE, response.getStatusCode());
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testReadinessCheckFailedHttpCode() throws IOException {
HttpURLConnection huc = (HttpURLConnection) (new URL(
"http://localhost:8080/health/readiness").openConnection());
huc.setRequestMethod("HEAD");
huc.connect... |
#fixed code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@RequestMapping("/updateClusterConf")
public JSONObject updateClusterConf(HttpServletRequest request) throws IOException {
JSONObject result = new JSONObject();
String ipSpliter = ",";
String ips = BaseServlet.optional(request, "ips", "");... |
#fixed code
private void checkLocalConfig(CacheData cacheData) {
final String dataId = cacheData.dataId;
final String group = cacheData.group;
final String tenant = cacheData.tenant;
File path = LocalConfigInfoProcessor.getFailoverFile(agent.getName(), dat... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private void checkLocalConfig(CacheData cacheData) {
final String dataId = cacheData.dataId;
final String group = cacheData.group;
final String tenant = cacheData.tenant;
File path = LocalConfigInfoProcessor.getFailoverFile(agent.getName(... |
#fixed code
@Test
public void lotusNotesVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_LOTUS_NOTES.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//PRODID
{
P... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void lotusNotesVCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("John_Doe_LOTUS_NOTES.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V3_0, vcard.getVersion());
//PRODID
... |
#fixed code
@Override
protected void doUnmarshalValue(String value, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) {
if (subTypes.getValue() != null) {
setUrl(VCardStringUtils.unescape(value));
} else {
//instruct the marshaller to look for an e... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Override
protected void doUnmarshalValue(String value, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode) {
value = VCardStringUtils.unescape(value);
if (subTypes.getValue() != null) {
url = value;
} else {
VCardReader reader =... |
#fixed code
@Test
public void outlook2007VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2007.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
StructuredNam... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void outlook2007VCard() throws Exception {
VCardReader reader = new VCardReader(getClass().getResourceAsStream("outlook-2007.vcf"));
VCard vcard = reader.readNext();
//VERSION
assertEquals(VCardVersion.V2_1, vcard.getVersion());
//N
{
Structu... |
#fixed code
private String getCommandOutput(Command thisCommand, StreamConsumer stdOutConsumer, StreamConsumer stdErrConsumer, File tslintOutputFile, Integer timeoutMs) {
LOG.debug("Executing TsLint with command: " + thisCommand.toCommandLine());
// Timeout is specified ... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
private String getCommandOutput(Command thisCommand, StreamConsumer stdOutConsumer, StreamConsumer stdErrConsumer, File tslintOutputFile, Integer timeoutMs) {
LOG.debug("Executing TsLint with command: " + thisCommand.toCommandLine());
// Timeout is spec... |
#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... | Below is the vulnerable code, please generate the patch based on the following information. | #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... |
#fixed code
public void get(int domainId, ByteBuffer key, HostConnectionGetCallback resultHandler) {
try {
client.get(domainId, key, resultHandler);
} catch (TException e) {
resultHandler.onError(e);
}
} | Below is the vulnerable code, please generate the patch based on the following information. | #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 |
#fixed code
Host getHost() {
return host;
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
boolean isAvailable() {
return state != HostConnectionState.STANDBY;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION |
#fixed code
public void addCompleteTask(GetTask task) {
synchronized (getTasksComplete) {
getTasksComplete.addLast(task);
}
//dispatcherThread.interrupt();
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void addCompleteTask(GetTask task) {
synchronized (getTasksComplete) {
getTasksComplete.addLast(task);
}
dispatcherThread.interrupt();
}
#location 5
#vulnerability type THREAD_SAFETY_VIOL... |
#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
@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 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 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
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 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 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
public void close() {
doClose(lbProxyBean, protobufRpcProxyList);
super.close();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION |
#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 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 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 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
public void testSelectTransactedGetAs() {
db() //
.select("select name from person") //
.transacted() //
.getAs(String.class) //
.test() //
.awaitDone(TIMEOUT_SECONDS, Time... |
#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 testSelectTransactedChained() throws Exception {
Database db = db();
db //
.select("select score from person where name=?") //
.parameters("FRED", "JOSEPH") //
.transacted() //
... |
#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
// TODO fix test
public void testMaxIdleTime() throws InterruptedException {
TestScheduler s = new TestScheduler();
AtomicInteger count = new AtomicInteger();
AtomicInteger disposed = new AtomicInteger();
MemberF... |
#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
private void testHealthCheck(Predicate<Connection> healthy) throws InterruptedException {
TestScheduler scheduler = new TestScheduler();
NonBlockingConnectionPool pool = Pools //
.nonBlocking() //
.connectionProvider(Data... |
#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 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 testAutoMapToInterfaceWithIndexTooSmall() {
try (Database db = db()) {
db //
.select("select name, score from person order by name") //
.autoMap(Person7.class) //
.firstOrErr... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testAutoMapToInterfaceWithIndexTooSmall() {
db() //
.select("select name, score from person order by name") //
.autoMap(Person7.class) //
.firstOrError() //
.map(Person7::examS... |
#fixed code
public static Database test(int maxPoolSize) {
Preconditions.checkArgument(maxPoolSize > 0, "maxPoolSize must be greater than 0");
return Database.from( //
Pools.nonBlocking() //
.connectionProvider(testConnectionProvide... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public static Database test(int maxPoolSize) {
Preconditions.checkArgument(maxPoolSize > 0, "maxPoolSize must be greater than 0");
return Database.from( //
Pools.nonBlocking() //
.connectionProvider(testConnectionP... |
#fixed code
@Test
public void testSelectWithFetchSizeZero() {
try (Database db = db()) {
db.select("select score from person order by name") //
.fetchSize(0) //
.getAs(Integer.class) //
.test() //
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void testSelectWithFetchSizeZero() {
db().select("select score from person order by name") //
.fetchSize(0) //
.getAs(Integer.class) //
.test() //
.awaitDone(TIMEOUT_SECONDS, TimeUn... |
#fixed code
public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) {
String message = formatMessage(issuer, type, key, replacements);
for (String msg : ACFPatterns.NEWLINE.split(message)) {
issuer.sendM... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void sendMessage(CommandIssuer issuer, MessageType type, MessageKeyProvider key, String... replacements) {
String message = getLocales().getMessage(issuer, key.getMessageKey());
if (replacements.length > 0) {
message = ACFUtil.replaceS... |
#fixed code
public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args) {
return tabComplete(issuer, commandLabel, args, false);
} | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args)
throws IllegalArgumentException {
commandLabel = commandLabel.toLowerCase();
try {
CommandOperationContext commandOperationContext = preCommand... |
#fixed code
public boolean hasLink(final String pid, final String rel,
final String href) throws IOException {
this.checkExist(pid);
try (final Item item = this.item()) {
return !new Xocument(item.path()).nodes(
String.format(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public boolean hasLink(final String pid, final String rel,
final String href) throws IOException {
if (!this.exists(pid)) {
throw new IllegalArgumentException(
new Par(
"Project %s doesn't exist, can't chec... |
#fixed code
@Test
public void rejectsIfAlreadyApplied() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final People people = new People(farm).bootstrap();
final String uid = "yegor256";
people.touch(uid);
people.apply(uid, In... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void rejectsIfAlreadyApplied() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final People people = new People(farm).bootstrap();
final String uid = "yegor256";
people.touch(uid);
people.apply(u... |
#fixed code
@Test
public void rendersAgendaPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void rendersAgendaPage() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final String uid = "yegor256";
final People people = new People(farm).bootstrap();
people.touch(uid);
people.invite(uid, "... |
#fixed code
@Test
public void rendersReport() throws Exception {
final Farm farm = new FtFarm(new PropsFarm(new FkFarm()));
final String uid = "yegor256";
new ClaimOut()
.type("Order was given")
.param("login", uid)
.postTo(... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void rendersReport() throws Exception {
final Farm farm = new FtFarm(new PropsFarm(new FkFarm()));
final String uid = "yegor256";
new ClaimOut()
.type("Order was given")
.param("login", uid)
.p... |
#fixed code
public Collection<String> links(final String pid) throws IOException {
this.checkExist(pid);
try (final Item item = this.item()) {
return new SolidList<>(
new Mapped<>(
xml -> String.format(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public Collection<String> links(final String pid) throws IOException {
if (!this.exists(pid)) {
throw new IllegalArgumentException(
new Par(
"Project %s doesn't exist, can't get links"
).say(pid)
... |
#fixed code
@Test
public void rendersProfilePageWithRateInFirefox() throws Exception {
final Farm farm = FkFarm.props();
final double rate = 99.99;
final People people = new People(farm).bootstrap();
people.rate(
"yegor256", new Cash.S(Stri... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void rendersProfilePageWithRateInFirefox() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final double rate = 99.99;
final People people = new People(farm).bootstrap();
people.rate(
"yegor25... |
#fixed code
@Test
public void rendersSingleArtifact() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkApp(farm).act(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void rendersSingleArtifact() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final Catalog catalog = new Catalog(new Pmo(farm)).bootstrap();
final String pid = "A1B2C3D4F";
catalog.add(pid, String.format... |
#fixed code
@Test
public void acceptIfNeverApplied() throws Exception {
final Farm farm = FkFarm.props();
final People people = new People(farm).bootstrap();
final String uid = "yegor256";
people.touch(uid);
final Request req = new RqWithUser(
... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
@Test
public void acceptIfNeverApplied() throws Exception {
final Farm farm = new PropsFarm(new FkFarm());
final People people = new People(farm).bootstrap();
final String uid = "yegor256";
people.touch(uid);
final Request req... |
#fixed code
public void title(final String pid, final String title)
throws IOException {
this.checkExist(pid);
try (final Item item = this.item()) {
new Xocument(item.path()).modify(
new Directives()
.xpath(String.fo... | Below is the vulnerable code, please generate the patch based on the following information. | #vulnerable code
public void title(final String pid, final String title)
throws IOException {
if (!this.exists(pid)) {
throw new IllegalArgumentException(
new Par(
"Project %s doesn't exist, can't change title"
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.