input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code private static void show(final String msg, final Stats s, final long start) { final long elapsed = System.currentTimeMillis() - start; System.out.printf("%-20s: %5dms " + s.count + " lines "+ s.fields + " fields%n",msg,elapsed); elapsedTimes[num+...
#fixed code private static void show(final String msg, final Stats s, final long start) { final long elapsed = System.currentTimeMillis() - start; System.out.printf("%-20s: %5dms %d lines %d fields%n", msg, elapsed, s.count, s.fields); elapsedTimes[num] = elapsed;...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyLineBehaviourCSV() throws Exception { String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; String[]...
#fixed code @Test public void testEmptyLineBehaviourCSV() throws Exception { String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; String[][] res...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNextToken3Escaping() throws IOException { /* file: a,\,,b * \,, */ final String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne"; final CSVFormat format = CSVFormat.newBuilder().withEscape('\\').withIgnoreE...
#fixed code @Test public void testNextToken3Escaping() throws IOException { /* file: a,\,,b * \,, */ final String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne"; final CSVFormat format = formatWithEscaping.toBuilder().withIgnoreEmptyLines(false...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelFormat1() throws IOException { final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; final String...
#fixed code @Test public void testExcelFormat1() throws IOException { final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; final String[][] r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIgnoreEmptyLines() throws IOException { final String code = "\nfoo,baar\n\r\n,\n\n,world\r\n\n"; //String code = "world\r\n\n"; //String code = "foo;baar\r\n\r\nhello;\r\n\r\nworld;\r\n"; final CSVParser parser =...
#fixed code @Test public void testIgnoreEmptyLines() throws IOException { final String code = "\nfoo,baar\n\r\n,\n\n,world\r\n\n"; //String code = "world\r\n\n"; //String code = "foo;baar\r\n\r\nhello;\r\n\r\nworld;\r\n"; final CSVParser parser = CSVPa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test @Ignore public void testBackslashEscapingOld() throws IOException { final String code = "one,two,three\n" + "on\\\"e,two\n" + "on\"e,two\n" + "one,\"tw\\\"o\"\n...
#fixed code @Test @Ignore public void testBackslashEscapingOld() throws IOException { final String code = "one,two,three\n" + "on\\\"e,two\n" + "on\"e,two\n" + "one,\"tw\\\"o\"\n" ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRemoveAndAddColumns() throws IOException { // do: final CSVPrinter printer = new CSVPrinter(new StringBuilder(), CSVFormat.DEFAULT); final Map<String, String> map = recordWithHeader.toMap(); map.remove("OldColumn...
#fixed code @Test public void testRemoveAndAddColumns() throws IOException { // do: final CSVPrinter printer = new CSVPrinter(new StringBuilder(), CSVFormat.DEFAULT); final Map<String, String> map = recordWithHeader.toMap(); map.remove("OldColumn"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBackslashEscaping2() throws IOException { // To avoid confusion over the need for escaping chars in java code, // We will test with a forward slash as the escape char, and a single // quote as the encapsulator. ...
#fixed code @Test public void testBackslashEscaping2() throws IOException { // To avoid confusion over the need for escaping chars in java code, // We will test with a forward slash as the escape char, and a single // quote as the encapsulator. final...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelFormat2() throws Exception { String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""}, ...
#fixed code @Test public void testExcelFormat2() throws Exception { String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""}, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCarriageReturnEndings() throws IOException { String code = "foo\rbaar,\rhello,world\r,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); String[][] data = parser.getRecords(); assertEquals(4, data.l...
#fixed code @Test public void testCarriageReturnEndings() throws IOException { String code = "foo\rbaar,\rhello,world\r,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); List<CSVRecord> records = parser.getRecords(); assertEquals(4, reco...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testReadLine() throws Exception { br = getEBR(""); assertTrue(br.readLine() == null); br = getEBR("\n"); assertTrue(br.readLine().equals("")); assertTrue(br.readLine() == null); br = getEBR("foo\n\nhello"); assertEquals(0,...
#fixed code public void testReadLine() throws Exception { ExtendedBufferedReader br = getEBR(""); assertTrue(br.readLine() == null); br = getEBR("\n"); assertTrue(br.readLine().equals("")); assertTrue(br.readLine() == null); br = getEBR("foo\n\nhello"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCSVResource() throws Exception { String line = readTestData(); assertNotNull("file must contain config line", line); final String[] split = line.split(" "); assertTrue(testName + " require 1 param", split.length ...
#fixed code @Test public void testCSVResource() throws Exception { String line = readTestData(); assertNotNull("file must contain config line", line); final String[] split = line.split(" "); assertTrue(testName + " require 1 param", split.length >= 1);...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br...
#fixed code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getBufferedReader("abcdefg"); ref[0] = 'a'; ref[1] = 'b'; ref[2] = 'c'; assertE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadLookahead2() throws Exception { final char[] ref = new char[5]; final char[] res = new char[5]; final ExtendedBufferedReader br = getBufferedReader("abcdefg"); ref[0] = 'a'; ref[1] = 'b'; ref...
#fixed code @Test public void testReadLookahead2() throws Exception { final char[] ref = new char[5]; final char[] res = new char[5]; final ExtendedBufferedReader br = getBufferedReader("abcdefg"); ref[0] = 'a'; ref[1] = 'b'; ref[2] = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testForEach() { List<String[]> records = new ArrayList<String[]>(); String code = "a,b,c\n1,2,3\nx,y,z"; Reader in = new StringReader(code); for (String[] record : new CSVParser(in)) { records.add...
#fixed code public void testForEach() { List<String[]> records = new ArrayList<String[]>(); Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z"); for (String[] record : CSVFormat.DEFAULT.parse(in)) { records.add(record); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyInput() throws Exception { final ExtendedBufferedReader br = getBufferedReader(""); assertEquals(END_OF_STREAM, br.read()); assertEquals(END_OF_STREAM, br.lookAhead()); assertEquals(END_OF_STREAM, br.getLast...
#fixed code @Test public void testEmptyInput() throws Exception { final ExtendedBufferedReader br = getBufferedReader(""); assertEquals(END_OF_STREAM, br.read()); assertEquals(END_OF_STREAM, br.lookAhead()); assertEquals(END_OF_STREAM, br.getLastChar()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); ...
#fixed code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br.close(); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readL...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEndOfFileBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nwor...
#fixed code @Test public void testEndOfFileBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCSVFile() throws Exception { String line = readTestData(); assertNotNull("file must contain config line", line); final String[] split = line.split(" "); assertTrue(testName+" require 1 param", split.length >= 1);...
#fixed code @Test public void testCSVFile() throws Exception { String line = readTestData(); assertNotNull("file must contain config line", line); final String[] split = line.split(" "); assertTrue(testName+" require 1 param", split.length >= 1); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testSkip0() throws Exception { br = getEBR(""); assertEquals(0, br.skip(0)); assertEquals(0, br.skip(1)); br = getEBR(""); assertEquals(0, br.skip(1)); br = getEBR("abcdefg"); assertEquals(0, br.skip(0)); assertEq...
#fixed code public void testSkip0() throws Exception { ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.skip(0)); assertEquals(0, br.skip(1)); br = getEBR(""); assertEquals(0, br.skip(1)); br = getEBR("abcdefg"); assertEquals(0, br.skip(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertTrue(br.readLine() == null); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertTrue(br.readLine() ...
#fixed code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); br ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelPrintAllIterableOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(Arrays.asList(new List[] { Arrays.asLis...
#fixed code @Test public void testExcelPrintAllIterableOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(Arrays.asList(new List[] { Arrays.asList(new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyFile() throws Exception { final CSVParser parser = CSVParser.parseString("", CSVFormat.DEFAULT); assertNull(parser.nextRecord()); } #location 4 #vulnerability ty...
#fixed code @Test public void testEmptyFile() throws Exception { final CSVParser parser = CSVParser.parse("", CSVFormat.DEFAULT); assertNull(parser.nextRecord()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void testCSVLexer(final boolean newToken, String test) throws Exception { Token token = new Token(); for (int i = 0; i < max; i++) { final BufferedReader reader = getReader(); Lexer lexer = new CSVLexer(format, new Exten...
#fixed code private static void testCSVLexer(final boolean newToken, String test) throws Exception { Token token = new Token(); String dynamic = ""; for (int i = 0; i < max; i++) { final ExtendedBufferedReader input = new ExtendedBufferedReader(getReader())...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDelimiterIsWhitespace() throws IOException { final String code = "one\ttwo\t\tfour \t five\t six"; final Lexer parser = getLexer(code, CSVFormat.TDF); assertTokenEquals(TOKEN, "one", parser.nextToken(new Token())); ...
#fixed code @Test public void testDelimiterIsWhitespace() throws IOException { final String code = "one\ttwo\t\tfour \t five\t six"; final Lexer parser = getLexer(code, CSVFormat.TDF); assertThat(parser.nextToken(new Token()), matches(TOKEN, "one")); a...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPrinter4() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a", "b\"c"); assertEquals("a,\"b\"\"c\"" + record...
#fixed code @Test public void testPrinter4() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a", "b\"c"); assertEquals("a,\"b\"\"c\"" + recordSepara...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelPrintAllArrayOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(new List[] { Arrays.asList(new String[] { ...
#fixed code @Test public void testExcelPrintAllArrayOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(new List[] { Arrays.asList(new String[] { "r1c1"...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyLineBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; ...
#fixed code @Test public void testEmptyLineBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; final ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNextToken3Escaping() throws IOException { /* file: a,\,,b * \,, */ String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\n"; CSVFormat format = CSVFormat.DEFAULT.withEscape('\\'); assertTrue(format.isEs...
#fixed code @Test public void testNextToken3Escaping() throws IOException { /* file: a,\,,b * \,, */ String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne"; CSVFormat format = CSVFormat.DEFAULT.withEscape('\\').withEmptyLinesIgnored(false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEndOfFileBehaviorCSV() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,...
#fixed code @Test public void testEndOfFileBehaviorCSV() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\"",...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetRecords() throws IOException { final CSVParser parser = CSVParser.parseString(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); final List<CSVRecord> records = parser.getRecords(); assertEquals(RESULT.le...
#fixed code @Test public void testGetRecords() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); final List<CSVRecord> records = parser.getRecords(); assertEquals(RESULT.length, record...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void testParseCommonsCSV() throws Exception { for (int i = 0; i < max; i++) { final BufferedReader reader = getReader(); final CSVParser parser = new CSVParser(reader, format); final long t0 = System.currentTimeMilli...
#fixed code private static void testParseCommonsCSV() throws Exception { for (int i = 0; i < max; i++) { final BufferedReader reader = getReader(); final CSVParser parser = new CSVParser(reader, format); final long t0 = System.currentTimeMillis(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDefaultFormat() throws IOException { String code = "" + "a,b\n" // 1) + "\"\n\",\" \"\n" // 2) + "\"\",#\n" // 2) ; String[][] res = { ...
#fixed code @Test public void testDefaultFormat() throws IOException { String code = "" + "a,b\n" // 1) + "\"\n\",\" \"\n" // 2) + "\"\",#\n" // 2) ; String[][] res = { {"a"...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test // TODO this may lead to strange behavior, throw an exception if iterator() has already been called? public void testMultipleIterators() throws Exception { final CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT); fi...
#fixed code @Test // TODO this may lead to strange behavior, throw an exception if iterator() has already been called? public void testMultipleIterators() throws Exception { final CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT); final It...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""...
#fixed code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""}, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBackslashEscaping2() throws IOException { // To avoid confusion over the need for escaping chars in java code, // We will test with a forward slash as the escape char, and a single // quote as the encapsulator. ...
#fixed code @Test public void testBackslashEscaping2() throws IOException { // To avoid confusion over the need for escaping chars in java code, // We will test with a forward slash as the escape char, and a single // quote as the encapsulator. Strin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void parse() throws IOException { final File csvData = new File("src/test/resources/csv-167/sample1.csv"); final BufferedReader br = new BufferedReader(new FileReader(csvData)); String s = null; int totcomment = 0; ...
#fixed code @Test public void parse() throws IOException { final BufferedReader br = new BufferedReader(getTestInput()); String s = null; int totcomment = 0; int totrecs = 0; boolean lastWasComment = false; while((s=br.readLine()) != nu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLineFeedEndings() throws IOException { final String code = "foo\nbaar,\nhello,world\n,kanu"; final CSVParser parser = new CSVParser(new StringReader(code)); final List<CSVRecord> records = parser.getRecords(); as...
#fixed code @Test public void testLineFeedEndings() throws IOException { final String code = "foo\nbaar,\nhello,world\n,kanu"; final CSVParser parser = CSVParser.parseString(code); final List<CSVRecord> records = parser.getRecords(); assertEquals(4, re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""...
#fixed code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""}, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord().val...
#fixed code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord().values())...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testParseCustomNullValues() throws IOException { final StringWriter sw = new StringWriter(); final CSVFormat format = CSVFormat.DEFAULT.withNullString("NULL"); final CSVPrinter printer = new CSVPrinter(sw, format); p...
#fixed code @Test public void testParseCustomNullValues() throws IOException { final StringWriter sw = new StringWriter(); final CSVFormat format = CSVFormat.DEFAULT.withNullString("NULL"); final CSVPrinter printer = new CSVPrinter(sw, format); printer...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPrinter2() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a,b", "b"); assertEquals("\"a,b\",b" + recordSepa...
#fixed code @Test public void testPrinter2() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a,b", "b"); assertEquals("\"a,b\",b" + recordSeparator,...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br...
#fixed code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getBufferedReader("abcdefg"); ref[0] = 'a'; ref[1] = 'b'; ref[2] = 'c'; assertE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetRecords() throws IOException { CSVParser parser = new CSVParser(new StringReader(code)); String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int...
#fixed code @Test public void testGetRecords() throws IOException { CSVParser parser = new CSVParser(new StringReader(code)); List<CSVRecord> records = parser.getRecords(); assertEquals(res.length, records.size()); assertTrue(records.size() > 0); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); ...
#fixed code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br.close(); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readL...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br = getEBR("abcdefg"); ref[0] = 'a'...
#fixed code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br = getEBR("abcdefg");...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCarriageReturnLineFeedEndings() throws IOException { final String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu"; final CSVParser parser = CSVParser.parse(code, CSVFormat.DEFAULT); final List<CSVRecord> records = parser.g...
#fixed code @Test public void testCarriageReturnLineFeedEndings() throws IOException { final String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu"; final CSVParser parser = CSVParser.parse(code, CSVFormat.DEFAULT); final List<CSVRecord> records = parser.getReco...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyLineBehaviourCSV() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; fi...
#fixed code @Test public void testEmptyLineBehaviourCSV() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; final St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void doOneRandom(final CSVFormat format) throws Exception { final Random r = new Random(); final int nLines = r.nextInt(4) + 1; final int nCol = r.nextInt(3) + 1; // nLines=1;nCol=2; final String[][] lines = new String[nLi...
#fixed code public void doOneRandom(final CSVFormat format) throws Exception { final Random r = new Random(); final int nLines = r.nextInt(4) + 1; final int nCol = r.nextInt(3) + 1; // nLines=1;nCol=2; final String[][] lines = new String[nLines][]...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEndOfFileBehaviorCSV() throws Exception { String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\"",...
#fixed code @Test public void testEndOfFileBehaviorCSV() throws Exception { String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\"", ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCarriageReturnLineFeedEndings() throws IOException { String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); String[][] data = parser.getRecords(); assertEq...
#fixed code @Test public void testCarriageReturnLineFeedEndings() throws IOException { String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); List<CSVRecord> records = parser.getRecords(); assert...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parseString(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord...
#fixed code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord().values())...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCarriageReturnEndings() throws IOException { final String code = "foo\rbaar,\rhello,world\r,kanu"; final CSVParser parser = new CSVParser(new StringReader(code)); final List<CSVRecord> records = parser.getRecords(); ...
#fixed code @Test public void testCarriageReturnEndings() throws IOException { final String code = "foo\rbaar,\rhello,world\r,kanu"; final CSVParser parser = CSVParser.parseString(code); final List<CSVRecord> records = parser.getRecords(); assertEquals...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelFormat1() throws IOException { final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; final String...
#fixed code @Test public void testExcelFormat1() throws IOException { final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; final String[][] r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void parseAlterColumn(final Parser parser, final PgTable table) { parser.expectOptional("COLUMN"); final String columnName = parser.parseIdentifier(); if (parser.expectOptional("SET")) { if (parser.expectO...
#fixed code private static void parseAlterColumn(final Parser parser, final PgTable table) { parser.expectOptional("COLUMN"); final String columnName = parser.parseIdentifier(); if (parser.expectOptional("SET")) { if (parser.expectOptiona...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "VIEW"); final String viewName = parser.parseIdentifier(); final PgView view = database.getSche...
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "VIEW"); final String viewName = parser.parseIdentifier(); final String schemaName = ParserUtils.getS...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(final PgDatabase database, final String command) { String line = command; final Matcher matcher = PATTERN_TABLE_NAME.matcher(line); final String tableName; if (matcher.find()) { tableName = matcher.gr...
#fixed code public static void parse(final PgDatabase database, final String command) { String line = command; final Matcher matcher = PATTERN_TABLE_NAME.matcher(line); final String tableName; if (matcher.find()) { tableName = matcher.group(1)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "TABLE"); parser.expectOptional("ONLY"); final String tableName = parser.parseIdentifier(); ...
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "TABLE"); parser.expectOptional("ONLY"); final String tableName = parser.parseIdentifier(); f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE", "SEQUENCE"); final String sequenceName = parser.parseIdentifier(); final PgSequence sequence =...
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE", "SEQUENCE"); final String sequenceName = parser.parseIdentifier(); final PgSequence sequence = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE"); parser.expectOptional("OR", "REPLACE"); parser.expect("FUNCTION"); final String funct...
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE"); parser.expectOptional("OR", "REPLACE"); parser.expect("FUNCTION"); final String functionNam...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Matcher matcher = PATTERN.matcher(command.trim()); if (matcher.matches()) { final String triggerName = matcher.group(1); final String when = matche...
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE", "TRIGGER"); final PgTrigger trigger = new PgTrigger(); trigger.setName(parser.parseIdentifier()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String loadText(String path) throws IOException { StringBuilder sbText = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path))); Str...
#fixed code private String loadText(String path) throws IOException { StringBuilder sbText = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path), "UTF-8")); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Set<String> loadDictionary(String path) throws IOException { Set<String> dictionary = new TreeSet<String>(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path)...
#fixed code private Set<String> loadDictionary(String path) throws IOException { Set<String> dictionary = new TreeSet<String>(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path), "UTF...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Function<Publisher<?>, Publisher<?>> lookup(String name) { Function<Publisher<?>, Publisher<?>> function = this.function; if (name != null && this.catalog != null) { Function<Publisher<?>, Publisher<?>> preferred = this.catalog .lookup(Function.class,...
#fixed code protected Function<Publisher<?>, Publisher<?>> lookup(String name) { Function<Publisher<?>, Publisher<?>> function = this.function; if (name != null && this.catalog != null) { @SuppressWarnings("unchecked") Function<Publisher<?>, Publisher<?>> preferred = this.catalog ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean isRetainOuputAsMessage(Message<?> message) { if (message.getHeaders().containsKey("message-type") && message.getHeaders().get("message-type").equals("cloudevent")) { return true; } return false; } #location 3...
#fixed code @Override public boolean isRetainOuputAsMessage(Message<?> message) { if (message.getHeaders().containsKey(MessageUtils.MESSAGE_TYPE) && message.getHeaders().get(MessageUtils.MESSAGE_TYPE).equals(CloudEventMessageUtils.CLOUDEVENT_VALUE)) { return true; } return fal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void deployAndExtractFunctions() throws Exception { // This one can only work if you change the boot classpath to contain reactor-core // and reactive-streams expected.expect(ClassCastException.class); @SuppressWarnings("unchecked") Flux<String> res...
#fixed code @Test public void deployAndExtractFunctions() throws Exception { // This one can only work if you change the boot classpath to contain reactor-core // and reactive-streams expected.expect(ClassCastException.class); @SuppressWarnings("unchecked") Flux<String> result = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public static Message<?> toBinary(Message<?> inputMessage, MessageConverter messageConverter) { Map<String, Object> headers = inputMessage.getHeaders(); CloudEventAttributes attributes = new CloudEventAttributes(headers); // first ch...
#fixed code @SuppressWarnings("unchecked") public static Message<?> toBinary(Message<?> inputMessage, MessageConverter messageConverter) { Map<String, Object> headers = inputMessage.getHeaders(); CloudEventAttributes attributes = new CloudEventAttributes(headers); // first check th...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean isRetainOuputAsMessage(Message<?> message) { return message.getHeaders().containsKey(MessageUtils.MESSAGE_TYPE) && message.getHeaders().get(MessageUtils.MESSAGE_TYPE).equals(CloudEventMessageUtils.CLOUDEVENT_VALUE); } ...
#fixed code @Override public boolean isRetainOuputAsMessage(Message<?> message) { return message.getHeaders().containsKey(MessageUtils.TARGET_PROTOCOL) || (message.getHeaders().containsKey(MessageUtils.MESSAGE_TYPE) && message.getHeaders().get(MessageUtils.MESSAGE_TYPE).equals(CloudEv...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") protected void initialize(ExecutionContext ctxt) { ConfigurableApplicationContext context = AzureSpringFunctionInitializer.context; if (!this.initialized.compareAndSet(false, true)) { return; } if (ctxt != null) { ctxt.getLog...
#fixed code @SuppressWarnings("unchecked") protected void initialize(ExecutionContext ctxt) { ConfigurableApplicationContext context = AzureSpringFunctionInitializer.context; if (!this.initialized.compareAndSet(false, true)) { return; } if (ctxt != null) { ctxt.getLogger()....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { try (InputStream in = getAndVerifySigningCertificateChainUrl(signingCertificateChainUrl).openConnection(...
#fixed code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { try (InputStream in = proxy != null ? getAndVerifySigningCertificateChainUrl(signingCertificateChainUrl).openC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { try (InputStream in = proxy != null ? getAndVerifySigningCertificateChainUrl(signingCertificateChainUrl)...
#fixed code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { for (int attempt = 0; attempt <= CERT_RETRIEVAL_RETRY_COUNT; attempt++) { InputStream in = null; try {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Performance.init(); physi...
#fixed code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Performance.init(); physicalDat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean tryLoadProtection(Block block) { Protection protection = lwc.getPhysicalDatabase().loadProtection(block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); if (protection != null) { // ensure it's the right block ...
#fixed code public boolean tryLoadProtection(Block block) { Protection protection = lwc.getPhysicalDatabase().loadProtection(block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); if (protection != null) { // ensure it's the right block ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private int getPlayerDropTransferTarget(LWCPlayer player) { Mode mode = player.getMode("dropTransfer"); String target = mode.getData(); try { return Integer.parseInt(target); } catch (NumberFormatException e) { } ...
#fixed code private int getPlayerDropTransferTarget(LWCPlayer player) { Mode mode = player.getMode("dropTransfer"); if (mode == null) { return -1; } String target = mode.getData(); try { return Integer.parseInt(target); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { LWC lwc = LWC.getInstance(); PhysDB physicalDatabase = lwc.getPhysicalDatabase(); // this patcher only does something exciting if you have mysql enabled // :-) if (physicalDatabase.getType() != Type.MySQL) { ...
#fixed code public void run() { LWC lwc = LWC.getInstance(); PhysDB physicalDatabase = lwc.getPhysicalDatabase(); // this patcher only does something exciting if you have mysql enabled // :-) if (physicalDatabase.getType() != Type.MySQL) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode...
#fixed code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode(plugi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Statistics.init(); physic...
#fixed code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Statistics.init(); physicalData...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Permission decodeJSON(JSONObject node) { Permission permission = new Permission(); // The values are stored as longs internally, despite us passing an int permission.setName((String) node.get("name")); permission.setType(Ty...
#fixed code public static Permission decodeJSON(JSONObject node) { Permission permission = new Permission(); Access access = Access.values()[((Long) node.get("rights")).intValue()]; if (access.ordinal() == 0) { access = Access.PLAYER; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode...
#fixed code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode(plugi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static AccessRight decodeJSON(JSONObject node) { AccessRight right = new AccessRight(); // The values are stored as longs internally, despite us passing an int right.setProtectionId(((Long) node.get("protection")).intValue()); rig...
#fixed code public static AccessRight decodeJSON(JSONObject node) { AccessRight right = new AccessRight(); // The values are stored as longs internally, despite us passing an int // right.setProtectionId(((Long) node.get("protection")).intValue()); right....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void initialize(final int cachePercent) throws IOException { final long fileBytes = file.length(); final long cacheSize = (fileBytes / 100) * cachePercent; final long cacheModulus = cacheSize == 0 ? fileBytes : cacheSize > fileBytes ? 1 : fileB...
#fixed code protected void initialize(final int cachePercent) throws IOException { cache = new Cache(file.length(), cachePercent); FileWord a; FileWord b = null; synchronized (cache) { position = 0; seek(position); while ((a = nextWord()) != null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected String readWord(final int index) throws IOException { int i = 0; if (!cache.isEmpty() && cache.firstKey() <= index) { i = cache.floorKey(index); } FileWord w; synchronized (cache) { position = i > 0 ? cache.get(i) : 0L; ...
#fixed code protected String readWord(final int index) throws IOException { FileWord w; int i; synchronized (cache) { final Cache.Entry entry = cache.get(index); i = entry.index; seek(entry.position); do { w = nextWord(); } while (i++...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HttpConfig files(String[] filePaths, String inputName, boolean forceRemoveContentTypeChraset) { synchronized (getClass()) { if(this.map==null){ this.map= new HashMap<String, Object>(); } } map.put(Utils.ENTITY_MULTIPART, filePaths); map.put(Utils.E...
#fixed code public HttpConfig files(String[] filePaths, String inputName, boolean forceRemoveContentTypeChraset) { // synchronized (getClass()) { // if(this.map==null){ // this.map= new HashMap<String, Object>(); // } // } // map.put(Utils.ENTITY_MULTIPART, filePaths); // map.put...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HttpConfig json(String json) { this.json = json; map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); return this; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public HttpConfig json(String json) { this.json = json; Map<String, Object> map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); maps.set(map); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Map<String, Object> map() { return map; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public Map<String, Object> map() { // return map; return maps.get(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HttpConfig json(String json) { this.json = json; map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); return this; } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public HttpConfig json(String json) { this.json = json; Map<String, Object> map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); maps.set(map); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String usageString(CommandLine commandLine, Help.Ansi ansi) throws UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); commandLine.usage(new PrintStream(baos, true, "UTF8"), ansi); String result...
#fixed code private static String usageString(CommandLine commandLine, Help.Ansi ansi) throws UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); commandLine.usage(new PrintStream(baos, true, "UTF8"), ansi); String result = bao...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void verify(final UChannel channel,String extension, final ISDKVerifyListener callback) { try{ JSONObject json = JSONObject.fromObject(extension); final String ts = json.getString("ts"); final String pla...
#fixed code @Override public void verify(final UChannel channel,String extension, final ISDKVerifyListener callback) { try{ JSONObject json = JSONObject.fromObject(extension); final String ts = json.getString("ts"); final String playerId ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testOverridenFields() throws Exception { MappingFileReader fileReader = new MappingFileReader("overridemapping.xml"); MappingFileData mappingFileData = fileReader.read(); MappingsParser mappingsParser = MappingsParser.getInstance(); map...
#fixed code @Test public void testOverridenFields() throws Exception { MappingFileReader fileReader = new MappingFileReader(XMLParserFactory.getInstance()); MappingFileData mappingFileData = fileReader.read("overridemapping.xml"); MappingsParser mappingsParser = MappingsParse...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDetectDuplicateMapping() throws Exception { MappingFileReader fileReader = new MappingFileReader("duplicateMapping.xml"); MappingFileData mappingFileData = fileReader.read(); try { parser.processMappings(mappingFileData.getClassMa...
#fixed code @Test public void testDetectDuplicateMapping() throws Exception { MappingFileReader fileReader = new MappingFileReader(XMLParserFactory.getInstance()); MappingFileData mappingFileData = fileReader.read("duplicateMapping.xml"); try { parser.processMappings(ma...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void writeDeepDestinationValue(Object destObj, Object destFieldValue, FieldMap fieldMap) { // follow deep field hierarchy. If any values are null along the way, then create a new instance DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(destObj, ...
#fixed code protected void writeDeepDestinationValue(Object destObj, Object destFieldValue, FieldMap fieldMap) { // follow deep field hierarchy. If any values are null along the way, then create a new instance DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(destObj, fieldM...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDuplicateMapIds() throws Exception { MappingFileReader fileReader = new MappingFileReader("duplicateMapIdsMapping.xml"); MappingFileData mappingFileData = fileReader.read(); try { parser.processMappings(mappingFileData.getClassMa...
#fixed code @Test public void testDuplicateMapIds() throws Exception { MappingFileReader fileReader = new MappingFileReader(XMLParserFactory.getInstance()); MappingFileData mappingFileData = fileReader.read("duplicateMapIdsMapping.xml"); try { parser.processMappings(ma...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } ca...
#fixed code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } catch (T...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String getBeanId() { Class<?> factoryClass = objectFactory(destObjClass).getClass(); Class<?> destClass = null; String methodName = "create" + destObjClass.substring(destObjClass.lastIndexOf(".") + 1) + StringUtils.capitalize(destFieldName); try { Method...
#fixed code public String getBeanId() { Class<?> factoryClass = objectFactory(destObjClass).getClass(); Class<?> destClass = null; String methodName = "create" + destObjClass.substring(destObjClass.lastIndexOf(".") + 1) + StringUtils.capitalize(destFieldName); try { Method metho...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getValue() { return value; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public long getValue() { return value.get(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } ca...
#fixed code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } catch (T...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean isEnumType(Class srcFieldClass, Class destFieldType){ if (GlobalSettings.getInstance().isJava5()){//Verify if running JRE is 1.5 or above if (srcFieldClass.isAnonymousClass()){ //If srcFieldClass is anonymous class, replace srcField...
#fixed code public static boolean isEnumType(Class srcFieldClass, Class destFieldType){ if (GlobalSettings.getInstance().isJava5()){//Verify if running JRE is 1.5 or above if ( ((Boolean) ReflectionUtils.invoke(Jdk5Methods.getInstance().getIsAnonymousClassMethod(), srcFieldClass,...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String getScript(String path) { StringBuilder sb = new StringBuilder(); InputStream stream = ScriptUtil.class.getClassLoader().getResourceAsStream(path); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); ...
#fixed code public static String getScript(String path) { StringBuilder sb = new StringBuilder(); InputStream stream = ScriptUtil.class.getClassLoader().getResourceAsStream(path); try (BufferedReader br = new BufferedReader(new InputStreamReader(stream))){ ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean limit() { String key = String.valueOf(System.currentTimeMillis() / 1000); Object result = null; RedisClusterConnection clusterConnection = jedis.getClusterConnection(); if (clusterConnection != null){ JedisClust...
#fixed code public boolean limit() { String key = String.valueOf(System.currentTimeMillis() / 1000); Object result = null; try { RedisClusterConnection clusterConnection = jedis.getClusterConnection(); JedisCluster jedisCluster = (JedisClus...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void init() { HostAndPort hostAndPort = new HostAndPort("10.19.13.51", 7000); JedisCluster jedisCluster = new JedisCluster(hostAndPort); //redisLimit = new RedisLimit.Builder(jedisCluster) // .limit(100) // ...
#fixed code private void init() { HostAndPort hostAndPort = new HostAndPort("10.19.13.51", 7000); JedisCluster jedisCluster = new JedisCluster(hostAndPort); redisLimit = new RedisLimit.Builder<>(jedisCluster) .limit(100) .build(); ...
Below is the vulnerable code, please generate the patch based on the following information.