output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
@Test
void resolveFieldOfEnumAsInternalClassOfInterfaceUnqualifiedDifferentPackage() throws IOException {
File src = new File("src/test/resources/internalClassInInterface");
File aClass = new File(src.getPath() + File.separator + "foo" + File.separator + "... | #vulnerable code
@Test
void resolveFieldOfEnumAsInternalClassOfInterfaceUnqualifiedDifferentPackage() throws IOException {
File src = new File("src/test/resources/internalClassInInterface");
File aClass = new File(src.getPath() + File.separator + "foo" + File.separat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void issue506() throws IOException {
ensureAllNodesHaveValidBeginPosition( "SourcesHelperOldVersion.java.txt" );
} | #vulnerable code
@Test
public void issue506() throws IOException {
InputStream is = this.getClass().getResourceAsStream("/com/github/javaparser/SourcesHelperOldVersion.java.txt");
ParseResult<CompilationUnit> res = new JavaParser().parse(ParseStart.COMPILATION_UNIT, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Generated("com.github.javaparser.generator.core.visitor.NoCommentHashCodeVisitorGenerator")
public Integer visit(final ConstructorDeclaration n, final Void arg) {
return (n.getBody().accept(this, arg)) * 31 + (n.getModifiers().hashCode()) * 31 + (n.getName().acce... | #vulnerable code
@Generated("com.github.javaparser.generator.core.visitor.NoCommentHashCodeVisitorGenerator")
public Integer visit(final ConstructorDeclaration n, final Void arg) {
return (n.getBody().accept(this, arg)) * 31 + (n.getModifiers().hashCode()) * 31 + (n.getName(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public CommentsCollection parse(final InputStream in, final String encoding) throws IOException, UnsupportedEncodingException {
boolean lastWasASlashR = false;
BufferedReader br = new BufferedReader(new InputStreamReader(in));
CommentsCollection commen... | #vulnerable code
public CommentsCollection parse(final InputStream in, final String encoding) throws IOException, UnsupportedEncodingException {
boolean lastWasASlashR = false;
BufferedReader br = new BufferedReader(new InputStreamReader(in));
CommentsCollection ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void solve(Path path) throws IOException {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.toString()... | #vulnerable code
public void solve(Path path) throws IOException {
File file = path.toFile();
if (file.isDirectory()) {
for (File f : file.listFiles()) {
solve(f.toPath());
}
} else {
if (file.getName().endsWith... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
void resolveFieldOfEnumAsInternalClassOfClassQualifiedSamePackage() throws IOException {
File src = new File("src/test/resources/enumLiteralsInAnnotatedClass");
File aClass = new File(src.getPath() + File.separator + "foo" + File.separator + "bar"
... | #vulnerable code
@Test
void resolveFieldOfEnumAsInternalClassOfClassQualifiedSamePackage() throws IOException {
File src = new File("src/test/resources/enumLiteralsInAnnotatedClass");
File aClass = new File(src.getPath() + File.separator + "foo" + File.separator + "b... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsMappingSettingAndTheMappingsProvided() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, fals... | #vulnerable code
@Test
public void handleAllFieldsMappingSettingAndTheMappingsProvided() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void returnAllFieldsAndApplyMappings() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", Schema.INT32_SCHE... | #vulnerable code
@Test
public void returnAllFieldsAndApplyMappings() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", Schema.INT3... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldReturnThePrimaryKeysAtTheEndWhenMultipleFieldsFormThePrimaryKey() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
... | #vulnerable code
@Test
public void shouldReturnThePrimaryKeysAtTheEndWhenMultipleFieldsFormThePrimaryKey() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void returnAllFieldsAndTheirBytesValue() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", Schema.INT32_SCHE... | #vulnerable code
@Test
public void returnAllFieldsAndTheirBytesValue() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", Schema.INT3... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsMappingSettingAndTheMappingsProvided() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, fals... | #vulnerable code
@Test
public void handleAllFieldsMappingSettingAndTheMappingsProvided() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void returnAllFieldsAndApplyMappings() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", Schema.INT32_SCHE... | #vulnerable code
@Test
public void returnAllFieldsAndApplyMappings() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", Schema.INT3... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsMappingSetting() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
DbTable ta... | #vulnerable code
@Test
public void handleAllFieldsMappingSetting() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
DbTa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = ConfigException.class)
public void throwAnExceptionWhenForANewTableToCreateWhichDoesNotAllowAutoCreation() throws SQLException {
Database changesExecutor = new Database(new HashSet<String>(),
new HashSet<String>(),
new DatabaseMeta... | #vulnerable code
@Test(expected = ConfigException.class)
public void throwAnExceptionWhenForANewTableToCreateWhichDoesNotAllowAutoCreation() throws SQLException {
Database changesExecutor = new Database(new HashSet<String>(),
new HashSet<String>(),
new Databa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsIncludedAndAnExistingMapping() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
... | #vulnerable code
@Test
public void handleAllFieldsIncludedAndAnExistingMapping() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleBatchedStatementPerRecordInsertingSameRecord100Times() throws SQLException {
String tableName = "batched_statement_test_100";
String createTable = "CREATE TABLE " + tableName + " (" +
" firstName TEXT," +
" lastNa... | #vulnerable code
@Test
public void handleBatchedStatementPerRecordInsertingSameRecord100Times() throws SQLException {
String tableName = "batched_statement_test_100";
String createTable = "CREATE TABLE " + tableName + " (" +
" firstName TEXT," +
" ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldReturnThePrimaryKeysAtTheEndWhenOneFieldIsPK() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("age", ... | #vulnerable code
@Test
public void shouldReturnThePrimaryKeysAtTheEndWhenOneFieldIsPK() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
.field("... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsIncludedAndAnExistingMapping() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
... | #vulnerable code
@Test
public void handleAllFieldsIncludedAndAnExistingMapping() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleBatchedStatementPerRecordInsertingSameRecord100Times() throws SQLException {
String tableName = "batched_statement_test_100";
String createTable = "CREATE TABLE " + tableName + " (" +
" firstName TEXT," +
" lastNa... | #vulnerable code
@Test
public void handleBatchedStatementPerRecordInsertingSameRecord100Times() throws SQLException {
String tableName = "batched_statement_test_100";
String createTable = "CREATE TABLE " + tableName + " (" +
" firstName TEXT," +
" ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsMappingSetting() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
DbTable ta... | #vulnerable code
@Test
public void handleAllFieldsMappingSetting() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
DbTa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldReturnThePrimaryKeysAtTheEndWhenMultipleFieldsFormThePrimaryKey() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
... | #vulnerable code
@Test
public void shouldReturnThePrimaryKeysAtTheEndWhenMultipleFieldsFormThePrimaryKey() {
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.STRING_SCHEMA)
.field("lastName", Schema.STRING_SCHEMA)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleBatchStatementPerRecordInsertingWithAutoCreatedColumnForPK() throws SQLException {
String tableName = "batch_100_auto_create_column";
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schema.OPTI... | #vulnerable code
@Test
public void handleBatchStatementPerRecordInsertingWithAutoCreatedColumnForPK() throws SQLException {
String tableName = "batch_100_auto_create_column";
Schema schema = SchemaBuilder.struct().name("com.example.Person")
.field("firstName", Schem... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void handleAllFieldsMappingSetting() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
DbTable ta... | #vulnerable code
@Test
public void handleAllFieldsMappingSetting() {
List<DbTableColumn> columns = Lists.newArrayList(
new DbTableColumn("col1", true, false, 1),
new DbTableColumn("col2", false, false, 1),
new DbTableColumn("col3", false, false, 1));
DbTa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void listenForEventPackets() throws IOException {
ByteArrayInputStream inputStream = channel.getInputStream();
try {
while (inputStream.peek() != -1) {
int packetLength = inputStream.readInteger(3);
inputStre... | #vulnerable code
private void listenForEventPackets() throws IOException {
ByteArrayInputStream inputStream = channel.getInputStream();
try {
while (inputStream.peek() != -1) {
int packetLength = inputStream.readInteger(3);
inp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void listenForEventPackets() throws IOException {
latch.countDown();
ByteArrayInputStream inputStream = channel.getInputStream();
try {
while (true) {
try {
inputStream.peek();
} c... | #vulnerable code
private void listenForEventPackets() throws IOException {
latch.countDown();
ByteArrayInputStream inputStream = channel.getInputStream();
while (channel.isOpen()) {
int packetLength = inputStream.readInteger(3);
inputStrea... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
try {
try {
Socket socket = socketFactory != null ? socketFactory.createSocke... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
try {
try {
Socket socket = socketFactory != null ? socketFactory.creat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void disconnect() throws IOException {
terminateKeepAliveThread();
terminateConnect();
} | #vulnerable code
public void disconnect() throws IOException {
shutdownLock.lock();
try {
if (isKeepAliveThreadRunning()) {
keepAliveThreadExecutor.shutdownNow();
}
disconnectChannel();
} finally {
s... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void connect() throws IOException {
if (!connectLock.tryLock()) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
boolean notifyWhenDisconnected = false;
try {
try {
chan... | #vulnerable code
public void connect() throws IOException {
if (connected) {
throw new IllegalStateException("BinaryLogClient is already connected");
}
GreetingPacket greetingPacket;
try {
try {
Socket socket = sock... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testChecksumNONE() throws Exception {
EventDeserializer eventDeserializer = new EventDeserializer();
BinaryLogFileReader reader = new BinaryLogFileReader(
new FileInputStream("src/test/resources/mysql-bin.checksum-none"), ... | #vulnerable code
@Test
public void testChecksumNONE() throws Exception {
EventDeserializer eventDeserializer = new EventDeserializer();
BinaryLogFileReader reader = new BinaryLogFileReader(new GZIPInputStream(
new FileInputStream("src/test/resources/m... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void disconnect() throws IOException {
shutdownLock.lock();
try {
if (isKeepAliveThreadRunning()) {
keepAliveThreadExecutor.shutdownNow();
}
disconnectChannel();
} finally {
shutdow... | #vulnerable code
public void disconnect() throws IOException {
try {
connected = false;
if (channel != null) {
channel.close();
}
} finally {
synchronized (lifecycleListeners) {
for (Lifecycl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<WordFrequency> loadFrequencies(final String input) {
try {
final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
frequencyAnalyzer.setWordFrequenciesToReturn(cliParameters.getWordCount());
frequencyAnalyz... | #vulnerable code
private List<WordFrequency> loadFrequencies(final String input) {
try {
final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
frequencyAnalyzer.setWordFrequenciesToReturn(cliParameters.getWordCount());
frequency... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void preOperation(AipRequest request) {
if (needAuth()) {
getAccessToken(config);
}
request.setHttpMethod(HttpMethodName.POST);
request.addHeader(Headers.CONTENT_TYPE, HttpContentType.FORM_URLENCODE_DATA);
request... | #vulnerable code
protected void preOperation(AipRequest request) {
if (needAuth()) {
getAccessToken();
}
request.setHttpMethod(HttpMethodName.POST);
request.addHeader(Headers.CONTENT_TYPE, HttpContentType.FORM_URLENCODE_DATA);
request... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSyncHandleTimeout() throws Exception {
RpcFuture<String> rpcFuture = new RpcFuture<String>(timeout, methodInfo, null, channelInfo, rpcClient);
try {
rpcFuture.get(100, TimeUnit.MILLISECONDS);
} catch (RpcException ... | #vulnerable code
@Test
public void testSyncHandleTimeout() throws Exception {
RpcFuture rpcFuture = new RpcFuture<String>(timeout, methodInfo, null, channelInfo, rpcClient);
Response resp = rpcFuture.get(100, TimeUnit.MILLISECONDS);
assertThat(resp.getExcepti... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Response decodeResponse(Object msg, ChannelHandlerContext ctx) {
FullHttpResponse httpResponse = (FullHttpResponse) msg;
try {
ChannelInfo channelInfo = ChannelInfo.getClientChannelInfo(ctx.channel());
Long correlat... | #vulnerable code
@Override
public Response decodeResponse(Object msg, ChannelHandlerContext ctx) {
FullHttpResponse httpResponse = (FullHttpResponse) msg;
try {
ChannelInfo channelInfo = ChannelInfo.getClientChannelInfo(ctx.channel());
Long lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSyncHandleSuccessfulResponse() throws Exception {
RpcFuture<String> rpcFuture = new RpcFuture<String>(timeout, methodInfo, null, channelInfo, rpcClient);
RpcResponse response = new RpcResponse();
response.setResult("hello worl... | #vulnerable code
@Test
public void testSyncHandleSuccessfulResponse() throws Exception {
RpcFuture rpcFuture = new RpcFuture<String>(timeout, methodInfo, null, channelInfo, rpcClient);
RpcResponse response = new RpcResponse();
response.setResult("hello world"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public ThreadPool getOrCreateClientWorkThreadPool(String serviceName, boolean isSharing, int threadNum) {
if (isSharing) {
if (defaultWorkThreadPool == null) {
synchronized (BrpcThreadPoolManager.class) {
if (defaultWork... | #vulnerable code
public ThreadPool getOrCreateClientWorkThreadPool(String serviceName, boolean isSharing, int threadNum) {
if (isSharing) {
if (defaultWorkThreadPool == null) {
synchronized (BrpcThreadPoolManager.class) {
if (defau... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void parseRpcExporterAnnotation(RpcExporter rpcExporter,
ConfigurableListableBeanFactory beanFactory,
Object bean) {
Class<?> serviceClass = AopUtils.getTargetClass(bean);
... | #vulnerable code
private void parseRpcExporterAnnotation(RpcExporter rpcExporter,
ConfigurableListableBeanFactory beanFactory,
Object bean) {
Class<?> serviceClass = AopUtils.getTargetClass(b... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public EventLoopGroup getOrCreateClientIoThreadPool(String serviceName, boolean isSharing,
int threadNum, int ioEventType) {
if (isSharing) {
if (defaultIoThreadPool == null) {
synchronized ... | #vulnerable code
public EventLoopGroup getOrCreateClientIoThreadPool(String serviceName, boolean isSharing,
int threadNum, int ioEventType) {
if (isSharing) {
if (defaultIoThreadPool == null) {
synchro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public ByteBuf encodeResponse(Request request, Response response) {
FullHttpRequest httpRequest = (FullHttpRequest) request.getMsg();
FullHttpResponse httpResponse = null;
try {
byte[] responseBytes;
if (response.... | #vulnerable code
@Override
public ByteBuf encodeResponse(Request request, Response response) {
FullHttpRequest httpRequest = (FullHttpRequest) request.getMsg();
FullHttpResponse httpResponse = null;
try {
if (response.getException() != null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Response executeWithRetry(Request request) {
Response response = null;
RpcException exception = null;
int currentTryTimes = 0;
int maxTryTimes = rpcClient.getRpcClientOptions().getMaxTryTimes();
while (currentTryTimes < maxTryTim... | #vulnerable code
public Response executeWithRetry(Request request) {
Response response = null;
RpcException exception = null;
int currentTryTimes = 0;
int maxTryTimes = rpcClient.getRpcClientOptions().getMaxTryTimes();
while (currentTryTimes < max... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSyncHandleFailResponse() throws Exception {
RpcFuture<String> rpcFuture = new RpcFuture<String>(timeout, methodInfo, null, channelInfo, rpcClient);
RpcResponse response = new RpcResponse();
RuntimeException ex = new RuntimeExc... | #vulnerable code
@Test
public void testSyncHandleFailResponse() throws Exception {
RpcFuture rpcFuture = new RpcFuture<String>(timeout, methodInfo, null, channelInfo, rpcClient);
RpcResponse response = new RpcResponse();
RuntimeException ex = new RuntimeExcep... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public VerbalExpression replace(String source, String value) {
this.updatePattern();
this.source.replaceAll(pattern,value);
return this;
} | #vulnerable code
public VerbalExpression replace(String source, String value) {
this.add("");
this.source.replaceAll(pattern,value);
return this;
}
#location 3
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void collectLibraryInputFiles()
{
if ( parsedIncludeJdkLibs )
{
final String slash = File.separator;
// we have to add the Java framework classes to the library JARs, since they are not
// distributed with the JA... | #vulnerable code
private void collectLibraryInputFiles()
{
if ( parsedIncludeJdkLibs )
{
final String slash = File.separator;
// we have to add the Java framework classes to the library JARs, since they are not
// distributed with ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public File getPlatform()
{
assertPathIsDirectory( sdkPath );
final File platformsDirectory = new File( sdkPath, PLATFORMS_FOLDER_NAME );
assertPathIsDirectory( platformsDirectory );
final File platformDirectory;
if ( androidTarge... | #vulnerable code
public File getPlatform()
{
assertPathIsDirectory( sdkPath );
final File platformsDirectory = new File( sdkPath, PLATFORMS_FOLDER_NAME );
assertPathIsDirectory( platformsDirectory );
final File platformDirectory;
if ( platfo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void execute() throws MojoExecutionException, MojoFailureException {
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(this.getLog());
if (androidManifestFile == null) {
androidM... | #vulnerable code
public void execute() throws MojoExecutionException, MojoFailureException {
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(this.getLog());
if (androidManifestFile == null) {
an... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void collectLibraryInputFiles()
{
if ( parsedIncludeJdkLibs )
{
// we have to add the Java framework classes to the library JARs, since they are not
// distributed with the JAR on Central, and since we'll strip them out of t... | #vulnerable code
private void collectLibraryInputFiles()
{
if ( parsedIncludeJdkLibs )
{
final String slash = File.separator;
// we have to add the Java framework classes to the library JARs, since they are not
// distributed with ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void runLint() throws MojoExecutionException
{
IssueRegistry registry = new BuiltinIssueRegistry();
LintCliFlags flags = new LintCliFlags();
flags.setQuiet( false );
LintCliClient client = new LintCliClient( flags );
try
... | #vulnerable code
private void runLint()
{
IssueRegistry registry = new BuiltinIssueRegistry();
LintCliFlags flags = new LintCliFlags();
flags.setQuiet( false );
LintCliClient client = new LintCliClient( flags );
File outHtmlFile = new File( ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public MakefileHolder createMakefileFromArtifacts( File outputDir, Set<Artifact> artifacts,
String ndkArchitecture,
boolean useHeaderArchives )
... | #vulnerable code
public MakefileHolder createMakefileFromArtifacts( File outputDir, Set<Artifact> artifacts,
String ndkArchitecture,
boolean useHeaderArchives )
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void generateBuildConfig() throws MojoExecutionException
{
getLog().debug( "Generating BuildConfig file" );
// Create the BuildConfig for our package.
String packageName = extractPackageNameFromAndroidManifest( androidManifestFile );
... | #vulnerable code
private void generateBuildConfig() throws MojoExecutionException
{
getLog().debug( "Generating BuildConfig file" );
// Create the BuildConfig for our package.
String packageName = extractPackageNameFromAndroidManifest( androidManifestFile );... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public MakefileHolder createMakefileFromArtifacts( File outputDir, Set<Artifact> artifacts,
String ndkArchitecture,
boolean useHeaderArchives )
... | #vulnerable code
public MakefileHolder createMakefileFromArtifacts( File outputDir, Set<Artifact> artifacts,
String ndkArchitecture,
boolean useHeaderArchives )
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void performVersionCodeUpdateFromVersion( Element manifestElement )
{
String verString = project.getVersion();
getLog().debug( "Generating versionCode for " + verString );
String verCode = generateVersionCodeFromVersionName( verString );
... | #vulnerable code
private void performVersionCodeUpdateFromVersion( Element manifestElement )
{
String verString = project.getVersion();
getLog().debug( "Generating versionCode for " + verString );
ArtifactVersion artifactVersion = new DefaultArtifactVersion( ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void updateWithMetaInf( ZipOutputStream zos, File jarFile, Set<String> entries, boolean metaInfOnly )
throws ZipException, IOException
{
ZipFile zin = new ZipFile( jarFile );
for( Enumeration<? extends ZipEntry> en = zin.entries(); en.hasMoreElements(); ) {
Zip... | #vulnerable code
private void updateWithMetaInf( ZipOutputStream zos, File jarFile, Set<String> entries, boolean metaInfOnly )
throws ZipException, IOException
{
ZipFile zin = new ZipFile( jarFile );
for( Enumeration<? extends ZipEntry> en = zin.entries(); en.hasMoreElements(); ) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testTokenFilter() throws IOException{
StringReader sr = new StringReader("刘德华");
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_41);
PinyinTokenFilter filter = new PinyinTokenFilter(analyzer.tokenStream("f",sr),"","none")... | #vulnerable code
@Test
public void testTokenFilter() throws IOException{
StringReader sr = new StringReader("刘德华");
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_36);
PinyinTokenFilter filter = new PinyinTokenFilter(analyzer.tokenStream("f",sr),"","... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public V put(K key, V value) {
return (V)doOp(ClusterOperation.CONCURRENT_MAP_PUT, Serializer.toByte(key), Serializer.toByte(value));
} | #vulnerable code
public V put(K key, V value) {
Packet request = createRequestPacket();
request.setTxnId(0);
request.setOperation(ClusterOperation.CONCURRENT_MAP_PUT);
request.setKey(Serializer.toByte(key));
request.setValue(Serializer.toByte(value));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void process(Object obj) {
long processStart = System.nanoTime();
if (obj instanceof Invocation) {
Invocation inv = (Invocation) obj;
MemberImpl memberFrom = getMember(inv.conn.getEndPoint());
if (memberFrom != null) {
memberFrom.didRead();
}
int op... | #vulnerable code
public void process(Object obj) {
long processStart = System.nanoTime();
if (obj instanceof Invocation) {
Invocation inv = (Invocation) obj;
MemberImpl memberFrom = getMember(inv.conn.getEndPoint());
if (memberFrom != null) {
memberFrom.didRead();
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
while (running) {
Object obj = null;
try {
lsBuffer.clear();
queue.drainTo(lsBuffer);
int size = lsBuffer.size();
if (size > 0) {
for (int i = 0; i < size; i++) {
obj = lsBuffer.get(i);
checkHeartbeat();
process... | #vulnerable code
public void run() {
while (running) {
Object obj = null;
try {
lsBuffer.clear();
queue.drainTo(lsBuffer);
int size = lsBuffer.size();
if (size > 0) {
for (int i = 0; i < size; i++) {
obj = lsBuffer.get(i);
process(obj);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void handle(Invocation inv) {
try {
if (inv.operation == OP_RESPONSE) {
handleResponse(inv);
} else if (inv.operation == OP_REMOTELY_PROCESS_AND_RESPONSE) {
Data data = inv.doTake(inv.data);
RemotelyProcessable rp = (RemotelyProcessable) ThreadContext.... | #vulnerable code
public void handle(Invocation inv) {
try {
if (inv.operation == OP_RESPONSE) {
handleResponse(inv);
} else if (inv.operation == OP_BIND) {
Address addressEndPoint = (Address) inv.getValueObject();
ConnectionManager.get().bind(addressEndPoint, inv.conn);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public V get(Object key) {
return (V)doOp(ClusterOperation.CONCURRENT_MAP_GET, Serializer.toByte(key), null);
} | #vulnerable code
public V get(Object key) {
// MapGetCall mGet = new MapGetCall();
Packet request = createRequestPacket();
request.setOperation(ClusterOperation.CONCURRENT_MAP_GET);
request.setKey(Serializer.toByte(key));
Packet response = callAndGetResult(req... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
while (running) {
Object obj = null;
try {
lsBuffer.clear();
queue.drainTo(lsBuffer);
int size = lsBuffer.size();
if (size > 0) {
for (int i = 0; i < size; i++) {
obj = lsBuffer.get(i);
checkHeartbeat();
process... | #vulnerable code
public void run() {
while (running) {
Object obj = null;
try {
lsBuffer.clear();
queue.drainTo(lsBuffer);
int size = lsBuffer.size();
if (size > 0) {
for (int i = 0; i < size; i++) {
obj = lsBuffer.get(i);
process(obj);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void readData(DataInput in) throws IOException {
numberOfPuts = in.readLong();
numberOfGets = in.readLong();
numberOfRemoves = in.readLong();
numberOfOtherOperations = in.readLong();
periodStart = in.readLong();
periodEnd... | #vulnerable code
public void readData(DataInput in) throws IOException {
mapPuts.set(in.readLong());
mapGets.set(in.readLong());
mapRemoves.set(in.readLong());
startTime = in.readLong();
endTime = in.readLong();
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
boolean readPackets = false;
boolean readProcessables = false;
while (running) {
readPackets = (dequeuePackets() != 0);
readProcessables = (dequeueProcessables() != 0);
if (!readPackets && !readPr... | #vulnerable code
public void run() {
boolean readPackets = false;
boolean readProcessables = false;
while (running) {
readPackets = (dequeuePackets() != 0);
readProcessables = (dequeueProcessables() != 0);
if (!readPackets && !... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void reArrangeBlocks() {
if (concurrentMapManager.isMaster()) {
Map<Address, Integer> addressBlocks = getCurrentMemberBlocks();
if (addressBlocks.size() == 0) {
return;
}
List<Block> lsBlocksToRedistribut... | #vulnerable code
void migrateBlock(final Block blockInfo) {
if (!concurrentMapManager.isBlockInfoValid(blockInfo)) {
return;
}
if (!thisAddress.equals(blockInfo.getOwner())) {
throw new RuntimeException();
}
if (!blockInfo.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void syncForDead(Address addressDead) {
MemberImpl member = getNextMemberBeforeSync(addressDead, true, 1);
if (DEBUG) {
log(addressDead + " is dead and its backup was " + member);
}
Address addressNewOwner = (member == null) ? thisA... | #vulnerable code
void doPublish(Request req) {
Q q = getQ(req.name);
if (q.blCurrentPut == null) {
q.setCurrentPut();
}
int index = q.publish(req);
req.longValue = index;
req.response = Boolean.TRUE;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void reArrangeBlocks() {
if (concurrentMapManager.isMaster()) {
List<MemberImpl> lsMembers = concurrentMapManager.lsMembers;
// make sue that all blocks are actually created
for (int i = 0; i < BLOCK_COUNT; i++) {
Bl... | #vulnerable code
void migrateBlock(final Block block) {
if (!concurrentMapManager.isBlockInfoValid(block)) {
return;
}
if (!thisAddress.equals(block.getOwner())) {
throw new RuntimeException();
}
if (block.getMigrationAddre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void writeData(DataOutput out) throws IOException {
out.writeLong(numberOfPuts);
out.writeLong(numberOfGets);
out.writeLong(numberOfRemoves);
out.writeLong(numberOfOtherOperations);
out.writeLong(periodStart);
out.writeLo... | #vulnerable code
public void writeData(DataOutput out) throws IOException {
out.writeLong(mapPuts.get());
out.writeLong(mapGets.get());
out.writeLong(mapRemoves.get());
out.writeLong(startTime);
out.writeLong(endTime);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void readFrom(DataInputStream dis) throws IOException {
headerSize = dis.readInt();
keySize = dis.readInt();
valueSize = dis.readInt();
headerInBytes = new byte[headerSize];
dis.read(headerInBytes);
ByteArrayInputStream bis = new ByteArrayInputStream(hea... | #vulnerable code
public void readFrom(DataInputStream dis) throws IOException {
System.out.println("Available:" + dis.available());
headerSize = dis.readInt();
keySize = dis.readInt();
valueSize = dis.readInt();
headerInBytes = new byte[headerSize];
dis.read(headerInBytes);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void syncForDead(Address addressDead) {
MemberImpl member = getNextMemberBeforeSync(addressDead, true, 1);
if (DEBUG) {
log(addressDead + " is dead and its backup was " + member);
}
Address addressNewOwner = (member == null) ? thisA... | #vulnerable code
void doAddTopicListener(Request req) {
for (MemberImpl member : lsMembers) {
if (member.localMember()) {
handleListenerRegisterations(true, req.name, req.key, req.caller, true);
} else if (!member.getAddress().equals(req.c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void reArrangeBlocks() {
if (concurrentMapManager.isMaster()) {
Map<Address, Integer> addressBlocks = getCurrentMemberBlocks();
if (addressBlocks.size() == 0) {
return;
}
List<Block> lsBlocksToRedistribut... | #vulnerable code
void initiateMigration() {
for (int i = 0; i < BLOCK_COUNT; i++) {
Block block = blocks[i];
if (block == null) {
block = concurrentMapManager.getOrCreateBlock(i);
block.setOwner(thisAddress);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void readFrom(DataInputStream dis) throws IOException {
headerSize = dis.readInt();
keySize = dis.readInt();
valueSize = dis.readInt();
headerInBytes = new byte[headerSize];
dis.read(headerInBytes);
ByteArrayInputStream bis = new ByteArrayInputStream(hea... | #vulnerable code
public void readFrom(DataInputStream dis) throws IOException {
System.out.println("Available:" + dis.available());
headerSize = dis.readInt();
keySize = dis.readInt();
valueSize = dis.readInt();
headerInBytes = new byte[headerSize];
dis.read(headerInBytes);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long getPeriodEnd() {
return periodEnd;
} | #vulnerable code
public long getPeriodEnd() {
return endTime;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void describeAsAdditionalInfo_notEmpty() {
Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable();
addCompareException(exceptions);
assertExpectedFacts(
exceptions.describeAsAdditionalInfo(),
"additional... | #vulnerable code
@Test
public void describeAsAdditionalInfo_notEmpty() {
Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable();
addCompareException(exceptions);
assertExpectedFacts(
exceptions.describeAsAdditionalInfo().asIterable(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void hasField(String fieldName) {
if (getSubject() == null) {
failureStrategy.fail("Cannot determine a field name from a null object.");
return; // not all failures throw exceptions.
}
check().that(getSubject().getClass()).hasField(fieldName);
} | #vulnerable code
public void hasField(String fieldName) {
if (getSubject() == null) {
failWithoutSubject("<null> has a field named <" + fieldName + ">");
}
Class<?> clazz = getSubject().getClass();
try {
clazz.getField(fieldName);
} catch (NoSuchFieldExcept... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void describeAsAdditionalInfo_empty() {
Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable();
assertThat(exceptions.describeAsAdditionalInfo()).isEmpty();
} | #vulnerable code
@Test
public void describeAsAdditionalInfo_empty() {
Correspondence.ExceptionStore exceptions = Correspondence.ExceptionStore.forIterable();
assertThat(exceptions.describeAsAdditionalInfo().asIterable()).isEmpty();
}
#location 4
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getConceptNetUrl() {
String urlFromConfigOrDefault = (String)getConfiguration().getSettingValueFor(CONFIG_KEY_URL);
return urlFromConfigOrDefault == null
? DEFAULT_CONCEPTNET_URL
: urlFromConfigOrDefault;
} | #vulnerable code
public String getConceptNetUrl() {
String urlFromConfigOrDefault = getConfiguration().getSettingValueFor(CONFIG_KEY_URL).toString();
return urlFromConfigOrDefault == null
? DEFAULT_CONCEPTNET_URL
: urlFromConfigOrDefault;... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public SingleResult process(TextRankRequest request) {
TextRank textrank = new TextRank(getDatabase(), getNLPManager().getConfiguration());
if (request.getStopWords() != null
&& !request.getStopWords().isEmpty()) {
textrank.setSt... | #vulnerable code
public SingleResult process(TextRankRequest request) {
TextRank textrank = new TextRank(getDatabase(), getNLPManager().getConfiguration());
if (request.getStopWords() != null
&& !request.getStopWords().isEmpty()) {
textrank... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Map<Long, Map<Long, CoOccurrenceItem>> createCooccurrences(Node annotatedText) {
Map<String, Object> params = new HashMap<>();
params.put("id", annotatedText.getId());
String query;
if (respectSentences) {
query = COOCCURRENC... | #vulnerable code
public Map<Long, Map<Long, CoOccurrenceItem>> createCooccurrences(Node annotatedText) {
Map<String, Object> params = new HashMap<>();
params.put("id", annotatedText.getId());
String query;
if (respectSentences) {
query = COOCC... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException {
Map<String, Object> params = new HashMap<>();
params.put("id", firstNode);
Result res = database.execute(DEFAULT_VECTOR_QUERY_WITH_CONCEPT, params);
... | #vulnerable code
private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException {
Map<String, Object> params = new HashMap<>();
params.put("id", firstNode);
Result res = database.execute("MATCH (doc:AnnotatedText)\n"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public SingleResult process(TextRankRequest request) {
TextRankResult result = compute(request);
TextRankPersister persister = new TextRankPersister(Label.label(request.getKeywordLabel()));
persister.peristKeywords(result.getResult(), request.getNode()... | #vulnerable code
public SingleResult process(TextRankRequest request) {
TextRank.Builder textrankBuilder = new TextRank.Builder(getDatabase(), getNLPManager().getConfiguration());
if (request.getStopWords() != null
&& !request.getStopWords().isEmpty()) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean evaluate(Node annotatedText, int iter, double damp, double threshold) {
Map<Long, Map<Long, CoOccurrenceItem>> coOccurrence = createCooccurrences(annotatedText);
PageRank pageRank = new PageRank(database);
if (useTfIdfWeights) {
... | #vulnerable code
public boolean evaluate(Node annotatedText, int iter, double damp, double threshold) {
Map<Long, Map<Long, CoOccurrenceItem>> coOccurrence = createCooccurrences(annotatedText);
PageRank pageRank = new PageRank(database);
if (useTfIdfWeights) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Tag annotateTag(String text, String language) {
PipelineSpecification spec = getDefaultPipeline(language);
if (spec == null) {
LOG.warn("No default annotator for language: " + language);
return null;
}
TextProcess... | #vulnerable code
public Tag annotateTag(String text, String language) {
PipelineSpecification spec = getDefaultPipeline(language);
TextProcessor processor = getTextProcessor(spec.getTextProcessor());
return processor.annotateTag(text, spec);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void initializePipelineWithoutNEs() {
if (!NLPManager.getInstance().hasPipeline(PIPELINE_WITHOUT_NER)) {
Map<String, Object> params = new HashMap<>();
params.put("tokenize", true);
params.put("ner", false);
Strin... | #vulnerable code
private void initializePipelineWithoutNEs() {
//System.out.println(" >>> default processor: " + NLPManager.getInstance().getTextProcessorsManager().getDefaultProcessor().getAlias());
Map<String, Object> params = new HashMap<>();
params.put("token... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Procedure(name = "ga.nlp.parser.powerpoint")
public Stream<Page> parsePowerpoint(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) {
PowerpointParser parser = (PowerpointParser) getNLPManager().getExten... | #vulnerable code
@Procedure(name = "ga.nlp.parser.powerpoint")
public Stream<Page> parsePowerpoint(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) {
PowerpointParser parser = (PowerpointParser) getNLPManager().ge... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<String, Keyword> checkNextKeyword(long tagId, KeywordExtractedItem keywordOccurrence, Map<Long, Map<Long, CoOccurrenceItem>> coOccurrences, Map<Long, KeywordExtractedItem> keywords) {
Map<String, Keyword> results = new HashMap<>();
if (!coOccurrenc... | #vulnerable code
private Map<String, Keyword> checkNextKeyword(long tagId, KeywordExtractedItem keywordOccurrence, Map<Long, Map<Long, CoOccurrenceItem>> coOccurrences, Map<Long, KeywordExtractedItem> keywords) {
Map<String, Keyword> results = new HashMap<>();
if (!coOcc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Procedure(name = "ga.nlp.parser.pdf")
public Stream<Page> parsePdf(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) {
TikaPDFParser parser = (TikaPDFParser) getNLPManager().getExtension(TikaPDFParser.c... | #vulnerable code
@Procedure(name = "ga.nlp.parser.pdf")
public Stream<Page> parsePdf(@Name("file") String filename, @Name(value = "filterPatterns", defaultValue = "") List<String> filterPatterns) {
TikaPDFParser parser = (TikaPDFParser) getNLPManager().getExtension(TikaPDFPa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException {
Map<String, Object> params = new HashMap<>();
params.put("id", firstNode);
Result res = database.execute(DEFAULT_VECTOR_QUERY_WITH_CONCEPT, params);
... | #vulnerable code
private Map<Long, Float> createFeatureMapWithCN5New(long firstNode) throws QueryExecutionException {
Map<String, Object> params = new HashMap<>();
params.put("id", firstNode);
Result res = database.execute("MATCH (doc:AnnotatedText)\n"
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean handle(LoginPacket packet) {
// Check for supported protocol
int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion());
if (index < 0) {
session.getBedrockSession().di... | #vulnerable code
@Override
public boolean handle(LoginPacket packet) {
// Check for supported protocol
int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion());
if (index < 0) {
session.getBedrockSessio... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean handle(LoginPacket packet) {
// Check for supported protocol
int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion());
if (index < 0) {
upstream.disconnect();
... | #vulnerable code
@Override
public boolean handle(LoginPacket packet) {
// TODO: move out of here? idk
UpstreamSession session = new UpstreamSession(this.session);
this.session.setPlayer(session);
try {
// Get chain data that contains ide... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean handle(LoginPacket packet) {
// Check for supported protocol
int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion());
if (index < 0) {
session.getBedrockSession().di... | #vulnerable code
@Override
public boolean handle(LoginPacket packet) {
// Check for supported protocol
int index = Arrays.binarySearch(DragonProxy.BEDROCK_SUPPORTED_PROTOCOLS, packet.getProtocolVersion());
if (index < 0) {
session.getBedrockSessio... | 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.