input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Test
public void whenWritingVehicleV2_readingAgainAssignsCorrectType(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl typ... | #fixed code
@Test
public void whenWritingVehicleV2_readingAgainAssignsCorrectType(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl type2 = V... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String filename) {
logger.debug("read vrp: {}", filename);
XMLConfiguration xmlConfig = new XMLConfiguration();
xmlConfig.setFileName(filename);
xmlConfig.setAttributeSplittingDisabled(true);
xmlConfig.setDelimite... | #fixed code
public void read(String filename) {
logger.debug("read vrp: {}", filename);
XMLConfiguration xmlConfig = createXMLConfiguration();
try {
xmlConfig.load(filename);
} catch (ConfigurationException e) {
throw new RuntimeExc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@JsonIgnore
@Override
public String getImageId() {
/*Image image = getImage();
return (image != null) ? image.getId() : null;*/
if(image instanceof Map) {
Map<String, String> map = (Map<String, String>) image;
return map.get("id");
}
return getImage().get... | #fixed code
@JsonIgnore
@Override
public String getImageId() {
/*Image image = getImage();
return (image != null) ? image.getId() : null;*/
if(image instanceof Map) {
Map<String, String> map = (Map<String, String>) image;
return map.get("id");
}
return null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpResponse execute() throws Exception {
StringBuilder requestBody = new StringBuilder();
if (request.getEntity() != null) {
String content = ObjectMapperSingleton.getContext(request.getEntity().getClass()).writer().writeValueAsString... | #fixed code
public HttpResponse execute() throws Exception {
StringBuilder requestBody = new StringBuilder();
if (request.getEntity() != null) {
String content = ObjectMapperSingleton.getContext(request.getEntity().getClass()).writer().writeValueAsString(reque... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String resolveV3(URLResolverParams p) {
Token token = p.token;
//in v3 api, if user has no default project, and token is unscoped, no catalog will be returned
//then if service is Identity service, should directly return the endpoint bac... | #fixed code
private String resolveV3(URLResolverParams p) {
Token token = p.token;
//in v3 api, if user has no default project, and token is unscoped, no catalog will be returned
//then if service is Identity service, should directly return the endpoint back
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static IpPool getIpPool() {
if (ipPool == null) {
synchronized (IpPoolHolder.class) {
if (ipPool == null) {
ipPool = IpPool.create(DungProxyContext.create().buildDefaultConfigFile().handleConfig());
... | #fixed code
public static IpPool getIpPool() {
if (ipPool == null) {
synchronized (IpPoolHolder.class) {
if (ipPool == null) {
ipPool = IpPool.create(DungProxyContext.create().buildDefaultConfigFile());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public AvProxy bind(String url, Object userID) {
if (testUrls.size() < 10) {
testUrls.add(url);
} else {
testUrls.set(random.nextInt(10), url);
}
if (consistentBuckets.size() < minSize) {
fresh();
... | #fixed code
public AvProxy bind(String url, Object userID) {
if (testUrls.size() < 10) {
testUrls.add(url);
} else {
testUrls.set(random.nextInt(10), url);
}
if (consistentBuckets.size() < minSize) {
refreshInNewThread()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public AvProxy bind(String url) {
if (testUrls.size() < 10) {
testUrls.add(url);
} else {
testUrls.set(random.nextInt(10), url);
}
if (needFresh()) {
refresh();// 在新线程刷新
}
readWriteLock... | #fixed code
public AvProxy bind(String url) {
if (testUrls.size() < 10) {
testUrls.add(url);
} else {
testUrls.set(random.nextInt(10), url);
}
if (needFresh()) {
refresh();// 在新线程刷新
}
return smartProxyQue... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void refresh() {
if (testUrls.size() == 0) {
return;// 数据还没有进来,不refresh
}
int expectedThreadNumber = expectedRefreshTaskNumber();
if (refreshTaskNumber.get() > expectedThreadNumber) {
logger.info("当前刷新线程数:{}... | #fixed code
public void refresh() {
if (testUrls.size() == 0) {
return;// 数据还没有进来,不refresh
}
int expectedThreadNumber = expectedRefreshTaskNumber();
if (refreshTaskNumber.get() > expectedThreadNumber) {
// logger.info("当前刷新线程数:{} 大于... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testNPE() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream = getPrintStream(os);
sqlLine.setOutputStream(sqllineOutputStream);
sqlLine.setErrorStream(sqlline... | #fixed code
@Test
public void testNPE() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream = getPrintStream(os);
sqlLine.setOutputStream(sqllineOutputStream);
sqlLine.setErrorStream(sqllineOutputStream);
try {
sqlLine.runC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testHelpSet() {
final String expected = "1/1 !help set\n"
+ "!set List / set a sqlline variable\n"
+ "\n"
+ "Variables:\n"
+ "\n"
+ "Variable Value Description\n"
+... | #fixed code
@Test
public void testHelpSet() {
final String expected = "1/1 !help set\n"
+ "!set List / set a sqlline variable\n"
+ "\n"
+ "Variables:\n"
+ "\n"
+ "Variable Value Description\n"
+ "====... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMaxHistoryFileRows() {
final SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new Buffer... | #fixed code
@Test
public void testMaxHistoryFileRows() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new BufferedWriter(
new OutputStreamWriter... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Driver [] scanDriversOLD(String line)
{
long start = System.currentTimeMillis();
Set paths = new HashSet();
Set driverClasses = new HashSet();
for (
StringTokenizer tok =
new StringTokenizer(
... | #fixed code
SqlLine()
{
sqlLineCommandCompleter = new SQLLineCommandCompleter();
// attempt to dynamically load signal handler
try {
Class handlerClass = Class.forName("sqlline.SunSignalHandler");
signalHandler = (SqlLineSignalHandler)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testPromptWithNickname() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine sqlLine = new SqlLine();
try {
final SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(st... | #fixed code
@Test
public void testPromptWithNickname() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
final SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
fi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInitArgsForSuccessConnection() {
try {
final String[] nicknames = new String[1];
new MockUp<sqlline.DatabaseConnection>() {
@Mock
void setNickname(String nickname) {
nicknames[0] = nickname;
}
... | #fixed code
@Test
public void testInitArgsForSuccessConnection() {
try {
final String[] nicknames = new String[1];
new MockUp<sqlline.DatabaseConnection>() {
@Mock
void setNickname(String nickname) {
nicknames[0] = nickname;
}
};
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ConsoleReader getConsoleReader(InputStream inputStream)
throws IOException
{
Terminal terminal = Terminal.setupTerminal();
if (inputStream != null) {
// ### NOTE: fix for sf.net bug 879425.
reader =
... | #fixed code
public ConsoleReader getConsoleReader(InputStream inputStream)
throws IOException
{
Terminal terminal = TerminalFactory.create();
if (inputStream != null) {
// ### NOTE: fix for sf.net bug 879425.
reader =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMultilineScriptWithH2Comments() {
final SqlLine sqlLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
final File tmpHistoryFile = createTempFile("queryToExecute", "temp");
try (BufferedWriter bw... | #fixed code
@Test
public void testMultilineScriptWithH2Comments() {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
final File tmpHistoryFile = createTempFile("queryToExecute", "temp");
try (BufferedWriter bw =
new BufferedWriter(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testOutputWithFailingColumnDisplaySize(
@Mocked final JDBCResultSetMetaData meta) {
try {
new Expectations() {
{
meta.getColumnCount();
result = 3;
meta.getColumnLabel(1);
result = "TABLE... | #fixed code
@Test
public void testOutputWithFailingColumnDisplaySize(
@Mocked final JDBCResultSetMetaData meta) {
try {
new Expectations() {
{
meta.getColumnCount();
result = 3;
meta.getColumnLabel(1);
result = "TABLE_CAT";... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConfirmFlagEffects() {
new MockUp<sqlline.Commands>() {
@Mock
int getUserAnswer(String question, int... allowedAnswers) {
return 'n';
}
};
final SqlLine line = new SqlLine();
assertThat(line.getOpts().getC... | #fixed code
@Test
public void testConfirmFlagEffects() {
new MockUp<sqlline.Commands>() {
@Mock
int getUserAnswer(String question, int... allowedAnswers) {
return 'n';
}
};
assertThat(sqlLine.getOpts().getConfirm(), is(false));
assertThat(sqlLin... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testOutputWithFailingColumnDisplaySize(
@Mocked final JDBCResultSetMetaData meta) {
try {
new Expectations() {
{
meta.getColumnCount();
result = 3;
meta.getColumnLabel(1);
result = "TABLE... | #fixed code
@Test
public void testOutputWithFailingColumnDisplaySize(
@Mocked final JDBCResultSetMetaData meta) {
try {
new Expectations() {
{
meta.getColumnCount();
result = 3;
meta.getColumnLabel(1);
result = "TABLE_CAT";... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMaxHistoryFileRows() {
final SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new Buffer... | #fixed code
@Test
public void testMaxHistoryFileRows() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new BufferedWriter(
new OutputStreamWriter... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithDbPropertyAsParameter2() {
SqlLine beeLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(beeLine, os, false, "-e", "!set maxwidth 80");
assertT... | #fixed code
@Test
public void testConnectWithDbPropertyAsParameter2() {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExceptionConfirmPattern() {
try {
final SqlLine line = new SqlLine();
final ByteArrayOutputStream os = new ByteArrayOutputStream();
assertThat(line.getOpts().getConfirm(), is(false));
SqlLine.Status status =
be... | #fixed code
@Test
public void testExceptionConfirmPattern() {
try {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
assertThat(sqlLine.getOpts().getConfirm(), is(false));
SqlLine.Status status =
begin(sqlLine, os, false, "-e",
"... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void assertFileContains(File file, Matcher matcher)
throws IOException {
final BufferedReader br = new BufferedReader(new FileReader(file));
final StringWriter stringWriter = new StringWriter();
for (;;) {
final String line = br.readLine();... | #fixed code
private void assertFileContains(File file, Matcher matcher)
throws IOException {
final BufferedReader br = new BufferedReader(
new InputStreamReader(
new FileInputStream(file), StandardCharsets.UTF_8.name()));
final StringWriter stringWriter = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSave() {
final SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
SqlLine.Status status = begin(beeLine, os, false,
"-e", "!save");
assertThat(status, equalTo(SqlLine.Sta... | #fixed code
@Test
public void testSave() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final String testSqllinePropertiesFile = "test.sqlline.properties";
try {
SqlLine.Status status = begin(sqlLine, os, false,
"--propertiesFile=" + testSqllineProp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMultilineScriptWithH2Comments() {
final SqlLine sqlLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
final File tmpHistoryFile = createTempFile("queryToExecute", "temp");
try (BufferedWriter bw... | #fixed code
@Test
public void testMultilineScriptWithH2Comments() {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
final File tmpHistoryFile = createTempFile("queryToExecute", "temp");
try (BufferedWriter bw =
new BufferedWriter(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecutionException(@Mocked final JDBCDatabaseMetaData meta,
@Mocked final JDBCResultSet resultSet) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDataba... | #fixed code
@Test
public void testExecutionException(@Mocked final JDBCDatabaseMetaData meta,
@Mocked final JDBCResultSet resultSet) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProd... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithoutPassword() {
new MockUp<sqlline.Commands>() {
@Mock
String readPassword(String url) {
return "";
}
};
SqlLine beeLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream... | #fixed code
@Test
public void testConnectWithoutPassword() {
new MockUp<sqlline.Commands>() {
@Mock
String readPassword(String url) {
return "";
}
};
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testManual() {
final String expectedLine = "sqlline version";
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
new MockUp<Commands>() {
@Mock
void less(Terminal terminal, InputStream in, PrintStream out,
... | #fixed code
@Test
public void testManual() {
final String expectedLine = "sqlline version";
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
new MockUp<Commands>() {
@Mock
void less(Terminal terminal, InputStream in, PrintStream out,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithDbPropertyAsParameter2() {
SqlLine beeLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(beeLine, os, false, "-e", "!set maxwidth 80");
assertT... | #fixed code
@Test
public void testConnectWithDbPropertyAsParameter2() {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCommandHandlerOnStartup() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
final String[] args = {
"-e", "!set maxwidth 80",
"-ch", "sqlline.extensions.HelloWorldCommandHandler"}... | #fixed code
@Test
public void testCommandHandlerOnStartup() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final String[] args = {
"-e", "!set maxwidth 80",
"-ch", "sqlline.extensions.HelloWorldCommandHandler"};
begin(sqlLine, os, false, args);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testNPE() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream = getPrintStream(os);
sqlLine.setOutputStream(sqllineOutputStream);
sqlLine.setErrorStream(sqlline... | #fixed code
@Test
public void testNPE() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream = getPrintStream(os);
sqlLine.setOutputStream(sqllineOutputStream);
sqlLine.setErrorStream(sqllineOutputStream);
try {
sqlLine.runC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExceptionConfirmPattern() {
try {
final SqlLine line = new SqlLine();
final ByteArrayOutputStream os = new ByteArrayOutputStream();
assertThat(line.getOpts().getConfirm(), is(false));
SqlLine.Status status =
be... | #fixed code
@Test
public void testExceptionConfirmPattern() {
try {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
assertThat(sqlLine.getOpts().getConfirm(), is(false));
SqlLine.Status status =
begin(sqlLine, os, false, "-e",
"... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSave() {
final SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
SqlLine.Status status = begin(beeLine, os, false,
"-e", "!save");
assertThat(status, equalTo(SqlLine.Sta... | #fixed code
@Test
public void testSave() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final String testSqllinePropertiesFile = "test.sqlline.properties";
try {
SqlLine.Status status = begin(sqlLine, os, false,
"--propertiesFile=" + testSqllineProp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecutionWithNotSupportedMethods(
@Mocked final JDBCDatabaseMetaData meta) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProductName();
... | #fixed code
@Test
public void testExecutionWithNotSupportedMethods(
@Mocked final JDBCDatabaseMetaData meta) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProductName();
res... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testPromptWithConnection() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine sqlLine = new SqlLine();
try {
final SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(... | #fixed code
@Test
public void testPromptWithConnection() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
final SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCommandHandler() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
try {
final String script = "!commandhandler"
+ " sqll... | #fixed code
@Test
public void testCommandHandler() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
try {
final String script = "!commandhandler"
+ " sqlline.extensions.HelloWorld2CommandHandler"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInitArgsForUserNameAndPasswordWithSpaces() {
try {
final SqlLine sqlLine = new SqlLine();
final DatabaseConnection[] databaseConnection = new DatabaseConnection[1];
new MockUp<sqlline.DatabaseConnections>() {
@Mock
... | #fixed code
@Test
public void testInitArgsForUserNameAndPasswordWithSpaces() {
try {
final DatabaseConnection[] databaseConnection = new DatabaseConnection[1];
new MockUp<sqlline.DatabaseConnections>() {
@Mock
public void setConnection(DatabaseConnection c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMetadataForClassHierarchy() {
final SqlLine beeLine = new SqlLine();
new MockUp<JDBCConnection>() {
@Mock
public DatabaseMetaData getMetaData() throws SQLException {
return new CustomDatabaseMetadata(
(JDBCC... | #fixed code
@Test
public void testMetadataForClassHierarchy() {
new MockUp<JDBCConnection>() {
@Mock
public DatabaseMetaData getMetaData() throws SQLException {
return new CustomDatabaseMetadata(
(JDBCConnection) sqlLine.getConnection());
}
}... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testNPE() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream = getPrintStream(os);
sqlLine.setOutputStream(sqllineOutputStream);
sqlLine.setErrorStream(sqlline... | #fixed code
@Test
public void testNPE() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream = getPrintStream(os);
sqlLine.setOutputStream(sqllineOutputStream);
sqlLine.setErrorStream(sqllineOutputStream);
try {
sqlLine.runC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStartupArgsWithoutUrl() {
try {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream =
new PrintStream(os, false, StandardCharsets.UTF_8.name());
... | #fixed code
@Test
public void testStartupArgsWithoutUrl() {
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream =
new PrintStream(os, false, StandardCharsets.UTF_8.name());
sqlLine.setOutputStream(sqllineOutputStre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void manual(String line, DispatchCallback callback)
throws IOException {
InputStream in = SqlLine.class.getResourceAsStream("manual.txt");
if (in == null) {
callback.setToFailure();
sqlLine.error(sqlLine.loc("no-manual"));
return;
... | #fixed code
public void manual(String line, DispatchCallback callback)
throws IOException {
InputStream in = SqlLine.class.getResourceAsStream("manual.txt");
if (in == null) {
callback.setToFailure();
sqlLine.error(sqlLine.loc("no-manual"));
return;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testManual() {
final String expectedLine = "sqlline version";
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
new MockUp<Commands>() {
@Mock
void less(Terminal terminal, InputStream in, PrintStream out,
... | #fixed code
@Test
public void testManual() {
final String expectedLine = "sqlline version";
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
new MockUp<Commands>() {
@Mock
void less(Terminal terminal, InputStream in, PrintStream out,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTimeFormat() {
// Use System.err as it is used in sqlline.SqlLineOpts#set
final PrintStream originalErr = System.err;
try {
final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
System.setErr(
new Prin... | #fixed code
@Test
public void testTimeFormat() {
// Use System.err as it is used in sqlline.SqlLineOpts#set
final PrintStream originalErr = System.err;
try {
final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
System.setErr(
new PrintStrea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithDbProperty() {
SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine.Status status =
begin(beeLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLi... | #fixed code
@Test
public void testConnectWithDbProperty() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
DispatchCallback dc = n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStartupArgsWithoutUrl() {
try {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream =
new PrintStream(os, false, StandardCharsets.UTF_8.name());
... | #fixed code
@Test
public void testStartupArgsWithoutUrl() {
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream =
new PrintStream(os, false, StandardCharsets.UTF_8.name());
sqlLine.setOutputStream(sqllineOutputStre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInitArgsForUserNameAndPasswordWithSpaces() {
try {
final SqlLine sqlLine = new SqlLine();
final DatabaseConnection[] databaseConnection = new DatabaseConnection[1];
new MockUp<sqlline.DatabaseConnections>() {
@Mock
... | #fixed code
@Test
public void testInitArgsForUserNameAndPasswordWithSpaces() {
try {
final DatabaseConnection[] databaseConnection = new DatabaseConnection[1];
new MockUp<sqlline.DatabaseConnections>() {
@Mock
public void setConnection(DatabaseConnection c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecutionWithNotSupportedMethods(
@Mocked final JDBCDatabaseMetaData meta) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProductName();
... | #fixed code
@Test
public void testExecutionWithNotSupportedMethods(
@Mocked final JDBCDatabaseMetaData meta) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProductName();
res... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCustomPromptHandler() {
SqlLine sqlLine = new SqlLine();
sqlLine.runCommands(new DispatchCallback(),
"!connect "
+ SqlLineArgsTest.ConnectionSpec.H2.url + " "
+ SqlLineArgsTest.ConnectionSpec.H2.username + " ... | #fixed code
@Test
public void testCustomPromptHandler() {
sqlLine.runCommands(new DispatchCallback(),
"!connect "
+ SqlLineArgsTest.ConnectionSpec.H2.url + " "
+ SqlLineArgsTest.ConnectionSpec.H2.username + " \"\"",
"!prompthandler sqlline.exte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testOutputWithFailingColumnDisplaySize(
@Mocked final JDBCResultSetMetaData meta) {
try {
new Expectations() {
{
meta.getColumnCount();
result = 3;
meta.getColumnLabel(1);
result = "TABLE... | #fixed code
@Test
public void testOutputWithFailingColumnDisplaySize(
@Mocked final JDBCResultSetMetaData meta) {
try {
new Expectations() {
{
meta.getColumnCount();
result = 3;
meta.getColumnLabel(1);
result = "TABLE_CAT";... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStartupArgsWithoutUrl() {
try {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream =
new PrintStream(os, false, StandardCharsets.UTF_8.name());
... | #fixed code
@Test
public void testStartupArgsWithoutUrl() {
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream sqllineOutputStream =
new PrintStream(os, false, StandardCharsets.UTF_8.name());
sqlLine.setOutputStream(sqllineOutputStre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCommandHandler() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
try {
final String script = "!commandhandler"
+ " sqll... | #fixed code
@Test
public void testCommandHandler() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
try {
final String script = "!commandhandler"
+ " sqlline.extensions.HelloWorld2CommandHandler"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithDbPropertyAsParameter() {
SqlLine beeLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(beeLine, os, false, "-e", "!set maxwidth 80");
assertTh... | #fixed code
@Test
public void testConnectWithDbPropertyAsParameter() {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testPromptWithNickname() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine sqlLine = new SqlLine();
try {
final SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(st... | #fixed code
@Test
public void testPromptWithNickname() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
final SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
fi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecutionException(@Mocked final JDBCDatabaseMetaData meta,
@Mocked final JDBCResultSet resultSet) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDataba... | #fixed code
@Test
public void testExecutionException(@Mocked final JDBCDatabaseMetaData meta,
@Mocked final JDBCResultSet resultSet) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProd... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecutionWithNotSupportedMethods(
@Mocked final JDBCDatabaseMetaData meta) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProductName();
... | #fixed code
@Test
public void testExecutionWithNotSupportedMethods(
@Mocked final JDBCDatabaseMetaData meta) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProductName();
res... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCustomPromptHandler() {
SqlLine sqlLine = new SqlLine();
sqlLine.runCommands(new DispatchCallback(),
"!connect "
+ SqlLineArgsTest.ConnectionSpec.H2.url + " "
+ SqlLineArgsTest.ConnectionSpec.H2.username + " ... | #fixed code
@Test
public void testCustomPromptHandler() {
sqlLine.runCommands(new DispatchCallback(),
"!connect "
+ SqlLineArgsTest.ConnectionSpec.H2.url + " "
+ SqlLineArgsTest.ConnectionSpec.H2.username + " \"\"",
"!prompthandler sqlline.exte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testMetadataForClassHierarchy() {
final SqlLine beeLine = new SqlLine();
new MockUp<JDBCConnection>() {
@Mock
public DatabaseMetaData getMetaData() throws SQLException {
return new CustomDatabaseMetadata(
(JDBCC... | #fixed code
@Test
public void testMetadataForClassHierarchy() {
new MockUp<JDBCConnection>() {
@Mock
public DatabaseMetaData getMetaData() throws SQLException {
return new CustomDatabaseMetadata(
(JDBCConnection) sqlLine.getConnection());
}
}... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConfirmPattern() {
final SqlLine line = new SqlLine();
assertThat(line.getOpts().getConfirm(), is(false));
final ByteArrayOutputStream os = new ByteArrayOutputStream();
begin(line, os, false, "-e",
"!set confirmPattern \"^(... | #fixed code
@Test
public void testConfirmPattern() {
assertThat(sqlLine.getOpts().getConfirm(), is(false));
final ByteArrayOutputStream os = new ByteArrayOutputStream();
begin(sqlLine, os, false, "-e",
"!set confirmPattern \"^(?i:(TRUNCATE|ALTER))\"");
assertThat... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRerun() {
final SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new BufferedWriter(
... | #fixed code
@Test
public void testRerun() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new BufferedWriter(
new OutputStreamWriter(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConfirmFlag() {
try {
final SqlLine line = new SqlLine();
final ByteArrayOutputStream os = new ByteArrayOutputStream();
assertThat(line.getOpts().getConfirm(), is(false));
begin(line, os, false, "-e", "!set confirm true"... | #fixed code
@Test
public void testConfirmFlag() {
try {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
assertThat(sqlLine.getOpts().getConfirm(), is(false));
begin(sqlLine, os, false, "-e", "!set confirm true");
assertThat(sqlLine.getOpts().getC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRerun() {
final SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new BufferedWriter(
... | #fixed code
@Test
public void testRerun() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
try (BufferedWriter bw =
new BufferedWriter(
new OutputStreamWriter(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithoutPassword() {
new MockUp<sqlline.Commands>() {
@Mock
String readPassword(String url) {
return "";
}
};
SqlLine beeLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream... | #fixed code
@Test
public void testConnectWithoutPassword() {
new MockUp<sqlline.Commands>() {
@Mock
String readPassword(String url) {
return "";
}
};
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithDbProperty() {
SqlLine beeLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine.Status status =
begin(beeLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLi... | #fixed code
@Test
public void testConnectWithDbProperty() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
DispatchCallback dc = n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testInitArgsForSuccessConnection() {
try {
final String[] nicknames = new String[1];
new MockUp<sqlline.DatabaseConnection>() {
@Mock
void setNickname(String nickname) {
nicknames[0] = nickname;
}
... | #fixed code
@Test
public void testInitArgsForSuccessConnection() {
try {
final String[] nicknames = new String[1];
new MockUp<sqlline.DatabaseConnection>() {
@Mock
void setNickname(String nickname) {
nicknames[0] = nickname;
}
};
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testExecutionException(@Mocked final JDBCDatabaseMetaData meta,
@Mocked final JDBCResultSet resultSet) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDataba... | #fixed code
@Test
public void testExecutionException(@Mocked final JDBCDatabaseMetaData meta,
@Mocked final JDBCResultSet resultSet) {
try {
new Expectations() {
{
// prevent calls to functions that also call resultSet.next
meta.getDatabaseProd... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCommandHandlerOnStartup() {
SqlLine sqlLine = new SqlLine();
ByteArrayOutputStream os = new ByteArrayOutputStream();
final String[] args = {
"-e", "!set maxwidth 80",
"-ch", "sqlline.extensions.HelloWorldCommandHandler"}... | #fixed code
@Test
public void testCommandHandlerOnStartup() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
final String[] args = {
"-e", "!set maxwidth 80",
"-ch", "sqlline.extensions.HelloWorldCommandHandler"};
begin(sqlLine, os, false, args);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void begin(String [] args, InputStream inputStream)
throws IOException
{
try {
// load the options first, so we can override on the command line
command.load(null, null);
opts.load();
} catch (Exception e) ... | #fixed code
SqlLine()
{
// registerKnownDrivers ();
sqlLineCommandCompleter = new SQLLineCommandCompleter();
// attempt to dynamically load signal handler
try {
Class handlerClass = Class.forName("sqlline.SunSignalHandler");
s... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSetNonIntValuesToIntProperties() {
SqlLine sqlLine = new SqlLine();
final String headerIntervalScript = "!set headerinterval abc\n";
checkScriptFile(headerIntervalScript, false, equalTo(SqlLine.Status.OK),
containsString(sqlLine... | #fixed code
@Test
public void testSetNonIntValuesToIntProperties() {
final String headerIntervalScript = "!set headerinterval abc\n";
checkScriptFile(headerIntervalScript, true, equalTo(SqlLine.Status.OK),
containsString(sqlLine.loc("not-a-number", "headerinterval", "abc"... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testConnectWithDbPropertyAsParameter() {
SqlLine beeLine = new SqlLine();
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(beeLine, os, false, "-e", "!set maxwidth 80");
assertTh... | #fixed code
@Test
public void testConnectWithDbPropertyAsParameter() {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
SqlLine.Status status =
begin(sqlLine, os, false, "-e", "!set maxwidth 80");
assertThat(status, equalTo(SqlLine.Status.OK));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
void generatedBeanWithFluentSetterShouldBeCorrectlyPopulated() {
// when
FluentSetterBean fluentSetterBean = easyRandom.nextObject(FluentSetterBean.class);
// then
assertThat(fluentSetterBean.getName()).isNotEmpty();
}
... | #fixed code
@Test
void generatedBeanWithFluentSetterShouldBeCorrectlyPopulated() {
// when
ChainedSetterBean chainedSetterBean = easyRandom.nextObject(ChainedSetterBean.class);
// then
assertThat(chainedSetterBean.getName()).isNotEmpty();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Populator getPopulatorFromSpringContext(String contextFileName) {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextFileName);
return applicationContext.getBean(Populator.class);
}
... | #fixed code
private Populator getPopulatorFromSpringContext(String contextFileName) {
try (AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextFileName)) {
return applicationContext.getBean(Populator.class);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Randomizer<?> getRandomizer(Field field) {
Class<?> fieldType = field.getType();
Pattern patternAnnotation = getAnnotation(field, Pattern.class);
final String regex = patternAnnotation.regexp();
if (fieldType.equals(String.class))... | #fixed code
public Randomizer<?> getRandomizer(Field field) {
Class<?> fieldType = field.getType();
Pattern patternAnnotation = io.github.benas.randombeans.util.ReflectionUtils
.getAnnotation(field, Pattern.class);
final String regex = patternAnno... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public <T> List<T> populateBeans(final Class<T> type, final String... excludeFieldsName) {
byte size = (byte) Math.abs((Byte) DefaultRandomizer.getRandomValue(Byte.TYPE));
return populateBeans(type, size, excludeFieldsName);
}
... | #fixed code
@Override
public <T> List<T> populateBeans(final Class<T> type, final String... excludeFieldsName) {
int size = new RandomDataGenerator().nextInt(1, Short.MAX_VALUE);
return populateBeans(type, size, excludeFieldsName);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
void customRegistryTest() {
// given
class Salary {
@Digits(integer = 2, fraction = 2) // OSS developer salary.. :-)
private BigDecimal amount;
}
EasyRandomParameters parameters = new EasyRandomP... | #fixed code
@Test
void customRegistryTest() {
// given
class Amount {
@NotNull
@Digits(integer = 12, fraction = 3)
protected BigDecimal amount;
}
class DiscountEffect {
@Digits(integer = 6, fraction = 4)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
Object getRandomPrimitiveArray(final Class<?> primitiveType) {
int size = abs(aNewByteRandomizer().getRandomValue());
// TODO A bounty will be offered to anybody that comes with a generic template method for that..
if (primitiveType.equals(Byte.T... | #fixed code
ArrayPopulator(final EnhancedRandomImpl enhancedRandom) {
this.enhancedRandom = enhancedRandom;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldGenerateTheSameValueForTheSameSeed() {
String javaVersion = System.getProperty("java.specification.version");
if (javaVersion.startsWith("9") || javaVersion.startsWith("10")) {
assertThat(aNewLocaleRandomizer(SEED)... | #fixed code
@Test
public void shouldGenerateTheSameValueForTheSameSeed() {
BigDecimal javaVersion = new BigDecimal(System.getProperty("java.specification.version"));
if (javaVersion.compareTo(new BigDecimal("11")) >= 0) {
assertThat(aNewLocaleRandomizer(SE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldGenerateTheSameValueForTheSameSeed() {
if (System.getProperty("java.specification.version").startsWith("9")) {
assertThat(aNewLocaleRandomizer(SEED).getRandomValue()).isEqualTo(new Locale("sw", "ke"));
} else {
... | #fixed code
@Test
public void shouldGenerateTheSameValueForTheSameSeed() {
String javaVersion = System.getProperty("java.specification.version");
if (javaVersion.startsWith("9") || javaVersion.startsWith("10")) {
assertThat(aNewLocaleRandomizer(SEED).getRa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetDeclaredFields() throws Exception {
String javaVersion = System.getProperty("java.specification.version");
if (javaVersion.startsWith("9") || javaVersion.startsWith("10")) {
assertThat(ReflectionUtils.getDeclaredF... | #fixed code
@Test
public void testGetDeclaredFields() throws Exception {
BigDecimal javaVersion = new BigDecimal(System.getProperty("java.specification.version"));
if (javaVersion.compareTo(new BigDecimal("9")) >= 0) {
assertThat(ReflectionUtils.getDeclare... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Randomizer<?> getRandomizer(Field field) {
Class<?> fieldType = field.getType();
Size sizeAnnotation = getAnnotation(field, Size.class);
final int min = sizeAnnotation.min();
final int max = sizeAnnotation.max();
if (field... | #fixed code
public Randomizer<?> getRandomizer(Field field) {
Class<?> fieldType = field.getType();
Size sizeAnnotation = io.github.benas.randombeans.util.ReflectionUtils
.getAnnotation(field, Size.class);
final int min = sizeAnnotation.min();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetDeclaredFields() throws Exception {
if (System.getProperty("java.specification.version").startsWith("9")) {
assertThat(ReflectionUtils.getDeclaredFields(Street.class)).hasSize(22);
} else {
assertThat(... | #fixed code
@Test
public void testGetDeclaredFields() throws Exception {
String javaVersion = System.getProperty("java.specification.version");
if (javaVersion.startsWith("9") || javaVersion.startsWith("10")) {
assertThat(ReflectionUtils.getDeclaredFields(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testJPopulatorFactoryBeanWithCustomRandomizers() {
ApplicationContext applicationContext =
new ClassPathXmlApplicationContext("/application-context-with-custom-randomizers.xml");
Populator populator = (Populator) a... | #fixed code
@Test
public void testJPopulatorFactoryBeanWithCustomRandomizers() {
Populator populator = getPopulatorFromSpringContext("/application-context-with-custom-randomizers.xml");
// the populator managed by spring should be correctly configured
assert... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
synchronized (messageInfo) {
if (messageIsRequest) {
boolean isRequestChanged = false;
MessageEditor editer = new MessageEditor(messageIsRequ... | #fixed code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
if (messageIsRequest) {
Getter getter = new Getter(helpers);
URL url = getter.getURL(messageInfo);
String host = getter.getHost(messageInfo);
Stri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
synchronized (messageInfo) {
if (messageIsRequest) {
boolean isRequestChanged = false;
MessageEditor editer = new MessageEditor(messageIsRequ... | #fixed code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
if (messageIsRequest) {
Getter getter = new Getter(helpers);
URL url = getter.getURL(messageInfo);
String host = getter.getHost(messageInfo);
Stri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getHTTPBasicCredentials(IHttpRequestResponse messageInfo) throws Exception{
String authHeader = getHeaderValue(true, messageInfo, "Authorization").trim();
String[] parts = authHeader.split("\\s");
if (parts.length != 2)
... | #fixed code
public String getHTTPBasicCredentials(IHttpRequestResponse messageInfo) throws Exception{
String authHeader = getHeaderValueOf(true, messageInfo, "Authorization").trim();
String[] parts = authHeader.split("\\s");
if (parts.length != 2)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
synchronized (messageInfo) {
if (messageIsRequest) {
boolean isRequestChanged = false;
MessageEditor editer = new MessageEditor(messageIsRequ... | #fixed code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
if (messageIsRequest) {
Getter getter = new Getter(helpers);
URL url = getter.getURL(messageInfo);
String host = getter.getHost(messageInfo);
Stri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> possibleHeaderNames(IContextMenuInvocation invocation) {
IHttpRequestResponse[] selectedItems = invocation.getSelectedMessages();
//byte selectedInvocationContext = invocation.getInvocationContext();
Getter getter = new Getter(burp.callbacks.getHe... | #fixed code
public List<String> possibleHeaderNames(IContextMenuInvocation invocation) {
IHttpRequestResponse[] selectedItems = invocation.getSelectedMessages();
//byte selectedInvocationContext = invocation.getInvocationContext();
Getter getter = new Getter(burp.callbacks.getHelpers(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void removeRows(int[] rows) {
PrintWriter stdout1 = new PrintWriter(BurpExtender.callbacks.getStdout(), true);
synchronized (configEntries) {
//because thread let the delete action not in order, so we must loop in here.
//list length and index changed afte... | #fixed code
public void removeRows(int[] rows) {
PrintWriter stdout1 = new PrintWriter(BurpExtender.callbacks.getStdout(), true);
synchronized (configEntries) {
//because thread let the delete action not in order, so we must loop in here.
//list length and index changed after ever... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void startCmdConsole() {
try {
Process process = null;
if (Utils.isWindows()) {
process = Runtime.getRuntime().exec("cmd /c start cmd.exe");
} else {
if (new File("/bin/sh").exists()) {
Runtime.getRuntime().exec("/bin/sh");
}else i... | #fixed code
public static void startCmdConsole() {
try {
Process process = null;
if (Utils.isWindows()) {
process = Runtime.getRuntime().exec("cmd /c start cmd.exe");
} else if (Utils.isMac()){
process = Runtime.getRuntime().exec("open -n -F -a /Applications/Utilities/Ter... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getHTTPBasicCredentials(IHttpRequestResponse messageInfo) throws Exception{
String authHeader = getHeaderValueOf(true, messageInfo, "Authorization").trim();
String[] parts = authHeader.split("\\s");
if (parts.length != 2)... | #fixed code
public String getHTTPBasicCredentials(IHttpRequestResponse messageInfo) throws Exception{
String authHeader = getHeaderValueOf(true, messageInfo, "Authorization").trim();
String[] parts = authHeader.split("\\s");
if (parts.length != 2)
throw new Exception("Wrong numbe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> possibleHeaderNames(IContextMenuInvocation invocation) {
IHttpRequestResponse[] selectedItems = invocation.getSelectedMessages();
//byte selectedInvocationContext = invocation.getInvocationContext();
Getter getter = new Getter(burp.callbacks.getHe... | #fixed code
public List<String> possibleHeaderNames(IContextMenuInvocation invocation) {
IHttpRequestResponse[] selectedItems = invocation.getSelectedMessages();
//byte selectedInvocationContext = invocation.getInvocationContext();
Getter getter = new Getter(burp.callbacks.getHelpers(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
if (messageIsRequest){
boolean isRequestChanged = false;
MessageEditor editer = new MessageEditor(messageIsRequest,messageInfo,helpers)... | #fixed code
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) {
synchronized (messageInfo) {
if (messageIsRequest) {
String firstRequest = new String(messageInfo.getRequest());
int code = messageInfo.hashCode();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void readClasspathResource() {
boolean ok = true;
ok |= Str.in ("apple", IO.read ( "classpath://testfile.txt" ))
|| die( "two slashes should work" );
//Proper URL
ok |= Str.in ("apple", IO.read ( "clas... | #fixed code
@Test
public void readClasspathResource() {
boolean ok = true;
ok |= Str.in ("apple", IO.read ( "classpath://testfile.txt" ))
|| die( "two slashes should work" );
//Proper URL
ok |= Str.in ("apple", IO.read ( "classpath:... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void readClasspathResource() {
boolean ok = true;
ok |= Str.in ("apple", IO.read ( "classpath://testfile.txt" ))
|| die( "two slashes should work" );
//Proper URL
ok |= Str.in ("apple", IO.read ( "clas... | #fixed code
@Test
public void readClasspathResource() {
boolean ok = true;
ok |= Str.in ("apple", IO.read ( "classpath://testfile.txt" ))
|| die( "two slashes should work" );
//Proper URL
ok |= Str.in ("apple", IO.read ( "classpath:... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Map<String, Pair<Method>> getPropertySetterGetterMethods(
Class<? extends Object> theClass ) {
Method[] methods = theClass.getMethods ( );
Map<String, Pair<Method>> methodMap = new LinkedHashMap<> ( methods.length );
L... | #fixed code
public static Map<String, Pair<Method>> getPropertySetterGetterMethods(
Class<? extends Object> theClass ) {
Method[] methods = theClass.getMethods ( );
Map<String, Pair<Method>> methodMap = new LinkedHashMap<> ( methods.length );
List<Me... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void readClasspathResource() {
boolean ok = true;
ok |= Str.in ("apple", IO.read ( "classpath://testfile.txt" ))
|| die( "two slashes should work" );
//Proper URL
ok |= Str.in ("apple", IO.read ( "clas... | #fixed code
@Test
public void readClasspathResource() {
boolean ok = true;
ok |= Str.in ("apple", IO.read ( "classpath://testfile.txt" ))
|| die( "two slashes should work" );
//Proper URL
ok |= Str.in ("apple", IO.read ( "classpath:... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void doExecute()
throws MojoExecutionException, MojoFailureException
{
setup();
boolean generated = false;
// java -cp gwt-dev.jar:gwt-user.jar
// com.google.gwt.resources.css.InterfaceGenerator -standalone -typeName s... | #fixed code
public void doExecute()
throws MojoExecutionException, MojoFailureException
{
setup();
boolean generated = false;
// java -cp gwt-dev.jar:gwt-user.jar
// com.google.gwt.resources.css.InterfaceGenerator -standalone -typeName some.pa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void doExecute()
throws MojoExecutionException, MojoFailureException
{
setup();
boolean generated = false;
// java -cp gwt-dev.jar:gwt-user.jar
// com.google.gwt.resources.css.InterfaceGenerator -standalone -typeName s... | #fixed code
public void doExecute()
throws MojoExecutionException, MojoFailureException
{
setup();
boolean generated = false;
// java -cp gwt-dev.jar:gwt-user.jar
// com.google.gwt.resources.css.InterfaceGenerator -standalone -typeName some.pa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void profile() throws IOException {
BaseConfiguration config = new BaseConfiguration();
config.addProperty(Graph.GRAPH, ElasticGraph.class.getName());
config.addProperty("elasticsearch.cluster.name", "test");
String index... | #fixed code
@Test
public void profile() throws IOException {
BaseConfiguration config = new BaseConfiguration();
config.addProperty(Graph.GRAPH, ElasticGraph.class.getName());
config.addProperty("elasticsearch.cluster.name", "test");
config.addProperty... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void hasNot() throws IOException {
BaseConfiguration config = new BaseConfiguration();
config.addProperty(Graph.GRAPH, ElasticGraph.class.getName());
config.addProperty("elasticsearch.cluster.name", "test2");
String index... | #fixed code
@Test
public void hasNot() throws IOException {
BaseConfiguration config = new BaseConfiguration();
config.addProperty("elasticsearch.cluster.name", "test");
config.addProperty("elasticsearch.index.name", "graph");
config.addProperty("elast... | 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.