input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public static void main(String[] args) throws SQLException, Exception { AllBenchmark.runBenchmark(DbHelper.mockDb(), SmallBenchmarkObject.class, DynamicJdbcMapperForEachBenchmark.class, BenchmarkConstants.SINGLE_QUERY_SIZE, BenchmarkConstants.SINGLE_NB_ITERATION); } ...
#fixed code public static void main(String[] args) throws SQLException, Exception { AllBenchmark.runBenchmark(DbHelper.getConnection(args), DynamicJdbcMapperForEachBenchmark.class); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> CsvMapperBuilder<T> newBuilder(final Class<T> target) { CsvMapperBuilder<T> builder = new CsvMapperBuilder<T>(target, getClassMeta(target), aliases, customReaders, propertyNameMatcherFactory); builder.fieldMapperErrorHandler(fieldMapperErrorHandler); build...
#fixed code public <T> CsvMapperBuilder<T> newBuilder(final Class<T> target) { ClassMeta<T> classMeta = getClassMeta(target); CsvMapperBuilder<T> builder = new CsvMapperBuilder<T>(target, classMeta, aliases, customReaders, propertyNameMatcherFactory); builder.fieldMapperErrorHandler(f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ResultSetMapperBuilder<T> addMapping(String property, String column) { Setter<T, Object> setter = setterFactory.getSetter(target, property); Mapper<ResultSet, T> fieldMapper; if (setter.getPropertyType().isPrimitive()) { fieldMapper = primitiveFieldMa...
#fixed code public ResultSetMapperBuilder<T> addMapping(String property, String column) { Setter<T, Object> setter = setterFactory.getSetter(target, property); addMapping(setter, column); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testComposition() { CsvColumnDefinition compose = CsvColumnDefinition.compose(CsvColumnDefinition.compose(CsvColumnDefinition.dateFormatDefinition("yyyyMM"), CsvColumnDefinition.renameDefinition("blop")), CsvColumnDefinitio...
#fixed code @Test public void testComposition() { CsvColumnDefinition compose = CsvColumnDefinition.dateFormatDefinition("yyyyMM").addRename("blop").addCustomReader( new CellValueReader<Integer>() { @Override public Int...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <S, T> Instantiator<S, T> getInstantiator(final Class<S> source, final Class<T> target) throws NoSuchMethodException, SecurityException { final Constructor<T> constructor = getSmallerConstructor(target); Object[] args; if (constructor.getParameterTypes()...
#fixed code public <S, T> Instantiator<S, T> getInstantiator(final Class<S> source, final Class<T> target) throws NoSuchMethodException, SecurityException { final Constructor<T> constructor = getSmallerConstructor(target); if (constructor == null) { throw new NoSuchMethodException...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testArrayElementConstructorInjectionWithIncompatibleConstructorUseIncompatibleOutlay() { ClassMeta<ObjectWithIncompatibleConstructor[]> classMeta = ReflectionService.newInstance().getClassMeta(ObjectWithIncompatibleConstructor[].class); ...
#fixed code @Test public void testArrayElementConstructorInjectionWithIncompatibleConstructorUseIncompatibleOutlay() { ClassMeta<ObjectWithIncompatibleConstructor[]> classMeta = ReflectionService.newInstance().getRootClassMeta(ObjectWithIncompatibleConstructor[].class); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") protected void _addMapping(K key, final FieldMapperColumnDefinition<K, S> columnDefinition) { final FieldMapperColumnDefinition<K, S> composedDefinition = FieldMapperColumnDefinition.compose(columnDefinition, columnDefinitions.getColumnDef...
#fixed code @SuppressWarnings("unchecked") protected void _addMapping(K key, final FieldMapperColumnDefinition<K, S> columnDefinition) { final FieldMapperColumnDefinition<K, S> composedDefinition = FieldMapperColumnDefinition.compose(columnDefinition, columnDefinitions.getColumnDefinitio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFindElementOnArray() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getClassMeta(DbObject[].class); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPropertyFinder(); PropertyMeta<DbObject...
#fixed code @Test public void testFindElementOnArray() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getRootClassMeta(DbObject[].class); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPropertyFinder(); PropertyMeta<DbObject[]...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testArrayElementConstructorInjectionWithIncompatibleConstructorUseCompatibleOutlay() { ClassMeta<ObjectWithIncompatibleConstructor[]> classMeta = ReflectionService.newInstance().getClassMeta(ObjectWithIncompatibleConstructor[].class); ...
#fixed code @Test public void testArrayElementConstructorInjectionWithIncompatibleConstructorUseCompatibleOutlay() { ClassMeta<ObjectWithIncompatibleConstructor[]> classMeta = ReflectionService.newInstance().getRootClassMeta(ObjectWithIncompatibleConstructor[].class); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPrimitiveField() { ClassMeta<DbObject> classMeta = ReflectionService.newInstance(true, false).getClassMeta(DbObject.class); PropertyMeta<DbObject, Long> id = classMeta.newPropertyFinder().<Long>findProperty(new DefaultPropertyNameMatcher("id"));...
#fixed code @Test public void testPrimitiveField() { ClassMeta<DbObject> classMeta = ReflectionService.newInstance(true, false).getRootClassMeta(DbObject.class); PropertyMeta<DbObject, Long> id = classMeta.newPropertyFinder().<Long>findProperty(new DefaultPropertyNameMatcher("id")); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFindElementOnTuple() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getClassMeta(Tuples.typeDef(String.class, DbObject.class, DbObject.class)); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPrope...
#fixed code @Test public void testFindElementOnTuple() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getRootClassMeta(Tuples.typeDef(String.class, DbObject.class, DbObject.class)); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPropert...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ResultSetMapperBuilder<T> addMapping(String property, int column) { Setter<T, Object> setter = setterFactory.getSetter(target, property); Mapper<ResultSet, T> fieldMapper; if (setter.getPropertyType().isPrimitive()) { fieldMapper = primitiveFieldMappe...
#fixed code public ResultSetMapperBuilder<T> addMapping(String property, int column) { Setter<T, Object> setter = setterFactory.getSetter(target, property); addMapping(setter, column); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } ...
#fixed code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } logge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printExecution(ExecutionMetric execution) { output.printf(" count = %d%n", execution.counter.count); output.printf(" last rate = %2.2f/s%n", execution.counter.lastRate); output.printf(" mean rate = %2.2f/s%n", execution.counte...
#fixed code private void printExecution(ExecutionMetric execution) { output.printf(" count = %d%n", execution.counter.count); output.printf(" last rate = %2.2f/s%n", execution.counter.lastRate); output.printf(" mean rate = %2.2f/s%n", execution.counter.mean...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void nullAndEmpty() { // toJson测试 // // Null Bean TestBean nullBean = null; String nullBeanString = binder.toJson(nullBean); assertEquals("null", nullBeanString); // Empty List List<String> emptyList = Lists.newArrayList(); String emptyListS...
#fixed code @Test public void nullAndEmpty() { // toJson测试 // // Null Bean TestBean nullBean = null; String nullBeanString = binder.toJson(nullBean); assertThat(nullBeanString).isEqualTo("null"); // Empty List List<String> emptyList = Lists.newArrayList(); String emptyLis...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public UserDTO getUser(@PathVariable("id") Long id) { User user = accountService.getUser(id); // 使用Dozer转换DTO类,并补充Dozer不能自动绑定的属性 UserDTO dto = BeanMapper.map(user, UserDTO.class); dto.set...
#fixed code @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public UserDTO getUser(@PathVariable("id") Long id) { User user = accountService.getUser(id); if (user == null) { String message = "用户不存在(id:" + id + ")"; logger.warn(message); throw new R...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } ...
#fixed code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } logge...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void reportExecution(String name, ExecutionMetric execution, long timestamp) throws IOException { send(MetricRegistry.name(prefix, name, "count"), format(execution.counter.count), timestamp); send(MetricRegistry.name(prefix, name, "min"), format(execution.hist...
#fixed code private void reportExecution(String name, ExecutionMetric execution, long timestamp) throws IOException { send(MetricRegistry.name(prefix, name, "count"), format(execution.counterMetric.lastCount), timestamp); send(MetricRegistry.name(prefix, name, "min"), format(execution....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public HistogramMetric calculateMetric() { // 快照当前的数据,在计算时不阻塞新的metrics update. List<Long> snapshotList = null; synchronized (lock) { snapshotList = measurements; measurements = new LinkedList(); } if (snapshotList.isEmpty()) { return createEmptyMetric(...
#fixed code public HistogramMetric calculateMetric() { // 快照当前的数据,在计算时不阻塞新的metrics update. List<Long> snapshotList = measurements; measurements = new LinkedList(); if (snapshotList.isEmpty()) { return createEmptyMetric(); } // 按数值大小排序,以快速支持百分比过滤 Collections.sort(snapshot...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static InetAddress findLocalAddressViaNetworkInterface() { // 如果hostname +/etc/hosts 得到的是127.0.0.1, 则首选这块网卡 String preferNamePrefix = SystemPropertiesUtil.getString("localhost.prefer.nic.prefix", "LOCALHOST_PREFER_NIC_PREFIX", "bond0."); // 如果hostname +/e...
#fixed code private static InetAddress findLocalAddressViaNetworkInterface() { // 如果hostname +/etc/hosts 得到的是127.0.0.1, 则首选这块网卡 String preferNamePrefix = SystemPropertiesUtil.getString("localhost.prefer.nic.prefix", "LOCALHOST_PREFER_NIC_PREFIX", "bond0."); // 如果hostname +/etc/hos...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %2.2f/s%n", counter.lastRate); output.printf(" ...
#fixed code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %d%n", counter.lastRate); output.printf(" mean ra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %2.2f/s%n", timer.counterMetric.lastRate); output.printf(" mean rate = %2.2f/s%n", timer.counterMetric...
#fixed code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %d%n", timer.counterMetric.lastRate); output.printf(" mean rate = %d%n", timer.counterMetric.meanRate); ou...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %2.2f/s%n", counter.lastRate); output.printf(" ...
#fixed code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %d%n", counter.lastRate); output.printf(" mean ra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %2.2f/s%n", timer.counterMetric.lastRate); output.printf(" mean rate = %2.2f/s%n", timer.counterMetric...
#fixed code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %d%n", timer.counterMetric.lastRate); output.printf(" mean rate = %d%n", timer.counterMetric.meanRate); ou...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printHistogram(HistogramMetric histogram) { output.printf(" min = %d%n", histogram.min); output.printf(" max = %d%n", histogram.max); output.printf(" mean = %2.2f%n", histogram.mean); for (Entry<Double, Long> pc...
#fixed code private void printHistogram(HistogramMetric histogram) { output.printf(" min = %d%n", histogram.min); output.printf(" max = %d%n", histogram.max); output.printf(" mean = %2.2f%n", histogram.mean); for (Entry<Double, Long> pct : hi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isIn...
#fixed code public static VideoInfo getVideoInfo(File input) { VideoInfo vi = new VideoInfo(); if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFfmpegBinary()); commands.addAll(BaseCommandOption.toInputCommonsCmdArrays(input.get...
#fixed code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isInfoEnabl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String handler(InputStream errorStream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream,BaseCommandOption.UTF8)); StringBuffer sb = new StringBuffer(); String line; try { ...
#fixed code public String handler(InputStream errorStream) throws IOException { FileChannel inputChannel =null; if (errorStream instanceof FileInputStream) { inputChannel = ((FileInputStream) errorStream).getChannel(); } else{ return ""; } ByteArrayOutput...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isInf...
#fixed code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isInfoEnab...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void agglomerate(LinkageStrategy linkageStrategy) { Collections.sort(distances); if (distances.size() > 0) { ClusterPair minDistLink = distances.remove(0); clusters.remove(minDistLink.getrCluster()); clusters.remove(minDistLink.getlCluster()); Clust...
#fixed code public void agglomerate(LinkageStrategy linkageStrategy) { Collections.sort(distances); if (distances.size() > 0) { ClusterPair minDistLink = distances.remove(0); clusters.remove(minDistLink.getrCluster()); clusters.remove(minDistLink.getlCluster()); Cluster old...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public PdfObject getDestinationPage(final HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject()); return array.get(0, false); } #location 5 ...
#fixed code @Override public PdfObject getDestinationPage(final HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject()); return array != null ? array.get(0, false) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public OutputStream writeFloat(float value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public OutputStream writeFloat(float value) throws IOException { int intPart = (int) value; int fractalPart = (int) (value - (int) value) * 1000; writeInteger(intPart, 8).writeByte((byte) '.').writeInteger(fractalPart, 4); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public OutputStream writeBoolean(boolean value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public OutputStream writeBoolean(boolean value) throws IOException { write(value ? booleanTrue : booleanFalse); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfN...
#fixed code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfName.Si...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void outlinesTest() throws IOException, PdfException { PdfReader reader = new PdfReader(new FileInputStream(sourceFolder+"iphone_user_guide.pdf")); PdfDocument pdfDoc = new PdfDocument(reader); PdfOutline outlines = pdfDoc.getCa...
#fixed code @Test public void outlinesTest() throws IOException, PdfException { PdfReader reader = new PdfReader(new FileInputStream(sourceFolder+"iphone_user_guide.pdf")); PdfDocument pdfDoc = new PdfDocument(reader); PdfOutline outlines = pdfDoc.getOutlines...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest03() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest03.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest03.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest03() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest03.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest03.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void flatFields() { if (document.isAppendMode()) { throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode); } List<PdfFormField> fields = getFormFields(); PdfPage page = null; for (PdfForm...
#fixed code public void flatFields() { if (document.isAppendMode()) { throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode); } Map<String, PdfFormField> fields = getFormFields(); PdfPage page = null; for (Map.En...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public OutputStream writeDouble(double value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public OutputStream writeDouble(double value) throws IOException { return writeFloat((float)value); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void taggingTest05() throws Exception { FileInputStream fis = new FileInputStream(sourceFolder + "iphone_user_guide.pdf"); PdfReader reader = new PdfReader(fis); PdfDocument document = new PdfDocument(reader); Assert.ass...
#fixed code @Test public void taggingTest05() throws Exception { FileInputStream fis = new FileInputStream(sourceFolder + "iphone_user_guide.pdf"); PdfReader reader = new PdfReader(fis); PdfDocument source = new PdfDocument(reader); PdfWriter writer =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest03() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest03.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest03.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest03() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest03.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest03.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public PdfObject getDestinationPage(HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject().toUnicodeString()); return array.get(0, false); } #location 5...
#fixed code @Override public PdfObject getDestinationPage(HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject().toUnicodeString()); return array != null ? array.get(0, false) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void formFieldTest01() throws IOException { PdfReader reader = new PdfReader(sourceFolder + "formFieldFile.pdf"); PdfDocument pdfDoc = new PdfDocument(reader); PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, false); ...
#fixed code @Test public void formFieldTest01() throws IOException { PdfReader reader = new PdfReader(sourceFolder + "formFieldFile.pdf"); PdfDocument pdfDoc = new PdfDocument(reader); PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, false); Map<St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfStream stream = new PdfStream(document); PdfCanvas canvas = new PdfCanvas(stream, new PdfResources()); Rectangle rect = placeBarcode(canvas, barColor, textCo...
#fixed code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfFormXObject xObject = new PdfFormXObject(document, null); Rectangle rect = placeBarcode(new PdfCanvas(xObject), barColor, textColor); xObject.setBBox(rect.toPdfArr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void justify(float width) { float ratio = .5f; float freeWidth = occupiedArea.getBBox().getX() + width - getLastChildRenderer().getOccupiedArea().getBBox().getX() - getLastChildRenderer().getOccupiedArea().getBBox().getWidth(); ...
#fixed code protected void justify(float width) { float ratio = getPropertyAsFloat(Property.SPACING_RATIO); float freeWidth = occupiedArea.getBBox().getX() + width - getLastChildRenderer().getOccupiedArea().getBBox().getX() - getLastChildRenderer().getOccu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void create1000PagesDocumentWithFullCompression() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutp...
#fixed code @Test public void create1000PagesDocumentWithFullCompression() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutputStre...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void buildResources(PdfDictionary dictionary) throws PdfException { for (PdfName resourceType : dictionary.keySet()) { if (nameToResource.get(resourceType) == null) { nameToResource.put(resourceType, new HashMap<PdfName, Pdf...
#fixed code protected void buildResources(PdfDictionary dictionary) throws PdfException { for (PdfName resourceType : dictionary.keySet()) { if (nameToResource.get(resourceType) == null) { nameToResource.put(resourceType, new HashMap<PdfName, PdfObject...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfN...
#fixed code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfName.Si...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfStream stream = new PdfStream(document); PdfCanvas canvas = new PdfCanvas(stream, new PdfResources()); Rectangle rect = placeBarcode(canvas, barColor, textCo...
#fixed code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfFormXObject xObject = new PdfFormXObject(document, null); Rectangle rect = placeBarcode(new PdfCanvas(xObject), barColor, textColor); xObject.setBBox(rect.toPdfArr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void flatFields() { if (document.isAppendMode()) { throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode); } List<PdfFormField> fields = getFormFields(); PdfPage page = null; for (PdfForm...
#fixed code public void flatFields() { if (document.isAppendMode()) { throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode); } Map<String, PdfFormField> fields = getFormFields(); PdfPage page = null; for (Map.En...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void create1000PagesDocument() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutputStream fos = new ...
#fixed code @Test public void create1000PagesDocument() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutputStream fos = new FileOu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public PdfObjectStream getObjectStream() throws IOException, PdfException { if (!fullCompression) return null; if (objectStream == null) { objectStream = new PdfObjectStream(pdfDocument); } if (objectStream.getSize...
#fixed code public PdfObjectStream getObjectStream() throws IOException, PdfException { if (!fullCompression) return null; if (objectStream == null) { objectStream = new PdfObjectStream(pdfDocument); } if (objectStream.getSize() == ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void addChild(IRenderer renderer) { super.addChild(renderer); if (currentArea == null) { currentArea = getNextArea(); // try { // new PdfCanvas(document.getPdfDocument().getPage(currentArea.getP...
#fixed code @Override public void addChild(IRenderer renderer) { super.addChild(renderer); if (currentArea == null) { currentArea = getNextArea(); // try { // new PdfCanvas(document.getPdfDocument().getPage(currentArea.getPageNum...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public OutputStream writeInteger(int value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public OutputStream writeInteger(int value) throws IOException { writeInteger(value, 8); return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(o...
#fixed code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(outFile...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getSysUser().getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return...
#fixed code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return true; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void execute(JobExecutionContext context) throws JobExecutionException { try { System.out.println("执行命令中。。。"); String id = context.getJobDetail().getName(); TestJobs job = null; for (int i = 0; i < QueueListener.list.size(); i++) { jo...
#fixed code @Override public void execute(JobExecutionContext context) throws JobExecutionException { try { System.out.println("执行命令中。。。"); String id = context.getJobDetail().getName(); TestJobs job = testJobsService.load(Integer.valueOf(id)); toRunTask(job.getPlanproj(), ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getSysUser().getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return...
#fixed code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return true; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void execute(JobExecutionContext context) throws JobExecutionException { try { String name = context.getJobDetail().getName(); if(name.indexOf(PublicConst.JOBTASKNAMETYPE)>-1){ TestJobs job = new TestJobs(); String id=name.substring...
#fixed code @Override public void execute(JobExecutionContext context) throws JobExecutionException { try { String name = context.getJobDetail().getName(); if(name.indexOf(PublicConst.JOBTASKNAMETYPE)>-1){ TestJobs job = new TestJobs(); String id=name.substring(0,nam...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(...
#fixed code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(uuid);...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(...
#fixed code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(uuid);...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static NSObject parse(final byte[] bytes) throws Exception { InputStream is = new InputStream() { private int pos = 0; @Override public int read() throws IOException { if (pos >= bytes.length) { ...
#fixed code public static NSObject parse(final byte[] bytes) throws Exception { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); return parse(bis); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void initDocBuilder() throws ParserConfigurationException { boolean offline = false; try { URL dtdUrl = new URL("http://www.apple.com/DTDs/PropertyList-1.0.dtd"); InputStream dtdIs = dtdUrl.openStream(); ...
#fixed code private static void initDocBuilder() throws ParserConfigurationException { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setIgnoringComments(true); docBuilder = docBuilderFactory.newDocumentBuilder(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void saveAsXML(NSObject root, File out) throws IOException { FileWriter fw = new FileWriter(out); fw.write(root.toXMLPropertyList()); fw.close(); } #location 5 #vulnerabi...
#fixed code public static void saveAsXML(NSObject root, File out) throws IOException { OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(out), "UTF-8"); w.write(root.toXMLPropertyList()); w.close(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); return parse(fis); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); String magicString = new String(readAll(fis, 8), 0, 8); fis.close(); if (magicString.startsWith("bplist00")) { return BinaryProper...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); byte[] magic = new byte[8]; fis.read(magic); String magic_string = new String(magic); fis.close(); if (magic_string.star...
#fixed code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); return parse(fis); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void runTagger() throws IOException, ClassNotFoundException { tagger = new Tagger(); if (!justTokenize) { tagger.loadModel(modelFilename); } if (inputFormat.equals("conll")) { runTaggerInEvalMode(); return; } assert (inputFormat.equals...
#fixed code public void runTagger() throws IOException, ClassNotFoundException { tagger = new Tagger(); if (!justTokenize) { tagger.loadModel(modelFilename); } if (inputFormat.equals("conll")) { runTaggerInEvalMode(); return; } assert (inputFormat.equals("json...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ArrayList<Sentence> readFile(String filename) throws IOException { BufferedReader reader = BasicFileIO.openFileToRead(filename); ArrayList sentences = new ArrayList<String>(); ArrayList<String> curLines = new ArrayList<String>(); String line; while...
#fixed code public static ArrayList<Sentence> readFile(String filename) throws IOException { BufferedReader reader = BasicFileIO.openFileToReadUTF8(filename); ArrayList sentences = new ArrayList<String>(); ArrayList<String> curLines = new ArrayList<String>(); String line; while (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ArrayList<Sentence> readFile(String filename) throws IOException { BufferedReader reader = BasicFileIO.openFileToRead(filename); ArrayList sentences = new ArrayList<String>(); ArrayList<String> curLines = new ArrayList<String>(); String line; while...
#fixed code public static ArrayList<Sentence> readFile(String filename) throws IOException { BufferedReader reader = BasicFileIO.openFileToReadUTF8(filename); ArrayList sentences = new ArrayList<String>(); ArrayList<String> curLines = new ArrayList<String>(); String line; while (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Transactional public Operation save(Long apiId, Long resourceId, Operation operation) { Resource resource = resourceRepository.findByApiIdAndId(apiId, resourceId); HeimdallException.checkThrow(resource == null, GLOBAL_RESOURCE_NOT_FOUND); ...
#fixed code @Transactional public Operation save(Long apiId, Long resourceId, Operation operation) { Resource resource = resourceRepository.findByApiIdAndId(apiId, resourceId); HeimdallException.checkThrow(resource == null, GLOBAL_RESOURCE_NOT_FOUND); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
#fixed code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (entry.getKey() !=...
#fixed code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (entry.getKey() != null)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (Objeto.no...
#fixed code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (Objeto.notBlank...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object run() { long startTime = System.currentTimeMillis(); RequestContext context = RequestContext.getCurrentContext(); HttpServletRequest request = context.getRequest(); String verb = getVerb(request); String uri = this.helper.buildZuulReques...
#fixed code @Override public Object run() { long startTime = System.currentTimeMillis(); RequestContext context = RequestContext.getCurrentContext(); HttpServletRequest request = context.getRequest(); HttpHost httpHost = new HttpHost( context.getRouteHost().getHost(), cont...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean validatePlan(Set<String> pathsAllowed, Set<String> pathsNotAllowed, String inboundURL, HttpServletRequest req, Long referenceId) { if ((inboundURL != null && !inboundURL.isEmpty()) && !isHostValidToInboundURL(req, inboundURL)) { ...
#fixed code private boolean validatePlan(Set<String> pathsAllowed, Set<String> pathsNotAllowed, String inboundURL, HttpServletRequest req, Long referenceId) { final Plan plan1 = planRepository.findOne(referenceId); if (plan1 != null) if (!Status.ACTIVE.equals...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void execute() throws Throwable { RequestContext ctx = RequestContext.getCurrentContext(); RequestResponseParser r = new RequestResponseParser(); r.setUri(UrlUtil.getCurrentUrl(ctx.getRequest())); Map<String, String> headers = ...
#fixed code private void execute() throws Throwable { RequestContext ctx = RequestContext.getCurrentContext(); RequestResponseParser r = new RequestResponseParser(); r.setUri(UrlUtil.getCurrentUrl(ctx.getRequest())); Map<String, String> headers = Respons...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void execute() { Helper helper = new HelperImpl(); RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); RequestResponseParser r = new RequestResponseParser(); r.setHeade...
#fixed code private void execute() { RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); RequestResponseParser r = new RequestResponseParser(); r.setHeaders(getRequestHeadersInfo(request)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void execute(Integer status, String body) { Helper helper = new HelperImpl(); RequestContext ctx = RequestContext.getCurrentContext(); String response; if (helper.json().isJson(body)) { response = helper.json().parse(...
#fixed code public void execute(Integer status, String body) { RequestContext ctx = RequestContext.getCurrentContext(); String response; if (helper.json().isJson(body)) { response = helper.json().parse(body); helper.call().response().hea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private MongoDatabase database() { return createMongoClient().getDatabase(databaseName); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code private MongoDatabase database() { return this.mongoClient.getDatabase(databaseName); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void cacheInterceptor(String cacheName, Long timeToLive, List<String> headers, List<String> queryParams) { Helper helper = new HelperImpl(); RedissonClient redisson = (RedissonClient) BeanManager.getBean(RedissonClient.class); RequestCo...
#fixed code public void cacheInterceptor(String cacheName, Long timeToLive, List<String> headers, List<String> queryParams) { RedissonClient redisson = (RedissonClient) BeanManager.getBean(RedissonClient.class); RequestContext context = RequestContext.getCurrentContext(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
#fixed code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void stop() { this.stop = true; this.torrentFileProvider.unRegisterListener(this); this.thread.interrupt(); try { this.thread.join(); } catch (final InterruptedException ignored) { } ...
#fixed code @Override public void stop() { try { this.lock.writeLock().lock(); this.stop = true; this.torrentFileProvider.unRegisterListener(this); this.thread.interrupt(); try { this.thread.join(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void start() { this.stop = false; this.thread = new Thread(() -> { while (!this.stop) { final List<AnnounceRequest> availables = this.delayQueue.getAvailables(); for (final AnnounceRequest...
#fixed code @Override public void start() { this.stop = false; this.thread = new Thread(() -> { while (!this.stop) { for (final AnnounceRequest req : this.delayQueue.getAvailables()) { this.announcerExecutor.execute(req...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldHandleNullConfig() throws Throwable { // Given Driver driver = GraphDatabase.driver( neo4j.address(), AuthTokens.none(), null ); Session session = driver.session(); // When session.close(); ...
#fixed code @Test public void shouldHandleNullConfig() throws Throwable { // Given try( Driver driver = GraphDatabase.driver( neo4j.address(), AuthTokens.none(), null ) ) { Session session = driver.session(); // When se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( m...
#fixed code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void saveTrustedHost( String fingerprint ) throws IOException { this.fingerprint = fingerprint; logger.info( "Adding %s as known and trusted certificate for %s.", fingerprint, serverId ); createKnownCertFileIfNotExists(); as...
#fixed code private void saveTrustedHost( String fingerprint ) throws IOException { this.fingerprint = fingerprint; logger.info( "Adding %s as known and trusted certificate for %s.", fingerprint, serverId ); createKnownCertFileIfNotExists(); assertKn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( ...
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( URI.cr...
Below is the vulnerable code, please generate the patch based on the following information.