output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code public void destroy() { //kill running threads scheduler.shutdownNow(); }
#vulnerable code public void destroy() { //kill running threads executorService.shutdownNow(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) req; final HttpServletResponse response = (HttpServletResponse) res; ...
#vulnerable code public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) req; final HttpServletResponse response = (HttpServletResponse) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testNoProcessorWroManagerFactory() throws IOException { final WroManagerFactory factory = new ServletContextAwareWroManagerFactory(); manager = factory.getInstance(); manager.setModelFactory(getValidModelFactory()); final HttpServletRequest r...
#vulnerable code @Test public void testNoProcessorWroManagerFactory() throws IOException { final WroManagerFactory factory = new ServletContextAwareWroManagerFactory(); manager = factory.getInstance(); manager.setModelFactory(getValidModelFactory()); final HttpServletReq...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void onRuntimeException(final RuntimeException e, final HttpServletResponse response, final FilterChain chain) { LOG.debug("RuntimeException occured", e); try { LOG.debug("Cannot process. Proceeding with chain execution."); chain.doFilter(Conte...
#vulnerable code protected void onRuntimeException(final RuntimeException e, final HttpServletResponse response, final FilterChain chain) { LOG.debug("RuntimeException occured", e); try { LOG.debug("Cannot process. Proceeding with chain execution."); final OutputSt...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private InputStream locateStreamFromJar(final String uri, final File jarPath) throws IOException { LOG.debug("\t\tLocating stream from jar"); String classPath = FilenameUtils.getPath(uri); final String wildcard = FilenameUtils.getName(uri); if (classPath....
#vulnerable code private InputStream locateStreamFromJar(final String uri, final File jarPath) throws IOException { LOG.debug("\t\tLocating stream from jar"); String classPath = FilenameUtils.getPath(uri); final String wildcard = FilenameUtils.getName(uri); if (...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void onRuntimeException(final RuntimeException e, final HttpServletResponse response, final FilterChain chain) { LOG.debug("RuntimeException occured", e); try { LOG.debug("Cannot process. Proceeding with chain execution."); chain.doFilter(Conte...
#vulnerable code protected void onRuntimeException(final RuntimeException e, final HttpServletResponse response, final FilterChain chain) { LOG.debug("RuntimeException occured", e); try { LOG.debug("Cannot process. Proceeding with chain execution."); final OutputSt...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void process(final Reader reader, final Writer writer) throws IOException { final StopWatch watch = new StopWatch(); watch.start("pack"); final String content = IOUtils.toString(reader); try { final JavaScriptCompressor compressor = new JavaScri...
#vulnerable code public void process(final Reader reader, final Writer writer) throws IOException { final StopWatch watch = new StopWatch(); watch.start("pack"); final InputStream is = new ByteArrayInputStream(IOUtils.toByteArray(reader)); try { final JavaScriptC...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void onModelPeriodChanged() { //force scheduler to reload model = null; }
#vulnerable code public void onModelPeriodChanged() { //force scheduler to reload initScheduler(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String getScalarValue(String key) throws ConfiguratorException { return remove(key).asScalar().getValue(); }
#vulnerable code public String getScalarValue(String key) throws ConfiguratorException { return get(key).asScalar().getValue(); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Object configure(Object c) throws Exception { final ExtensionList list = Jenkins.getInstance().getExtensionList(target); if (list.size() != 1) { throw new IllegalStateException(); } final Object o = list.get(0);...
#vulnerable code @Override public Object configure(Object c) throws Exception { final ExtensionList list = Jenkins.getInstance().getExtensionList(target); if (list.size() != 1) { throw new IllegalStateException(); } final Object o = list.g...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Object configure(Object c) throws Exception { Map config = c instanceof Map ? (Map) c : Collections.EMPTY_MAP; final Constructor constructor = getDataBoundConstructor(target); if (constructor == null) { throw new Ille...
#vulnerable code @Override public Object configure(Object c) throws Exception { Map config = c instanceof Map ? (Map) c : Collections.EMPTY_MAP; final Constructor constructor = getDataBoundConstructor(target); if (constructor == null) { throw ne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void configure(Map config, T instance) throws Exception { final Set<Attribute> attributes = describe(); for (Attribute attribute : attributes) { final String name = attribute.getName(); final Object sub = removeIgnoreCase(con...
#vulnerable code protected void configure(Map config, T instance) throws Exception { final Set<Attribute> attributes = describe(); for (Attribute attribute : attributes) { final String name = attribute.getName(); final Object sub = removeIgnoreCa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Nonnull private static RoleMap retrieveRoleMap(@Nonnull CNode config, @Nonnull String name, Configurator<RoleDefinition> configurator) throws ConfiguratorException { Mapping map = config.asMapping(); final CNode c = map.get(name); TreeMap<Role, S...
#vulnerable code @Nonnull private static RoleMap retrieveRoleMap(@Nonnull CNode config, @Nonnull String name, Configurator<RoleDefinition> configurator) throws ConfiguratorException { Mapping map = config.asMapping(); final Sequence c = map.get(name).asSequence(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @CheckForNull @Override public CNode describe(T instance) throws Exception { // Here we assume a correctly designed DataBound Object will have required attributes set by DataBoundConstructor // and all others using DataBoundSetters. So constructor par...
#vulnerable code @CheckForNull @Override public CNode describe(T instance) throws Exception { // Here we assume a correctly designed DataBound Object will have required attributes set by DataBoundConstructor // and all others using DataBoundSetters. So construct...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Nonnull @Override public T configure(CNode c, ConfigurationContext context) throws ConfiguratorException { final Mapping mapping = (c != null ? c.asMapping() : Mapping.EMPTY); final T instance = instance(mapping, context); if (instance instanc...
#vulnerable code @Nonnull @Override public T configure(CNode c, ConfigurationContext context) throws ConfiguratorException { final Mapping mapping = (c != null ? c.asMapping() : Mapping.EMPTY); final T instance = instance(mapping, context); if (instance i...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public ProjectMatrixAuthorizationStrategy configure(Object config) throws ConfiguratorException { Map map = (Map) config; Collection o = (Collection<?>)map.get("grantedPermissions"); Configurator<GroupPermissionDefinition> permissionConfi...
#vulnerable code @Override public ProjectMatrixAuthorizationStrategy configure(Object config) throws Exception { Map map = (Map) config; Collection o = (Collection<?>)map.get("grantedPermissions"); Configurator<GroupPermissionDefinition> permissionConfigurato...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @POST public FormValidation doCheckNewSource(@QueryParameter String newSource) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); String normalizedSource = Util.fixEmptyAndTrim(newSource); File file = new File(Util.fixNull(normalizedSourc...
#vulnerable code @POST public FormValidation doCheckNewSource(@QueryParameter String newSource) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); String normalizedSource = Util.fixEmptyAndTrim(newSource); File file = new File(Util.fixNull(normalize...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean equals(O o1, O o2) throws Exception { final Object v1 = getValue(o1); final Object v2 = getValue(o2); if (v1 == null && v2 == null) return true; return (v1 != null && v1.equals(v2)); }
#vulnerable code public boolean equals(O o1, O o2) throws Exception { final Object v1 = getValue(o1); final Object v2 = getValue(o2); if (v1 == null && v2 == null) return true; return (v1.equals(v2)); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public GlobalMatrixAuthorizationStrategy configure(Object config) throws ConfiguratorException { Map map = (Map) config; Collection o = (Collection<?>)map.get("grantedPermissions"); Configurator<GroupPermissionDefinition> permissionConfig...
#vulnerable code @Override public GlobalMatrixAuthorizationStrategy configure(Object config) throws Exception { Map map = (Map) config; Collection o = (Collection<?>)map.get("grantedPermissions"); Configurator<GroupPermissionDefinition> permissionConfigurator...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @CheckForNull @Override public CNode describe(T instance) throws Exception { // Here we assume a correctly designed DataBound Object will have required attributes set by DataBoundConstructor // and all others using DataBoundSetters. So constructor par...
#vulnerable code @CheckForNull @Override public CNode describe(T instance) throws Exception { // Here we assume a correctly designed DataBound Object will have required attributes set by DataBoundConstructor // and all others using DataBoundSetters. So construct...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void configure(Map config, T instance) throws Exception { final Set<Attribute> attributes = describe(); for (Attribute attribute : attributes) { final String name = attribute.getName(); final Object sub = removeIgnoreCase(con...
#vulnerable code protected void configure(Map config, T instance) throws Exception { final Set<Attribute> attributes = describe(); for (Attribute attribute : attributes) { final String name = attribute.getName(); final Object sub = removeIgnoreCa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public DLegerEntry get(Long index) { PreConditions.check(index <= legerEndIndex && index >= legerBeginIndex, DLegerException.Code.INDEX_OUT_OF_RANGE, String.format("%d should between %d-%d", index, legerBeginIndex, legerEndIndex), memberState.getLeaderId...
#vulnerable code @Override public DLegerEntry get(Long index) { PreConditions.check(index <= legerEndIndex, DLegerException.Code.INDEX_OUT_OF_RANGE, String.format("%d should < %d", index, legerEndIndex), memberState.getLeaderId()); SelectMmapBufferResult indexSbr = i...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void recover() { final List<MmapFile> mappedFiles = this.dataFileQueue.getMappedFiles(); if (mappedFiles.isEmpty()) { this.indexFileQueue.updateWherePosition(0); this.indexFileQueue.truncateDirtyFiles(0); return; ...
#vulnerable code public void recover() { final List<MmapFile> mappedFiles = this.dataFileQueue.getMappedFiles(); if (mappedFiles.isEmpty()) { this.indexFileQueue.updateWherePosition(0); this.indexFileQueue.truncateDirtyFiles(0); return...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void changeRoleToCandidate(long term) { logger.info("[{}][ChangeRoleToCandidate] from term: {} and currterm: {}", memberState.getSelfId(), term, memberState.currTerm()); memberState.changeToCandidate(term); }
#vulnerable code public void changeRoleToCandidate(long term) { logger.info("[{}][ChangeRoleToCandidate] from term: {} and currterm: {}", memberState.getSelfId(), term, memberState.currTerm()); memberState.changeToCandidate(term); nextTimeToRequestVote = -1; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void recover() { final List<MmapFile> mappedFiles = this.dataFileQueue.getMappedFiles(); if (mappedFiles.isEmpty()) { this.indexFileQueue.updateWherePosition(0); this.indexFileQueue.truncateDirtyFiles(0); return; ...
#vulnerable code public void recover() { final List<MmapFile> mappedFiles = this.dataFileQueue.getMappedFiles(); if (mappedFiles.isEmpty()) { this.indexFileQueue.updateWherePosition(0); this.indexFileQueue.truncateDirtyFiles(0); return...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public long append(byte[] data, int pos, int len, boolean useBlank) { if (preAppend(len, useBlank) == -1) { return -1; } MmapFile mappedFile = getLastMappedFile(); long currPosition = mappedFile.getFileFromOffset() + mappedFile.getW...
#vulnerable code public long append(byte[] data, int pos, int len, boolean useBlank) { MmapFile mappedFile = getLastMappedFile(); if (null == mappedFile || mappedFile.isFull()) { mappedFile = getLastMappedFile(0); } if (null == mappedFile) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public CompletableFuture<HeartBeatResponse> handleHeartBeat(HeartBeatRequest request) throws Exception { if (request.getTerm() < memberState.currTerm()) { return CompletableFuture.completedFuture((HeartBeatResponse) new HeartBeatResponse().term(memberState...
#vulnerable code public CompletableFuture<HeartBeatResponse> handleHeartBeat(HeartBeatRequest request) throws Exception { if (request.getTerm() < memberState.currTerm()) { return CompletableFuture.completedFuture((HeartBeatResponse) new HeartBeatResponse().term(membe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public long append(byte[] data, int pos, int len, boolean useBlank) { if (preAppend(len, useBlank) == -1) { return -1; } MmapFile mappedFile = getLastMappedFile(); long currPosition = mappedFile.getFileFromOffset() + mappedFile.getW...
#vulnerable code public long append(byte[] data, int pos, int len, boolean useBlank) { MmapFile mappedFile = getLastMappedFile(); if (null == mappedFile || mappedFile.isFull()) { mappedFile = getLastMappedFile(0); } if (null == mappedFile) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public DLegerEntry get(Long index) { PreConditions.check(index <= legerEndIndex && index >= legerBeginIndex, DLegerException.Code.INDEX_OUT_OF_RANGE, String.format("%d should between %d-%d", index, legerBeginIndex, legerEndIndex), memberState.getLeaderId...
#vulnerable code @Override public DLegerEntry get(Long index) { PreConditions.check(index <= legerEndIndex && index >= legerBeginIndex, DLegerException.Code.INDEX_OUT_OF_RANGE, String.format("%d should between %d-%d", index, legerBeginIndex, legerEndIndex), memberState.getLe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void recover() { final List<MmapFile> mappedFiles = this.dataFileQueue.getMappedFiles(); if (mappedFiles.isEmpty()) { this.indexFileQueue.updateWherePosition(0); this.indexFileQueue.truncateDirtyFiles(0); return; ...
#vulnerable code public void recover() { final List<MmapFile> mappedFiles = this.dataFileQueue.getMappedFiles(); if (mappedFiles.isEmpty()) { this.indexFileQueue.updateWherePosition(0); this.indexFileQueue.truncateDirtyFiles(0); return...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private InputStream buildWrappedInputStream(InputStream downloadInputStream) throws TransformerException, IOException { // Pass the download input stream through a Transformer that removes the XML // declaration. Create a new TransformerFactory and Transformer on...
#vulnerable code private InputStream buildWrappedInputStream(InputStream downloadInputStream) throws TransformerException, IOException { // Pass the download input stream through a transformer that removes the XML // declaration. Transformer omitXmlDeclarationTransforme...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testMarkNotSupported() throws Exception { byte[] plaintext = getRandomBytes(1); final String password = "Testing1234"; JNCryptor cryptor = new AES256JNCryptor(); byte[] data = cryptor.encryptData(plaintext, password.toCharArray()); ...
#vulnerable code @Test public void testMarkNotSupported() throws Exception { byte[] plaintext = getRandomBytes(1); final String password = "Testing1234"; JNCryptor cryptor = new AES256JNCryptor(); byte[] data = cryptor.encryptData(plaintext, password.toCharArray()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String getLine(File file, int line) throws IOException { BufferedReader reader = Files.newBufferedReader(file.toPath(), Options.encoding); String msg = ""; for (int i = 0; i <= line; i++) msg = reader.readLine(); reader.close(); return msg...
#vulnerable code private static String getLine(File file, int line) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(file)); String msg = ""; for (int i = 0; i <= line; i++) msg = reader.readLine(); reader.close(); return msg; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected static ClassInfo guessPackageAndClass(File lexFile) throws FileNotFoundException, IOException { assert lexFile.isAbsolute() : lexFile; LineNumberReader reader = new LineNumberReader(new FileReader(lexFile)); try { ClassInfo classInfo = ne...
#vulnerable code protected static ClassInfo guessPackageAndClass(File lexFile) throws FileNotFoundException, IOException { assert lexFile.isAbsolute() : lexFile; LineNumberReader reader = new LineNumberReader(new FileReader(lexFile)); ClassInfo classInfo = new ClassInfo(); whi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String getPageContent(URL url) throws IOException { try(InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8")) { StringBuilder builder = new StringBuilder(); char[] buf = new char[BUF_SIZE]; int charsRead; while ((charsR...
#vulnerable code private String getPageContent(URL url) throws IOException { InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8"); StringBuilder builder = new StringBuilder(); char[] buf = new char[BUF_SIZE]; int charsRead; while ((charsRead = re...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void runNext() throws TestFailException, UnsupportedEncodingException { // Get first file and remove it from vector InputOutput current = inputOutput.remove(0); // Create List with only first input in List<String> param = new ArrayList<String>(); pa...
#vulnerable code public void runNext() throws TestFailException { // Get first file and remove it from vector InputOutput current = inputOutput.remove(0); // Create List with only first input in List<String> param = new ArrayList<String>(); param.add(current.getName(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private byte[] loadJarData(String path, String fileName) { ZipFile zipFile; ZipEntry entry; int size; try { zipFile = new ZipFile(new File(path)); entry = zipFile.getEntry(fileName); if (entry == null) { zipFile.close(); return...
#vulnerable code private byte[] loadJarData(String path, String fileName) { ZipFile zipFile; ZipEntry entry; int size; try { zipFile = new ZipFile(new File(path)); entry = zipFile.getEntry(fileName); if (entry == null) return null; size = (int) ent...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void findPackageAndClass() throws IOException { // find name of the package and class in jflex source file packageName = null; className = null; LineNumberReader reader = new LineNumberReader(new FileReader(inputFile)); try { while (className =...
#vulnerable code public void findPackageAndClass() throws IOException { // find name of the package and class in jflex source file packageName = null; className = null; LineNumberReader reader = new LineNumberReader(new FileReader(inputFile)); while (className == null || packag...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private byte[] loadJarData(String path, String fileName) { ZipFile zipFile; ZipEntry entry; int size; try { zipFile = new ZipFile(new File(path)); entry = zipFile.getEntry(fileName); if (entry == null) { zipFile.close(); return...
#vulnerable code private byte[] loadJarData(String path, String fileName) { ZipFile zipFile; ZipEntry entry; int size; try { zipFile = new ZipFile(new File(path)); entry = zipFile.getEntry(fileName); if (entry == null) return null; size = (int) ent...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void read(String skeletonFilename) throws Exception { ClassLoader loader = UnicodePropertiesSkeleton.class.getClassLoader(); URL url = loader.getResource(skeletonFilename); if (null == url) { throw new Exception("Cannot locate '" + skeletonFilename ...
#vulnerable code public void read(String skeletonFilename) throws Exception { ClassLoader loader = UnicodePropertiesSkeleton.class.getClassLoader(); URL url = loader.getResource(skeletonFilename); if (null == url) { throw new Exception("Cannot locate '" + skeletonFilen...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private InputStream getZipEntryStream(String file, String entryName) { try (ZipFile zip = new ZipFile(new File(file))) { ZipEntry entry = zip.getEntry(entryName); if (entry == null) return null; return zip.getInputStream(entry); } catch (IOExcept...
#vulnerable code private InputStream getZipEntryStream(String file, String entryName) { try { ZipFile zip = new ZipFile(new File(file)); ZipEntry entry = zip.getEntry(entryName); if (entry == null) return null; return zip.getInputStream(entry); } catc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String getPageContent(URL url) throws IOException { try(InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8")) { StringBuilder builder = new StringBuilder(); char[] buf = new char[BUF_SIZE]; int charsRead; while ((charsR...
#vulnerable code private String getPageContent(URL url) throws IOException { InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8"); StringBuilder builder = new StringBuilder(); char[] buf = new char[BUF_SIZE]; int charsRead; while ((charsRead = re...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private InputStream getZipEntryStream(String file, String entryName) { try (ZipFile zip = new ZipFile(new File(file))) { ZipEntry entry = zip.getEntry(entryName); if (entry == null) return null; return zip.getInputStream(entry); } catch (IOExcept...
#vulnerable code private InputStream getZipEntryStream(String file, String entryName) { try { ZipFile zip = new ZipFile(new File(file)); ZipEntry entry = zip.getEntry(entryName); if (entry == null) return null; return zip.getInputStream(entry); } catc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void copyTo(Wire wire) { while (bytes.remaining() > 0) { int code = bytes.readUnsignedByte(); switch (code >> 4) { case NUM0: case NUM1: case NUM2: case NUM3: ...
#vulnerable code @Override public void copyTo(Wire wire) { while (bytes.remaining() > 0) { int code = bytes.readUnsignedByte(); switch (code >> 4) { case NUM0: case NUM1: case NUM2: case ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean readOne() { try (DocumentContext context = in.readingDocument()) { if (!context.isPresent()) return false; if (context.isMetaData()) return readOneMetaData(context); assert context.isD...
#vulnerable code public boolean readOne() { for (; ; ) { try (DocumentContext context = in.readingDocument()) { if (!context.isPresent()) return false; if (context.isMetaData()) { StringBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void setupOrTeardown(DbUnitTestContext testContext, boolean isSetup, Collection<AnnotationAttributes> annotations) throws Exception { IDatabaseConnection connection = testContext.getConnection(); for (AnnotationAttributes annotation : annotations) { List<IDataS...
#vulnerable code private void setupOrTeardown(DbUnitTestContext testContext, boolean isSetup, Collection<AnnotationAttributes> annotations) throws Exception { IDatabaseConnection connection = testContext.getConnection(); DatabaseOperation lastOperation = null; for (AnnotationAttri...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public ListenableFuture<IBigQueue> queueReadyForDequeue() { initializeFutureIfNecessary(); return dequeueFuture; }
#vulnerable code @Override public ListenableFuture<IBigQueue> queueReadyForDequeue() { futureLock.lock(); if (dequeueFuture == null || dequeueFuture.isDone() || dequeueFuture.isCancelled()) { dequeueFuture = SettableFuture.create(); } futu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void close() throws IOException { if (this.queueFrontIndexPageFactory != null) { this.queueFrontIndexPageFactory.releaseCachedPages(); } synchronized (futureLock) { /* Cancel the future but don't interrup...
#vulnerable code @Override public void close() throws IOException { if (this.queueFrontIndexPageFactory != null) { this.queueFrontIndexPageFactory.releaseCachedPages(); } if (dequeueFuture != null) { /* Cancel the future but don't int...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstructor5() { ClassCastInputCSVException e = new ClassCastInputCSVException(Integer.valueOf(23), String.class, ANONYMOUS_CSVCONTEXT, PROCESSOR); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(PROCESSOR, e.getOffendingProces...
#vulnerable code @Test public void testConstructor5(){ ClassCastInputCSVException e = new ClassCastInputCSVException(Integer.valueOf(23), String.class, ANONYMOUS_CSVCONTEXT, PROCESSOR); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(PROCESSOR, e.getOffendingProc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstructor3() { NullInputException e = new NullInputException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause()); e.printStackTra...
#vulnerable code @Test public void testConstructor3() { NullInputException e = new NullInputException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause())...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testProcesssedRead() throws Exception { UserBean user; final String[] header = inFile.getCSVHeader(true); assertThat(header[2], is("date")); user = inFile.read(UserBean.class, header, processors); Assert.assertEquals("read elem ", "Klaus", user.getU...
#vulnerable code @Test public void testProcesssedRead() throws Exception { UserBean user; final String[] header = inFile.getCSVHeader(true); user = inFile.read(UserBean.class, header, processors); Assert.assertEquals("read elem ", "Klaus", user.getUsername()); Assert.assertEqua...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetHeaderNoCheck() throws IOException { assertEquals(4, abstractReader.getHeader(false).length); assertEquals(4, abstractReader.getHeader(false).length); assertEquals(4, abstractReader.getHeader(false).length); assertNull(abstractReader.getHeader(f...
#vulnerable code @Test public void testGetHeaderNoCheck() throws IOException { assertEquals(4, abstractReader.getCsvHeader(false).length); assertEquals(4, abstractReader.getCsvHeader(false).length); assertEquals(4, abstractReader.getCsvHeader(false).length); assertNull(abstractRea...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstructor2() { NullInputException e = new NullInputException(MSG, PROCESSOR, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(PROCESSOR, e.getOffendingProcessor()); assertEquals(THROWABLE, e.getCause()); e.printStackTrace(); // ...
#vulnerable code @Test public void testConstructor2() { NullInputException e = new NullInputException(MSG, PROCESSOR, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(PROCESSOR, e.getOffendingProcessor()); assertEquals(THROWABLE, e.getCause()); e.printSta...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void should_escape() { final MockWriter absWriter = new MockWriter(new StringWriter(), CsvPreference.EXCEL_PREFERENCE); assertThat(columnsToWrite.length, is(expectedReadResultsFromColumnToWrite.length)); for( int i = 0; i < columnsToWrite.length; i++ ) { ...
#vulnerable code @Test public void should_escape() { final TestClass absWriter = new TestClass(new StringWriter(), CsvPreference.EXCEL_PREFERENCE); assertThat(columnsToWrite.length, is(expectedReadResultsFromColumnToWrite.length)); for( int i = 0; i < columnsToWrite.length; i++ )...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstuctor5(){ SuperCSVException e = new SuperCSVException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause()); e.printStackTrace()...
#vulnerable code @Test public void testConstuctor5(){ SuperCSVException e = new SuperCSVException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstructor2(){ SuperCSVReflectionException e = new SuperCSVReflectionException(MSG, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(THROWABLE, e.getCause()); e.printStackTrace(); // test with null msg e = new SuperCSVReflectionE...
#vulnerable code @Test public void testConstructor2(){ SuperCSVReflectionException e = new SuperCSVReflectionException(MSG, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(THROWABLE, e.getCause()); e.printStackTrace(); // test with null msg e = new ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstuctor3(){ SuperCSVException e = new SuperCSVException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause()); e.printStackTrace()...
#vulnerable code @Test public void testConstuctor3(){ SuperCSVException e = new SuperCSVException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConstructor1() { ClassCastInputCSVException e = new ClassCastInputCSVException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE, e.getCause()); ...
#vulnerable code @Test public void testConstructor1(){ ClassCastInputCSVException e = new ClassCastInputCSVException(MSG, ANONYMOUS_CSVCONTEXT, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(THROWABLE...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String getConversationId() { return null; }
#vulnerable code @Override public String getConversationId() { return getViewCache().getCurrentConversationId(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitializationOnlyTheFirstTime() throws InterruptedException { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConfigurat...
#vulnerable code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitializationOnlyTheFirstTime() throws InterruptedException { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConf...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected void startJetty() { rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(handlerList, sessionManager, ...
#vulnerable code @Override protected void startJetty() { ApplicationContext rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(hand...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static <K, V> V getSingleValue(Map<K, V> map) { return getSingleOrNull(map.entrySet()).getValue(); }
#vulnerable code private static <K, V> V getSingleValue(Map<K, V> map) { return getSingle(map.entrySet()).getValue(); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void verifyRandomWalkerModuleCorrectlyGeneratesReasonablePageRankMeasurements() throws InterruptedException { // firstly, generate a graph final int numberOfNodes = 50; GraphGenerator graphGenerator = new Neo4jGraphGenerator(database); LOG.info("Generating...
#vulnerable code @Test public void verifyRandomWalkerModuleCorrectlyGeneratesReasonablePageRankMeasurements() throws InterruptedException { // firstly, generate a graph final int numberOfNodes = 10; GraphGenerator graphGenerator = new Neo4jGraphGenerator(database); LOG.info("Gene...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected void startJetty() { rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(handlerList, sessionManager, ...
#vulnerable code @Override protected void startJetty() { ApplicationContext rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(hand...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitialization() { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConfiguration.getInstance()); Mockito.doThrow(...
#vulnerable code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitialization() { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConfiguration.getInstance()); Mockito.do...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void load(InputStream input) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); for (;;) { String line = reader.readLine(); if (line == null) { brea...
#vulnerable code public void load(InputStream input) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(input)); for (;;) { String line = reader.readLine(); if (line == null) { break; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void javaUtilLogging() { String tainted = req.getParameter("test"); String safe = "safe"; Logger logger = Logger.getLogger(Logging.class.getName()); logger.setLevel(Level.ALL); ConsoleHandler handler = new ConsoleHandler(); ...
#vulnerable code public void javaUtilLogging() { String tainted = System.getProperty(""); String safe = "safe"; Logger logger = Logger.getLogger(Logging.class.getName()); logger.setLevel(Level.ALL); ConsoleHandler handler = new ConsoleHandler(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private byte[] buildFakePluginJar() throws IOException, URISyntaxException { ClassLoader cl = getClass().getClassLoader(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JarOutputStream jar = new JarOutputStream(buffer); final UR...
#vulnerable code private byte[] buildFakePluginJar() throws IOException { ClassLoader cl = getClass().getClassLoader(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JarOutputStream jar = new JarOutputStream(buffer); //Add files to the jar...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void visitInvoke(InvokeInstruction obj) { assert obj != null; TaintMethodSummary methodSummary = getMethodSummary(obj); Taint taint = getMethodTaint(methodSummary); assert taint != null; if (taint.isUnknown()) { tain...
#vulnerable code private void visitInvoke(InvokeInstruction obj) { assert obj != null; TaintMethodSummary methodSummary = getMethodSummary(obj); Taint taint = getMethodTaint(methodSummary); assert taint != null; if (taint.isUnknown()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void visitInvoke(InvokeInstruction obj) { assert obj != null; try { TaintMethodConfig methodConfig = getMethodConfig(obj); Taint taint = getMethodTaint(methodConfig); assert taint != null; if (FindSecBugs...
#vulnerable code private void visitInvoke(InvokeInstruction obj) { assert obj != null; try { TaintMethodConfig methodConfig = getMethodConfig(obj); ObjectType realInstanceClass = (methodConfig == null) ? null : methodConfig.get...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static List<String> loadFileContent(String path) { BufferedReader stream = null; try { InputStream in = TaintAnalysis.class.getClassLoader().getResourceAsStream(path); stream = new BufferedReader(new InputStreamReader(in, "utf-8...
#vulnerable code private static List<String> loadFileContent(String path) { try { InputStream in = TaintAnalysis.class.getClassLoader().getResourceAsStream(path); BufferedReader stream = new BufferedReader(new InputStreamReader(in)); String li...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static List<String> loadFileContent(String path) { try (InputStream in = TaintAnalysis.class.getClassLoader().getResourceAsStream(path); BufferedReader stream = new BufferedReader(new InputStreamReader(in, "utf-8"))) { Str...
#vulnerable code private static List<String> loadFileContent(String path) { BufferedReader stream = null; try { InputStream in = TaintAnalysis.class.getClassLoader().getResourceAsStream(path); stream = new BufferedReader(new InputStreamReader(in, ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private byte[] buildFakePluginJar() throws IOException, URISyntaxException { ClassLoader cl = getClass().getClassLoader(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JarOutputStream jar = new JarOutputStream(buffer); final UR...
#vulnerable code private byte[] buildFakePluginJar() throws IOException { ClassLoader cl = getClass().getClassLoader(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JarOutputStream jar = new JarOutputStream(buffer); //Add files to the jar...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws IOException { Function<LookupResult, Integer> resultTransformer = new Function<LookupResult, Integer>() { @Nullable @Override public Integer apply(@Nullable LookupResult input) { return input.weight(); ...
#vulnerable code public static void main(String[] args) throws IOException { Function<LookupResult, Integer> resultTransformer = new Function<LookupResult, Integer>() { @Nullable @Override public Integer apply(@Nullable LookupResult input) { return input.weig...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Set<T> current() { return records; }
#vulnerable code @Override public Set<T> current() { ImmutableSet.Builder<T> records = ImmutableSet.builder(); for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { records.addAll(changeNotifier.current()); } return records.build(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws ExecutionException, InterruptedException, IOException { DnsSrvResolver resolver = DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .metered(REPORTER) .dnsLookupTim...
#vulnerable code public static void main(String[] args) throws ExecutionException, InterruptedException, IOException { DnsSrvResolver resolver = DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .metered(REPORTER) .dnsLoo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws IOException { Function<LookupResult, Integer> resultTransformer = new Function<LookupResult, Integer>() { @Nullable @Override public Integer apply(@Nullable LookupResult input) { return input.weight(); ...
#vulnerable code public static void main(String[] args) throws IOException { Function<LookupResult, Integer> resultTransformer = new Function<LookupResult, Integer>() { @Nullable @Override public Integer apply(@Nullable LookupResult input) { return input.weig...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Set<T> aggregateSet() { if (areAllInitial(changeNotifiers)) { return ChangeNotifiers.initialEmptyDataInstance(); } ImmutableSet.Builder<T> records = ImmutableSet.builder(); for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { rec...
#vulnerable code private Set<T> aggregateSet() { ImmutableSet.Builder<T> records = ImmutableSet.builder(); for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { records.addAll(changeNotifier.current()); } return records.build(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws IOException { Function<LookupResult, Integer> resultTransformer = new Function<LookupResult, Integer>() { @Nullable @Override public Integer apply(@Nullable LookupResult input) { return input.weight(); ...
#vulnerable code public static void main(String[] args) throws IOException { DnsSrvResolver resolver = DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .dnsLookupTimeoutMillis(1000) .build(); PollingDnsSrvResolver<S...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean putConfig(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUT, timeoutMills); etcdConfigExecutor.execute(() -> complete(getClient().getK...
#vulnerable code @Override public boolean putConfig(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUT, timeoutMills); etcdConfigExecutor.execute(() -> { compl...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { TCCResource tccResource = (TCCResource) tccResourceCache.get(resourceId); if (tccResource == null) { th...
#vulnerable code @Override public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { TCCResource tccResource = (TCCResource) tccResourceCache.get(resourceId); if (tccResource == null) {...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static RegistryService getInstance() { RegistryType registryType = null; try { registryType = RegistryType.getType( ConfigurationFactory.FILE_INSTANCE.getConfig( ConfigurationKeys.FILE_ROOT_REGISTRY + Conf...
#vulnerable code public static RegistryService getInstance() { ConfigType configType = null; try { configType = ConfigType.getType( ConfigurationFactory.FILE_INSTANCE.getConfig( ConfigurationKeys.FILE_ROOT_REGISTRY + Config...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigOperation.REMOVE, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); retur...
#vulnerable code @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigOperation.REMOVE, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static <T, S extends Statement> T execute(SQLRecognizer sqlRecognizer, StatementProxy<S> statementProxy, StatementCallback<T, S> statementCallback, ...
#vulnerable code public static <T, S extends Statement> T execute(SQLRecognizer sqlRecognizer, StatementProxy<S> statementProxy, StatementCallback<T, S> statementCallback, ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { TCCResource tccResource = (TCCResource) tccResourceCache.get(resourceId); if(tccResource == null){ throw ...
#vulnerable code @Override public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { TCCResource tccResource = (TCCResource) tccResourceCache.get(resourceId); if(tccResource == null){ ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static long generateUUID() { long id = UUID.incrementAndGet(); if (id >= getMaxUUID()) { synchronized (UUID) { if (UUID.get() >= id) { id -= UUID_INTERNAL; UUID.set(id); ...
#vulnerable code public static long generateUUID() { long id = UUID.incrementAndGet(); if (id >= UUID_INTERNAL * (serverNodeId + 1)) { synchronized (UUID) { if (UUID.get() >= id) { id -= UUID_INTERNAL; U...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public DataSource generateDataSource() { DruidDataSource ds = new DruidDataSource(); ds.setDriverClassName(getDriverClassName()); ds.setDriverClassLoader(getDriverClassLoader()); ds.setUrl(getUrl()); ds.setUsername(getUser...
#vulnerable code @Override public DataSource generateDataSource() { DruidDataSource ds = new DruidDataSource(); ds.setDriverClassName(getDriverClassName()); ds.setUrl(getUrl()); ds.setUsername(getUser()); ds.setPassword(getPassword()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Configuration getInstance() { ConfigType configType = null; String configTypeName = null; try { configTypeName = FILE_INSTANCE.getConfig(ConfigurationKeys.FILE_ROOT_CONFIG + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR ...
#vulnerable code public static Configuration getInstance() { ConfigType configType = null; try { configType = ConfigType.getType( FILE_INSTANCE.getConfig(ConfigurationKeys.FILE_ROOT_CONFIG + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRestoredFromFileRollbackRetry() throws Exception { SessionHolder.init("file"); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionH...
#vulnerable code @Test public void testRestoredFromFileRollbackRetry() throws Exception { SessionHolder.init("."); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(Sessio...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configChangeNot...
#vulnerable code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configCha...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBigDataWrite() throws Exception { File seataFile = Files.newTemporaryFile(); FileTransactionStoreManager fileTransactionStoreManager = null; try { fileTransactionStoreManager = new FileTransactionStoreManager(seata...
#vulnerable code @Test public void testBigDataWrite() throws Exception { File seataFile = Files.newTemporaryFile(); try { FileTransactionStoreManager fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), null); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static long generateUUID() { return IdWorker.getInstance().nextId(); }
#vulnerable code public static long generateUUID() { long id = UUID.incrementAndGet(); if (id >= getMaxUUID()) { synchronized (UUID) { if (UUID.get() >= id) { id -= UUID_INTERNAL; UUID.set(id); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { ProtocolV1Client client = new ProtocolV1Client(); client.connect("127.0.0.1", 8811, 500); Map<String, String> head = new HashMap<>(); head.put("tracerId", "xxadadadada"); head.put("token", "adad...
#vulnerable code public static void main(String[] args) throws InterruptedException, TimeoutException, ExecutionException { ProtocolV1Client client = new ProtocolV1Client(); client.connect("127.0.0.1", 8811, 500); Map<String, String> head = new HashMap<>(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void subscribe(String cluster, Watch.Listener listener) throws Exception { listenerMap.putIfAbsent(cluster, new HashSet<>()); listenerMap.get(cluster).add(listener); EtcdWatcher watcher = watcherMap.computeIfAbsent(cluster, w -> ne...
#vulnerable code @Override public void subscribe(String cluster, Watch.Listener listener) throws Exception { listenerMap.putIfAbsent(cluster, new HashSet<>()); listenerMap.get(cluster).add(listener); EtcdWatcher watcher = watcherMap.computeIfAbsent(cluster, w...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean putConfigIfAbsent(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUTIFABSENT, timeoutMills); consulNotifierExecutor.execute(() -> { ...
#vulnerable code @Override public boolean putConfigIfAbsent(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUTIFABSENT, timeoutMills); consulConfigExecutor.execute(() -> {...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testRestoredFromFile2() throws Exception { SessionHolder.init("file"); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionHolder.getRootSessionMan...
#vulnerable code public void testRestoredFromFile2() throws Exception { SessionHolder.init("."); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionHolder.getRootSession...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static TableMeta resultSetMetaToSchema(ResultSetMetaData rsmd, DatabaseMetaData dbmd, String tableName) throws SQLException { String schemaName = rsmd.getSchemaName(1); String catalogName = rsmd.getCatalogName(1); TableMeta tm = new Ta...
#vulnerable code private static TableMeta resultSetMetaToSchema(ResultSetMetaData rsmd, DatabaseMetaData dbmd, String tableName) throws SQLException { String schemaName = rsmd.getSchemaName(1); String catalogName = rsmd.getCatalogName(1); TableMeta tm = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); etcdConfigExecutor.execute(() -> complete(getClie...
#vulnerable code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); etcdConfigExecutor.execute(() -> { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); consulNotifierExecutor.execute(() -> { ...
#vulnerable code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); consulConfigExecutor.execute(() -> { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { try { BranchCommitRequest request = new B...
#vulnerable code @Override public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { try { BranchCommitRequest request =...
Below is the vulnerable code, please generate the patch based on the following information.