input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#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...
#fixed code @Override public void close() throws IOException { if (this.queueFrontIndexPageFactory != null) { this.queueFrontIndexPageFactory.releaseCachedPages(); } synchronized (futureLock) { /* Cancel the future but don't interrup...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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())...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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(); // ...
Below is the vulnerable code, please generate the patch based on the following information.
#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++ )...
#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++ ) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#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()); ...
#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()...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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()); ...
#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()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConstuctor6(){ SuperCSVException e = new SuperCSVException(MSG, ANONYMOUS_CSVCONTEXT, PROCESSOR, THROWABLE); assertEquals(CONCATENATED_MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(PROCESSOR, e.getO...
#fixed code @Test public void testConstuctor6(){ SuperCSVException e = new SuperCSVException(MSG, ANONYMOUS_CSVCONTEXT, PROCESSOR, THROWABLE); assertEquals(MSG, e.getMessage()); assertEquals(ANONYMOUS_CSVCONTEXT, e.getCsvContext()); assertEquals(PROCESSOR, e.getOffendingProcessor()...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getConversationId() { return getViewCache().getCurrentConversationId(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public String getConversationId() { return null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitializationOnlyTheFirstTime() throws InterruptedException { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConf...
#fixed code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitializationOnlyTheFirstTime() throws InterruptedException { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConfigurat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void startJetty() { ApplicationContext rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(hand...
#fixed code @Override protected void startJetty() { rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(handlerList, sessionManager, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static <K, V> V getSingleValue(Map<K, V> map) { return getSingle(map.entrySet()).getValue(); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private static <K, V> V getSingleValue(Map<K, V> map) { return getSingleOrNull(map.entrySet()).getValue(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void verifyRandomWalkerModuleCorrectlyGeneratesReasonablePageRankMeasurements() throws InterruptedException { // firstly, generate a graph final int numberOfNodes = 10; GraphGenerator graphGenerator = new Neo4jGraphGenerator(database); LOG.info("Gene...
#fixed code @Test public void verifyRandomWalkerModuleCorrectlyGeneratesReasonablePageRankMeasurements() throws InterruptedException { // firstly, generate a graph final int numberOfNodes = 50; GraphGenerator graphGenerator = new Neo4jGraphGenerator(database); LOG.info("Generating...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void startJetty() { ApplicationContext rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(hand...
#fixed code @Override protected void startJetty() { rootContext = createRootApplicationContext(); HandlerList handlerList = findHandlerList(); SessionManager sessionManager = findSessionManager(handlerList); addHandlers(handlerList, sessionManager, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitialization() { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConfiguration.getInstance()); Mockito.do...
#fixed code @Test public void moduleThrowingInitExceptionShouldBeMarkedForReinitialization() { final TxDrivenModule mockModule = createMockModule(); when(mockModule.getConfiguration()).thenReturn(NullTxDrivenModuleConfiguration.getInstance()); Mockito.doThrow(...
Below is the vulnerable code, please generate the patch based on the following information.
#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; ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); ...
#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(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code private byte[] buildFakePluginJar() throws IOException, URISyntaxException { ClassLoader cl = getClass().getClassLoader(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JarOutputStream jar = new JarOutputStream(buffer); final UR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void visitInvoke(InvokeInstruction obj) { assert obj != null; TaintMethodSummary methodSummary = getMethodSummary(obj); Taint taint = getMethodTaint(methodSummary); assert taint != null; if (taint.isUnknown()) { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void visitInvoke(InvokeInstruction obj) { assert obj != null; try { TaintMethodConfig methodConfig = getMethodConfig(obj); ObjectType realInstanceClass = (methodConfig == null) ? null : methodConfig.get...
#fixed code private void visitInvoke(InvokeInstruction obj) { assert obj != null; try { TaintMethodConfig methodConfig = getMethodConfig(obj); Taint taint = getMethodTaint(methodConfig); assert taint != null; if (FindSecBugs...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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, ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code private byte[] buildFakePluginJar() throws IOException, URISyntaxException { ClassLoader cl = getClass().getClassLoader(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JarOutputStream jar = new JarOutputStream(buffer); final UR...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); } ...
#fixed code @Override public Set<T> current() { return records; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws ExecutionException, InterruptedException, IOException { DnsSrvResolver resolver = DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .metered(REPORTER) .dnsLoo...
#fixed code public static void main(String[] args) throws ExecutionException, InterruptedException, IOException { DnsSrvResolver resolver = DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .metered(REPORTER) .dnsLookupTim...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); } ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws IOException { DnsSrvResolver resolver = DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .dnsLookupTimeoutMillis(1000) .build(); PollingDnsSrvResolver<S...
#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(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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) {...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static RegistryService getInstance() { ConfigType configType = null; try { configType = ConfigType.getType( ConfigurationFactory.FILE_INSTANCE.getConfig( ConfigurationKeys.FILE_ROOT_REGISTRY + Config...
#fixed code public static RegistryService getInstance() { RegistryType registryType = null; try { registryType = RegistryType.getType( ConfigurationFactory.FILE_INSTANCE.getConfig( ConfigurationKeys.FILE_ROOT_REGISTRY + Conf...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigOperation.REMOVE, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T, S extends Statement> T execute(SQLRecognizer sqlRecognizer, StatementProxy<S> statementProxy, StatementCallback<T, S> statementCallback, ...
#fixed 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.
#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){ ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object invoke(ServiceTaskState serviceTaskState, Object... input) { ServiceTaskStateImpl state = (ServiceTaskStateImpl) serviceTaskState; Object bean = applicationContext.getBean(state.getServiceName()); Method method = st...
#fixed code @Override public Object invoke(ServiceTaskState serviceTaskState, Object... input) { ServiceTaskStateImpl state = (ServiceTaskStateImpl) serviceTaskState; if(state.isAsync()){ if(threadPoolExecutor == null){ if(LOGGER.isWarnEnab...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public DataSource generateDataSource() { DruidDataSource ds = new DruidDataSource(); ds.setDriverClassName(getDriverClassName()); ds.setUrl(getUrl()); ds.setUsername(getUser()); ds.setPassword(getPassword()); ...
#fixed code @Override public DataSource generateDataSource() { DruidDataSource ds = new DruidDataSource(); ds.setDriverClassName(getDriverClassName()); ds.setDriverClassLoader(getDriverClassLoader()); ds.setUrl(getUrl()); ds.setUsername(getUser...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configCha...
#fixed code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configChangeNot...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBigDataWrite() throws Exception { File seataFile = Files.newTemporaryFile(); try { FileTransactionStoreManager fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), null); ...
#fixed code @Test public void testBigDataWrite() throws Exception { File seataFile = Files.newTemporaryFile(); FileTransactionStoreManager fileTransactionStoreManager = null; try { fileTransactionStoreManager = new FileTransactionStoreManager(seata...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) { try { if (msg instanceof RpcMessage) { RpcMessage rpcMessage = (RpcMessage) msg; int fullLength = 13; int headLeng...
#fixed code @Override public void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) { try { if (msg instanceof RpcMessage) { RpcMessage rpcMessage = (RpcMessage) msg; int fullLength = ProtocolConstants.V1_HEAD_LENGTH; ...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#fixed code public static long generateUUID() { return IdWorker.getInstance().nextId(); }
Below is the vulnerable code, please generate the patch based on the following information.
#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<>(); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean putConfigIfAbsent(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUTIFABSENT, timeoutMills); consulConfigExecutor.execute(() -> {...
#fixed code @Override public boolean putConfigIfAbsent(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUTIFABSENT, timeoutMills); consulNotifierExecutor.execute(() -> { ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 = ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); etcdConfigExecutor.execute(() -> { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); consulConfigExecutor.execute(() -> { ...
#fixed code @Override public String getConfig(String dataId, String defaultValue, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, defaultValue, ConfigFuture.ConfigOperation.GET, timeoutMills); consulNotifierExecutor.execute(() -> { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { try { BranchCommitRequest request =...
#fixed code @Override public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { try { BranchCommitRequest request = new B...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Connection getConnectionProxy(Connection connection) throws SQLException { Connection physicalConn = connection.unwrap(Connection.class); XAConnection xaConnection = XAUtils.createXAConnection(physicalConn, this); ConnectionProxyXA conn...
#fixed code protected Connection getConnectionProxy(Connection connection) throws SQLException { if (!RootContext.inGlobalTransaction()) { return connection; } return getConnectionProxyXA(connection); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigFuture.ConfigOperation.REMOVE, timeoutMills); consulConfigExecutor.execute(() -> { complete(getCons...
#fixed code @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigFuture.ConfigOperation.REMOVE, timeoutMills); consulNotifierExecutor.execute(() -> { complete(getConsulCl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRestoredFromFileCommitRetry() throws Exception { SessionHolder.init("."); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionH...
#fixed code @Test public void testRestoredFromFileCommitRetry() throws Exception { SessionHolder.init("file"); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionHold...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object invoke(ServiceTaskState serviceTaskState, Object... input) { ServiceTaskStateImpl state = (ServiceTaskStateImpl) serviceTaskState; Object bean = applicationContext.getBean(state.getServiceName()); Method method = st...
#fixed code @Override public Object invoke(ServiceTaskState serviceTaskState, Object... input) { ServiceTaskStateImpl state = (ServiceTaskStateImpl) serviceTaskState; if(state.isAsync()){ if(threadPoolExecutor == null){ if(LOGGER.isWarnEnab...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void refresh(final DataSourceProxy dataSourceProxy){ ConcurrentMap<String, TableMeta> tableMetaMap = TABLE_META_CACHE.asMap(); for (Entry<String, TableMeta> entry : tableMetaMap.entrySet()) { try { TableMeta tabl...
#fixed code public static void refresh(final DataSourceProxy dataSourceProxy){ ConcurrentMap<String, TableMeta> tableMetaMap = TABLE_META_CACHE.asMap(); for (Entry<String, TableMeta> entry : tableMetaMap.entrySet()) { String key = getCacheKey(dataSourceProxy, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] decompress(byte[] bytes) { if (bytes == null) { throw new NullPointerException("bytes is null"); } ByteArrayOutputStream out = null; GZIPInputStream gunzip = null; try { out = new ByteA...
#fixed code public static byte[] decompress(byte[] bytes) { if (bytes == null) { throw new NullPointerException("bytes is null"); } ByteArrayOutputStream out = new ByteArrayOutputStream(); try (GZIPInputStream gunzip = new GZIPInputStream(new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRestoredFromFile() throws Exception { SessionHolder.init("."); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionHolder.getRo...
#fixed code @Test public void testRestoredFromFile() throws Exception { SessionHolder.init("file"); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(SessionHolder.getRootS...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configCha...
#fixed code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configChangeNot...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean putConfig(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUT, timeoutMills); consulConfigExecutor.execute(() -> { com...
#fixed code @Override public boolean putConfig(String dataId, String content, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, content, ConfigFuture.ConfigOperation.PUT, timeoutMills); consulNotifierExecutor.execute(() -> { complet...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRestoredFromFileAsyncCommitting() throws Exception { SessionHolder.init("."); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(Sess...
#fixed code @Test public void testRestoredFromFileAsyncCommitting() throws Exception { SessionHolder.init("file"); GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000); globalSession.addSessionLifecycleListener(Session...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void refreshTest_0() { MockDriver mockDriver = new MockDriver(columnMetas, indexMetas); DruidDataSource druidDataSource = new DruidDataSource(); druidDataSource.setUrl("jdbc:mock:xxx"); druidDataSource.setDriver(mockDriv...
#fixed code @Test public void refreshTest_0() throws SQLException { MockDriver mockDriver = new MockDriver(columnMetas, indexMetas); DruidDataSource druidDataSource = new DruidDataSource(); druidDataSource.setUrl("jdbc:mock:xxx"); druidDataSource.setD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configCha...
#fixed code @Override public void addConfigListener(String dataId, ConfigChangeListener listener) { configListenersMap.putIfAbsent(dataId, new ArrayList<>()); configChangeNotifiersMap.putIfAbsent(dataId, new ArrayList<>()); ConfigChangeNotifier configChangeNot...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean removeConfig(String dataId, long timeoutMills) { ConfigFuture configFuture = new ConfigFuture(dataId, null, ConfigOperation.REMOVE, timeoutMills); configOperateExecutor.submit(new ConfigOperateRunnable(configFuture)); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void registerResource(String resourceGroupId, String resourceId) { if (LOGGER.isInfoEnabled()) { LOGGER.info("register to RM resourceId:" + resourceId); } if (getClientChannelManager().getChannels().isEmpty()) { get...
#fixed code public void registerResource(String resourceGroupId, String resourceId) { if (LOGGER.isInfoEnabled()) { LOGGER.info("register to RM resourceId:{}", resourceId); } if (getClientChannelManager().getChannels().isEmpty()) { getClien...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { try { BranchRollbackRequest request = n...
#fixed code @Override public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException { try { BranchRollbackRequest request = new Bra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingEscapedXml() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader.readRec...
#fixed code @Test public void testReadingEscapedXml() throws Exception { // given xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readRecord(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Before public void setUp() throws Exception { when(record.getPayload()).thenReturn(PAYLOAD); file = new File(JAVA_IO_TMPDIR + FILE_SEPARATOR + "test.txt"); file.createNewFile(); writer = new FileRecordWriter(new FileWriter(file)); ...
#fixed code @Before public void setUp() throws Exception { Files.createFile(path); record1 = new StringRecord(header, "foo"); record2 = new StringRecord(header, "bar"); writer = new FileRecordWriter(path); writer.open(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { //Create queues BlockingQueue<Record> appleQueue = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> orangeQueue = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> ...
#fixed code public static void main(String[] args) throws Exception { String fruits = "1,apple\n2,orange\n3,banana\n4,apple\n5,pear"; // Create queues BlockingQueue<Record> appleQueue = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> orangeQueue...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { // Input file tweets.csv File tweets = new File(args[0]); //Create queues BlockingQueue<Record> queue1 = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> queue2 =...
#fixed code public static void main(String[] args) throws Exception { // Input file tweets.csv File tweets = new File(args[0]); // Create queues BlockingQueue<Record> queue1 = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> queue2 = new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void configure() throws BatchConfigurationException { /* * Configure CB4J logger */ logger.setUseParentHandlers(false); ConsoleHandler consoleHandler = new ConsoleHandler(); consoleHandler.setFormatter(new LogFor...
#fixed code public void configure() throws BatchConfigurationException { /* * Configure CB4J logger */ configureCB4JLogger(); logger.info("Configuration started at : " + new Date()); /* * Configure record reader */ ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void open() throws Exception { currentRecordNumber = 0; scanner = new Scanner(new FileInputStream(input), charsetName); } #location 4 #vulnerability type RESOURCE_LEAK
#fixed code @Override public void open() throws Exception { currentRecordNumber = 0; scanner = new Scanner(input, charsetName); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { // Input file tweets.csv File tweets = new File(args[0]); //Create queues BlockingQueue<Record> queue1 = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> queue2 =...
#fixed code public static void main(String[] args) throws Exception { // Input file tweets.csv File tweets = new File(args[0]); // Create queues BlockingQueue<Record> queue1 = new LinkedBlockingQueue<Record>(); BlockingQueue<Record> queue2 = new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xls").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xls").toURI()); Job job = JobBu...
#fixed code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xlsx").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xlsx").toURI()); Job job = JobBuilde...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testXmlRecordReading() throws Exception { String expectedDataSourceName = dataSource.getAbsolutePath(); XmlRecord xmlRecord = xmlFileRecordReader.readRecord(); assertThat(xmlRecord.getHeader().getNumber()).isEqualTo(1L); ...
#fixed code @Test public void testXmlRecordReading() throws Exception { // given dataSource = new File("src/test/resources/data.xml"); xmlFileRecordReader = new XmlFileRecordReader(dataSource, "data"); xmlFileRecordReader.open(); String expecte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public StringRecord processRecord(final Record<P> record) throws Exception { StringWriter stringWriter = new StringWriter(); CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat); Iterable<Object> iterable = fieldExtractor...
#fixed code @Override public StringRecord processRecord(final Record<P> record) throws Exception { StringWriter stringWriter = new StringWriter(); CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat); Iterable<Object> iterable = fieldExtractor.extra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingXmlWithCustomNamespace() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("bean", getDataSource("/beans.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader....
#fixed code @Test public void testReadingXmlWithCustomNamespace() throws Exception { // given xmlRecordReader = new XmlRecordReader("bean", getDataSource("/beans.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingEscapedXml() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader.readRec...
#fixed code @Test public void testReadingEscapedXml() throws Exception { // given xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readRecord(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testXmlRecordReading() throws Exception { String expectedDataSourceName = dataSource.getAbsolutePath(); XmlRecord xmlRecord = xmlFileRecordReader.readRecord(); assertThat(xmlRecord.getHeader().getNumber()).isEqualTo(1L); ...
#fixed code @Test public void testXmlRecordReading() throws Exception { // given dataSource = new File("src/test/resources/data.xml"); xmlFileRecordReader = new XmlFileRecordReader(dataSource, "data"); xmlFileRecordReader.open(); String expecte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRecordLimit() throws Exception { List<String> dataSource = Arrays.asList("foo", "bar", "baz"); JobReport jobReport = aNewJob() .reader(new IterableRecordReader(dataSource)) .limit(2) ...
#fixed code @Test public void testRecordLimit() throws Exception { List<String> dataSource = Arrays.asList("foo", "bar", "baz"); JobReport jobReport = aNewJob() .reader(new IterableRecordReader(dataSource)) .limit(2) .p...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingEscapedXml() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader.readRec...
#fixed code @Test public void testReadingEscapedXml() throws Exception { // given xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readRecord(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testXmlRecordReading() throws Exception { String expectedDataSourceName = dataSource.getAbsolutePath(); XmlRecord xmlRecord = xmlFileRecordReader.readRecord(); assertThat(xmlRecord.getHeader().getNumber()).isEqualTo(1L); ...
#fixed code @Test public void testXmlRecordReading() throws Exception { // given dataSource = new File("src/test/resources/data.xml"); xmlFileRecordReader = new XmlFileRecordReader(dataSource, "data"); xmlFileRecordReader.open(); String expecte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testXmlRecordReading() throws Exception { String expectedDataSourceName = dataSource.getAbsolutePath(); XmlRecord xmlRecord = xmlFileRecordReader.readRecord(); assertThat(xmlRecord.getHeader().getNumber()).isEqualTo(1L); ...
#fixed code @Test public void testXmlRecordReading() throws Exception { // given dataSource = new File("src/test/resources/data.xml"); xmlFileRecordReader = new XmlFileRecordReader(dataSource, "data"); xmlFileRecordReader.open(); String expecte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xls").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xls").toURI()); Job job = JobBu...
#fixed code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xlsx").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xlsx").toURI()); Job job = JobBuilde...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xlsx").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xlsx").toURI()); String[] fiel...
#fixed code @Test public void integrationTest() throws Exception { Path inputTweets = Paths.get("src/test/resources/tweets-in.xlsx"); Path outputTweets = Paths.get("src/test/resources/tweets-out.xlsx"); String[] fields = {"id", "user", "message"}; Jo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test @SuppressWarnings("unchecked") public void integrationTest() throws Exception { String dataSource = "foo" + LINE_SEPARATOR + "" + LINE_SEPARATOR + "bar" + LINE_SEPARATOR + "" + LINE_SEPARATOR; JobReport jobReport = aNewJob() ...
#fixed code @Test @SuppressWarnings("unchecked") public void integrationTest() throws Exception { String dataSource = "foo" + LINE_SEPARATOR + "" + LINE_SEPARATOR + "bar" + LINE_SEPARATOR + "" + LINE_SEPARATOR; JobReport jobReport = aNewJob() .rea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingEscapedXml() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader.readRec...
#fixed code @Test public void testReadingEscapedXml() throws Exception { // given xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readRecord(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testXmlRecordReading() throws Exception { String expectedDataSourceName = dataSource.getAbsolutePath(); XmlRecord xmlRecord = xmlFileRecordReader.readRecord(); assertThat(xmlRecord.getHeader().getNumber()).isEqualTo(1L); ...
#fixed code @Test public void testXmlRecordReading() throws Exception { // given dataSource = new File("src/test/resources/data.xml"); xmlFileRecordReader = new XmlFileRecordReader(dataSource, "data"); xmlFileRecordReader.open(); String expecte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xls").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xls").toURI()); Job job = JobBu...
#fixed code @Test public void integrationTest() throws Exception { File inputTweets = new File(this.getClass().getResource("/tweets-in.xls").toURI()); File outputTweets = new File(this.getClass().getResource("/tweets-out.xls").toURI()); Job job = JobBuilder....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingEscapedXml() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader.readRec...
#fixed code @Test public void testReadingEscapedXml() throws Exception { // given xmlRecordReader = new XmlRecordReader("website", getDataSource("/websites.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readRecord(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadingXmlWithCustomNamespace() throws Exception { xmlRecordReader.close(); xmlRecordReader = new XmlRecordReader("bean", getDataSource("/beans.xml")); xmlRecordReader.open(); XmlRecord record = xmlRecordReader....
#fixed code @Test public void testReadingXmlWithCustomNamespace() throws Exception { // given xmlRecordReader = new XmlRecordReader("bean", getDataSource("/beans.xml")); xmlRecordReader.open(); // when XmlRecord record1 = xmlRecordReader.readR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String validateRecord(Record record) { String error = super.validateRecord(record); if (error.length() == 0){//no errors after applying declared validators on each field => all fields are valid //add custom validation :...
#fixed code @Override public String validateRecord(Record record) { String error = super.validateRecord(record); if (error == null){//no errors after applying declared validators on each field => all fields are valid //add custom validation : field 2 con...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run() { final SingleWriterRecorder recorder = new SingleWriterRecorder( config.lowestTrackableValue, config.highestTrackableValue, config.numberOfSi...
#fixed code @Override public void run() { final SingleWriterRecorder recorder = new SingleWriterRecorder( config.lowestTrackableValue, config.highestTrackableValue, config.numberOfSignific...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void init() { KafkaConsumer kafkaConsumer=new KafkaConsumer(getProperties()); //kafka消费消息,接收MQTT发来的消息 kafkaConsumer.subscribe(Arrays.asList(conf.get("mqttwk.broker.kafka.producer.topic"))); int sum=0; while (true) { ...
#fixed code public void init() { KafkaConsumer kafkaConsumer=new KafkaConsumer(getProperties()); //kafka消费消息,接收MQTT发来的消息 kafkaConsumer.subscribe(Arrays.asList(conf.get("mqttwk.broker.kafka.producer.topic"))); int sum=0; while (true) { C...
Below is the vulnerable code, please generate the patch based on the following information.