input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Test public void publicResourceHandlerTest() throws URISyntaxException { PublicResourceHandler handler = new PublicResourceHandler(); URL resourceUrl = handler.getResourceUrl("VISIBLE"); assertNotNull(resourceUrl); Path visibleFile ...
#fixed code @Test public void publicResourceHandlerTest() throws URISyntaxException { PublicResourceHandler handler = new PublicResourceHandler(); URL resourceUrl = handler.getResourceUrl("VISIBLE"); assertNotNull(resourceUrl); Path visibleFile = Path...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String injectVersion(String resourcePath) { URL resourceUrl = getResourceUrl(resourcePath); try { long lastModified = resourceUrl.openConnection().getLastModified(); // check for extension int extensionAt = res...
#fixed code public String injectVersion(String resourcePath) { String version = getResourceVersion(resourcePath); if (StringUtils.isNullOrEmpty(version)) { // unversioned, pass-through resource path return resourcePath; } // check ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code String buildRealData(final ConditionZkDTO condition, final ServerWebExchange exchange) { String realData = ""; if (condition.getParamType().equals(ParamTypeEnum.QUERY.getName())) { final MultiValueMap<String, String> queryParams = exchange.ge...
#fixed code String buildRealData(final ConditionZkDTO condition, final ServerWebExchange exchange) { String realData = ""; if (condition.getParamType().equals(ParamTypeEnum.QUERY.getName())) { final MultiValueMap<String, String> queryParams = exchange.getReque...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void roundRobinLoadBalanceTest() { List<DivideUpstream> divideUpstreamList = Arrays.asList(50, 20, 30).stream() .map(weight -> { DivideUpstream divideUpstream = new DivideUpstr...
#fixed code @Test public void roundRobinLoadBalanceTest() { List<DivideUpstream> divideUpstreamList = Stream.of(50, 20, 30) .map(weight -> { DivideUpstream divideUpstream = new DivideUpstream(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception { String[] args = agentArgument.split(":"); if (args.length < 2 || args.length > 3) { System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<...
#fixed code public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception { String[] args = agentArgument.split(":"); if (args.length < 2 || args.length > 3) { System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void agentLoads() throws IOException, InterruptedException { // If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually. final String buildDirectory = (String) System.getProperties().get("b...
#fixed code @Test public void agentLoads() throws IOException, InterruptedException { // If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually. final String buildDirectory = (String) System.getProperties().get("buildDi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("Usage: WebServer <port> <yaml configuration file>"); System.exit(1); } JmxCollector jc = new JmxCollector(new FileReader(args[1])).register()...
#fixed code public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("Usage: WebServer <port> <yaml configuration file>"); System.exit(1); } JmxCollector jc = new JmxCollector(new File(args[1])).register(); int ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void agentLoads() throws IOException, InterruptedException { // If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually. final String buildDirectory = (String) System.getProperties().get("b...
#fixed code @Test public void agentLoads() throws IOException, InterruptedException { // If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually. final String buildDirectory = (String) System.getProperties().get("buildDi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void agentLoads() throws IOException, InterruptedException { // If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually. final String buildDirectory = (String) System.getProperties().get("b...
#fixed code @Test public void agentLoads() throws IOException, InterruptedException { // If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually. final String buildDirectory = (String) System.getProperties().get("buildDi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception { String[] args = agentArgument.split(":"); if (args.length < 2 || args.length > 3) { System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<...
#fixed code public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception { String[] args = agentArgument.split(":"); if (args.length < 2 || args.length > 3) { System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception { String[] args = agentArgument.split(":"); if (args.length < 2 || args.length > 3) { System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<...
#fixed code public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception { String[] args = agentArgument.split(":"); if (args.length < 2 || args.length > 3) { System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void beforeClass() { for (File file : customFileLog("").listFiles()) { if (file.getPath().contains("tracer-self.log") || file.getPath().contains("sync.log") || file.getPath().contains("rpc-profile.log") ...
#fixed code @BeforeClass public static void beforeClass() { File[] traceFiles = customFileLog("").listFiles(); if (traceFiles == null) { return; } for (File file : traceFiles) { if (file.getPath().contains("tracer-self.log") || ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Map<String, Object> customSettingsFlat() { return ImmutableMap.<String, Object>builder() .put(HTTP_INCOMING_AUTH_TYPE, IlpOverHttpLinkSettings.AuthType.JWT_HS_256.name()) .put(HTTP_INCOMING_TOKEN_ISSUER, "https://incoming-issuer.example.com/"...
#fixed code protected Map<String, Object> customSettingsFlat() { return customSettingsFlat(IlpOverHttpLinkSettings.AuthType.JWT_HS_256, IlpOverHttpLinkSettings.AuthType.JWT_HS_256); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Node<S> next() { // Take the next node from the stack. Node<S> current = popUnvisited(); // Take the associated state S currentState = current.transition().to(); // Explore the adjacent neighbors for(Transition<S> s...
#fixed code public Node<S> next(){ if (next != null){ Node<S> e = next; next = nextUnvisited(); return e; } else { return nextUnvisited(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public GraphEdge<V,E> connect(V v1, V v2, E value){ //check input if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null"); GraphEdge<V,E> edge = new GraphEdge<V, E>(v1, v2, value); GraphEdge<V,E> edgeRev...
#fixed code public GraphEdge<V,E> connect(V v1, V v2, E value){ // Check non-null arguments if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null"); // Ensure that the vertices are in the graph add(v1); add(v2); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() { String[] testMaze = { "XX@XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XX XXXXXXXXXXXXX XXXXXXXXXXX", "XX XXXXXXXXXX XXX XX XXXX", "XXXXX XXXXXX XXX XX XXX XXXX", "XXX ...
#fixed code @Test public void test() { String[] testMaze = { "XX@XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XX XXXXXXXXXXXXX XXXXXXXXXXX", "XX XXXXXXXXXX XXX XX XXXX", "XXXXX XXXXXX XXX XX XXX XXXX", "XXX XX XXX...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public GraphEdge<V,E> connect(V v1, V v2, E value){ //check input if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null"); GraphEdge<V,E> edge = new GraphEdge<V, E>(v1, v2, value); GraphEdge<V,E> edgeRev...
#fixed code public GraphEdge<V,E> connect(V v1, V v2, E value){ // Check non-null arguments if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null"); // Ensure that the vertices are in the graph add(v1); add(v2); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void benchmark() throws InterruptedException { System.out.println("Maze | Hipster-Dijkstra (ms) | JUNG-Dijkstra (ms)"); System.out.println("-------------------------------------------------"); final int times = 5; for (in...
#fixed code @Test public void benchmark() throws InterruptedException { Benchmark bench = new Benchmark(); // Hipster-Dijkstra bench.add("Hipster-Dijkstra", new Algorithm() { AStar<Point> it; Maze2D maze; public void initialize(Maze2D maz...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testRestartAuditorBookieAfterCrashing() throws Exception { BookieServer auditor = verifyAuditor(); shudownBookie(auditor); // restarting Bookie with same configurations. int indexOfDownBookie = bs.indexOf(auditor);...
#fixed code @Test public void testRestartAuditorBookieAfterCrashing() throws Exception { BookieServer auditor = verifyAuditor(); shudownBookie(auditor); // restarting Bookie with same configurations. int indexOfDownBookie = bs.indexOf(auditor); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void handleSubscribeMessage(PubSubResponse response) { if (logger.isDebugEnabled()) logger.debug("Handling a Subscribe message in response: " + response + ", topic: " + origSubData.topic.toStringUtf8() + ", subscriberI...
#fixed code public void handleSubscribeMessage(PubSubResponse response) { if (logger.isDebugEnabled()) { logger.debug("Handling a Subscribe message in response: {}, topic: {}, subscriberId: {}", new Object[] { response, getOrigSubData().topic.toStr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void close() { synchronized (this) { state = ConnectionState.DISCONNECTED; } if (channel != null) { channel.close().awaitUninterruptibly(); } if (readTimeoutTimer != null) { readTimeoutTi...
#fixed code public void close() { closeInternal(true); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run() { while (running) { synchronized (this) { try { wait(gcWaitTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); ...
#fixed code @Override public void run() { while (running) { synchronized (this) { try { wait(gcWaitTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public byte[] readMasterKey(long ledgerId) throws IOException, BookieException { synchronized(fileInfoCache) { FileInfo fi = fileInfoCache.get(ledgerId); if (fi == null) { File lf = findIndexFile(ledgerId); ...
#fixed code @Override public byte[] readMasterKey(long ledgerId) throws IOException, BookieException { synchronized(fileInfoCache) { FileInfo fi = fileInfoCache.get(ledgerId); if (fi == null) { File lf = findIndexFile(ledgerId); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void writeIndexFileForLedger(File indexDir, long ledgerId, byte[] masterKey) throws Exception { File fn = new File(indexDir, LedgerCache.getLedgerName(ledgerId)); fn.getParentFile().mkdirs(); ...
#fixed code private void writeIndexFileForLedger(File indexDir, long ledgerId, byte[] masterKey) throws Exception { File fn = new File(indexDir, LedgerCache.getLedgerName(ledgerId)); fn.getParentFile().mkdirs(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { LOG.info("Disconnected from bookie: " + addr); errorOutOutstandingEntries(); channel.close(); state = ConnectionState.DISCONN...
#fixed code @Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { LOG.info("Disconnected from bookie: " + addr); errorOutOutstandingEntries(); channel.close(); synchronized (this) { sta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteSyncSingleClient() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test public void testReadWriteSyncSingleClient() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout=60000) public void testLastConfirmedAdd() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test(timeout=60000) public void testLastConfirmedAdd() throws Exception { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSyncReadAsyncWriteStringsSingleClient() throws IOException { LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT"); String charset = "utf-8"; LOG.debug("Default charset: " + Charset.defaultCharset()); try { ...
#fixed code @Test public void testSyncReadAsyncWriteStringsSingleClient() throws IOException { SyncObj sync = new SyncObj(); LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT"); String charset = "utf-8"; LOG.debug("Default charset: " + Charset.defa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void close() { synchronized (this) { state = ConnectionState.DISCONNECTED; } if (channel != null) { channel.close().awaitUninterruptibly(); } if (readTimeoutTimer != null) { readTimeoutTi...
#fixed code public void close() { closeInternal(true); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { if(rc != BKException.Code.OK) fail("Return code is not OK: " + rc); ls = seq; synchronized (sync) { sync.value = true; ...
#fixed code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { SyncObj sync = (SyncObj) ctx; sync.setLedgerEntries(seq); sync.setReturnCode(rc); synchronized (sync) { sync.value = true; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public StatsLogger getStatsLogger(String name) { initIfNecessary(); return new CodahaleStatsLogger(metrics, name); } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public StatsLogger getStatsLogger(String name) { initIfNecessary(); return new CodahaleStatsLogger(getMetrics(), name); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code FileInfo getFileInfo(Long ledger, byte masterKey[]) throws IOException { synchronized(fileInfoCache) { FileInfo fi = fileInfoCache.get(ledger); if (fi == null) { File lf = findIndexFile(ledger); if (lf == n...
#fixed code FileInfo getFileInfo(Long ledger, byte masterKey[]) throws IOException { synchronized(fileInfoCache) { FileInfo fi = fileInfoCache.get(ledger); if (fi == null) { File lf = findIndexFile(ledger); if (lf == null) {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Latency min/avg/max: " + getMinLatency() + "/" + getAvgLatency() + "/" + getMaxLatency() + "\n"); sb.append("Received: " + getPacketsReceived() + "\n"); ...
#fixed code @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Latency min/avg/max: " + getMinLatency() + "/" + getAvgLatency() + "/" + getMaxLatency() + "\n"); sb.append("Received: " + getPacketsReceived() + "\n"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void connectIfNeededAndDoOp(GenericCallback<Void> op) { boolean doOpNow; // common case without lock first if (channel != null && state == ConnectionState.CONNECTED) { doOpNow = true; } else { synchronized (this)...
#fixed code void connectIfNeededAndDoOp(GenericCallback<Void> op) { boolean doOpNow; synchronized (this) { if (channel != null && state == ConnectionState.CONNECTED) { doOpNow = true; } else { // if reached here, ch...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSimpleBookieLedgerMapping() throws Exception { LedgerManagerFactory newLedgerManagerFactory = LedgerManagerFactory .newLedgerManagerFactory(baseConf, zkc); LedgerManager ledgerManager = newLedgerManagerFactory ...
#fixed code @Test public void testSimpleBookieLedgerMapping() throws Exception { for (int i = 0; i < numberOfLedgers; i++) { createAndAddEntriesToLedger().close(); } BookieLedgerIndexer bookieLedgerIndex = new BookieLedgerIndexer( ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteZero() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); LOG.in...
#fixed code @Test public void testReadWriteZero() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); LOG.info("Le...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setMessageHandler(MessageHandler messageHandler) { if (logger.isDebugEnabled()) logger.debug("Setting the messageHandler for topic: " + origSubData.topic.toStringUtf8() + ", subscriberId: " + origSubData.subscribe...
#fixed code public void setMessageHandler(MessageHandler messageHandler) { if (logger.isDebugEnabled()) { logger.debug("Setting the messageHandler for topic: {}, subscriberId: {}", getOrigSubData().topic.toStringUtf8(), ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { if(rc != BKException.Code.OK) fail("Return code is not OK: " + rc); ls = seq; synchronized (sync) { sync.value = true; ...
#fixed code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { SyncObj sync = (SyncObj) ctx; sync.setLedgerEntries(seq); sync.setReturnCode(rc); synchronized (sync) { sync.value = true; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteAsyncSingleClient() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test public void testReadWriteAsyncSingleClient() throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGarbageCollectLedgers() throws Exception { int numLedgers = 100; int numRemovedLedgers = 10; final Set<Long> createdLedgers = new HashSet<Long>(); final Set<Long> removedLedgers = new HashSet<Long>(); /...
#fixed code @Test public void testGarbageCollectLedgers() throws Exception { int numLedgers = 100; int numRemovedLedgers = 10; final Set<Long> createdLedgers = new HashSet<Long>(); final Set<Long> removedLedgers = new HashSet<Long>(); // crea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void start(Configuration conf) { initIfNecessary(); int metricsOutputFrequency = conf.getInt("codahaleStatsOutputFrequencySeconds", 60); String prefix = conf.getString("codahaleStatsPrefix", ""); String graphiteHost ...
#fixed code @Override public void start(Configuration conf) { initIfNecessary(); int metricsOutputFrequency = conf.getInt("codahaleStatsOutputFrequencySeconds", 60); String prefix = conf.getString("codahaleStatsPrefix", ""); String graphiteHost = conf...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { // get back to prev value lh.lastAddConfirmed--; if (rc == BKException.Code.OK) { LedgerEntry entry = seq.nextElement(); ...
#fixed code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { if (rc == BKException.Code.OK) { LedgerEntry entry = seq.nextElement(); byte[] data = entry.getEntry(); /* * W...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void doPublish(PubSubData pubSubData, Channel channel) { // Create a PubSubRequest PubSubRequest.Builder pubsubRequestBuilder = PubSubRequest.newBuilder(); pubsubRequestBuilder.setProtocolVersion(ProtocolVersion.VERSION_ONE); pu...
#fixed code protected void doPublish(PubSubData pubSubData, Channel channel) { // Create a PubSubRequest PubSubRequest.Builder pubsubRequestBuilder = PubSubRequest.newBuilder(); pubsubRequestBuilder.setProtocolVersion(ProtocolVersion.VERSION_ONE); pubsubRe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void setLastLogId(File dir, long logId) throws IOException { FileOutputStream fos; fos = new FileOutputStream(new File(dir, "lastId")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); try { bw.writ...
#fixed code private void setLastLogId(File dir, long logId) throws IOException { FileOutputStream fos; fos = new FileOutputStream(new File(dir, "lastId")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); try { bw.write(Long...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteRangeAsyncSingleClient() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test public void testReadWriteRangeAsyncSingleClient() throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { if (rc != 0) fail("Failed to write entry"); ls = seq; synchronized (sync) { sync.value = true; sync.no...
#fixed code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { SyncObj x = (SyncObj) ctx; if (rc != 0) { LOG.error("Failure during add {}", rc); x.failureOccurred = true; } sy...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected synchronized void messageConsumed(Message message) { if (logger.isDebugEnabled()) logger.debug("Message has been successfully consumed by the client app for message: " + message + ", topic: " + origSubData.topic.toS...
#fixed code protected synchronized void messageConsumed(Message message) { if (logger.isDebugEnabled()) logger.debug("Message has been successfully consumed by the client app for message: " + message + ", topic: " + origSubData.topic.toStringU...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout=60000) public void testReadFromOpenLedger() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId()...
#fixed code @Test(timeout=60000) public void testReadFromOpenLedger() throws Exception { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void processResult(int rc, String path, Object ctx, List<String> children) { if (rc != KeeperException.Code.OK.intValue()) { //logger.error("Error while reading bookies", KeeperException.create(Code.get(rc), path)); ...
#fixed code @Override public void processResult(int rc, String path, Object ctx, List<String> children) { if (rc != KeeperException.Code.OK.intValue()) { //logger.error("Error while reading bookies", KeeperException.create(Code.get(rc), path)); // try...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSyncReadAsyncWriteStringsSingleClient() throws IOException { LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT"); String charset = "utf-8"; LOG.debug("Default charset: " + Charset.defaultCharset()); try { ...
#fixed code @Test public void testSyncReadAsyncWriteStringsSingleClient() throws IOException { SyncObj sync = new SyncObj(); LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT"); String charset = "utf-8"; LOG.debug("Default charset: " + Charset.defa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void auxTestReadWriteAsyncSingleClient(BookieServer bs) throws IOException { try { // Create a ledger lh = bkc.createLedger(3, 2, digestType, ledgerPassword); ledgerId = lh.getId(); LOG.info("Ledger ID: " + lh.get...
#fixed code void auxTestReadWriteAsyncSingleClient(BookieServer bs) throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(3, 2, digestType, ledgerPassword); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout=60000) public void testLastConfirmedAdd() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test(timeout=60000) public void testLastConfirmedAdd() throws Exception { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void doPublish(PubSubData pubSubData, Channel channel) { // Create a PubSubRequest PubSubRequest.Builder pubsubRequestBuilder = PubSubRequest.newBuilder(); pubsubRequestBuilder.setProtocolVersion(ProtocolVersion.VERSION_ONE); pu...
#fixed code protected void doPublish(PubSubData pubSubData, Channel channel) { // Create a PubSubRequest PubSubRequest.Builder pubsubRequestBuilder = PubSubRequest.newBuilder(); pubsubRequestBuilder.setProtocolVersion(ProtocolVersion.VERSION_ONE); pubsubRe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private long readLastLogId(File f) { FileInputStream fis; try { fis = new FileInputStream(new File(f, "lastId")); } catch (FileNotFoundException e) { return -1; } BufferedReader br = new BufferedReader(new ...
#fixed code private long readLastLogId(File f) { FileInputStream fis; try { fis = new FileInputStream(new File(f, "lastId")); } catch (FileNotFoundException e) { return -1; } BufferedReader br = new BufferedReader(new InputS...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSyncReadAsyncWriteStringsSingleClient() throws IOException { LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT"); String charset = "utf-8"; LOG.debug("Default charset: " + Charset.defaultCharset()); try { ...
#fixed code @Test public void testSyncReadAsyncWriteStringsSingleClient() throws IOException { SyncObj sync = new SyncObj(); LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT"); String charset = "utf-8"; LOG.debug("Default charset: " + Charset.defa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { // get back to prev value lh.lastAddConfirmed--; if (rc == BKException.Code.OK) { LedgerEntry entry = seq.nextElement(); ...
#fixed code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { if (rc == BKException.Code.OK) { LedgerEntry entry = seq.nextElement(); byte[] data = entry.getEntry(); /* * W...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteRangeAsyncSingleClient() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test public void testReadWriteRangeAsyncSingleClient() throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteAsyncLength() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test public void testReadWriteAsyncLength() throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); le...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { LOG.info("Running..."); long start = previous = System.currentTimeMillis(); byte messageCount = 0; int sent = 0; Thread reporter = new Thread() { public void run() { try { ...
#fixed code public void run() { LOG.info("Running..."); long start = previous = System.currentTimeMillis(); int sent = 0; Thread reporter = new Thread() { public void run() { try { while(true) {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEnsembleReformation() throws Exception { try { LedgerManagerFactory newLedgerManagerFactory = LedgerManagerFactory .newLedgerManagerFactory(baseConf, zkc); LedgerManager ledgerManager = newLed...
#fixed code @Test public void testEnsembleReformation() throws Exception { try { LedgerHandle lh1 = createAndAddEntriesToLedger(); LedgerHandle lh2 = createAndAddEntriesToLedger(); startNewBookie(); shutdownBookie(bs.size() - 2...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void handleBookieFailure(InetSocketAddress addr, final int bookieIndex) { InetSocketAddress newBookie; if (LOG.isDebugEnabled()) { LOG.debug("Handling failure of bookie: " + addr + " index: " + bookieIndex); } ...
#fixed code LedgerHandle(BookKeeper bk, long ledgerId, LedgerMetadata metadata, DigestType digestType, byte[] password) throws GeneralSecurityException, NumberFormatException { this.bk = bk; this.metadata = metadata; if (metadata.isCl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void setLastLogId(File dir, long logId) throws IOException { FileOutputStream fos; fos = new FileOutputStream(new File(dir, "lastId")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); try { bw.writ...
#fixed code private void setLastLogId(File dir, long logId) throws IOException { FileOutputStream fos; fos = new FileOutputStream(new File(dir, "lastId")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); try { bw.write(Long...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { if (rc != 0) fail("Failed to write entry"); ls = seq; synchronized (sync) { sync.value = true; sync.no...
#fixed code @Override public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) { SyncObj x = (SyncObj) ctx; if (rc != 0) { LOG.error("Failure during add {}", rc); x.failureOccurred = true; } sy...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout = 60000) public void testWhenNoLogsToCompact() throws Exception { tearDown(); // I dont want the test infrastructure ServerConfiguration conf = new ServerConfiguration(); File tmpDir = File.createTempFile("bkTest", ".dir"); ...
#fixed code @Test(timeout = 60000) public void testWhenNoLogsToCompact() throws Exception { tearDown(); // I dont want the test infrastructure ServerConfiguration conf = new ServerConfiguration(); File tmpDir = File.createTempFile("bkTest", ".dir"); tm...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void handleBookieFailure(final InetSocketAddress addr, final int bookieIndex) { InetSocketAddress newBookie; LOG.debug("Handling failure of bookie: {} index: {}", addr, bookieIndex); final ArrayList<InetSocketAddress> newEnsemble = new ArrayList...
#fixed code LedgerHandle(BookKeeper bk, long ledgerId, LedgerMetadata metadata, DigestType digestType, byte[] password) throws GeneralSecurityException, NumberFormatException { this.bk = bk; this.metadata = metadata; if (metadata.isCl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout=60000) public void testLastConfirmedAdd() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test(timeout=60000) public void testLastConfirmedAdd() throws Exception { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void compactEntryLog(long entryLogId) { EntryLogMetadata entryLogMeta = entryLogMetaMap.get(entryLogId); if (null == entryLogMeta) { LOG.warn("Can't get entry log meta when compacting entry log " + entryLogId + "."); ret...
#fixed code protected void compactEntryLog(long entryLogId) { EntryLogMetadata entryLogMeta = entryLogMetaMap.get(entryLogId); if (null == entryLogMeta) { LOG.warn("Can't get entry log meta when compacting entry log " + entryLogId + "."); return; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMultiLedger() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); lh2 = bkc.createLedger(digestType, ledgerPassword); long ledgerId = lh.getId...
#fixed code @Test public void testMultiLedger() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); lh2 = bkc.createLedger(digestType, ledgerPassword); long ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void auxTestReadWriteAsyncSingleClient(BookieServer bs) throws IOException { try { // Create a ledger lh = bkc.createLedger(3, 2, digestType, ledgerPassword); ledgerId = lh.getId(); LOG.info("Ledger ID: " + lh.get...
#fixed code void auxTestReadWriteAsyncSingleClient(BookieServer bs) throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(3, 2, digestType, ledgerPassword); ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testWithoutZookeeper() throws Exception { LedgerManagerFactory newLedgerManagerFactory = LedgerManagerFactory .newLedgerManagerFactory(baseConf, zkc); LedgerManager ledgerManager = newLedgerManagerFactory ...
#fixed code @Test public void testWithoutZookeeper() throws Exception { for (int i = 0; i < numberOfLedgers; i++) { createAndAddEntriesToLedger().close(); } BookieLedgerIndexer bookieLedgerIndex = new BookieLedgerIndexer( ledgerMan...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteAsyncSingleClient() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ledgerId = lh.getId(); ...
#fixed code @Test public void testReadWriteAsyncSingleClient() throws IOException { SyncObj sync = new SyncObj(); try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); // bkc.initMessageDigest("SHA1"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initiate() { /** * Enable fencing on this op. When the read request reaches the bookies * server it will fence off the ledger, stopping any subsequent operation * from writing to it. */ int flags = BookieP...
#fixed code public void initiate() { ReadLastConfirmedOp rlcop = new ReadLastConfirmedOp(lh, new ReadLastConfirmedOp.LastConfirmedDataCallback() { public void readLastConfirmedDataComplete(int rc, RecoveryData data) { if (rc == ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadWriteAsyncSingleClientThrottle() throws IOException, NoSuchFieldException, IllegalAccessException { try { Integer throttle = 100; ThrottleTestCallback tcb = new ThrottleTestCallback(throttle); ...
#fixed code @Test public void testReadWriteAsyncSingleClientThrottle() throws IOException, NoSuchFieldException, IllegalAccessException { SyncObj sync = new SyncObj(); try { Integer throttle = 100; ThrottleTestCallback tcb = new Thrott...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMultiLedger() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); lh2 = bkc.createLedger(digestType, ledgerPassword); long ledgerId = lh.getId...
#fixed code @Test public void testMultiLedger() throws IOException { try { // Create a ledger lh = bkc.createLedger(digestType, ledgerPassword); lh2 = bkc.createLedger(digestType, ledgerPassword); long ledgerId = lh.getId(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.isEnabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke");...
#fixed code @Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object eval(final String js) { try { Object _xblockexpression = null; { this.assertScriptEngine(); if (((this.maxCPUTimeInMs).longValue() == 0)) { return this.scriptEngine.eval(js); } Object _xsy...
#fixed code @Override public Object eval(final String js) { try { Object _xblockexpression = null; { this.assertScriptEngine(); if (((this.maxCPUTimeInMs).longValue() == 0)) { if (this.debug) { InputOutput.<String>println("--- Running...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void callOnError(final ExecutionError error) { if (onError != null) { onError.call(error); } synchronized (error.getContext()) { callOnTerminate((C) error.getContext()); error.getContext().notifyAll(...
#fixed code protected void callOnError(final ExecutionError error) { if (onError != null) { onError.call(error); } callOnTerminate((C) error.getContext()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void callOnFinalState(final State<C> state, final C context) { try { if (onFinalStateHandler != null) { if (isTrace()) log.debug("when final state {} for {} <<<", state, context); onFinal...
#fixed code protected void callOnFinalState(final State<C> state, final C context) { try { if (onFinalStateHandler != null) { if (isTrace()) log.debug("when final state {} for {} <<<", state, context); onFinalStateH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void callOnFinalState(final State<C> state, final C context) { try { if (onFinalStateHandler != null) { if (isTrace()) log.debug("when final state {} for {} <<<", state, context); onFinal...
#fixed code protected void callOnFinalState(final State<C> state, final C context) { try { if (onFinalStateHandler != null) { if (isTrace()) log.debug("when final state {} for {} <<<", state, context); onFinalStateH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void tableWrite() { String fileName = TestFileUtil.getPath() + "tableWrite" + System.currentTimeMillis() + ".xlsx"; // 这里直接写多个table的案例了,如果只有一个 也可以直一行代码搞定,参照其他案例 // 这里 需要指定写用哪个class去写 ExcelWriter excelWriter = null; ...
#fixed code @Test public void tableWrite() { String fileName = TestFileUtil.getPath() + "tableWrite" + System.currentTimeMillis() + ".xlsx"; // 这里直接写多个table的案例了,如果只有一个 也可以直一行代码搞定,参照其他案例 // 这里 需要指定写用哪个class去写 ExcelWriter excelWriter = null; try ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @GET @Path("/result_counter/{identifier}") @Produces("application/json") public EnumMap<ResultType, Integer> getCounterResults(@PathParam("identifier") String executionIdentifier) { try { return AlgorithmExecutionCache.getResultCounter(executionIdentifier)...
#fixed code @GET @Path("/result_counter/{identifier}") @Produces("application/json") public EnumMap<ResultType, Integer> getCounterResults(@PathParam("identifier") String executionIdentifier) { try { return this.resultCounts.get(executionIdentifier); } catch (Exception ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected AlgorithmExecutor buildExecutor(String algorithmName) throws FileNotFoundException, UnsupportedEncodingException { FunctionalDependencyResultReceiver fdResultReceiver = new FunctionalDependencyPrinter(getResultFileName(algorithmName), getResultDirectoryNam...
#fixed code protected AlgorithmExecutor buildExecutor(String algorithmName) throws FileNotFoundException, UnsupportedEncodingException { LinkedList<ResultPrinter> resultPrinters = new LinkedList<ResultPrinter>(); FunctionalDependencyPrinter fdResultReceiver = new FunctionalDepen...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void executeUniqueColumnCombinationsAlgorithmTest() { // Setup AlgorithmExecuter executer = new AlgorithmExecuter(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); List<ConfigurationValue> configs = new ArrayList<ConfigurationValue>();...
#fixed code @Test public void executeUniqueColumnCombinationsAlgorithmTest() { // Setup List<ConfigurationValue> configs = new ArrayList<ConfigurationValue>(); configs.add(new ConfigurationValueString("pathToInputFile", "blub")); UniqueColumnCombinationResultReceiver resultReceiver...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGenerateNewCsvFile() throws IOException { // Setup SimpleRelationalInput csv = generator.generateNewCsvFile(); // Check result // The csv should contain both lines and iterate through them with next. assertEquals(csvFileFixture.expectedF...
#fixed code @Test public void testGenerateNewCsvFile() throws SimpleRelationalInputGenerationException, IOException { // Setup SimpleRelationalInput csv = generator.generateNewCopy(); // Check result // The csv should contain both lines and iterate through them with next. asse...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void receiveResult(ColumnCombination columnCombination) { try { FileWriter writer = new FileWriter(this.file, true); writer.write(columnCombination.toString() + "\n"); writer.close(); } catch (IOException e) { // TODO Auto-generated catch ...
#fixed code @Override public void receiveResult(ColumnCombination columnCombination) { appendToResultFile(columnCombination.toString()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected AlgorithmExecutor buildExecutor(String algorithmName) throws FileNotFoundException, UnsupportedEncodingException { FunctionalDependencyResultReceiver fdResultReceiver = new FunctionalDependencyPrinter(getResultFileName(algorithmName), getResultDirectoryNam...
#fixed code protected AlgorithmExecutor buildExecutor(String algorithmName) throws FileNotFoundException, UnsupportedEncodingException { LinkedList<ResultPrinter> resultPrinters = new LinkedList<ResultPrinter>(); FunctionalDependencyPrinter fdResultReceiver = new FunctionalDepen...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGenerateNewCsvFile() throws IOException { // Setup SimpleRelationalInput csv = generator.generateNewCsvFile(); // Check result // The csv should contain both lines and iterate through them with next. assertEquals(csvFileFixture.expectedF...
#fixed code @Test public void testGenerateNewCsvFile() throws SimpleRelationalInputGenerationException, IOException { // Setup SimpleRelationalInput csv = generator.generateNewCopy(); // Check result // The csv should contain both lines and iterate through them with next. asse...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public T loadAlgorithm(String path) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException { String pathToFolder = ClassLoader.getSystemReso...
#fixed code public T loadAlgorithm(String path) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException { String pathToFolder = ClassLoader.getSystemResource("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAddAlgorithm() throws EntityStorageException { // Setup HibernateUtil.clear(); AlgorithmServiceImpl finderService = new AlgorithmServiceImpl(); // Execute functionality: add an IND algorithm Algorithm algorithm = new Algorithm...
#fixed code @Test public void testAddAlgorithm() throws EntityStorageException, AlgorithmLoadingException { // Setup HibernateUtil.clear(); AlgorithmServiceImpl finderService = new AlgorithmServiceImpl(); // Execute functionality: add an IND algorithm Algorithm algo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void executeAlgorithm(String algorithmName, List<InputParameter> parameters) throws AlgorithmConfigurationException, AlgorithmLoadingException, AlgorithmExecutionException { List<ConfigurationValue> configs = convertInputParameters(parameters); tr...
#fixed code @Override public void executeAlgorithm(String algorithmName, List<InputParameter> parameters) throws AlgorithmConfigurationException, AlgorithmLoadingException, AlgorithmExecutionException { List<ConfigurationValue> configs = convertInputParameters(parameters); Algorithm...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ConfigurationSettingCsvFile getValues() { if (this.listbox.getSelectedValue().equals("--")) { this.messageReceiver.addError("You must choose a CSV file!"); return null; } FileInput currentFileInput = this.fileInputs.get( this.listbo...
#fixed code public ConfigurationSettingCsvFile getValues() throws InputValidationException { String selectedValue = this.listbox.getSelectedValue(); if (selectedValue.equals("--")) { throw new InputValidationException("You must choose a CSV file!"); } FileInput curr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGenerateNewCsvFile() throws SimpleRelationalInputGenerationException, IOException { // Setup SimpleRelationalInput csv = generator.generateNewCopy(); // Check result // The csv should contain both lines and iterate through them with next. ...
#fixed code @Test public void testGenerateNewCsvFile() throws SimpleRelationalInputGenerationException, InputIterationException { // Setup SimpleRelationalInput csv = generator.generateNewCopy(); // Check result // The csv should contain both lines and iterate through them with ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testUpdateOnSuccess() { // Set up TestHelper.resetDatabaseSync(); Execution execution = new Execution(null, 12); execution.setEnd(2345); BasePage parent = new BasePage(); ResultsPage page = new ResultsPage(parent); page.setMessage...
#fixed code public void testUpdateOnSuccess() { // Set up TestHelper.resetDatabaseSync(); Algorithm algorithm = new Algorithm("example_ind_algorithm.jar"); Execution execution = new Execution(algorithm, 12); execution.setEnd(2345); BasePage parent = new BasePage()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Result> fetchNewResults(String algorithmName){ List<Result> newResults = new LinkedList<Result>(); for (ResultPrinter printer : currentResultPrinters.get(algorithmName)) { // newResults.addAll(printer.getNewResults()); } newResults.add(new UniqueCo...
#fixed code public List<Result> fetchNewResults(String algorithmName){ List<Result> newResults = new LinkedList<Result>(); //newResults.add(currentResultReceivers.get(algorithmName).getNewResults()); newResults.add(new UniqueColumnCombination(new ColumnIdentifier("table", "col1")))...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAddAlgorithm() throws EntityStorageException { // Setup HibernateUtil.clear(); AlgorithmServiceImpl finderService = new AlgorithmServiceImpl(); // Execute functionality: add an IND algorithm Algorithm algorithm = new Algorithm...
#fixed code @Test public void testAddAlgorithm() throws EntityStorageException, AlgorithmLoadingException { // Setup HibernateUtil.clear(); AlgorithmServiceImpl finderService = new AlgorithmServiceImpl(); // Execute functionality: add an IND algorithm Algorithm algo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Class<?>> getAlgorithmInterfaces(File file) throws IOException, ClassNotFoundException { JarFile jar = new JarFile(file); Manifest man = jar.getManifest(); Attributes attr = man.getMainAttributes(); String className = attr.getValue(bootst...
#fixed code public List<Class<?>> getAlgorithmInterfaces(File file) throws IOException, ClassNotFoundException { JarFile jar = new JarFile(file); Manifest man = jar.getManifest(); Attributes attr = man.getMainAttributes(); String className = attr.getValue(bootstrapCla...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGenerateNewCsvFile() throws SimpleRelationalInputGenerationException, IOException { // Setup SimpleRelationalInput csv = generator.generateNewCopy(); // Check result // The csv should contain both lines and iterate through them with next. ...
#fixed code @Test public void testGenerateNewCsvFile() throws SimpleRelationalInputGenerationException, InputIterationException { // Setup SimpleRelationalInput csv = generator.generateNewCopy(); // Check result // The csv should contain both lines and iterate through them with ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected AlgorithmExecutor buildExecutor(String executionIdentifier) throws FileNotFoundException, UnsupportedEncodingException { ResultPrinter resultPrinter = new ResultPrinter(executionIdentifier, "results"); ResultsCache resultsCache = new ResultsCache()...
#fixed code protected AlgorithmExecutor buildExecutor(String executionIdentifier) throws FileNotFoundException, UnsupportedEncodingException { ResultPrinter resultPrinter = new ResultPrinter(executionIdentifier); ResultsCache resultsCache = new ResultsCache(); ResultsHub ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testStoreTableInput() throws EntityStorageException, InputValidationException { // Setup TestHelper.resetDatabaseSync(); BasePage parent = new BasePage(); InputConfigurationPage page = new InputConfigurationPage(parent); page.setEr...
#fixed code @Test public void testStoreTableInput() throws EntityStorageException, InputValidationException { // Setup TestHelper.resetDatabaseSync(); final boolean[] blocked = {true}; BasePage parent = new BasePage(); InputConfigurationPage page = new InputConfigura...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testNextSeparator() throws IOException { // Setup CsvFileOneLineFixture fixtureSeparator = new CsvFileOneLineFixture(';'); CsvFile csvFileSeparator = fixtureSeparator.getTestData(); // Check result assertEquals(fixtureSeparator.getExpectedS...
#fixed code @Test public void testNextSeparator() throws InputIterationException { // Setup CsvFileOneLineFixture fixtureSeparator = new CsvFileOneLineFixture(';'); CsvFile csvFileSeparator = fixtureSeparator.getTestData(); // Check result assertEquals(fixtureSeparator.getExp...
Below is the vulnerable code, please generate the patch based on the following information.