input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
protected void checkKeycloakSession(Request request, HttpFacade facade) {
if (request.getSessionInternal(false) == null || request.getSessionInternal().getPrincipal() == null) return;
RefreshableKeycloakSecurityContext session = (RefreshableKeycloakSecur... | #fixed code
protected void checkKeycloakSession(Request request, HttpFacade facade) {
if (request.getSessionInternal(false) == null || request.getSessionInternal().getPrincipal() == null) return;
RefreshableKeycloakSecurityContext session = (RefreshableKeycloakSecurityCon... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String getPemFromKey(Key key) {
StringWriter writer = new StringWriter();
PEMWriter pemWriter = new PEMWriter(writer);
try {
pemWriter.writeObject(key);
pemWriter.flush();
} catch (IOException e) {
... | #fixed code
public static String getPemFromKey(Key key) {
StringWriter writer = new StringWriter();
PEMWriter pemWriter = new PEMWriter(writer);
try {
pemWriter.writeObject(key);
pemWriter.flush();
pemWriter.close();
} c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void backchannelLogout(UserSessionModel userSession, ClientSessionModel clientSession) {
ClientModel client = clientSession.getClient();
if (!(client instanceof ApplicationModel)) return;
ApplicationModel app = (ApplicationMo... | #fixed code
@Override
public void backchannelLogout(UserSessionModel userSession, ClientSessionModel clientSession) {
ClientModel client = clientSession.getClient();
if (!(client instanceof ApplicationModel)) return;
ApplicationModel app = (ApplicationModel)cl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String[] getReferrer() {
String referrer = uriInfo.getQueryParameters().getFirst("referrer");
if (referrer == null) {
return null;
}
String referrerUri = uriInfo.getQueryParameters().getFirst("referrer_uri");
... | #fixed code
private String[] getReferrer() {
String referrer = uriInfo.getQueryParameters().getFirst("referrer");
if (referrer == null) {
return null;
}
String referrerUri = uriInfo.getQueryParameters().getFirst("referrer_uri");
Appli... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String getPemFromCertificate(X509Certificate certificate) {
StringWriter writer = new StringWriter();
PEMWriter pemWriter = new PEMWriter(writer);
try {
pemWriter.writeObject(certificate);
pemWriter.flush();
... | #fixed code
public static String getPemFromCertificate(X509Certificate certificate) {
StringWriter writer = new StringWriter();
PEMWriter pemWriter = new PEMWriter(writer);
try {
pemWriter.writeObject(certificate);
pemWriter.flush();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void checkKeycloakSession(Request request, HttpFacade facade) {
if (request.getSessionInternal(false) == null || request.getPrincipal() == null) return;
RefreshableKeycloakSecurityContext session = (RefreshableKeycloakSecurityContext) request.g... | #fixed code
protected void checkKeycloakSession(Request request, HttpFacade facade) {
if (request.getSessionInternal(false) == null || request.getPrincipal() == null) return;
RefreshableKeycloakSecurityContext session = (RefreshableKeycloakSecurityContext) request.getSess... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.... | #fixed code
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
addModules(deploymentUnit);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void copySnapshot() {
int length = dirtyIndex.get();
if (length <= dirtyArray.length) {
for (int i = 0; i < length; i++) {
int index = dirtyArray[i];
this.snapshot[index] = live[index];
}
} else {
for (int i = 0; i < live.length; i+... | #fixed code
@Override
public void copySnapshot() {
int length = dirtyIndex.get();
if (length <= dirtySize) {
for (int i = 0; i < length; i++) {
int index = dirtyArray.get(i);
this.snapshot[index] = getLive(i);
}
} else {
for (int i = 0; i < snapshot.length; i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@DelayedWrite
public short set(int index, short value) {
synchronized (live) {
live[index] = value;
}
int localDirtyIndex = dirtyIndex.getAndIncrement();
if (localDirtyIndex < dirtyArray.length) {
dirtyArray[localDirtyIndex] = index;
}
return snapshot[in... | #fixed code
@DelayedWrite
public short set(int index, short value) {
boolean success = false;
int divIndex = index >> 1;
boolean isZero = (index & 0x1) == 0;
short one;
short zero;
short old = 0;
while (!success) {
int packed = live.get(divIndex);
if (isZero) {
o... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void copySnapshot() {
int length = dirtyIndex.get();
if (length <= dirtyArray.length) {
for (int i = 0; i < length; i++) {
int index = dirtyArray[i];
this.snapshot[index] = live[index];
}
} else {
for (int i = 0; i < live.length; i+... | #fixed code
@Override
public void copySnapshot() {
int length = dirtyIndex.get();
if (length <= dirtySize) {
for (int i = 0; i < length; i++) {
int index = dirtyArray.get(i);
this.snapshot[index] = getLive(i);
}
} else {
for (int i = 0; i < snapshot.length; i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@DelayedWrite
public short set(int index, short value) {
synchronized (live) {
live[index] = value;
}
int localDirtyIndex = dirtyIndex.getAndIncrement();
if (localDirtyIndex < dirtyArray.length) {
dirtyArray[localDirtyIndex] = index;
}
return snapshot[in... | #fixed code
@DelayedWrite
public short set(int index, short value) {
boolean success = false;
int divIndex = index >> 1;
boolean isZero = (index & 0x1) == 0;
short one;
short zero;
short old = 0;
while (!success) {
int packed = live.get(divIndex);
if (isZero) {
o... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static KeePassDatabase getInstance(File keePassDatabaseFile) {
if(keePassDatabaseFile == null) {
throw new IllegalArgumentException("You must provide a valid KeePass database file.");
}
try {
return getInstance(new FileInputStream(keePassDatabaseFile)... | #fixed code
public static KeePassDatabase getInstance(File keePassDatabaseFile) {
if(keePassDatabaseFile == null) {
throw new IllegalArgumentException("You must provide a valid KeePass database file.");
}
InputStream keePassDatabaseStream = null;
try {
keePassDatabaseStream... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectGroups() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().parse(... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectGroups() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
List<Group> groups = keePassFile.getTopGroups();
Assert.assertNotNull(groups);
Assert.assertEquals(6, gr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectGroups() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().parse(... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectGroups() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
List<Group> groups = keePassFile.getTopGroups();
Assert.assertNotNull(groups);
Assert.assertEquals(6, gr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectMetadata() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().pars... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectMetadata() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
Assert.assertEquals("KeePass", keePassFile.getMeta().getGenerator());
Assert.assertEquals("TestDatabase", keeP... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean isPasswordProtected() {
return getPropertyByName(PASSWORD).isProtected();
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public boolean isPasswordProtected() {
return getPropertyByName(PASSWORD).isProtected();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectGroups() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().parse(... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectGroups() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
List<Group> groups = keePassFile.getTopGroups();
Assert.assertNotNull(groups);
Assert.assertEquals(6, gr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean isTitleProtected() {
return getPropertyByName(TITLE).isProtected();
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public boolean isTitleProtected() {
return getPropertyByName(TITLE).isProtected();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenWritingDatabaseFileShouldBeAbleToReadItAlso() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new KeePassDatabaseXmlParser().fromXml... | #fixed code
@Test
public void whenWritingDatabaseFileShouldBeAbleToReadItAlso() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new KeePassDatabaseXmlParser().fromXml(fileI... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private byte[] processDatabaseEncryption(boolean encrypt, byte[] database, KeePassHeader header, byte[] aesKey)
throws IOException {
byte[] metaData = new byte[KeePassHeader.VERSION_SIGNATURE_LENGTH + header.getHeaderSize()];
BufferedInputStream bufferedInputStream ... | #fixed code
private byte[] processDatabaseEncryption(boolean encrypt, byte[] database, KeePassHeader header, byte[] aesKey)
throws IOException {
byte[] metaData = new byte[KeePassHeader.VERSION_SIGNATURE_LENGTH + header.getHeaderSize()];
SafeInputStream inputStream = new SafeInputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private KeePassFile parseKeePassXml() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new KeePassDatabaseXmlParser().fromXml(fileInputStream,
Salsa20.c... | #fixed code
private KeePassFile parseKeePassXml() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new KeePassDatabaseXmlParser().fromXml(fileInputStream);
new ProtectedVa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectEntries() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().parse... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectEntries() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
List<Entry> entries = keePassFile.getTopEntries();
Assert.assertNotNull(entries);
Assert.assertEquals(2... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected = UnsupportedOperationException.class)
public void whenVersionIsNotSupportedShouldThrowException() throws IOException {
KeePassHeader header = new KeePassHeader(new RandomGenerator());
// new v4 format
FileInputStream ... | #fixed code
@Test(expected = UnsupportedOperationException.class)
public void whenVersionIsNotSupportedShouldThrowException() throws IOException {
KeePassHeader header = new KeePassHeader(new RandomGenerator());
// unsupported format --> e.g. v5
byte[... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private byte[] processDatabaseEncryption(boolean encrypt, byte[] database, KeePassHeader header, byte[] aesKey)
throws IOException {
byte[] metaData = new byte[KeePassHeader.VERSION_SIGNATURE_LENGTH + header.getHeaderSize()];
BufferedInputStream bufferedInputStream ... | #fixed code
private byte[] processDatabaseEncryption(boolean encrypt, byte[] database, KeePassHeader header, byte[] aesKey)
throws IOException {
byte[] metaData = new byte[KeePassHeader.VERSION_SIGNATURE_LENGTH + header.getHeaderSize()];
SafeInputStream inputStream = new SafeInputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenWritingKeePassFileShouldBeAbleToReadItAgain() throws IOException {
// Read decrypted and write again
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassDatabaseXmlParser parser = new ... | #fixed code
@Test
public void whenWritingKeePassFileShouldBeAbleToReadItAgain() throws IOException {
// Read decrypted and write again
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassDatabaseXmlParser parser = new KeePas... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public KeePassFile openDatabase(String password) {
try {
byte[] aesDecryptedDbFile = decrypter.decryptDatabase(password, keepassHeader, keepassFile);
byte[] startBytes = new byte[32];
ByteArrayInputStream decryptedStream = new ByteArrayInputStream(aesDecrypt... | #fixed code
public KeePassFile openDatabase(String password) {
try {
byte[] passwordBytes = password.getBytes("UTF-8");
byte[] hashedPassword = Sha256.hash(passwordBytes);
return decryptAndParseDatabase(hashedPassword);
} catch (UnsupportedEncodingException e) {
throw ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectEntries() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().parse... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectEntries() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
List<Entry> entries = keePassFile.getTopEntries();
Assert.assertNotNull(entries);
Assert.assertEquals(2... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private byte[] unHashBlockStream(SafeInputStream decryptedStream) throws IOException {
HashedBlockInputStream hashedBlockInputStream = new HashedBlockInputStream(decryptedStream);
byte[] hashedBlockBytes = StreamUtils.toByteArray(hashedBlockInputStream);
return hashe... | #fixed code
private byte[] unHashBlockStream(SafeInputStream decryptedStream) throws IOException {
HashedBlockInputStream hashedBlockInputStream = new HashedBlockInputStream(decryptedStream);
return StreamUtils.toByteArray(hashedBlockInputStream);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void checkVersionSupport(byte[] keepassFile) throws IOException {
BufferedInputStream bufferedInputStream = new BufferedInputStream(new ByteArrayInputStream(keepassFile));
byte[] signature = new byte[VERSION_SIGNATURE_LENGTH];
bufferedInputStream.read(signatu... | #fixed code
public void checkVersionSupport(byte[] keepassFile) throws IOException {
BufferedInputStream inputStream = new BufferedInputStream(new ByteArrayInputStream(keepassFile));
byte[] signature = new byte[VERSION_SIGNATURE_LENGTH];
int readBytes = inputStream.read(signature);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public KeePassFile openDatabase(String password) {
try {
byte[] aesDecryptedDbFile = decrypter.decryptDatabase(password, keepassHeader, keepassFile);
byte[] startBytes = new byte[32];
ByteArrayInputStream decryptedStream = new ByteArrayInputStream(aesDecrypt... | #fixed code
public KeePassFile openDatabase(String password) {
try {
byte[] passwordBytes = password.getBytes("UTF-8");
byte[] hashedPassword = Sha256.hash(passwordBytes);
return decryptAndParseDatabase(hashedPassword);
} catch (UnsupportedEncodingException e) {
throw ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsKeyFileShouldParseFileAndReturnCorrectData() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/DatabaseWithKeyfile.key");
KeyFile keyFile = new KeyFileXmlParser().fromXml(fileInputStr... | #fixed code
@Test
public void whenInputIsKeyFileShouldParseFileAndReturnCorrectData() throws IOException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/DatabaseWithKeyfile.key");
byte[] keyFileContent = StreamUtils.toByteArray(fileInputStream);
KeyFil... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectMetadata() throws FileNotFoundException {
FileInputStream fileInputStream = new FileInputStream("target/test-classes/testDatabase_decrypted.xml");
KeePassFile keePassFile = new XmlParser().pars... | #fixed code
@Test
public void whenInputIsValidKeePassXmlShouldParseFileAndReturnCorrectMetadata() throws FileNotFoundException {
KeePassFile keePassFile = parseKeePassXml();
Assert.assertEquals("KeePass", keePassFile.getMeta().getGenerator());
Assert.assertEquals("TestDatabase", keeP... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
String allExtractRegularUrl = "http://localhost:8080/HtmlExtractorServer/api/all_extract_regular.jsp";
String redisHost = "localhost";
int redisPort = 6379;
HtmlExtractor htmlExtractor = H... | #fixed code
public static void main(String[] args) {
usage1();
//usage2();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
//下面的三种方法代表了3种不同的使用模式,只能单独使用
//usage1();
//usage2();
usage3();
}
#location 5
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public static void main(String[] args) {
//下面的三种方法代表了3种不同的使用模式,只能单独使用
//usage1();
usage2();
//usage3();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public ValueBlock filter(PositionBlock positions)
{
// find selected positions
Set<Integer> indexes = new HashSet<>();
for (long position : positions.getPositions()) {
if (range.contains(position)) {
... | #fixed code
@Override
public ValueBlock filter(PositionBlock positions)
{
return MaskedValueBlock.maskBlock(this, positions);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAverageAll()
{
List<Tuple> expected = computeExpected("SELECT AVG(totalprice) FROM orders", DOUBLE);
TupleStream price = createBlockStream(ordersData, Column.ORDER_TOTALPRICE, DOUBLE);
AggregationOperator aggregatio... | #fixed code
@Test
public void testAverageAll()
{
List<Tuple> expected = computeExpected("SELECT AVG(totalprice) FROM orders", DOUBLE);
TupleStream price = createTupleStream(ordersData, Column.ORDER_TOTALPRICE, DOUBLE);
AggregationOperator aggregation = ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Tuple createTuple(String value)
{
byte[] bytes = value.getBytes(UTF_8);
Slice slice = Slices.allocate(bytes.length + SIZE_OF_SHORT);
slice.output()
.appendShort(bytes.length + 2)
.appendBytes(bytes);
... | #fixed code
private Tuple createTuple(String value)
{
TupleInfo tupleInfo = new TupleInfo(VARIABLE_BINARY);
Tuple tuple = tupleInfo.builder()
.append(Slices.wrappedBuffer(value.getBytes(UTF_8)))
.build();
return tuple;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCountAll()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM orders", FIXED_INT_64);
TupleStream orders = createBlockStream(ordersData, Column.ORDER_ORDERKEY, FIXED_INT_64);
AggregationOperator aggregat... | #fixed code
@Test
public void testCountAll()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM orders", FIXED_INT_64);
TupleStream orders = createTupleStream(ordersData, Column.ORDER_ORDERKEY, FIXED_INT_64);
AggregationOperator aggregation = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void writeTo(List<UncompressedBlock> blocks,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputSt... | #fixed code
@Override
public void writeTo(List<UncompressedBlock> blocks,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream o... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCountAllWithComparison()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM lineitem WHERE tax < discount", FIXED_INT_64);
TupleStream discount = createBlockStream(lineitemData, Column.LINEITEM_DISCOUNT, DOUBLE)... | #fixed code
@Test
public void testCountAllWithComparison()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM lineitem WHERE tax < discount", FIXED_INT_64);
TupleStream discount = createTupleStream(lineitemData, Column.LINEITEM_DISCOUNT, DOUBLE);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void writeTo(UncompressedBlock block,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream ou... | #fixed code
@Override
public void writeTo(UncompressedBlock block,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream output)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCountAllWithPredicate()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM orders WHERE orderstatus = 'F'", FIXED_INT_64);
TupleStream orderStatus = createBlockStream(ordersData, Column.ORDER_ORDERSTATUS, VARIAB... | #fixed code
@Test
public void testCountAllWithPredicate()
{
List<Tuple> expected = computeExpected("SELECT COUNT(*) FROM orders WHERE orderstatus = 'F'", FIXED_INT_64);
TupleStream orderStatus = createTupleStream(ordersData, Column.ORDER_ORDERSTATUS, VARIABLE_BIN... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSelectWithComparison()
{
List<Tuple> expected = computeExpected("SELECT orderkey FROM lineitem WHERE tax < discount", FIXED_INT_64);
RowSourceBuilder orderKey = createBlockStream(lineitemData, Column.LINEITEM_ORDERKEY, FIXE... | #fixed code
@Test
public void testSelectWithComparison()
{
List<Tuple> expected = computeExpected("SELECT orderkey FROM lineitem WHERE tax < discount", FIXED_INT_64);
RowSourceBuilder orderKey = createTupleStream(lineitemData, Column.LINEITEM_ORDERKEY, FIXED_INT_... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Tuple createTuple(String key, long count)
{
byte[] bytes = key.getBytes(Charsets.UTF_8);
Slice slice = Slices.allocate(SIZE_OF_LONG + SIZE_OF_SHORT + bytes.length);
slice.output()
.appendLong(count)
.a... | #fixed code
private Tuple createTuple(String key, long count)
{
TupleInfo tupleInfo = new TupleInfo(VARIABLE_BINARY, FIXED_INT_64);
Tuple tuple = tupleInfo.builder()
.append(Slices.wrappedBuffer(key.getBytes(UTF_8)))
.append(count)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCreatePipelineAggregatedSharedTask() throws Exception {
FreeStyleProject build1 = jenkins.createFreeStyleProject("build1");
FreeStyleProject build2 = jenkins.createFreeStyleProject("build2");
FreeStyleProject sonar = jen... | #fixed code
@Test
public void testCreatePipelineAggregatedSharedTask() throws Exception {
FreeStyleProject build1 = jenkins.createFreeStyleProject("build1");
FreeStyleProject build2 = jenkins.createFreeStyleProject("build2");
FreeStyleProject sonar = jenkins.c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Pipeline getPipeline() {
AbstractProject first = Jenkins.getInstance().getItem(firstJob, Jenkins.getInstance(), AbstractProject.class);
AbstractBuild prevBuild = null;
List<Stage> stages = newArrayList();
boolean isFirst = true;
... | #fixed code
public Pipeline getPipeline() {
AbstractProject first = Jenkins.getInstance().getItem(firstJob, Jenkins.getInstance(), AbstractProject.class);
AbstractBuild prevBuild = null;
List<Stage> stages = newArrayList();
for (AbstractProject job : getA... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Pipeline createPipelineAggregated(Pipeline pipeline) {
List<Stage> stages = new ArrayList<>();
for (Stage stage : pipeline.getStages()) {
List<Task> tasks = new ArrayList<>();
AbstractBuild firstTask = getJenkinsJob(stag... | #fixed code
public Pipeline createPipelineAggregated(Pipeline pipeline) {
List<Stage> stages = new ArrayList<>();
for (Stage stage : pipeline.getStages()) {
List<Task> tasks = new ArrayList<>();
AbstractBuild firstTask = getJenkinsJob(stage.getT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void parseContent() {
String temp = StringUtils.decodeXml(Content);
if (MsgType == WechatMessage.MSGTYPE_EMOTICON) {
text = new EmojiMsgXmlHandler(temp).getHtml(getMediaLink(), this);
}
else if (MsgType == WechatMessage... | #fixed code
public void parseContent() {
if (MsgType == WechatMessage.MSGTYPE_EMOTICON) {
text = new EmojiMsgXmlHandler(this).getHtml(getMediaLink());
}
else if (MsgType == WechatMessage.MSGTYPE_IMAGE) {
text = new ImageMsgXmlHandler(this).... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setUp() throws Exception {
String content = File2String.read("appmsg-file.xml");
handler = new AppMsgXmlHandler(content);
}
#location 4
#vulnerability type NULL_DEREFER... | #fixed code
@Before
public void setUp() throws Exception {
String content = File2String.read("appmsg-file.xml");
WechatMessage m = new WechatMessage();
m.Content = content;
handler = new AppMsgXmlHandler(m);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception{
// 创建一个新对象时需要扫描二维码登录,并且传一个处理接收到消息的回调,如果你不需要接收消息,可以传null
final SmartQQClient client = new SmartQQClient();
client.setWorkDir(new File("target").getAbsoluteFile());
DefaultLoginCallba... | #fixed code
public static void main(String[] args) throws Exception {
// 创建一个新对象时需要扫描二维码登录,并且传一个处理接收到消息的回调,如果你不需要接收消息,可以传null
final SmartQQClient client = new SmartQQClient();
client.setWorkDir(new File("target").getAbsoluteFile());
DefaultLoginCallback lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void parseContent() {
String temp = StringUtils.decodeXml(Content);
if (MsgType == WechatMessage.MSGTYPE_EMOTICON) {
text = new EmojiMsgXmlHandler(temp).getHtml(getMediaLink(), this);
}
else if (MsgType == WechatMessage... | #fixed code
public void parseContent() {
if (MsgType == WechatMessage.MSGTYPE_EMOTICON) {
text = new EmojiMsgXmlHandler(this).getHtml(getMediaLink());
}
else if (MsgType == WechatMessage.MSGTYPE_IMAGE) {
text = new ImageMsgXmlHandler(this).... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setUp() throws Exception {
String content = File2String.read("init.xml");
handler = new InitMsgXmlHandler(content);
}
#location 4
#vulnerability type NULL_DEREFERENCE | #fixed code
@Before
public void setUp() throws Exception {
String content = File2String.read("init.xml");
WechatMessage m = new WechatMessage();
m.Content = content;
handler = new InitMsgXmlHandler(m);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetRecents() {
AppMsgInfo info = handler.decode();
Assert.assertEquals("南京abc.xlsx", info.title);
System.out.println(info);
handler = new AppMsgXmlHandler(
File2String.read("appmsg-publis... | #fixed code
@Test
public void testGetRecents() {
AppMsgInfo info = handler.decode();
Assert.assertEquals("南京abc.xlsx", info.title);
System.out.println(info);
WechatMessage m = new WechatMessage();
m.Content = File2String.read("appmsg-publisher.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void parseContent() {
String temp = StringUtils.decodeXml(Content);
if (MsgType == WechatMessage.MSGTYPE_EMOTICON) {
text = new EmojiMsgXmlHandler(temp).getHtml(getMediaLink(), this);
}
else if (MsgType == WechatMessage... | #fixed code
public void parseContent() {
if (MsgType == WechatMessage.MSGTYPE_EMOTICON) {
text = new EmojiMsgXmlHandler(this).getHtml(getMediaLink());
}
else if (MsgType == WechatMessage.MSGTYPE_IMAGE) {
text = new ImageMsgXmlHandler(this).... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Connection getConnection(String dbPath) throws SQLException {
// 先进先出原则
SqliteBaseConnection currCon = null;
synchronized (idleConList) {
// 当可用连接池不为空时候
if (SqliteUtils.isNotEmpty(idleConList)) {
... | #fixed code
public static Connection getConnection(String dbPath) throws SQLException {
if(DEFAULT_DB_PATH.equals(dbPath)){
return getConnection();
}else {
SqliteBaseConnection currCon = createBaseConnection(dbPath);
addRunningConnectio... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Connection getConnection(String dbPath) throws SQLException {
// 先进先出原则
SqliteBaseConnection currCon = null;
synchronized (idleConList) {
// 当可用连接池不为空时候
if (SqliteUtils.isNotEmpty(idleConList)) {
... | #fixed code
public static Connection getConnection(String dbPath) throws SQLException {
if(DEFAULT_DB_PATH.equals(dbPath)){
return getConnection();
}else {
SqliteBaseConnection currCon = createBaseConnection(dbPath);
addRunningConnectio... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Map<String, GssFunction> get() {
return new ImmutableMap.Builder<String, GssFunction>()
// Arithmetic functions.
.put("add", new GssFunctions.AddToNumericValue())
.put("sub", new GssFunctions.SubtractFromNumericValue())
.put("mul... | #fixed code
public Map<String, GssFunction> get() {
return GssFunctions.getFunctionMap();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Map<String, String> getFilenameProvideMap() {
return ImmutableMap.copyOf(filenameProvideMap);
}
#location 1
#vulnerability type CHECKERS_IMMUTABLE_CAST | #fixed code
public Map<String, String> getFilenameProvideMap() {
return filenameProvideMap;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ZooKeeper getClient(){
if (zooKeeper==null) {
try {
if (INSTANCE_INIT_LOCK.tryLock(2, TimeUnit.SECONDS)) {
if (zooKeeper==null) { // 二次校验,防止并发创建client
try {
zooKeeper = new ZooKeeper(zkaddress, 10000, watcher); // TODO,本地变量方式,成功才会赋值
... | #fixed code
public ZooKeeper getClient(){
if (zooKeeper==null) {
try {
if (INSTANCE_INIT_LOCK.tryLock(2, TimeUnit.SECONDS)) {
if (zooKeeper==null) { // 二次校验,防止并发创建client
// init new-client
ZooKeeper newZk = null;
try {
newZk = new ZooKeeper(zkaddress... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static String getAddress() {
if (LOCAL_ADDRESS != null) {
return LOCAL_ADDRESS;
}
InetAddress localAddress = getFirstValidAddress();
LOCAL_ADDRESS = localAddress.getHostAddress();
return LOCAL_ADDRESS;
}
... | #fixed code
private static String getAddress() {
if (LOCAL_ADDRESS != null) {
return LOCAL_ADDRESS;
}
InetAddress localAddress = getFirstValidAddress();
LOCAL_ADDRESS = localAddress != null ? localAddress.getHostAddress() : null;
return... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("rawtypes")
@Override
public void onFinished(Invocation invocation,Object result) {
Object[] args = invocation.getArgs();
MappedStatement mt = (MappedStatement)args[0];
String mapperNameSpace = mt.getId().substring(0, mt.getId().lastIndexOf(SP... | #fixed code
@SuppressWarnings("rawtypes")
@Override
public void onFinished(Invocation invocation,Object result) {
Object[] args = invocation.getArgs();
MappedStatement mt = (MappedStatement)args[0];
String mapperNameSpace = mt.getId().substring(0, mt.getId().lastIndexOf(SPLIT_PO... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void resetCorrectOffsets() {
KafkaConsumerCommand consumerCommand = new KafkaConsumerCommand(consumerContext.getProperties().getProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
try {
List<TopicInfo> topicInfos = consumerCommand.consumerGroup(consumerCo... | #fixed code
private void resetCorrectOffsets() {
consumer.pause(consumer.assignment());
Map<String, List<PartitionInfo>> topicInfos = consumer.listTopics();
Set<String> topics = topicInfos.keySet();
List<String> expectTopics = new ArrayList<>(topicHandlers.keySet());
List<Pa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void start() {
for (int i = 0; i < topicHandlers.size(); i++) {
ConsumerWorker<String, DefaultMessage> consumer = new ConsumerWorker<>(configs, topicHandlers,processExecutor);
consumers.add(consumer);
fetcheExecutor.submit(consumer);
}
}
... | #fixed code
@Override
public void start() {
createKafkaConsumer();
//按主题数创建ConsumerWorker线程
for (int i = 0; i < topicHandlers.size(); i++) {
ConsumerWorker consumer = new ConsumerWorker();
consumerWorks.add(consumer);
fetcheExecutor.submit(consumer);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private synchronized static void load() {
try {
if(!properties.isEmpty())return;
File dir = new File(Thread.currentThread().getContextClassLoader().getResource("").getPath());
File[] propFiles = dir.listFiles(new FilenameFilter() {
@Override
pu... | #fixed code
private synchronized static void load() {
try {
if(inited)return;
File dir = new File(Thread.currentThread().getContextClassLoader().getResource("").getPath());
loadPropertiesFromFile(dir);
inited = true;
} catch (Exception e) {
inited = true;
thro... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object onInterceptor(Invocation invocation) throws Throwable {
final Executor executor = (Executor) invocation.getTarget();
final Object[] args = invocation.getArgs();
final RowBounds rowBounds = (R... | #fixed code
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object onInterceptor(Invocation invocation) throws Throwable {
final Executor executor = (Executor) invocation.getTarget();
final Object[] args = invocation.getArgs();
final MappedStatement orignMappedSta... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void setRuning(String jobName, Date fireTime) {
updatingStatus = false;
try {
JobConfig config = getConf(jobName,false);
config.setRunning(true);
config.setLastFireTime(fireTime);
config.setCurrentNodeId(JobContext.getContext().getNodeI... | #fixed code
@Override
public void setRuning(String jobName, Date fireTime) {
updatingStatus = false;
try {
JobConfig config = getConf(jobName,false);
config.setRunning(true);
config.setLastFireTime(fireTime);
config.setModifyTime(Calendar.getInstance().getTimeInMillis())... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("rawtypes")
@Override
public void onFinished(Invocation invocation,Object result) {
Object[] args = invocation.getArgs();
MappedStatement mt = (MappedStatement)args[0];
QueryMethodCache cacheInfo = null;
if(mt.getSqlCommandType().equals(SqlC... | #fixed code
@SuppressWarnings("rawtypes")
@Override
public void onFinished(Invocation invocation,Object result) {
Object[] args = invocation.getArgs();
MappedStatement mt = (MappedStatement)args[0];
String mapperNameSpace = mt.getId().substring(0, mt.getId().lastIndexOf(SPLIT_PO... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected XInputStream open(String path) throws Exception {
//
final RandomAccessFile file = new RandomAccessFile(path, "r");
final XInputStream is = new XInputStreamImpl(new RamdomAccessFileInputStream(file));
try {
// Check binlog magic
final byte[] magic =... | #fixed code
protected XInputStream open(String path) throws Exception {
//
final XInputStream is = new XInputStreamImpl(new FileInputStream(path));
try {
// Check binlog magic
final byte[] magic = is.readBytes(MySQLConstants.BINLOG_MAGIC.length);
if(!CodecUtils.equals(magic, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected XInputStream open(String path) throws Exception {
//
final RandomAccessFile file = new RandomAccessFile(path, "r");
final XInputStream is = new XInputStreamImpl(new RamdomAccessFileInputStream(file));
try {
// Check binlog magic
final byte[] magic =... | #fixed code
protected XInputStream open(String path) throws Exception {
//
final XInputStream is = new XInputStreamImpl(new RamdomAccessFileInputStream(new File(path)));
try {
// Check binlog magic
final byte[] magic = is.readBytes(MySQLConstants.BINLOG_MAGIC.length);
if(!Cod... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
AnsiConsole.systemInstall();
PrintStream out = System.out;
FileInputStream f = new FileInputStream("src/test/resources/jansi.ans");
int c;
while( (c=f.read())>=0 ) {
out.... | #fixed code
public static void main(String[] args) throws IOException {
String file = "src/test/resources/jansi.ans";
if( args.length>0 )
file = args[0];
// Allows us to disable ANSI processing.
if( "true".equals(System.getProperty("jansi", "true"... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Country Country(String ip_address) {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet("https://geoip.maxmind.com/geoip/country/" + ip_address);
httpget.addHeader("Accept","application/json");
httpget.addH... | #fixed code
Client(String user_id, String license_key) {
this.user_id = user_id;
this.license_key = license_key;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main( String[] args )
{
try {
String user_id = args[0];
String license_key = args[1];
String ip_address = args[2];
Client cl = new Client(user_id,license_key);
JSONObject o = cl.Country(ip_address);
o = o.getJSO... | #fixed code
public static void main( String[] args )
{
String user_id = args[0];
String license_key = args[1];
String ip_address = args[2];
Client cl = new Client(user_id,license_key);
Country c = cl.Country(ip_address);
System.out.println(c.get_countr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private JSONObject responseFor(String path, String ip_address)
throws GeoIP2Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
// String uri = "https://ct4-test.maxmind.com/geoip/" + path + "/" +
... | #fixed code
private JSONObject responseFor(String path, String ip_address)
throws GeoIP2Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
String uri = "https://" + host;
if (host.startsWith("localhost")) {
uri = "http://" ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Country Country(String ip_address) {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet("https://geoip.maxmind.com/geoip/country/" + ip_address);
httpget.addHeader("Accept","application/json");
httpget.addH... | #fixed code
Client(String user_id, String license_key) {
this.user_id = user_id;
this.license_key = license_key;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, Pagination pagination, int depth) {
String url = session.ensureTransaction().url();
String entityType = session.entityType(type.getName());
Query... | #fixed code
@Override
public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, Pagination pagination, int depth) {
Transaction tx = session.ensureTransaction();
String entityType = session.entityType(type.getName());
QueryStatemen... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> T load(Class<T> type, Long id, int depth) {
String url = session.ensureTransaction().url();
QueryStatements queryStatements = session.queryStatementsFor(type);
Query qry = queryStatements.findOne(id,depth);
try (N... | #fixed code
@Override
public <T> T load(Class<T> type, Long id, int depth) {
Transaction tx = session.ensureTransaction();
QueryStatements queryStatements = session.queryStatementsFor(type);
Query qry = queryStatements.findOne(id,depth);
try (Neo4jResp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private boolean bothWayMappingRequired(Object srcObject, String relationshipType, Object tgtObject, String relationshipDirection) {
boolean mapBothWays = false;
ClassInfo tgtInfo = metaData.classInfo(tgtObject);
for (FieldInfo tgtRelReader : tgt... | #fixed code
private boolean bothWayMappingRequired(Object srcObject, String relationshipType, Object tgtObject, String relationshipDirection) {
boolean mapBothWays = false;
ClassInfo tgtInfo = metaData.classInfo(tgtObject);
if(tgtInfo == null) {
LOGGE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> void deleteAll(Class<T> type) {
ClassInfo classInfo = session.metaData().classInfo(type.getName());
if (classInfo != null) {
String url = session.ensureTransaction().url();
ParameterisedStatement request =... | #fixed code
@Override
public <T> void deleteAll(Class<T> type) {
ClassInfo classInfo = session.metaData().classInfo(type.getName());
if (classInfo != null) {
Transaction tx = session.ensureTransaction();
ParameterisedStatement request = getDel... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Result query(String cypher, Map<String, ?> parameters, boolean readOnly) {
validateQuery(cypher, parameters, readOnly);
//If readOnly=true, just execute the query. If false, execute the query and return stats as well
if(read... | #fixed code
@Override
public Result query(String cypher, Map<String, ?> parameters, boolean readOnly) {
validateQuery(cypher, parameters, readOnly);
//If readOnly=true, just execute the query. If false, execute the query and return stats as well
if(readOnly) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public <T> Collection<T> loadAll(Collection<T> objects, SortOrder sortOrder, Pagination pagination, int depth) {
if (objects == null || objects.isEmpty()) {
return objects;
}
Set<Serializable> ids = new LinkedHashSet<>();
Cl... | #fixed code
public <T> Collection<T> loadAll(Collection<T> objects, SortOrder sortOrder, Pagination pagination, int depth) {
if (objects == null || objects.isEmpty()) {
return objects;
}
ClassInfo commonClassInfo = findCommonClassInfo(objects);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void scan(List<String> classPaths, ClassFileProcessor processor) {
this.classPaths = classPaths;
this.processor = processor;
List<File> classPathElements = getUniqueClasspathElements(classPaths);
try {
for (File class... | #fixed code
public void scan(List<String> classPaths, ClassFileProcessor processor) {
this.classPaths = classPaths;
this.processor = processor;
Set<File> classPathElements = getUniqueClasspathElements(classPaths);
LOGGER.debug("Classpath elements:");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, Pagination pagination, int depth) {
String url = session.ensureTransaction().url();
String entityType = session.entityType(type.getName());
Query... | #fixed code
@Override
public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, Pagination pagination, int depth) {
Transaction tx = session.ensureTransaction();
String entityType = session.entityType(type.getName());
QueryStatemen... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void configure(Configuration configuration) {
driver = null;
Components.configuration = configuration;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public static void configure(Configuration configuration) {
destroy();
Components.configuration = configuration;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Collection<Injectable<?>> start(GraphDatabaseService graphDatabaseService, Configuration config) {
EmbeddedDriver embeddedDriver = new EmbeddedDriver(graphDatabaseService);
sessionFactory = new SessionFactory(packages);
retur... | #fixed code
@Override
public Collection<Injectable<?>> start(GraphDatabaseService graphDatabaseService, Configuration config) {
EmbeddedDriver embeddedDriver = new EmbeddedDriver(graphDatabaseService);
sessionFactory = createSessionFactory(embeddedDriver);
ret... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldParseDataInRowResponseCorrectly() {
try (Response<DefaultRestModel> rsp = new TestRestHttpResponse((rowResultsAndNoErrors()))) {
DefaultRestModel restModel = rsp.next();
assertNotNull(restModel);
O... | #fixed code
@Test
public void shouldParseDataInRowResponseCorrectly() {
try (Response<DefaultRestModel> rsp = new TestRestHttpResponse((rowResultsAndNoErrors()))) {
DefaultRestModel restModel = rsp.next();
assertNotNull(restModel);
Map<Str... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testIndexesAreSuccessfullyAsserted() {
createLoginConstraint();
Components.getConfiguration().setAutoIndex("assert");
AutoIndexManager indexManager = new AutoIndexManager(metaData, Components.driver());
assertEquals(AutoIndexMode.ASSERT.getNam... | #fixed code
@Test
public void testIndexesAreSuccessfullyAsserted() {
createLoginConstraint();
baseConfiguration.setAutoIndex("assert");
AutoIndexManager indexManager = new AutoIndexManager(metaData, Components.driver(), baseConfiguration);
assertEquals(AutoIndexMode.ASSERT.getNa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public RelationalWriter getIterableWriter(ClassInfo classInfo, Class<?> parameterType, String relationshipType, String relationshipDirection) {
if(iterableWriterCache.get(classInfo) == null) {
iterableWriterCache.put(classInfo, new Hash... | #fixed code
@Override
public RelationalWriter getIterableWriter(ClassInfo classInfo, Class<?> parameterType, String relationshipType, String relationshipDirection) {
if(!iterableWriterCache.containsKey(classInfo)) {
iterableWriterCache.put(classInfo, new HashMap<D... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void setProperties(List<Property<String, Object>> propertyList, Object instance) {
ClassInfo classInfo = metadata.classInfo(instance);
Collection<FieldInfo> compositeFields = classInfo.fieldsInfo().compositeFields();
if (compositeFields.... | #fixed code
private void setProperties(List<Property<String, Object>> propertyList, Object instance) {
ClassInfo classInfo = metadata.classInfo(instance);
getCompositeProperties(propertyList, classInfo).forEach( (field, v) -> field.write(instance, v));
for (Prop... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void purgeDatabase() {
String url = session.ensureTransaction().url();
session.requestHandler().execute(new DeleteNodeStatements().purge(), url).close();
session.context().clear();
}
#location... | #fixed code
@Override
public void purgeDatabase() {
Transaction tx = session.ensureTransaction();
session.requestHandler().execute(new DeleteNodeStatements().purge(), tx).close();
session.context().clear();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public <T, ID extends Serializable> T load(Class<T> type, ID id, int depth) {
final FieldInfo primaryIndexField = session.metaData().classInfo(type.getName()).primaryIndexField();
if (primaryIndexField != null && !primaryIndexField.isTypeOf(id.getClass(... | #fixed code
public <T, ID extends Serializable> T load(Class<T> type, ID id, int depth) {
ClassInfo classInfo = session.metaData().classInfo(type.getName());
if (classInfo == null) {
throw new IllegalArgumentException(type + " is not a managed entity.");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> Collection<T> loadAll(Class<T> type, Collection<Long> ids, SortOrder sortOrder, Pagination pagination, int depth) {
String url = session.ensureTransaction().url();
String entityType = session.entityType(type.getName());
... | #fixed code
@Override
public <T> Collection<T> loadAll(Class<T> type, Collection<Long> ids, SortOrder sortOrder, Pagination pagination, int depth) {
Transaction tx = session.ensureTransaction();
String entityType = session.entityType(type.getName());
QuerySt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public long countEntitiesOfType(Class<?> entity) {
ClassInfo classInfo = session.metaData().classInfo(entity.getName());
if (classInfo == null) {
return 0;
}
RowModelQuery countStatement = new AggregateStatement... | #fixed code
@Override
public long countEntitiesOfType(Class<?> entity) {
ClassInfo classInfo = session.metaData().classInfo(entity.getName());
if (classInfo == null) {
return 0;
}
RowModelQuery countStatement = new AggregateStatements().co... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public FieldInfo propertyField(String propertyName) {
for (FieldInfo fieldInfo : propertyFields()) {
if (fieldInfo.property().equalsIgnoreCase(propertyName)) {
return fieldInfo;
}
}
return null;
}
... | #fixed code
public FieldInfo propertyField(String propertyName) {
if (propertyFields == null) {
Collection<FieldInfo> fieldInfos = propertyFields();
propertyFields = new HashMap<>(fieldInfos.size());
for (FieldInfo fieldInfo : fieldInfos) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> void delete(T object) {
if (object.getClass().isArray() || Iterable.class.isAssignableFrom(object.getClass())) {
deleteAll(object);
} else {
ClassInfo classInfo = session.metaData().classInfo(object);
... | #fixed code
@Override
public <T> void delete(T object) {
if (object.getClass().isArray() || Iterable.class.isAssignableFrom(object.getClass())) {
deleteAll(object);
} else {
ClassInfo classInfo = session.metaData().classInfo(object);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public RelationalReader getIterableReader(ClassInfo classInfo, Class<?> parameterType, String relationshipType, String relationshipDirection) {
if(iterableReaderCache.get(classInfo) == null) {
iterableReaderCache.put(classInfo, new Hash... | #fixed code
@Override
public RelationalReader getIterableReader(ClassInfo classInfo, Class<?> parameterType, String relationshipType, String relationshipDirection) {
if(!iterableReaderCache.containsKey(classInfo)) {
iterableReaderCache.put(classInfo, new HashMap<D... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testChangedPropertyDetected() {
ClassInfo classInfo = metaData.classInfo(Teacher.class.getName());
Teacher teacher = new Teacher("Miss White");
objectMemo.remember(teacher, classInfo);
teacher.setId(115L); // the ... | #fixed code
@Test
public void testChangedPropertyDetected() {
Teacher teacher = new Teacher("Miss White");
teacher.setId(115L); // the id field must not be part of the memoised property list
mappingContext.remember(teacher);
teacher.setName("Mrs Jone... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> T load(Class<T> type, Long id, int depth) {
String url = session.ensureTransaction().url();
QueryStatements queryStatements = session.queryStatementsFor(type);
Query qry = queryStatements.findOne(id,depth);
try (N... | #fixed code
@Override
public <T> T load(Class<T> type, Long id, int depth) {
Transaction tx = session.ensureTransaction();
QueryStatements queryStatements = session.queryStatementsFor(type);
Query qry = queryStatements.findOne(id,depth);
try (Neo4jResp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Long nativeId(Object entity) {
ClassInfo classInfo = metaData.classInfo(entity);
generateIdIfNecessary(entity, classInfo);
if (classInfo.hasIdentityField()) {
return EntityUtils.identity(entity, metaData);
} else {
... | #fixed code
public Long nativeId(Object entity) {
ClassInfo classInfo = metaData.classInfo(entity);
if (classInfo == null) {
throw new IllegalArgumentException("Class " + entity.getClass() + " is not a valid entity class. "
+ "Please check the... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void mapOneToMany(Collection<Edge> oneToManyRelationships) {
EntityCollector entityCollector = new EntityCollector();
List<MappedRelationship> relationshipsToRegister = new ArrayList<>();
Set<Edge> registeredEdges = new HashSet<>();
... | #fixed code
private void mapOneToMany(Collection<Edge> oneToManyRelationships) {
EntityCollector entityCollector = new EntityCollector();
List<MappedRelationship> relationshipsToRegister = new ArrayList<>();
// first, build the full set of related entities of ea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Result query(String cypher, Map<String, ?> parameters, boolean readOnly) {
validateQuery(cypher, parameters, readOnly);
//If readOnly=true, just execute the query. If false, execute the query and return stats as well
if(read... | #fixed code
@Override
public Result query(String cypher, Map<String, ?> parameters, boolean readOnly) {
validateQuery(cypher, parameters, readOnly);
//If readOnly=true, just execute the query. If false, execute the query and return stats as well
if(readOnly) ... | 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.