output
stringlengths
79
30.1k
instruction
stringclasses
1 value
input
stringlengths
216
28.9k
#fixed code public void saveConfig(String configString, File file) throws IOException { String configuration = this.prepareConfigString(configString); BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void saveConfig(String configString, File file) throws IOException { String configuration = this.prepareConfigString(configString); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); writer.write(configur...
#fixed code @Deprecated protected JsonGenerator _createJsonGenerator(Writer out, IOContext ctxt) throws IOException { /* NOTE: MUST call the deprecated method until it is deleted, just so * that override still works as expected, for now. */ ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Deprecated protected JsonGenerator _createJsonGenerator(Writer out, IOContext ctxt) throws IOException { WriterBasedJsonGenerator gen = new WriterBasedJsonGenerator(ctxt, _generatorFeatures, _objectCodec, out); if (_chara...
#fixed code public void testFieldValueWrites() throws Exception { StringWriter sw = new StringWriter(); JsonGenerator gen = new JsonFactory().createGenerator(sw); gen.writeStartObject(); gen.writeNumberField("long", 3L); gen.writ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testFieldValueWrites() throws Exception { StringWriter sw = new StringWriter(); JsonGenerator gen = new JsonFactory().createJsonGenerator(sw); gen.writeStartObject(); gen.writeNumberField("long", 3L); ...
#fixed code public void testConvenienceMethods() throws Exception { StringWriter sw = new StringWriter(); JsonGenerator gen = new JsonFactory().createGenerator(sw); gen.writeStartObject(); final BigDecimal dec = new BigDecimal("0.1"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testConvenienceMethods() throws Exception { StringWriter sw = new StringWriter(); JsonGenerator gen = new JsonFactory().createJsonGenerator(sw); gen.writeStartObject(); final BigDecimal dec = new BigDecimal("0.1")...
#fixed code public void testInvalidObjectWrite() throws Exception { StringWriter sw = new StringWriter(); JsonGenerator gen = new JsonFactory().createGenerator(sw); gen.writeStartObject(); // Mismatch: try { gen.writeEndArra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testInvalidObjectWrite() throws Exception { StringWriter sw = new StringWriter(); JsonGenerator gen = new JsonFactory().createJsonGenerator(sw); gen.writeStartObject(); // Mismatch: try { gen.wr...
#fixed code public void run() { logger.info("ProactiveGcTask starting, oldGenOccupancyFraction:" + oldGenOccupancyFraction); try { long usedOldBytes = logOldGenStatus(); if (needTriggerGc(maxOldBytes, usedOldBytes, oldGenOccupancyFraction)) { preGc(); doGc(); postGc()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { log.info("ProactiveGcTask starting, oldGenOccupancyFraction:" + oldGenOccupancyFraction + ", datetime: " + new Date()); try { oldMemoryPool = getOldMemoryPool(); long maxOldBytes = getMemoryPoolMaxOrCommitted(oldMemoryPool); long oldUse...
#fixed code private void updateGC() { if (perfDataSupport) { ygcCount.update((Long) ygcCountCounter.getValue()); ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter)); fullgcCount.update((Long) fullGcCountCounter.getValue()); fullgcTimeMills.update(perfData.tickToMills(ful...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void updateGC() { if (perfDataSupport) { ygcCount.update((Long) ygcCountCounter.getValue()); ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter)); fullgcCount.update((Long) fullGcCountCounter.getValue()); fullgcTimeMills.update(perfData.tickToMil...
#fixed code private void updateGC() { if (perfDataSupport) { ygcCount.update(ygcCountCounter.longValue()); ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter)); if (fullGcCountCounter != null) { fullgcCount.update(fullGcCountCounter.longValue()); fullgcTimeMills.upda...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void updateGC() { if (perfDataSupport) { ygcCount.update(ygcCountCounter.longValue()); ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter)); if (fullGcCountCounter != null) { fullgcCount.update(fullGcCountCounter.longValue()); fullgcTimeMill...
#fixed code public Double getFGCT() throws Exception { if (fgcCollector == null) { return 0.0; } return Double.parseDouble(getAttribute(fgcCollector, COLLECTION_TIME_ATTRIBUTE).toString()) / 1000; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Double getFGCT() throws Exception { return Double.parseDouble(getAttribute(fgcCollector, COLLECTION_TIME_ATTRIBUTE).toString()) / 1000; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private List<String> readContractList() { return ResourceLoader .newBufferedReader(SLA_CONTRACTS_LIST, getClass()) .lines() .filter(l -> !l.startsWith("#")) .filter(l -> !l.trim().isEmpty()) .collect(toList()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<String> readContractList() { return ResourceLoader .getBufferedReader(getClass(), SLA_CONTRACTS_LIST) .lines() .filter(l -> !l.startsWith("#")) .filter(l -> !l.trim().isEmpty()) .collect(to...
#fixed code protected void updateExecutionTask(ResCloudlet rcl, double currentTime, Processor p) { NetworkCloudlet netcl = (NetworkCloudlet)rcl.getCloudlet(); if(!(netcl.getCurrentTask() instanceof CloudletExecutionTask)) throw new RuntimeException( ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void updateExecutionTask(ResCloudlet rcl, double currentTime, Processor p) { NetworkCloudlet netcl = (NetworkCloudlet)rcl.getCloudlet(); /** * @todo @author manoelcampos updates the execution * length of the task, considering ...
#fixed code public static GoogleTaskEventsTraceReader getInstance( final CloudSim simulation, final String filePath, final Function<TaskEvent, Cloudlet> cloudletCreationFunction) { final InputStream reader = ResourceLoader.newInputStream(filePath, Goog...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static GoogleTaskEventsTraceReader getInstance( final CloudSim simulation, final String filePath, final Function<TaskEvent, Cloudlet> cloudletCreationFunction) { final InputStream reader = ResourceLoader.getInputStream(filePath...
#fixed code private List<String> readContractList() { return ResourceLoader .newBufferedReader(SLA_CONTRACTS_LIST, getClass()) .lines() .map(String::trim) .filter(line -> !line.isEmpty()) .filter(line -> !line.startsWith...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<String> readContractList() { return ResourceLoader .getBufferedReader(getClass(), SLA_CONTRACTS_LIST) .lines() .map(String::trim) .filter(line -> !line.isEmpty()) .filter(line -> !line.star...
#fixed code public static SlaContract getInstance(final String jsonFilePath) { return getInstanceInternal(ResourceLoader.newInputStream(jsonFilePath, SlaContract.class)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static SlaContract getInstance(final String jsonFilePath) { return getInstanceInternal(ResourceLoader.getInputStream(jsonFilePath, SlaContract.class)); } #location 2 #vulnerability type RESOURC...
#fixed code @ManagedMetric(description = "Total Disk Space assigned") public long getTotalDiskAssigned() { return convertPotentialLong(parseStorageTotals().get("hdd").get("total")); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @ManagedMetric(description = "Total Disk Space assigned") public long getTotalDiskAssigned() { return (Long) parseStorageTotals().get("hdd").get("total"); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Test public void testMutators() { final CSVFormat format = new CSVFormat('!', '!', null, '!', '!', true, true, CRLF, null); assertEquals('?', format.withDelimiter('?').getDelimiter()); assertEquals('?', format.withQuoteChar('?').getQuoteChar().ch...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMutators() { final CSVFormat format = new CSVFormat('!', '!', null, '!', '!', true, true, CRLF, null); assertEquals('?', format.withDelimiter('?').getDelimiter()); assertEquals('?', format.withEncapsulator('?').getQuote...
#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 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 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 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 @Test @Ignore public void testBackslashEscapingOld() throws IOException { 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 @Ignore public void testBackslashEscapingOld() throws IOException { String code = "one,two,three\n" + "on\\\"e,two\n" + "on\"e,two\n" + "one,\"tw\\\"o\"\n" ...
#fixed code @Test public void testExcelFormat1() throws IOException { String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; String[][] res = { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExcelFormat1() throws IOException { String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; String[][] res = {...
#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 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 testDisabledComment() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printComment("This is a comment"); assertEquals("", sw.toStr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDisabledComment() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printComment("This is a comment"); assertEquals("", sw...
#fixed code @Test public void testEmptyLineBehaviourExcel() 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[][] r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyLineBehaviourExcel() 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 testGetRecords() throws IOException { final CSVParser parser = CSVParser.parseString(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); final List<CSVRecord> records = parser.getRecords(); assertEquals(RESULT.length, ...
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 = new CSVParser(new StringReader(CSVINPUT), CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); final List<CSVRecord> records = parser.getRecords(); assertEquals...
#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 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 testDefaultFormat() throws IOException { final String code = "" + "a,b#\n" // 1) + "\"\n\",\" \",#\n" // 2) + "#,\"\"\n" // 3) + "# Final comment\n"// 4) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDefaultFormat() throws IOException { final String code = "" + "a,b#\n" // 1) + "\"\n\",\" \",#\n" // 2) + "#,\"\"\n" // 3) + "# Final comment\n"// 4) ...
#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 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 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 @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 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 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 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 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 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 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 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 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 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 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 @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 @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 private void writeToLog(String type, String content) { writerThread.execute(()->{ String t = ServerTimeUtil.accurateToLogName(); File f = new File(logs, t + ".klog"); FileWriter fw = null; if (f.exists()) { try { fw = new FileWriter(f, true); fw.write...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void writeToLog(String type, String content) { String t = ServerTimeUtil.accurateToLogName(); File f = new File(logs, t + ".klog"); FileWriter fw = null; if (f.exists()) { try { fw = new FileWriter(f, true); fw.write("\r\n\r\nTIME:\r\n" + ServerT...
#fixed code @Override public String checkImportFolder(HttpServletRequest request) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String folderName = request.getParameter("folderName"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String checkImportFolder(HttpServletRequest request) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String folderName = request.getParameter("folderName...
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
#fixed code private void deleteFolder(String folderId) throws SQLException { Folder f = selectFolderById(folderId); List<Node> nodes = selectNodesByFolderId(folderId); int size = nodes.size(); if(f==null) { return; } // 删除该文件夹内的所有文件 for (int i = 0; i < size && gono; i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void deleteFolder(String folderId) throws SQLException { Folder f = selectFolderById(folderId); List<Node> nodes = selectNodesByFolderId(folderId); int size = nodes.size(); // 删除该文件夹内的所有文件 for (int i = 0; i < size && gono; i++) { deleteFile(nodes.get(i...
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
#fixed code private void createDefaultAccountPropertiesFile() { Printer.instance.print("正在生成初始账户配置文件(" + this.confdir + ACCOUNT_PROPERTIES_FILE + ")..."); final Properties dap = new Properties(); dap.setProperty(DEFAULT_ACCOUNT_ID + ".pwd", DEFAULT_ACCOUNT_PWD); dap.setProperty(DEFA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void createDefaultAccountPropertiesFile() { Printer.instance.print("正在生成初始账户配置文件(" + this.confdir + ACCOUNT_PROPERTIES_FILE + ")..."); final Properties dap = new Properties(); dap.setProperty(DEFAULT_ACCOUNT_ID + ".pwd", DEFAULT_ACCOUNT_PWD); dap.setPropert...
#fixed code @Override public boolean add(T e) { return internalAdd(e); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean add(T e) { return internalAdd(e, true); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code private boolean internalRemove(T element) { boolean success = false; if (element != null) { success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName()) .srem(JOhmUtils.getId(element).toString()) > 0; unindexValue...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean internalRemove(T element) { boolean success = nest.cat(JOhmUtils.getId(owner)).cat(field.getName()) .srem(JOhmUtils.getId(element).toString()) > 0; unindexValue(element); return success; } ...
#fixed code private boolean internalRemove(T element) { boolean success = false; if (element != null) { Integer lrem = nest.cat(JOhmUtils.getId(owner)) .cat(field.getName()).lrem(1, JOhmUtils.getId(element).toStr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean internalRemove(T element) { Integer lrem = nest.cat(JOhmUtils.getId(owner)).cat(field.getName()) .lrem(1, JOhmUtils.getId(element).toString()); unindexValue(element); return lrem > 0; } ...
#fixed code @Override public boolean add(T element) { return internalAdd(element); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean add(T element) { return internalAdd(element, true); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Test public void cannotSearchAfterDeletingIndexes() { User user = new User(); user.setAge(88); JOhm.save(user); user.setAge(77); // younger JOhm.save(user); user.setAge(66); // younger still JOhm.save(user); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void cannotSearchAfterDeletingIndexes() { User user = new User(); user.setAge(88); JOhm.save(user); user.setAge(77); // younger JOhm.save(user); user.setAge(66); // younger still JOhm.save(user);...
#fixed code @Test public void readPlainTextValuesWithCoverageContextContinuouslyWithReturnBody() throws ExecutionException, InterruptedException, UnknownHostException { final Map<String, RiakObject> results = performFBReadWithCoverageContext(true, true, false)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void readPlainTextValuesWithCoverageContextContinuouslyWithReturnBody() throws ExecutionException, InterruptedException, UnknownHostException { final Map<String, RiakObject> results = performFBReadWithCoverageContext(true, true);...
#fixed code @Test public void testInterruptedExceptionDealtWith() throws InterruptedException { final Throwable[] ex = {null}; int timeout = 1000; Thread testThread = new Thread(() -> { try { @SuppressWarnin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testInterruptedExceptionDealtWith() throws InterruptedException { final boolean[] caught = {false}; final InterruptedException[] ie = {null}; int timeout = 1000; Thread t = new Thread(() -> { ...
#fixed code public double createdUTC() throws IOException, ParseException { return Double.parseDouble(getUserInformation().get("created_utc").toString()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public double createdUTC() throws IOException, ParseException { return Double.parseDouble(info().get("created_utc").toString()); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code @Override protected void processEvents(int readyCount) throws IOReactorException { processSessionRequests(); if (readyCount > 0) { Set<SelectionKey> selectedKeys = this.selector.selectedKeys(); for (Iterator<SelectionKey> i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void processEvents(int readyCount) throws IOReactorException { processSessionRequests(); if (readyCount > 0) { Set<SelectionKey> selectedKeys = this.selector.selectedKeys(); for (Iterator<Selection...
#fixed code @Test public void testEntityWithInvalidContentLength() throws Exception { SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'}); HttpMessage message = new DummyHttpMessage(); // lenient mode message.getParams().setBool...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEntityWithInvalidContentLength() throws Exception { SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'}); HttpMessage message = new DummyHttpMessage(); // lenient mode message.getParams().s...
#fixed code @Test public void testEndOfStreamConditionReadingFooters() throws Exception { String s = "10\r\n1234567890123456\r\n" + "5\r\n12345\r\n5\r\n12345\r\n0\r\n"; ReadableByteChannel channel = new ReadableByteChannelMock( new Stri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEndOfStreamConditionReadingFooters() throws Exception { String s = "10\r\n1234567890123456\r\n" + "5\r\n12345\r\n5\r\n12345\r\n0\r\n"; ReadableByteChannel channel = new ReadableByteChannelMockup( ...
#fixed code public void testSimpleHttpPostsChunked() throws Exception { HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() { @Override protected HttpRequest generateRequest(Job testjob) { String s = testjob...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testSimpleHttpPostsChunked() throws Exception { HttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() { @Override protected HttpRequest generateRequest(TestJob testjob) { Stri...
#fixed code @Override protected void onResponseReceived(final HttpResponse response) throws IOException { this.response = response; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void onResponseReceived(final HttpResponse response) throws IOException { this.response = response; HttpEntity entity = this.response.getEntity(); if (entity != null) { long len = entity.getContentLength(); ...
#fixed code public void testSimpleHttpHeads() throws Exception { int connNo = 3; int reqNo = 20; Job[] jobs = new Job[connNo * reqNo]; for (int i = 0; i < jobs.length; i++) { jobs[i] = new Job(); } Queue<Job> queue = new Concurr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testSimpleHttpHeads() throws Exception { int connNo = 3; int reqNo = 20; TestJob[] jobs = new TestJob[connNo * reqNo]; for (int i = 0; i < jobs.length; i++) { jobs[i] = new TestJob(); } Queue<TestJo...
#fixed code @Test public void testConstructors() throws Exception { final ContentLengthOutputStream in = new ContentLengthOutputStream( new SessionOutputBufferMock(), 10L); in.close(); try { new ContentLengthOutputStream(null, 10L);...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConstructors() throws Exception { new ContentLengthOutputStream(new SessionOutputBufferMock(), 10L); try { new ContentLengthOutputStream(null, 10L); Assert.fail("IllegalArgumentException should have been ...
#fixed code public void testWriteBeyondFileSize() throws Exception { ReadableByteChannel channel = new ReadableByteChannelMockup( new String[] {"a"}, "US-ASCII"); HttpParams params = new BasicHttpParams(); SessionInputBuffer inbuf = new S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testWriteBeyondFileSize() throws Exception { ReadableByteChannel channel = new ReadableByteChannelMockup( new String[] {"a"}, "US-ASCII"); HttpParams params = new BasicHttpParams(); SessionInputBuffer inbuf =...
#fixed code public void testResponseContentNoEntity() throws Exception { HttpContext context = new BasicHttpContext(null); HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); ResponseContent interceptor = new ResponseConten...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testResponseContentNoEntity() throws Exception { HttpContext context = new HttpExecutionContext(null); HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); ResponseContent interceptor = new Resp...
#fixed code public void testInputThrottling() throws Exception { HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() { public void initalizeContext(final HttpContext context, final Object attachment) { context.setAt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testInputThrottling() throws Exception { HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() { public void initalizeContext(final HttpContext context, final Object attachment) { context...
#fixed code public static String toString( final HttpEntity entity, final String defaultCharset) throws IOException, ParseException { if (entity == null) { throw new IllegalArgumentException("HTTP entity may not be null"); } InputStream ins...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String toString( final HttpEntity entity, final String defaultCharset) throws IOException, ParseException { if (entity == null) { throw new IllegalArgumentException("HTTP entity may not be null"); } InputStre...
#fixed code protected void processEvent(final SelectionKey key) { IOSessionImpl session = (IOSessionImpl) key.attachment(); try { if (key.isAcceptable()) { acceptable(key); } if (key.isConnectable()) { co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void processEvent(final SelectionKey key) { SessionHandle handle = (SessionHandle) key.attachment(); IOSession session = handle.getSession(); try { if (key.isAcceptable()) { acceptable(key); } ...
#fixed code public void testBasicDecodingFile() throws Exception { ReadableByteChannel channel = new ReadableByteChannelMockup( new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII"); HttpParams params = new BasicHttpParams(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testBasicDecodingFile() throws Exception { ReadableByteChannel channel = new ReadableByteChannelMockup( new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII"); HttpParams params = new BasicHttpParams(); ...
#fixed code @Test public void testFoldedFooters() throws Exception { String s = "10;key=\"value\"\r\n1234567890123456\r\n" + "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n \r\n fghij\r\n\r\n"; ReadableByteChannel channel = new ReadableByteChan...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFoldedFooters() throws Exception { String s = "10;key=\"value\"\r\n1234567890123456\r\n" + "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n \r\n fghij\r\n\r\n"; ReadableByteChannel channel = new ReadableBy...
#fixed code @Test public void testEntityWithMultipleContentLengthAllWrong() throws Exception { SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'}); HttpMessage message = new DummyHttpMessage(); // lenient mode message.getParams(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEntityWithMultipleContentLengthAllWrong() throws Exception { SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'}); HttpMessage message = new DummyHttpMessage(); // lenient mode message.getP...
#fixed code public void testHttpPostsWithExpectationVerification() throws Exception { Job[] jobs = new Job[3]; jobs[0] = new Job("AAAAA", 10); jobs[1] = new Job("AAAAA", 10); jobs[2] = new Job("BBBBB", 20); Queue<Job> queue = new ConcurrentLinkedQu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testHttpPostsWithExpectationVerification() throws Exception { TestJob[] jobs = new TestJob[3]; jobs[0] = new TestJob("AAAAA", 10); jobs[1] = new TestJob("AAAAA", 10); jobs[2] = new TestJob("BBBBB", 20); Queue<TestJob> ...
#fixed code @Test public void testWriteBeyondFileSize() throws Exception { ReadableByteChannel channel = new ReadableByteChannelMock( new String[] {"a"}, "US-ASCII"); HttpParams params = new BasicHttpParams(); SessionInputBuffer inbuf = new Se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testWriteBeyondFileSize() throws Exception { ReadableByteChannel channel = new ReadableByteChannelMockup( new String[] {"a"}, "US-ASCII"); HttpParams params = new BasicHttpParams(); SessionInputBuffer inbuf ...
#fixed code public HttpClientConnection create(final HttpHost host) throws IOException { final String scheme = host.getSchemeName(); Socket socket = null; if ("http".equalsIgnoreCase(scheme)) { socket = this.plainfactory != null ? this.plainfactory.cre...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HttpClientConnection create(final HttpHost host) throws IOException { final String scheme = host.getSchemeName(); Socket socket = null; if ("http".equalsIgnoreCase(scheme)) { socket = this.plainfactory != null ? this.plainfacto...
#fixed code public void testHttpPostsWithExpectationVerification() throws Exception { Job[] jobs = new Job[3]; jobs[0] = new Job("AAAAA", 10); jobs[1] = new Job("AAAAA", 10); jobs[2] = new Job("BBBBB", 20); Queue<Job> queue = new ConcurrentLinkedQu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testHttpPostsWithExpectationVerification() throws Exception { TestJob[] jobs = new TestJob[3]; jobs[0] = new TestJob("AAAAA", 10); jobs[1] = new TestJob("AAAAA", 10); jobs[2] = new TestJob("BBBBB", 20); Queue<TestJob> ...
#fixed code @Test public void testResponseContentOverwriteHeaders() throws Exception { ResponseContent interceptor = new ResponseContent(true); HttpContext context = new BasicHttpContext(null); HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testResponseContentOverwriteHeaders() throws Exception { ResponseContent interceptor = new ResponseContent(true); HttpContext context = new BasicHttpContext(null); HttpResponse response = new BasicHttpResponse(HttpVersion.HT...
#fixed code @Test public void testBlockByAvailabilityOnAllServices() throws Exception { ApolloTestClient apolloTestClient = Common.signupAndLogin(); ApolloTestAdminClient apolloTestAdminClient = Common.getAndLoginApolloTestAdminClient(); String availability =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBlockByAvailabilityOnAllServices() throws Exception { ApolloTestClient apolloTestClient = Common.signupAndLogin(); ApolloTestAdminClient apolloTestAdminClient = Common.getAndLoginApolloTestAdminClient(); String availabi...
#fixed code @Test public void tooDeeplyNestedObjects() throws IOException { Object root = Boolean.TRUE; for (int i = 0; i < MAX_DEPTH + 1; i++) { root = singletonMap("a", root); } JsonReader reader = new JsonValueReader(root); for (int i = 0; i < MAX_DEPTH; i++) {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void tooDeeplyNestedObjects() throws IOException { Object root = Boolean.TRUE; for (int i = 0; i < 32; i++) { root = singletonMap("a", root); } JsonReader reader = new JsonValueReader(root); for (int i = 0; i < 31; i++) { reade...
#fixed code @Test public void readerUnquotedDoubleValue() throws Exception { JsonReader reader = factory.newReader("{5:1}"); reader.setLenient(true); reader.beginObject(); reader.promoteNameToValue(); assertThat(reader.nextDouble()).isEqualTo(5d); assertThat(reader....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void readerUnquotedDoubleValue() throws Exception { JsonReader reader = newReader("{5:1}"); reader.setLenient(true); reader.beginObject(); reader.promoteNameToValue(); assertThat(reader.nextDouble()).isEqualTo(5d); assertThat(reader.ne...
#fixed code public static JsonWriter of(BufferedSink sink) { return new JsonUtf8Writer(sink); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static JsonWriter of(BufferedSink sink) { return new JsonUt8Writer(sink); } #location 2 #vulnerability type RESOURCE_LEAK
#fixed code public boolean addOrReplace(byte[] key, V old, V value) { KeyBuffer keyBuffer = keySource(key); byte[] data = value(value); byte[] oldData = value(old); CheckSegment segment = segment(keyBuffer.hash()); return segment.put(keyBuffer...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean addOrReplace(byte[] key, V old, V value) { KeyBuffer keyBuffer = keySource(key); byte[] data = value(value); byte[] oldData = value(old); if (maxEntrySize > 0L && CheckSegment.sizeOf(keyBuffer, data) > maxEntrySize) ...
#fixed code public boolean put(byte[] key, V value) { KeyBuffer keyBuffer = keySource(key); byte[] data = value(value); CheckSegment segment = segment(keyBuffer.hash()); return segment.put(keyBuffer, data, false, null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean put(byte[] key, V value) { KeyBuffer keyBuffer = keySource(key); byte[] data = value(value); if (maxEntrySize > 0L && CheckSegment.sizeOf(keyBuffer, data) > maxEntrySize) { remove(key); putFailC...
#fixed code Parser(Parser p, String text) { this.logger = p.logger; this.properties = p.properties; this.infoMap = p.infoMap; this.tokens = new TokenIndexer(infoMap, new Tokenizer(text).tokenize()); this.lineSeparator = p.lineSeparator; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void parse(File outputFile, Context context, String[] includePath, String ... includes) throws IOException, ParserException { ArrayList<Token> tokenList = new ArrayList<Token>(); for (String include : includes) { File file = null; ...
#fixed code void init(long allocatedAddress, int allocatedCapacity, long ownerAddress, long deallocatorAddress) { address = allocatedAddress; position = 0; limit = allocatedCapacity; capacity = allocatedCapacity; deallocator(new NativeDeallocator(t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void init(long allocatedAddress, int allocatedCapacity, long deallocatorAddress) { address = allocatedAddress; position = 0; limit = allocatedCapacity; capacity = allocatedCapacity; deallocator(new NativeDeallocator(this, dealloca...
#fixed code public static File cacheResource(URL resourceURL, String target) throws IOException { // Find appropriate subdirectory in cache for the resource ... File urlFile; try { urlFile = new File(new URI(resourceURL.toString().split("#")[0])); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static File cacheResource(URL resourceURL, String target) throws IOException { // Find appropriate subdirectory in cache for the resource ... File urlFile; try { urlFile = new File(new URI(resourceURL.toString().split("#")[0]))...
#fixed code @RequestMapping(value = "/{id}", method = RequestMethod.PUT) public boolean updateRule(@PathVariable String id, @RequestBody RouteDTO routeDTO, @PathVariable String env) { Route route = routeService.findRoute(id); if (route == null) { throw new...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value = "/{id}", method = RequestMethod.PUT) public boolean updateRule(@PathVariable String id, @RequestBody RouteDTO routeDTO, @PathVariable String env) { Route route = routeService.findRoute(id); if (route == null) { //T...
#fixed code @Override public AnalysisResult run() throws Exception { long startMs = System.currentTimeMillis(); DataIngester ingester = conf.constructIngester(); List<Datum> data = ingester.getStream().drain(); long loadEndMs = System.currentTimeMillis...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public AnalysisResult run() throws Exception { long startMs = System.currentTimeMillis(); DataIngester ingester = conf.constructIngester(); List<Datum> data = ingester.getStream().drain(); long loadEndMs = System.currentTime...
#fixed code public static void buildSysGenProfilingFile() { long startMills = System.currentTimeMillis(); String filePath = ProfilingConfig.getInstance().getSysProfilingParamsFile(); String tempFilePath = filePath + "_tmp"; File tempFile = new File(tempFil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void buildSysGenProfilingFile() { long startMills = System.currentTimeMillis(); String filePath = ProfilingConfig.getInstance().getSysProfilingParamsFile(); String tempFilePath = filePath + "_tmp"; File tempFile = new File(t...
#fixed code public void encodePacket(Packet packet, ByteBuf buffer, ByteBufAllocator allocator, boolean binary, boolean jsonp) throws IOException { ByteBuf buf = buffer; if (!binary) { buf = allocateBuffer(allocator); } byte type = toChar(packe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void encodePacket(Packet packet, ByteBuf buffer, ByteBufAllocator allocator, boolean binary, boolean jsonp) throws IOException { ByteBuf buf = buffer; if (!binary) { buf = allocateBuffer(allocator); } byte type = toChar...
#fixed code @Test public void testDecodeWithData() throws IOException { JacksonJsonSupport jsonSupport = new JacksonJsonSupport(); jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class); PacketDecoder decoder = new PacketDecoder(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDecodeWithData() throws IOException { JacksonJsonSupport jsonSupport = new JacksonJsonSupport(); jsonSupport.addEventMapping("", "edwald", HashMap.class, Integer.class, String.class); PacketDecoder decoder = new PacketDe...
#fixed code @Test public void canUpsertWithWriteConcern() throws Exception { /* when */ WriteResult writeResult = collection.update("{}").upsert().concern(WriteConcern.SAFE).with("{$set:{name:'John'}}"); /* then */ People john = collection.findOne("{...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void canUpsertWithWriteConcern() throws Exception { WriteConcern writeConcern = spy(WriteConcern.SAFE); /* when */ WriteResult writeResult = collection.upsert("{}", "{$set:{name:'John'}}", writeConcern); /* then */ ...
#fixed code @Test //https://groups.google.com/forum/?fromgroups#!topic/jongo-user/p9CEKnkKX9Q public void canUpdateIntoAnArray() throws Exception { collection.insert("{friends:[{name:'Robert'},{name:'Peter'}]}"); collection.update("{ 'friends.name' : 'Peter' }")...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test //https://groups.google.com/forum/?fromgroups#!topic/jongo-user/p9CEKnkKX9Q public void canUpdateIntoAnArray() throws Exception { collection.insert("{friends:[{name:'Robert'},{name:'Peter'}]}"); collection.update("{ 'friends.name' : 'Pete...
#fixed code @Test public void canUpsert() throws Exception { /* when */ WriteResult writeResult = collection.update("{}").upsert().with("{$set:{name:'John'}}"); /* then */ People john = collection.findOne("{name:'John'}").as(People.class); as...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void canUpsert() throws Exception { /* when */ WriteResult writeResult = collection.upsert("{}", "{$set:{name:'John'}}"); /* then */ People john = collection.findOne("{name:'John'}").as(People.class); assertThat...
#fixed code @Test public void shouldAddHeader() throws IOException { driver.addExpectation(onRequestTo("/") .withHeader("X-Trace-ID", "16c38974-7530-11e5-bb35-10ddb1ee7671") .withHeader("X-Request-ID", "2e7a3324-7530-11e5-ad30-1...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldAddHeader() throws IOException { driver.addExpectation(onRequestTo("/") .withHeader("X-Trace-ID", "16c38974-7530-11e5-bb35-10ddb1ee7671") .withHeader("X-Request-ID", "2e7a3324-7530-11e5-...
#fixed code public static void start(List<GraphvizEngine> engines) throws IOException { final String executable = SystemUtils.executableName("java"); final List<String> cmd = new ArrayList<>(Arrays.asList( System.getProperty("java.home") + "/bin/" + execut...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void start(List<GraphvizEngine> engines) throws IOException { final boolean windows = System.getProperty("os.name").contains("windows"); final String executable = windows ? "java.exe" : "java"; final List<String> cmd = new ArrayList...
#fixed code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING) && !stat.compareAndSet(STAT_STOPPED, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run() { if (!stat.compareAndSet(STAT_INIT, STAT_RUNNING) && !stat.compareAndSet(STAT_STOPPED, STAT_RUNNING)) { throw new IllegalStateException("Spider is already running!"); } checkComponent()...
#fixed code @Test public void testRemovePadding() throws Exception { String name = new Json(text).removePadding("callback").jsonPath("$.name").get(); assertThat(name).isEqualTo("json"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRemovePadding() throws Exception { String name = new Json(text).removePadding("callback").jsonPath("$.name").get(); assertThat(name).isEqualTo("json"); Page page = null; page.getJson().jsonPath("$.name").get(); ...
#fixed code @Override public boolean tryAdvance(Consumer<? super E> action) { Objects.requireNonNull(action); if (exhausted) return false; LinkedBlockingDeque<E> q = queue; ReentrantLock lock = queueLock; Object p = current; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean tryAdvance(Consumer<? super E> action) { Objects.requireNonNull(action); LinkedBlockingDeque<E> q = queue; ReentrantLock lock = queueLock; if (!exhausted) { E e = null; lock.lock(); ...
#fixed code @Override @SuppressWarnings("unchecked") public void forEachRemaining(Consumer<? super E> action) { Objects.requireNonNull(action); int hi = getFence(); Object[] a = array; int i; for (i = index, index = hi; i < hi; i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override @SuppressWarnings("unchecked") public void forEachRemaining(Consumer<? super E> action) { Objects.requireNonNull(action); int i, hi; // hoist accesses and checks from loop Vector<E> lst = list; Object[] a; if ((h...
#fixed code private static Map<Integer, String> listProcessByJps(boolean v) { Map<Integer, String> result = new LinkedHashMap<Integer, String>(); String jps = "jps"; File jpsFile = findJps(); if (jpsFile != null) { jps = jpsFile.getAbsolutePat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static Map<Integer, String> listProcessByJps(boolean v) { Map<Integer, String> result = new LinkedHashMap<Integer, String>(); String jps = "jps"; File jpsFile = findJps(); if (jpsFile != null) { jps = jpsFile.getAbsol...
#fixed code @Override public void process(final CommandProcess process) { int exitCode = 0; RowAffect affect = new RowAffect(); try { Instrumentation inst = process.session().getInstrumentation(); ClassLoader classloader = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void process(final CommandProcess process) { int exitCode = 0; RowAffect affect = new RowAffect(); try { Instrumentation inst = process.session().getInstrumentation(); ClassLoader classloader = null; ...
#fixed code public static void write(String content, File output) throws IOException { try (final FileOutputStream out = new FileOutputStream(output); final OutputStreamWriter w = new OutputStreamWriter(out)) { w.write(content); w.flush(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void write(String content, File output) throws IOException { FileOutputStream out = new FileOutputStream(output); OutputStreamWriter w = new OutputStreamWriter(out); try { w.write(content); w.flush(); } finally { out.close(); } } ...
#fixed code public void close(IotHubConnectionStatusChangeReason reason, Throwable cause) throws DeviceClientException { if (reason == null) { //Codes_SRS_IOTHUBTRANSPORT_34_026: [If the supplied reason is null, this function shall throw an // ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void close(IotHubConnectionStatusChangeReason reason, Throwable cause) throws DeviceClientException { if (reason == null) { //Codes_SRS_IOTHUBTRANSPORT_34_026: [If the supplied reason is null, this function shall throw an ...
#fixed code public MojoExecutionService getMojoExecutionService() { return mojoExecutionService; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MojoExecutionService getMojoExecutionService() { checkBaseInitialization(); return mojoExecutionService; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Test public void testFromSettingsSimple() throws MojoExecutionException { setupServers(); AuthConfig config = factory.createAuthConfig(isPush, null, settings, "roland", "test.org"); assertNotNull(config); verifyAuthConfig(config, "roland",...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFromSettingsSimple() throws MojoExecutionException { setupServers(); AuthConfig config = factory.createAuthConfig(null,settings, "roland", "test.org"); assertNotNull(config); verifyAuthConfig(config, "roland", "s...
#fixed code private void execute() throws IOException, TransformerException, JAXBException { final CFLint cflint = new CFLint(loadConfig(configfile)); cflint.setVerbose(verbose); cflint.setLogError(logerror); cflint.setQuiet(quiet); cflint.setShowProgress(showprogress); cflint.s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void execute() throws IOException, TransformerException, JAXBException { CFLintConfig config = null; if(configfile != null){ if(configfile.toLowerCase().endsWith(".xml")){ config = ConfigUtils.unmarshal(new FileInputStream(configfile), CFLintConfig.class...
#fixed code @Override public void dispose() { if (!disposed.compareAndSet(false, true)) { return; } LOG.debug("Disposing GStreamer device"); close(); source.dispose(); filter.dispose(); jpegdec.dispose(); caps.dispose(); sink.dispose(); pipe.dispose(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void dispose() { if (!disposed.compareAndSet(false, true)) { return; } LOG.debug("Disposing GStreamer device"); close(); source.dispose(); filter.dispose(); jpegparse.dispose(); jpegdec.dispose(); caps.dispose(); sink.dispose();...
#fixed code @Override public void close() { if (!open.compareAndSet(true, false)) { return; } LOG.debug("Closing GStreamer device"); pipelineStop(); image = null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void close() { if (!open.compareAndSet(true, false)) { return; } LOG.debug("Closing GStreamer device"); image = null; LOG.debug("Unlink elements"); pipe.setState(State.NULL); Element.unlinkMany(source, filter, sink); pipe.removeMan...