input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Test
public void testValidMapStatementAndTrimMultipleWhitSpaces() throws Exception {
ForLoopStatement statement = transformer.transform(" k, v in collection ");
Assert.assertEquals(ForLoopStatement.Type.MAP, statement.getType());
... | #fixed code
@Test
public void testValidMapStatementAndTrimMultipleWhitSpaces() throws Exception {
ForLoopStatement statement = transformer.transform(" k, v in collection ");
MapForLoopStatement mapForLoopStatement = validateMapForLoopStatement(statement);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void beginTask(@Param(ScoreLangConstants.TASK_INPUTS_KEY) List<Input> taskInputs,
@Param(ScoreLangConstants.LOOP_KEY) LoopStatement loop,
@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv,
... | #fixed code
public void beginTask(@Param(ScoreLangConstants.TASK_INPUTS_KEY) List<Input> taskInputs,
@Param(ScoreLangConstants.LOOP_KEY) LoopStatement loop,
@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValues() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/sensitive/sensitive_values_op.sl").toURI();
CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), new ... | #fixed code
@Test
public void testValues() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/sensitive/sensitive_values_op.sl").toURI();
CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource), new HashSe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ReturnValues getExecutionReturnValues(){
if(StringUtils.isEmpty(result)){
throw new RuntimeException("Result of executing the test " + testCaseName + " cannot be empty");
}
if (outputs == null){
outputs = new HashMa... | #fixed code
public ReturnValues getExecutionReturnValues(){
// if(StringUtils.isEmpty(result)){
// throw new RuntimeException("Result of executing the test " + testCaseName + " cannot be empty");
// }
return new ReturnValues(outputs, result);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(timeout = DEFAULT_TIMEOUT)
public void doJavaActionSetKeyOnNonSerializableSessionTest() {
//prepare doAction arguments
RunEnvironment runEnv = new RunEnvironment();
HashMap<String, Object> nonSerializableExecutionData = new HashMap<>();... | #fixed code
@Test(timeout = DEFAULT_TIMEOUT)
public void doJavaActionSetKeyOnNonSerializableSessionTest() {
//prepare doAction arguments
RunEnvironment runEnv = new RunEnvironment();
HashMap<String, Object> nonSerializableExecutionData = new HashMap<>();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithLoops() throws Exception {
URI resource = getClass().getResource("/yaml/loops/simple_loop.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<SlangSource> path = Sets.newHa... | #fixed code
@Test
public void testFlowWithLoops() throws Exception {
URI resource = getClass().getResource("/yaml/loops/simple_loop.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<SlangSource> path = Sets.newHashSet(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithMapLoopsWithBreak() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_break_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_val... | #fixed code
@Test
public void testFlowWithMapLoopsWithBreak() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_break_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_value_is_... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidMapStatementWithoutSpaceAfterComma() throws Exception {
ForLoopStatement statement = transformer.transform("k,v in collection");
Assert.assertEquals(ForLoopStatement.Type.MAP, statement.getType());
Assert.assertEqua... | #fixed code
@Test
public void testValidMapStatementWithoutSpaceAfterComma() throws Exception {
ForLoopStatement statement = transformer.transform("k,v in collection");
MapForLoopStatement mapForLoopStatement = validateMapForLoopStatement(statement);
Assert.as... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithLoopsWithCustomNavigation() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_custom_navigation.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
... | #fixed code
@Test
public void testFlowWithLoopsWithCustomNavigation() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_custom_navigation.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFunctionsBasic() throws Exception {
URL resource = getClass().getResource("/yaml/functions/functions_test_flow.sl");
URI operation = getClass().getResource("/yaml/functions/functions_test_op.sl").toURI();
Set<SlangSource... | #fixed code
@Test
public void testFunctionsBasic() throws Exception {
URL resource = getClass().getResource("/yaml/functions/functions_test_flow.sl");
URI operation = getClass().getResource("/yaml/functions/functions_test_op.sl").toURI();
Set<SlangSource> path... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Long trigger(SlangTestCase testCase, CompilationArtifact compilationArtifact,
Map<String, ? extends Serializable> inputs,
Map<String, ? extends Serializable> systemProperties) {
String testCaseName = testCas... | #fixed code
public Long trigger(SlangTestCase testCase, CompilationArtifact compilationArtifact,
Map<String, ? extends Serializable> inputs,
Map<String, ? extends Serializable> systemProperties) {
String testCaseName = testCase.getN... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithMapLoopsWithCustomNavigation() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_custom_navigation_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toUR... | #fixed code
@Test
public void testFlowWithMapLoopsWithCustomNavigation() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_custom_navigation_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void joinBranches(@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv,
@Param(EXECUTION_RUNTIME_SERVICES) ExecutionRuntimeServices executionRuntimeServices,
@Param(ScoreLangConstants.TASK_AGGREGATE_KE... | #fixed code
public void joinBranches(@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv,
@Param(EXECUTION_RUNTIME_SERVICES) ExecutionRuntimeServices executionRuntimeServices,
@Param(ScoreLangConstants.TASK_AGGREGATE_KEY) Lis... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidMapStatementAndTrim() throws Exception {
ForLoopStatement statement = transformer.transform(" k, v in collection ");
Assert.assertEquals(ForLoopStatement.Type.MAP, statement.getType());
Assert.assertEquals("k v"... | #fixed code
@Test
public void testValidMapStatementAndTrim() throws Exception {
ForLoopStatement statement = transformer.transform(" k, v in collection ");
MapForLoopStatement mapForLoopStatement = validateMapForLoopStatement(statement);
Assert.assertEqua... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithMapLoopsWithBreak() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_break_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_val... | #fixed code
@Test
public void testFlowWithMapLoopsWithBreak() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_break_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_value_is_... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<ExecutionStep> buildTaskExecutionSteps(
Task task,
Map<String, Long> taskReferences, Deque<Task> tasks,
Flow compiledFlow) {
List<ExecutionStep> taskExecutionSteps = new ArrayList<>();
String taskName = ... | #fixed code
private List<ExecutionStep> buildTaskExecutionSteps(
Task task,
Map<String, Long> taskReferences, Deque<Task> tasks,
Flow compiledFlow) {
List<ExecutionStep> taskExecutionSteps = new ArrayList<>();
String taskName = task.g... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStepPublishValues() throws Exception {
URL resource = getClass().getResource("/yaml/binding_scope_flow.sl");
URI operation = getClass().getResource("/yaml/binding_scope_op.sl").toURI();
Set<SlangSource> path = Sets.newHa... | #fixed code
@Test
public void testStepPublishValues() throws Exception {
URL resource = getClass().getResource("/yaml/binding_scope_flow.sl");
URI operation = getClass().getResource("/yaml/binding_scope_op.sl").toURI();
Set<SlangSource> path = Sets.newHashSet(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidMapStatementSpaceBeforeComma() throws Exception {
ForLoopStatement statement = transformer.transform("k ,v in collection");
Assert.assertEquals(ForLoopStatement.Type.MAP, statement.getType());
Assert.assertEquals("k... | #fixed code
@Test
public void testValidMapStatementSpaceBeforeComma() throws Exception {
ForLoopStatement statement = transformer.transform("k ,v in collection");
MapForLoopStatement mapForLoopStatement = validateMapForLoopStatement(statement);
Assert.assertE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValues() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI();
URI operation1 = getClass().getResource("/yaml/formats/values_op.sl").toURI();
URI operation2 ... | #fixed code
@Test
public void testValues() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI();
URI operation1 = getClass().getResource("/yaml/formats/values_op.sl").toURI();
URI operation2 = getC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithMapLoopsWithCustomNavigation() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_custom_navigation_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toUR... | #fixed code
@Test
public void testFlowWithMapLoopsWithCustomNavigation() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_custom_navigation_with_map.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidMapStatementWithExpression() throws Exception {
ForLoopStatement statement = transformer.transform("k, v in dictionary.items()");
Assert.assertEquals(ForLoopStatement.Type.MAP, statement.getType());
Assert.assertEqu... | #fixed code
@Test
public void testValidMapStatementWithExpression() throws Exception {
ForLoopStatement statement = transformer.transform("k, v in dictionary.items()");
MapForLoopStatement mapForLoopStatement = validateMapForLoopStatement(statement);
Assert.a... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<StepData> buildBranchesData(List<LanguageEventData> data) {
List<StepData> branches = Lists.newArrayList();
for (LanguageEventData branchData : data) {
String path = branchData.getPath();
String stepName = branchData... | #fixed code
private List<StepData> buildBranchesData(List<LanguageEventData> data) {
List<StepData> branches = Lists.newArrayList();
for (LanguageEventData branchData : data) {
String path = branchData.getPath();
String stepName = branchData.getSt... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValuesInFlow() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI();
URI operation = getClass().getResource("/yaml/formats/values_op.sl").toURI();
SlangSour... | #fixed code
@Test
public void testValuesInFlow() throws Exception {
// compile
URI resource = getClass().getResource("/yaml/formats/values_flow.sl").toURI();
URI operation1 = getClass().getResource("/yaml/formats/values_op.sl").toURI();
URI operation2 ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithLoops() throws Exception {
URI resource = getClass().getResource("/yaml/loops/simple_loop.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<SlangSource> path = Sets.newHa... | #fixed code
@Test
public void testFlowWithLoops() throws Exception {
URI resource = getClass().getResource("/yaml/loops/simple_loop.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/print.sl").toURI();
Set<SlangSource> path = Sets.newHashSet(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testValidStatementWithSpaces() throws Exception {
ForLoopStatement statement = transformer.transform("x in range(0, 9)");
Assert.assertEquals(ForLoopStatement.Type.LIST, statement.getType());
Assert.assertEquals("x", stateme... | #fixed code
@Test
public void testValidStatementWithSpaces() throws Exception {
ForLoopStatement statement = transformer.transform("x in range(0, 9)");
ListForLoopStatement listForLoopStatement = validateListForLoopStatement(statement);
Assert.assertEquals("x... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlowWithLoopsWithBreak() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_break.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_value_is_2.sl")... | #fixed code
@Test
public void testFlowWithLoopsWithBreak() throws Exception {
URI resource = getClass().getResource("/yaml/loops/loop_with_break.sl").toURI();
URI operation1 = getClass().getResource("/yaml/loops/operation_that_goes_to_custom_when_value_is_2.sl").toURI... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<RuntimeException> validateModelWithDependencies(
Executable executable,
Map<String, Executable> dependencies,
Set<Executable> verifiedExecutables,
List<RuntimeException> errors) {
//validate that all r... | #fixed code
private List<RuntimeException> validateModelWithDependencies(
Executable executable,
Map<String, Executable> dependencies,
Set<Executable> verifiedExecutables,
List<RuntimeException> errors) {
//validate that all require... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void contextInitialized(ServletContextEvent servletContextEvent) {
info(getClass().getName() + " initializing context by loading some known offenders with system classloader");
// This part is heavily inspired by Tomcats JreMemoryLeakPreventionLis... | #fixed code
public void contextInitialized(ServletContextEvent servletContextEvent) {
final ServletContext servletContext = servletContextEvent.getServletContext();
stopThreads = ! "false".equals(servletContext.getInitParameter("ClassLoaderLeakPreventor.stopThreads"));
stopTim... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testRetryForResult() {
// Given retry for null
inv = new AsyncExecution(callable, new RetryPolicy().retryWhen(null), scheduler, future, null);
// When / Then
assertFalse(inv.complete(null));
assertTrue(inv.retryFor(null));
inv.prepare(... | #fixed code
public void testRetryForResult() {
// Given retry for null
exec = new AsyncExecution(callable, new RetryPolicy().retryWhen(null), scheduler, future, null);
// When / Then
assertFalse(exec.complete(null));
assertTrue(exec.retryFor(null));
exec.prepare();... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
public void testRetryOn() {
// Given retry on IllegalArgumentException
inv = new AsyncExecution(callable, new RetryPolicy().retryOn(IllegalArgumentException.class), scheduler, future,
null);
// When / Then
assertTr... | #fixed code
@SuppressWarnings("unchecked")
public void testRetryOn() {
// Given retry on IllegalArgumentException
exec = new AsyncExecution(callable, new RetryPolicy().retryOn(IllegalArgumentException.class), scheduler, future,
null);
// When / Then
assertTrue(ex... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings({ "rawtypes", "unchecked" })
private void assertGetFuture(Object callable) throws Throwable {
// Fail twice then succeed
when(service.connect()).thenThrow(failures(2, SocketException.class)).thenReturn(true);
boolean result = (boolean) (cal... | #fixed code
@SuppressWarnings({ "rawtypes", "unchecked" })
private void assertGetFuture(Object callable) throws Throwable {
// Fail twice then succeed
when(service.connect()).thenThrow(failures(2, SocketException.class)).thenReturn(true);
boolean result = (boolean) (callable ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testRetryForResultAndThrowable() {
// Given retry for null
inv = new AsyncExecution(callable, new RetryPolicy().retryWhen(null), scheduler, future, null);
// When / Then
assertFalse(inv.complete(null));
assertTrue(inv.retryFor(null, null))... | #fixed code
public void testRetryForResultAndThrowable() {
// Given retry for null
exec = new AsyncExecution(callable, new RetryPolicy().retryWhen(null), scheduler, future, null);
// When / Then
assertFalse(exec.complete(null));
assertTrue(exec.retryFor(null, null));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCompleteOrRetry() {
// Given retry on IllegalArgumentException
exec = new AsyncExecution(callable, scheduler, future, configFor(new RetryPolicy()));
// When / Then
exec.completeOrRetry(null, e);
assertFalse(exec.isComplete());
exec... | #fixed code
public void testCompleteOrRetry() {
// Given retry on IllegalArgumentException
exec = new AsyncExecution(callable, scheduler, future, configFor(new RetryPolicy()));
// When / Then
exec.completeOrRetry(null, e);
assertFalse(exec.isComplete());
exec.befor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
public void testRetryOn() {
// Given retry on IllegalArgumentException
exec = new AsyncExecution(callable, scheduler, future,
configFor(new RetryPolicy().retryOn(IllegalArgumentException.class)));
// When / Then
as... | #fixed code
@SuppressWarnings("unchecked")
public void testRetryOn() {
// Given retry on IllegalArgumentException
exec = new AsyncExecution(callable, scheduler, future,
configFor(new RetryPolicy().retryOn(IllegalArgumentException.class)));
// When / Then
assertTr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testGetAttemptCount() {
inv = new AsyncExecution(callable, new RetryPolicy(), scheduler, future, null);
inv.retryOn(e);
inv.prepare();
inv.retryOn(e);
assertEquals(inv.getExecutions(), 2);
}
#location 4
... | #fixed code
public void testGetAttemptCount() {
exec = new AsyncExecution(callable, new RetryPolicy(), scheduler, future, null);
exec.retryOn(e);
exec.prepare();
exec.retryOn(e);
assertEquals(exec.getExecutions(), 2);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/release/*
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/release/*
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/release/*
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/release/*
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// set git flow configuration
initGitFlowConfig();
// check uncommitted changes
checkUncommittedChanges();
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// set git flow configuration
initGitFlowConfig();
// check uncommitted changes
checkUncommittedChanges();
// ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// set git flow configuration
initGitFlowConfig();
// check uncommitted changes
checkUncommittedChanges();
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// set git flow configuration
initGitFlowConfig();
// check uncommitted changes
checkUncommittedChanges();
// ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
validateConfiguration();
try {
// set git flow configuration
initGitFlowConfig();
// check uncommitted changes
che... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
validateConfiguration();
try {
// set git flow configuration
initGitFlowConfig();
// check uncommitted changes
checkUnco... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
... | #fixed code
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// check uncommitted changes
checkUncommittedChanges();
// git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public <T, S extends Geometry> RTree<T, S> deserialize(long sizeBytes, InputStream is,
Func1<byte[], T> deserializer) throws IOException {
byte[] bytes = readFully(is, (int) sizeBytes);
Tree_ t = Tree_.getRootAsTree_(ByteBuffer.wrap(bytes));
... | #fixed code
public <T, S extends Geometry> RTree<T, S> deserialize(long sizeBytes, InputStream is,
Func1<byte[], T> deserializer) throws IOException {
byte[] bytes = readFully(is, (int) sizeBytes);
Tree_ t = Tree_.getRootAsTree_(ByteBuffer.wrap(bytes));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
static <T, S extends Geometry> List<Entry<T, S>> createEntries(Node_ node,
Func1<byte[], T> deserializer) {
List<Entry<T, S>> list = new ArrayList<Entry<T, S>>(node.entriesLength());
for (int i = 0; i < node... | #fixed code
@SuppressWarnings("unchecked")
static <T, S extends Geometry> List<Entry<T, S>> createEntries(Node_ node,
Func1<byte[], T> deserializer) {
List<Entry<T, S>> list = new ArrayList<Entry<T, S>>(node.entriesLength());
for (int i = 0; i < node.entri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSerializeRoundTrip() throws IOException {
RTree<Object, Point> tree = RTree.star().maxChildren(4).create();
tree = tree.add(GreekEarthquakes.entries()).last().toBlocking().single();
long t = System.currentTimeMillis();
... | #fixed code
@Test
public void testSerializeRoundTrip() throws IOException {
RTree<Object, Point> tree = RTree.star().maxChildren(10).create();
tree = tree.add(GreekEarthquakes.entries()).last().toBlocking().single();
long t = System.currentTimeMillis();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<Node<T, S>> createChildren() {
List<Node<T, S>> children = new ArrayList<Node<T, S>>(node.childrenLength());
for (int i = 0; i < node.childrenLength(); i++) {
children.add(
new NonLeafFlatBuffersStatic<T, S>(n... | #fixed code
private List<Node<T, S>> createChildren() {
List<Node<T, S>> children = new ArrayList<Node<T, S>>(node.childrenLength());
for (int i = 0; i < node.childrenLength(); i++) {
Node_ child = node.children(i);
if (child.childrenLength() > 0)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void roundTrip(InternalStructure structure, boolean backpressure) throws Exception {
RTree<Object, Point> tree = RTree.star().maxChildren(10).create();
tree = tree.add(GreekEarthquakes.entries()).last().toBlocking().single();
long t = Sys... | #fixed code
private void roundTrip(InternalStructure structure, boolean backpressure) throws Exception {
RTree<Object, Point> tree = RTree.star().maxChildren(10).create();
tree = tree.add(GreekEarthquakes.entries()).last().toBlocking().single();
long t = System.cu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
static <S extends Geometry> S toGeometry(Geometry_ g) {
final Geometry result;
byte type = g.type();
if (type == GeometryType_.Box) {
result = createBox(g.box());
} else if (type == GeometryT... | #fixed code
@SuppressWarnings("unchecked")
static <S extends Geometry> S toGeometry(Geometry_ g) {
final Geometry result;
byte type = g.type();
if (type == GeometryType_.Box) {
result = createBox(g.box());
} else if (type == GeometryType_.P... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<Node<T, S>> createChildren() {
List<Node<T, S>> children = new ArrayList<Node<T, S>>(node.childrenLength());
// reduce allocations by resusing objects
int numChildren = node.childrenLength();
for (int i = 0; i < numChildren; ... | #fixed code
private List<Node<T, S>> createChildren() {
List<Node<T, S>> children = new ArrayList<Node<T, S>>(node.childrenLength());
// reduce allocations by resusing objects
int numChildren = node.childrenLength();
for (int i = 0; i < numChildren; i++) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("unchecked")
static <S extends Geometry> S toGeometry(Geometry_ g) {
final Geometry result;
byte type = g.type();
if (type == GeometryType_.Box) {
result = createBox(g.box());
} else if (type == GeometryT... | #fixed code
@SuppressWarnings("unchecked")
static <S extends Geometry> S toGeometry(Geometry_ g) {
final Geometry result;
byte type = g.type();
if (type == GeometryType_.Box) {
result = createBox(g.box());
} else if (type == GeometryType_.P... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testSerializeRoundTrip() throws IOException {
RTree<Object, Point> tree = RTree.star().maxChildren(10).create();
tree = tree.add(GreekEarthquakes.entries()).last().toBlocking().single();
long t = System.currentTimeMillis();
... | #fixed code
@Test
public void testSerializeRoundTrip() throws IOException {
RTree<Object, Point> tree = RTree.star().maxChildren(10).create();
tree = tree.add(GreekEarthquakes.entries()).last().toBlocking().single();
long t = System.currentTimeMillis();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
protected SearchRequestBuilder _explain() throws SqlParseException {
BoolFilterBuilder boolFilter = null;
// set where
Where where = select.getWhere();
AggregationBuilder<?> lastAgg = null;
FilterAggregationBuilder filter = null;
if (where != null... | #fixed code
@Override
protected SearchRequestBuilder _explain() throws SqlParseException {
setWhere(select.getWhere());
AggregationBuilder<?> lastAgg = null;
if (select.getGroupBys().size() > 0) {
Field field = select.getGroupBys().get(0);
lastAgg = aggMaker.makeGroupAgg(field... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/home/an... | #fixed code
public static void main(String[] args) throws IOException {
Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/home/ansj/tem... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void findOrderBy(MySqlSelectQueryBlock query, Select select) throws SqlParseException {
SQLOrderBy orderBy = query.getOrderBy();
if (orderBy == null) {
return;
}
List<SQLSelectOrderByItem> items = orderBy.getItems();
List<String> lists = new ArrayList... | #fixed code
private void findOrderBy(MySqlSelectQueryBlock query, Select select) throws SqlParseException {
SQLOrderBy orderBy = query.getOrderBy();
if (orderBy == null) {
return;
}
List<SQLSelectOrderByItem> items = orderBy.getItems();
addOrderByToSelect(select, items,... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private SearchRequestBuilder explan(SQLQueryExpr SQLQueryExpr) throws SqlParseException {
Select select = new SqlParser().parseSelect(SQLQueryExpr);
Query query = null;
Client client = new TransportClient();
if (select.isAgg) {
query = new AggregationQuery(cl... | #fixed code
private SearchRequestBuilder explan(SQLQueryExpr SQLQueryExpr) throws SqlParseException {
Select select = new SqlParser().parseSelect(SQLQueryExpr);
Query query = null;
if (select.isAgg) {
query = new AggregationQuery(client, select);
} else {
query = new Default... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public IonValue singleValue(String ionText)
{
Iterator<IonValue> it = iterate(ionText);
return singleValue(it);
}
#location 4
#vulnerability type RESOURCE_LEAK | #fixed code
public IonValue singleValue(String ionText)
{
CloseableIterator<IonValue> it = iterate(ionText);
return singleValue(it);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean isInStruct()
{
return !containers.isEmpty() && currentContainer().type == ContainerType.STRUCT;
}
#location 3
#vulnerability type NULL_DEREFERENCE | #fixed code
public boolean isInStruct()
{
return currentContainerIndex >= 0 && currentContainer().type == ContainerType.STRUCT;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testWriteValueCopiesFieldName()
throws Exception
{
IonStruct data = struct("{a:{b:10}}");
IonReader ir = system().newReader(data);
ir.next();
ir.stepIn();
expectNextField(ir, "a");
iw = m... | #fixed code
@Test
public void testWriteValueCopiesFieldName()
throws Exception
{
IonStruct data = struct("{a:{b:10}}");
IonReader ir = system().newReader(data);
ir.next();
ir.stepIn();
expectNextField(ir, "a");
iw = makeWri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public IonValue singleValue(byte[] ionData)
{
Iterator<IonValue> it = iterate(ionData);
return singleValue(it);
}
#location 4
#vulnerability type RESOURCE_LEAK | #fixed code
public IonValue singleValue(byte[] ionData)
{
CloseableIterator<IonValue> iterator = iterate(ionData);
return singleValue(iterator);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testFlushingUnlockedSymtab()
throws Exception
{
iw = makeWriter();
iw.writeSymbol("force a local symtab");
SymbolTable symtab = iw.getSymbolTable();
symtab.intern("fred_1");
symtab.intern("fred_2");
... | #fixed code
@Test
public void testFlushingUnlockedSymtab()
throws Exception
{
byte[] bytes = flushUnlockedSymtab(false);
assertEquals(0, bytes.length);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void testTypeAnnotationHashCode(String text, IonType type)
{
checkType(type, oneValue("annot1::" + text));
checkType(type, oneValue("$99::" + text));
assertIonEqImpliesHashEq(oneValue("annot1::" + text),
... | #fixed code
protected void testTypeAnnotationHashCode(String text, IonType type)
{
String sharedSymbolTable = "$ion_symbol_table::{imports:[{name:\"foo\", version: 1, max_id:90}]}";
checkType(type, oneValue("annot1::" + text));
checkType(type, oneValue(sharedS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Ignore("Not ready yet")
public void testGetTVChangesList() throws MovieDbException {
LOG.info("getPersonChangesList");
TmdbResultsList<ChangedMedia> result = instance.getChangeList(MethodBase.PERSON, null, null, null);
assertFalse("No TV cha... | #fixed code
@Ignore("Not ready yet")
public void testGetTVChangesList() throws MovieDbException {
LOG.info("getPersonChangesList");
List<ChangeListItem> result = instance.getChangeList(MethodBase.PERSON, null, null, null);
assertFalse("No TV changes.", result.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGetMovieChangesList() throws MovieDbException {
LOG.info("getMovieChangesList");
TmdbResultsList<ChangedMedia> result = instance.getChangeList(MethodBase.MOVIE, null, null, null);
assertFalse("No movie changes.", result.... | #fixed code
@Test
public void testGetMovieChangesList() throws MovieDbException {
LOG.info("getMovieChangesList");
List<ChangeListItem> result = instance.getChangeList(MethodBase.MOVIE, null, null, null);
assertFalse("No movie changes.", result.isEmpty());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Ignore("Not ready yet")
public void testGetPersonChangesList() throws MovieDbException {
LOG.info("getPersonChangesList");
TmdbResultsList<ChangedMedia> result = instance.getChangeList(MethodBase.PERSON, null, null, null);
assertFalse("No Pe... | #fixed code
@Ignore("Not ready yet")
public void testGetPersonChangesList() throws MovieDbException {
LOG.info("getPersonChangesList");
List<ChangeListItem> result = instance.getChangeList(MethodBase.PERSON, null, null, null);
assertFalse("No Person changes.",... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void skillViolationAtAct1_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocati... | #fixed code
@Test
public void skillViolationAtAct1_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocationId) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void begin(VehicleRoute route) {
currentLoad = (int) stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING).toDouble();
this.route = route;
}
#location 3
#vulnerability type NULL_DE... | #fixed code
@Override
public void begin(VehicleRoute route) {
currentLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING, Capacity.class);
this.route = route;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp){
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
URL resource = Resource.getAsURL("greedySchrimpf.xml");
new AlgorithmConfigXmlReader(algorithmConfig).read(resource.getPath());
retur... | #fixed code
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp){
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
URL resource = Resource.getAsURL("greedySchrimpf.xml");
new AlgorithmConfigXmlReader(algorithmConfig).read(resource);
return VehicleRouting... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
if(job2insert instanceof Delivery){
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateIdFactory.LOAD_AT_DEPOT).toDouble()... | #fixed code
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
if(job2insert instanceof Delivery){
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateIdFactory.LOAD_AT_BEGINNING).toDouble();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp){
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
URL resource = Resource.getAsURL("schrimpf.xml");
new AlgorithmConfigXmlReader(algorithmConfig).read(resource.getPath());
return Vehi... | #fixed code
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp){
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
URL resource = Resource.getAsURL("schrimpf.xml");
new AlgorithmConfigXmlReader(algorithmConfig).read(resource);
return VehicleRoutingAlgori... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static void readDistances(Builder matrixBuilder) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/refuseCollectionExample_Distances")));
String line = null;
boolean firstLine = true;
while((line = r... | #fixed code
private static void readDistances(Builder matrixBuilder) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/refuseCollectionExample_Distances")));
String line = null;
boolean firstLine = true;
while((line = reader.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenSolving_deliverService1_shouldBeInRoute(){
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_iniRoutes.xml");
Veh... | #fixed code
@Test
public void whenSolving_deliverService1_shouldBeInRoute(){
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_iniRoutes.xml");
VehicleRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String filename){
BufferedReader reader = getBufferedReader(filename);
String line;
Coordinate[] coords = null;
Integer[] demands = null;
Integer capacity = null;
List<Integer> depotIds = new ArrayList<Int... | #fixed code
public void read(String filename){
BufferedReader reader = getBufferedReader(filename);
String line;
Coordinate[] coords = null;
int[] demands = null;
Integer capacity = null;
List<Integer> depotIds = new ArrayList<Integer>();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) {
if (vehicleRoutes.isEmpty()) {
return Collections.emptyList();
}
int nOfJobs2BeRemoved = Math.min(ruinShareFactory.createNumberToBeRemoved(), no... | #fixed code
@Override
public Collection<Job> ruinRoutes(Collection<VehicleRoute> vehicleRoutes) {
if (vehicleRoutes.isEmpty()) {
return Collections.emptyList();
}
int nOfJobs2BeRemoved = Math.min(ruinShareFactory.createNumberToBeRemoved(), noJobsTo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void begin(VehicleRoute route) {
currentLoad = (int) stateManager.getRouteState(route, StateIdFactory.LOAD_AT_DEPOT).toDouble();
this.route = route;
}
#location 3
#vulnerability type NULL_DERE... | #fixed code
@Override
public void begin(VehicleRoute route) {
currentLoad = (int) stateManager.getRouteState(route, StateIdFactory.LOAD_AT_BEGINNING).toDouble();
this.route = route;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStatesOfAct2(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(30.0, states.getActivityState(tour.getActivities().get(1), StateFactory.COSTS).toDouble(),0.05);
assertEquals(10.0, states.getActivityState(tour.ge... | #fixed code
@Test
public void testStatesOfAct2(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(30.0, states.getActivityState(act2, StateFactory.COSTS).toDouble(),0.05);
assertEquals(10.0, states.getActivityState(act2, StateFactory.LOAD).toDouble(),0.0... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String filename){
BufferedReader reader = getReader(filename);
String line = null;
boolean firstline = true;
Coordinate depotCoord = null;
int customerCount=0;
Integer nuOfCustomer = 0;
while((line=readLine(reader))!=null){
String trimedLi... | #fixed code
public void read(String filename){
BufferedReader reader = getReader(filename);
String line = null;
boolean firstline = true;
Coordinate depotCoord = null;
int customerCount=0;
Integer nuOfCustomer = 0;
while((line=readLine(reader))!=null){
String trimedLine = l... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String filename){
BufferedReader reader = getBufferedReader(filename);
String line;
Coordinate[] coords = null;
int[] demands = null;
Integer capacity = null;
String edgeType = null;
String edgeWei... | #fixed code
public void read(String filename){
BufferedReader reader = getBufferedReader(filename);
String line;
Coordinate[] coords = null;
int[] demands = null;
Integer capacity = null;
String edgeType = null;
String edgeWeightFor... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
if(job2insert instanceof Delivery){
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING).toDouble();
... | #fixed code
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
if(job2insert instanceof Delivery){
Capacity loadAtDepot = stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, Capacity.class);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void skillViolationAtAct4_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocati... | #fixed code
@Test
public void skillViolationAtAct4_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocationId) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void skillViolationAtAct2_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocati... | #fixed code
@Test
public void skillViolationAtAct2_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocationId) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenVehicleRouteIsEmpty_loadsAtBeginningAndEndShouldBeZero(){
StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
UpdateLoads updateLoads = new UpdateLoads(stateManager);
VehicleRoute route = VehicleRoute.emptyRoute();... | #fixed code
@Test
public void whenVehicleRouteIsEmpty_loadsAtBeginningAndEndShouldBeZero(){
StateManager stateManager = new StateManager(mock(VehicleRoutingTransportCosts.class));
UpdateLoads updateLoads = new UpdateLoads(stateManager);
VehicleRoute route = VehicleRoute.emptyRoute()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStatesOfAct1(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(10.0, states.getActivityState(tour.getActivities().get(0), StateFactory.COSTS).toDouble(),0.05);
assertEquals(5.0, states.getActivityState(tour.getAct... | #fixed code
@Test
public void testStatesOfAct1(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(10.0, states.getActivityState(act1, StateFactory.COSTS).toDouble(),0.05);
assertEquals(5.0, states.getActivityState(act1, StateFactory.LOAD).toDouble(),0.05... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenWritingVehicleV1_itsStartLocationMustBeWrittenCorrectly(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleType... | #fixed code
@Test
public void whenWritingVehicleV1_itsStartLocationMustBeWrittenCorrectly(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleTypeImpl t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String filename){
BufferedReader reader = getBufferedReader(filename);
String line;
Coordinate[] coords = null;
Integer[] demands = null;
Integer capacity = null;
List<Integer> depotIds = new ArrayList<Int... | #fixed code
public void read(String filename){
BufferedReader reader = getBufferedReader(filename);
String line;
Coordinate[] coords = null;
Integer[] demands = null;
Integer capacity = null;
List<Integer> depotIds = new ArrayList<Integer>(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
if(job2insert instanceof Delivery){
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING).toDouble();
... | #fixed code
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
if(job2insert instanceof Delivery){
Capacity loadAtDepot = stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, Capacity.class);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenWritingVehicleV2_readingItsLocationsAgainReturnsCorrectLocations(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
Ve... | #fixed code
@Test
public void whenWritingVehicleV2_readingItsLocationsAgainReturnsCorrectLocations(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build();
VehicleT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String fileName){
vrpBuilder.setFleetSize(FleetSize.INFINITE);
BufferedReader reader = getReader(fileName);
int vehicleCapacity = 0;
double serviceTime = 0.0;
double endTime = Double.MAX_VALUE;
int counter = 0;
String line = null;
while((li... | #fixed code
public void read(String fileName){
vrpBuilder.setFleetSize(FleetSize.INFINITE);
BufferedReader reader = getReader(fileName);
int vehicleCapacity = 0;
double serviceTime = 0.0;
double endTime = Double.MAX_VALUE;
int counter = 0;
String line = null;
while((line = r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStatesOfAct2(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(30.0, states.getActivityState(tour.getActivities().get(1), StateFactory.COSTS).toDouble(),0.05);
assertEquals(10.0, states.getActivityState(tour.ge... | #fixed code
@Test
public void testStatesOfAct2(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(30.0, states.getActivityState(act2, StateFactory.COSTS).toDouble(),0.05);
assertEquals(10.0, states.getActivityState(act2, StateFactory.LOAD).toDouble(),0.0... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenWritingVehicleV2_readingItsLocationsCoordsAgainReturnsCorrectLocationsCoords(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).b... | #fixed code
@Test
public void whenWritingVehicleV2_readingItsLocationsCoordsAgainReturnsCorrectLocationsCoords(){
Builder builder = VehicleRoutingProblem.Builder.newInstance();
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType").addCapacityDimension(0, 20).build()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private JsonNode buildTree_and_getRoot_fromFile(File jsonFile){
JsonNode node = null;
try {
ObjectMapper objectMapper = new ObjectMapper();
String jsonContent = "";
BufferedReader reader = new BufferedReader(new FileRe... | #fixed code
private JsonNode buildTree_and_getRoot_fromFile(File jsonFile){
JsonNode node = null;
try {
ObjectMapper objectMapper = new ObjectMapper();
node = objectMapper.readTree(new FileReader(jsonFile)).path(JsonConstants.PROBLEM);
} ca... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
@Category(IntegrationTest.class)
public void test() {
try {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
System.out.println(Solutions.bestOf(solutions).getCost());
Assert.assertTru... | #fixed code
@Test
@Category(IntegrationTest.class)
public void test() {
try {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
Assert.assertTrue(true);
} catch (Exception e) {
Assert.assertTrue(false)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public InsertionData calculate(final VehicleRoute currentRoute, final Job jobToInsert, final Vehicle newVehicle, double newVehicleDepartureTime, final Driver newDriver, final double bestKnownCosts) {
if(jobToInsert == null) throw new IllegalStateException("job... | #fixed code
@Override
public InsertionData calculate(final VehicleRoute currentRoute, final Job jobToInsert, final Vehicle newVehicle, double newVehicleDepartureTime, final Driver newDriver, final double bestKnownCosts) {
if(jobToInsert == null) throw new IllegalStateException("jobToInse... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void read(String matrixFile){
BufferedReader reader = getBufferedReader(matrixFile);
String line;
boolean isEdgeWeights = false;
int fromIndex = 0;
while( ( line = getLine(reader) ) != null ){
if(line.startsWith... | #fixed code
public void read(String matrixFile){
BufferedReader reader = getBufferedReader(matrixFile);
String line;
boolean isEdgeWeights = false;
int fromIndex = 0;
while( ( line = getLine(reader) ) != null ){
if(line.startsWith("EDGE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void whenVehicleRouteIsEmpty_loadsAtBeginningAndEndShouldBeZero(){
StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
UpdateLoads updateLoads = new UpdateLoads(stateManager);
VehicleRoute route = VehicleRoute.emptyRoute();... | #fixed code
@Test
public void whenVehicleRouteIsEmpty_loadsAtBeginningAndEndShouldBeZero(){
StateManager stateManager = new StateManager(mock(VehicleRoutingTransportCosts.class));
UpdateLoads updateLoads = new UpdateLoads(stateManager);
VehicleRoute route = VehicleRoute.emptyRoute()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testStatesOfAct1(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(10.0, states.getActivityState(tour.getActivities().get(0), StateFactory.COSTS).toDouble(),0.05);
assertEquals(5.0, states.getActivityState(tour.getAct... | #fixed code
@Test
public void testStatesOfAct1(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(10.0, states.getActivityState(act1, StateFactory.COSTS).toDouble(),0.05);
assertEquals(5.0, states.getActivityState(act1, StateFactory.LOAD).toDouble(),0.05... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public double getActivityStartTime(TourActivity activity, double arrivalTime) {
TimeWindow last = null;
for(int i=activity.getTimeWindows().size()-1; i >= 0; i--){
TimeWindow tw = activity.getTimeWindows().get(i);
if... | #fixed code
@Override
public double getActivityStartTime(TourActivity activity, double arrivalTime) {
return Math.max(arrivalTime,activity.getTheoreticalEarliestOperationStartTime());
// TimeWindow last = null;
// for(int i=activity.getTimeWindows().size()-1; i ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public boolean acceptSolution(Collection<VehicleRoutingProblemSolution> solutions, VehicleRoutingProblemSolution newSolution) {
boolean solutionAccepted = false;
if (solutions.size() < solutionMemory) {
solutions.add(newSolution);
solutionAccepted = tr... | #fixed code
@Override
public boolean acceptSolution(Collection<VehicleRoutingProblemSolution> solutions, VehicleRoutingProblemSolution newSolution) {
boolean solutionAccepted = false;
if (solutions.size() < solutionMemory) {
solutions.add(newSolution);
solutionAccepted = true;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void skillViolationAtAct3_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocati... | #fixed code
@Test
public void skillViolationAtAct3_shouldWork(){
SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution, new SolutionAnalyser.DistanceCalculator() {
@Override
public double getDistance(String fromLocationId, String toLocationId) ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) {
reset();
logger.info("---------------------------------------------------------------------");
logger... | #fixed code
@Override
public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) {
reset();
logger.info("---------------------------------------------------------------------");
logger.info(... | 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.