output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code public synchronized void fetchContainerLog(String containerId, LogOutputSpec spec) throws FileNotFoundException { dockerAccess.getLogSync(containerId, createLogCallback(spec)); }
#vulnerable code public synchronized void fetchContainerLog(String containerId, LogOutputSpec spec) throws FileNotFoundException { dockerAccess.getLogSync(containerId, new DefaultLogCallback(spec)); } #location 2 #vul...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testFromSettingsSimple() throws MojoExecutionException { setupServers(); AuthConfig config = factory.createAuthConfig(isPush, null, settings, "roland", "test.org"); assertNotNull(config); verifyAuthConfig(config, "roland",...
#vulnerable code @Test public void testFromSettingsSimple() throws MojoExecutionException { setupServers(); AuthConfig config = factory.createAuthConfig(null,settings, "roland", "test.org"); assertNotNull(config); verifyAuthConfig(config, "roland", "s...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public MojoExecutionService getMojoExecutionService() { return mojoExecutionService; }
#vulnerable code public MojoExecutionService getMojoExecutionService() { checkBaseInitialization(); return mojoExecutionService; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public synchronized void trackContainerLog(String containerId, LogOutputSpec spec) throws FileNotFoundException { LogGetHandle handle = dockerAccess.getLogAsync(containerId, createLogCallback(spec)); logHandles.put(containerId, handle); }
#vulnerable code public synchronized void trackContainerLog(String containerId, LogOutputSpec spec) throws FileNotFoundException { LogGetHandle handle = dockerAccess.getLogAsync(containerId, new DefaultLogCallback(spec)); logHandles.put(containerId, handle); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void fetchLogs() { try { callback.open(); this.request = getLogRequest(false); final HttpResponse response = client.execute(request); parseResponse(response); } catch (LogCallback.DoneException e) { ...
#vulnerable code public void fetchLogs() { try { callback.open(); this.request = getLogRequest(false); final HttpResponse respone = client.execute(request); parseResponse(respone); } catch (LogCallback.DoneException e) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void variableReplacement() throws MojoExecutionException { PortMapping mapping = createPortMapping("jolokia.port:8080","18181:8181","127.0.0.1:9090:9090", "127.0.0.1:other.port:5678"); updateDynamicMapping(mapping, 8080, 49900); upda...
#vulnerable code @Test public void variableReplacement() throws MojoExecutionException { PortMapping mapping = createPortMapping("jolokia.port:8080","18181:8181","127.0.0.1:9090:9090", "127.0.0.1:other.port:5678"); updateDynamicMapping(mapping, 8080, 49900); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getVersion() { try { return CFLintMain.class.getPackage().getImplementationVersion(); } catch (Exception e) { return ""; } }
#vulnerable code public static String getVersion() { final InputStream is = Version.class .getResourceAsStream("/META-INF/maven/com.github.cflint/CFLint/pom.properties"); try { final BufferedReader reader = new BufferedReader(new InputStreamRe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void execute() throws IOException, TransformerException, JAXBException { final CFLint cflint = new CFLint(loadConfig(configfile)); cflint.setVerbose(verbose); cflint.setLogError(logerror); cflint.setQuiet(quiet); cflint.setShowProgress(showprogress); cflint.s...
#vulnerable code private void execute() throws IOException, TransformerException, JAXBException { CFLintConfig config = null; if(configfile != null){ if(configfile.toLowerCase().endsWith(".xml")){ config = ConfigUtils.unmarshal(new FileInputStream(configfile), CFLintConfig.class...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static String load(final File file) { FileInputStream fis = null; try { fis = new FileInputStream(file); final byte[] b = new byte[fis.available()]; fis.read(b); return new String(b); } catch (final Exception e) { return null; } finally { try { if (...
#vulnerable code static String load(final File file) { FileInputStream fis; try { fis = new FileInputStream(file); final byte[] b = new byte[fis.available()]; fis.read(b); return new String(b); } catch (final Exception e) { return null; } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean include(final BugInfo bugInfo) { if (includeCodes != null && !includeCodes.contains(bugInfo.getMessageCode())){ return false; } if (data != null) { for (final Object item : data) { final JSONObject jsonObj = (JSONObject) item; if (jsonObj.conta...
#vulnerable code public boolean include(final BugInfo bugInfo) { if (includeCodes != null && !includeCodes.contains(bugInfo.getMessageCode())){ return false; } if (data != null) { for (final Object item : data) { final JSONObject jsonObj = (JSONObject) item; if (jsonObj...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getVersion() { try { return CFLintMain.class.getPackage().getImplementationVersion(); } catch (Exception e) { return ""; } }
#vulnerable code public static String getVersion() { final InputStream is = Version.class .getResourceAsStream("/META-INF/maven/com.github.cflint/CFLint/pom.properties"); try { final BufferedReader reader = new BufferedReader(new InputStreamRe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void execute() throws IOException, TransformerException, JAXBException { final CFLint cflint = new CFLint(loadConfig(configfile)); cflint.setVerbose(verbose); cflint.setLogError(logerror); cflint.setQuiet(quiet); cflint.setShowProgress(showprogress); cflint.s...
#vulnerable code private void execute() throws IOException, TransformerException, JAXBException { CFLintConfig config = null; if(configfile != null){ if(configfile.toLowerCase().endsWith(".xml")){ config = ConfigUtils.unmarshal(new FileInputStream(configfile), CFLintConfig.class...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getVersion() { try { return CFLintMain.class.getPackage().getImplementationVersion(); } catch (Exception e) { return ""; } }
#vulnerable code public static String getVersion() { final InputStream is = Version.class .getResourceAsStream("/META-INF/maven/com.github.cflint/CFLint/pom.properties"); try { final BufferedReader reader = new BufferedReader(new InputStreamRe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static CFLintConfig loadConfig(final String configfile) { if (configfile != null) { try { CFLintPluginInfo pluginInfo = null; if (configfile.toLowerCase().endsWith(".xml")) { final Object configOb...
#vulnerable code private static CFLintConfig loadConfig(final String configfile) { if (configfile != null) { try { CFLintPluginInfo pluginInfo=null; if (configfile.toLowerCase().endsWith(".xml")) { final Object conf...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void registerRuleOverrides(Context context, final Token functionToken) { final String mlText = PrecedingCommentReader.getMultiLine(context, functionToken); if(mlText != null && !mlText.isEmpty()){ final Pattern pattern = Pattern.compile(".*\\s*@CFLintIgnore\\s+(...
#vulnerable code protected void registerRuleOverrides(Context context, final Token functionToken) { Iterable<Token> tokens = context.beforeTokens(functionToken); for (Token currentTok : tokens) { if (currentTok.getChannel() == Token.HIDDEN_CHANNEL && currentTok.getType() == CFSCRIPT...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void execute() throws IOException, TransformerException, JAXBException, MarshallerException { final CFLint cflint = new CFLint(buildConfigChain()); cflint.setVerbose(verbose); cflint.setLogError(logerror); cflint.setQuiet(quiet); ...
#vulnerable code private void execute() throws IOException, TransformerException, JAXBException, MarshallerException { final CFLint cflint = new CFLint(buildConfigChain()); cflint.setVerbose(verbose); cflint.setLogError(logerror); cflint.setQuiet(quiet); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static String load(final File file) { FileInputStream fis = null; try { fis = new FileInputStream(file); final byte[] b = new byte[fis.available()]; fis.read(b); return new String(b); } catch (final Exception e) { return null; } finally { try { if (...
#vulnerable code static String load(final File file) { FileInputStream fis; try { fis = new FileInputStream(file); final byte[] b = new byte[fis.available()]; fis.read(b); return new String(b); } catch (final Exception e) { return null; } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void mergeConfigFileInFilter(CFLintFilter filter) { CFLintConfig cfg = loadConfig(configfile); if(cfg != null){ for(PluginMessage message : cfg.getIncludes()) { filter.includeCode(message.getCode()); } ...
#vulnerable code private void mergeConfigFileInFilter(CFLintFilter filter) { CFLintConfig cfg = loadConfig(configfile); for(PluginMessage message : cfg.getIncludes()) { filter.includeCode(message.getCode()); } for(PluginMessage mes...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void expression(final CFExpression expression, final Context context, final BugList bugs) { String repeatThreshold = getParameter("maximum"); String maxWarnings = getParameter("maxWarnings"); String warningScope = getParameter("warningScope"); if (rep...
#vulnerable code @Override public void expression(final CFExpression expression, final Context context, final BugList bugs) { String repeatThreshold = getParameter("maximum"); int threshold = REPEAT_THRESHOLD; if (repeatThreshold != null) { threshold = Integer.parseInt(repeatTh...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public AsyncIOWriter write(AtmosphereResponse r, byte[] data, int offset, int length) throws IOException { boolean transform = filters.size() > 0 && r.getStatus() < 400; if (transform) { data = transform(r, data, offset, length); ...
#vulnerable code @Override public AsyncIOWriter write(AtmosphereResponse r, byte[] data, int offset, int length) throws IOException { boolean transform = filters.size() > 0 && r.getStatus() < 400; if (transform) { data = transform(r, data, offset, length...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void _close() { if (!isClosed.getAndSet(true)) { headerWritten = false; final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); buffer.writeBytes(ENDCHUNK); channel.write(buffer).addListener(new ChannelFutureListene...
#vulnerable code void _close() { if (!isClosed.getAndSet(true)) { headerWritten = false; final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); ChannelBufferOutputStream c = new ChannelBufferOutputStream(buffer); try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void close() { if (!open.compareAndSet(true, false)) { return; } LOG.debug("Closing GStreamer device"); pipelineStop(); image = null; }
#vulnerable code @Override public void close() { if (!open.compareAndSet(true, false)) { return; } LOG.debug("Closing GStreamer device"); image = null; LOG.debug("Unlink elements"); pipe.setState(State.NULL); Element.unlinkMany(source, filter, sink); pipe.removeMan...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void resume() { if (!paused) { return; } paused = false; }
#vulnerable code public void resume() { if (!paused) { return; } synchronized (repainter) { repainter.notifyAll(); } paused = false; } #location 5 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void open() { if (!open.compareAndSet(false, true)) { return; } LOG.debug("Opening GStreamer device"); init(); starting.set(true); Dimension size = getResolution(); image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT...
#vulnerable code @Override public void open() { if (!open.compareAndSet(false, true)) { return; } LOG.debug("Opening GStreamer device"); init(); starting.set(true); Dimension size = getResolution(); image = new BufferedImage(size.width, size.height, BufferedImage.TY...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void dispose() { if (!disposed.compareAndSet(false, true)) { return; } LOG.debug("Disposing GStreamer device"); close(); source.dispose(); filter.dispose(); jpegparse.dispose(); jpegdec.dispose(); caps.dispose(); sink.dispose(); pip...
#vulnerable code @Override public void dispose() { if (!disposed.compareAndSet(false, true)) { return; } LOG.debug("Disposing GStreamer device"); close(); source.dispose(); filter.dispose(); jpegpar.dispose(); jpegdec.dispose(); caps.dispose(); sink.dispose(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void close() { if (!open.compareAndSet(true, false)) { return; } LOG.debug("Closing GStreamer device"); pipelineStop(); image = null; }
#vulnerable code @Override public void close() { if (!open.compareAndSet(true, false)) { return; } LOG.debug("Closing GStreamer device"); image = null; LOG.debug("Unlink elements"); pipe.setState(State.NULL); Element.unlinkMany(source, filter, sink); pipe.removeMan...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void open() { if (!open.compareAndSet(false, true)) { return; } LOG.debug("Opening GStreamer device"); init(); starting.set(true); Dimension size = getResolution(); image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT...
#vulnerable code @Override public void open() { if (!open.compareAndSet(false, true)) { return; } LOG.debug("Opening GStreamer device"); init(); starting.set(true); Dimension size = getResolution(); image = new BufferedImage(size.width, size.height, BufferedImage.TY...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void certificateReadThrowsRuntimeException() throws ExecutionException, InterruptedException { MockTokenServerTransport transport = new MockTokenServerTransport(); transport.addServiceAccount(ServiceAccount.EDITOR.getEmail(), ACCESS_TOKEN); Inp...
#vulnerable code @Test public void certificateReadThrowsRuntimeException() throws ExecutionException, InterruptedException, IOException { MockTokenServerTransport transport = new MockTokenServerTransport(); transport.addServiceAccount(ServiceAccount.EDITOR.getEmail(), ACCE...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public ConnectionContext getConnectionContext() { return new ConnectionContext( this.logger, wrapAuthTokenProvider(this.getAuthTokenProvider()), this.getExecutorService(), this.isPersistenceEnabled(), FirebaseDatabase.getSdkVersion(),...
#vulnerable code public ConnectionContext getConnectionContext() { return new ConnectionContext( this.getLogger(), wrapAuthTokenProvider(this.getAuthTokenProvider()), this.getExecutorService(), this.isPersistenceEnabled(), FirebaseDatabase.getSd...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String streamToString(InputStream inputStream) throws IOException { InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); return CharStreams.toString(reader); }
#vulnerable code private static String streamToString(InputStream inputStream) throws IOException { StringBuilder stringBuilder = new StringBuilder(); Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); char[] buffer = new char[256]; int length; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void refreshTokenReadThrowsRuntimeException() throws ExecutionException, InterruptedException { MockTokenServerTransport transport = new MockTokenServerTransport(); transport.addServiceAccount(ServiceAccount.EDITOR.getEmail(), ACCESS_TOKEN); In...
#vulnerable code @Test public void refreshTokenReadThrowsRuntimeException() throws ExecutionException, InterruptedException, IOException { MockTokenServerTransport transport = new MockTokenServerTransport(); transport.addServiceAccount(ServiceAccount.EDITOR.getEmail(), ACC...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canConvertDoubles() throws IOException { List<Double> doubles = Arrays.asList(Double.MAX_VALUE, Double.MIN_VALUE, Double.MIN_NORMAL); for (Double original : doubles) { String jsonString = JsonMapper.serializeJson(original); double convert...
#vulnerable code @Test public void canConvertDoubles() throws IOException { List<Double> doubles = Arrays.asList(Double.MAX_VALUE, Double.MIN_VALUE, Double.MIN_NORMAL); for (Double original : doubles) { String jsonString = JsonMapper.serializeJsonValue(original); dou...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void canConvertLongs() throws IOException { List<Long> longs = Arrays.asList(Long.MAX_VALUE, Long.MIN_VALUE); for (Long original : longs) { String jsonString = JsonMapper.serializeJson(original); long converted = (Long) JsonMapper.parseJsonVal...
#vulnerable code @Test public void canConvertLongs() throws IOException { List<Long> longs = Arrays.asList(Long.MAX_VALUE, Long.MIN_VALUE); for (Long original : longs) { String jsonString = JsonMapper.serializeJsonValue(original); long converted = (Long) JsonMapper.p...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDeleteInstanceIdError() throws Exception { final MockLowLevelHttpResponse response = new MockLowLevelHttpResponse(); MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); Fi...
#vulnerable code @Test public void testDeleteInstanceIdError() throws Exception { final MockLowLevelHttpResponse response = new MockLowLevelHttpResponse(); MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String streamToString(InputStream inputStream) throws IOException { InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); return CharStreams.toString(reader); }
#vulnerable code private static String streamToString(InputStream inputStream) throws IOException { StringBuilder stringBuilder = new StringBuilder(); Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); char[] buffer = new char[256]; int length; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) { Configuration cfg = parseLegacyConfiguration(); if (cfg == null) { cfg = parseConfiguration(args); } if (cfg == null) { Options options = createOptions(); printHelp(op...
#vulnerable code public static void main(String[] args) { String source = System.getProperty("source"); String destination = System.getProperty("destination"); if (source == null) { help(); return; } int thread...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private List<ApiParamDoc> getQueryParamsFromSpringAnnotation(Method method, Class<?> controller) { List<ApiParamDoc> apiParamDocs = new ArrayList<ApiParamDoc>(); if(controller.isAnnotationPresent(RequestMapping.class)) { RequestMapping requestMapping = controller.getAn...
#vulnerable code private List<ApiParamDoc> getQueryParamsFromSpringAnnotation(Method method, Class<?> controller) { List<ApiParamDoc> apiParamDocs = new ArrayList<ApiParamDoc>(); if(controller.isAnnotationPresent(RequestMapping.class)) { RequestMapping requestMapping = controller...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("resource") @Override public CBORParser createParser(File f) throws IOException { IOContext ctxt = _createContext(f, true); return _createParser(_decorate(new FileInputStream(f), ctxt), ctxt); }
#vulnerable code @SuppressWarnings("resource") @Override public CBORParser createParser(File f) throws IOException { return _createParser(new FileInputStream(f), _createContext(f, true)); } #location 4 #vulner...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private JsonToken _handleNestedKey(int tag) throws IOException { int wireType = (tag & 0x7); int id = (tag >> 3); ProtobufField f; if ((_currentField == null) || (f = _currentField.nextOrThisIf(id)) == null) { f = _currentMessa...
#vulnerable code private JsonToken _handleNestedKey(int tag) throws IOException { int wireType = (tag & 0x7); int id = (tag >> 3); ProtobufField f; if ((_currentField == null) || (f = _currentField.nextOrThisIf(id)) == null) { f = _curren...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private JsonToken _handleNestedKey(int tag) throws IOException { int wireType = (tag & 0x7); int id = (tag >> 3); ProtobufField f; if (_currentField != null) { if ((f = _currentField.nextOrThisIf(id)) == null) { ...
#vulnerable code private JsonToken _handleNestedKey(int tag) throws IOException { int wireType = (tag & 0x7); int id = (tag >> 3); ProtobufField f; if ((_currentField == null) || (f = _currentField.nextOrThisIf(id)) == null) { f = _curren...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGarbageCollectorExports() { assertEquals( 100L, registry.getSampleValue( "jvm_gc_collection_seconds_count", new String[]{"gc"}, new String[]{"MyGC1"}), .0000001); assertEquals( 1...
#vulnerable code @Test public void testGarbageCollectorExports() { assertEquals( 100L, registry.getSampleValue( GarbageCollectorExports.COLLECTIONS_COUNT_METRIC, new String[]{"gc"}, new String[]{"MyGC1"}), .0000001); as...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testMemoryPools() { assertEquals( 500000L, registry.getSampleValue( "jvm_memory_pool_bytes_used", new String[]{"pool"}, new String[]{"PS Eden Space"}), .0000001); assertEquals( 10000...
#vulnerable code @Test public void testMemoryPools() { assertEquals( 500000L, registry.getSampleValue( MemoryPoolsExports.POOLS_USED_METRIC, new String[]{"pool"}, new String[]{"PS-Eden-Space"}), .0000001); assertEquals(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void priceFormat() { assertEquals("%7.2f ", FRACTIONS.get("FOO").getPriceFormat()); }
#vulnerable code @Test public void priceFormat() { assertEquals("%7.2f ", INSTRUMENTS.get("FOO").getPriceFormat()); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void main(Config config, boolean taq) throws IOException { NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface"); InetAddress multicastGroup = Configs.getInetAddress(config, "market...
#vulnerable code private static void main(Config config, boolean taq) throws IOException { NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface"); InetAddress multicastGroup = Configs.getInetAddress(config, "...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void main(Config config, boolean taq) throws IOException { NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface"); InetAddress multicastGroup = Configs.getInetAddress(config, "market...
#vulnerable code private static void main(Config config, boolean taq) throws IOException { NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface"); InetAddress multicastGroup = Configs.getInetAddress(config, "...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void priceFractionDigits() { assertEquals(2, FRACTIONS.get("FOO").getPriceFractionDigits()); }
#vulnerable code @Test public void priceFractionDigits() { assertEquals(2, INSTRUMENTS.get("FOO").getPriceFractionDigits()); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void main(Config config, boolean tsv) throws IOException { NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "trade-report.multicast-interface"); InetAddress multicastGroup = Configs.getInetAddress(config, "trade...
#vulnerable code private static void main(Config config, boolean tsv) throws IOException { NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "trade-report.multicast-interface"); InetAddress multicastGroup = Configs.getInetAddress(config, ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void listen(boolean taq, Config config) throws IOException { Instruments instruments = Instruments.fromConfig(config, "instruments"); MarketDataListener listener = taq ? new TAQFormat(instruments) : new DisplayFormat(instruments); Mark...
#vulnerable code private static void listen(boolean taq, Config config) throws IOException { List<String> instruments = config.getStringList("instruments"); MarketDataListener listener = taq ? new TAQFormat() : new DisplayFormat(instruments); Market market = ne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void priceFactor() { assertEquals(100.0, FRACTIONS.get("FOO").getPriceFactor(), 0.0); }
#vulnerable code @Test public void priceFactor() { assertEquals(100.0, INSTRUMENTS.get("FOO").getPriceFactor(), 0.0); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code OrderBook(long instrument) { this.instrument = instrument; this.bids = new Long2LongRBTreeMap(BidComparator.INSTANCE); this.asks = new Long2LongRBTreeMap(AskComparator.INSTANCE); }
#vulnerable code boolean add(Side side, long price, long quantity) { Long2LongRBTreeMap levels = getLevels(side); long size = levels.get(price); levels.put(price, size + quantity); return price == levels.firstLongKey(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void run() throws IOException { LineReader reader = LineReaderBuilder.builder() .completer(new StringsCompleter(Commands.names().castToList())) .build(); printf("Type 'help' for help.\n"); while (!closed) { ...
#vulnerable code public void run() throws IOException { ConsoleReader reader = new ConsoleReader(); reader.addCompleter(new StringsCompleter(Commands.names().castToList())); printf("Type 'help' for help.\n"); while (!closed) { String line =...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void listen(boolean taq, Config config) throws IOException { Instruments instruments = Instruments.fromConfig(config, "instruments"); MarketDataListener listener = taq ? new TAQFormat(instruments) : new DisplayFormat(instruments); Mark...
#vulnerable code private static void listen(boolean taq, Config config) throws IOException { List<String> instruments = config.getStringList("instruments"); MarketDataListener listener = taq ? new TAQFormat() : new DisplayFormat(instruments); Market market = ne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; OrderBook book = books.get(instrument); if (book == null) return; Order order = new Order(book...
#vulnerable code public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; OrderBook book = books.get(instrument); if (book == null) return; Order order = book.add...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void run() throws IOException { LineReader reader = LineReaderBuilder.builder() .completer(new StringsCompleter(Commands.names().castToList())) .build(); printf("Type 'help' for help.\n"); while (!closed) { ...
#vulnerable code public void run() throws IOException { ConsoleReader reader = new ConsoleReader(); reader.addCompleter(new StringsCompleter(Commands.names().castToList())); printf("Type 'help' for help.\n"); while (!closed) { String line =...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code OrderBook(long instrument) { this.instrument = instrument; this.bids = new Long2LongRBTreeMap(BidComparator.INSTANCE); this.asks = new Long2LongRBTreeMap(AskComparator.INSTANCE); }
#vulnerable code boolean update(Side side, long price, long quantity) { Long2LongRBTreeMap levels = getLevels(side); long oldSize = levels.get(price); long newSize = oldSize + quantity; boolean onBestLevel = price == levels.firstLongKey(); if (...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void main(Config config) throws IOException { MarketDataServer marketData = marketData(config); MarketReportServer marketReport = marketReport(config); List<String> instruments = config.getStringList("instruments"); MatchingEn...
#vulnerable code private static void main(Config config) throws IOException { MarketDataServer marketData = marketData(config); String marketReportSession = config.getString("market-report.session"); InetAddress marketReportMulticastGroup = Configs.g...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run(ApplicationArguments args) throws Exception { try { // 测试 Redis连接是否正常 redisService.exists("febs_test"); } catch (Exception e) { log.error(" ____ __ _ _ "); log.error("| |_ /...
#vulnerable code @Override public void run(ApplicationArguments args) throws Exception { try { // 测试 Redis连接是否正常 redisService.exists("febs_test"); } catch (Exception e) { log.error(" ____ __ _ _ "); log.error("| ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String[] extendArgs(String file, String oldargs[], int offset) throws ArgumentParserException { List<String> list = new ArrayList<String>(); BufferedReader reader = null; try { reader = new BufferedReader(new InputStream...
#vulnerable code private String[] extendArgs(String file, String oldargs[], int offset) throws ArgumentParserException { List<String> list = new ArrayList<String>(); BufferedReader reader; try { reader = new BufferedReader(new InputStreamR...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void saveResource(String resourcePath, boolean replace) { if (resourcePath == null || resourcePath.equals("")) { throw new IllegalArgumentException("ResourcePath cannot be null or empty"); } resourcePath = resourcePath.replace('\\',...
#vulnerable code public void saveResource(String resourcePath, boolean replace) { if (resourcePath == null || resourcePath.equals("")) { throw new IllegalArgumentException("ResourcePath cannot be null or empty"); } resourcePath = resourcePath.replace...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException { Validate.notNull(file, "File cannot be null"); final FileInputStream stream = new FileInputStream(file); load(new InputStreamReader(stream, UTF8_OV...
#vulnerable code public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException { Validate.notNull(file, "File cannot be null"); load(new FileInputStream(file)); } #location 4 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException { return loadPlugin(file, false); }
#vulnerable code public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException { JavaPlugin result = null; PluginDescriptionFile description = null; if (!file.exists()) { throw new InvalidP...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; if (args.length < 1 || args.length > 4) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); ...
#vulnerable code @Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; if (args.length < 1 || args.length > 4) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void recalculatePermissions() { clearPermissions(); Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp()); Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent); for (Perm...
#vulnerable code public void recalculatePermissions() { dirtyPermissions = true; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { osArch = resolveArmArchType(); } else { String lc = osArch.toLowerCase(Locale.US); if(archMap...
#vulnerable code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { // Java 1.8 introduces a system property to determine armel or armhf if(System.getProperty("sun.arch.abi") != null ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code int shared_cache(boolean enable) throws SQLException { // The shared cache is per-process, so it is useless as // each nested connection is its own process. return -1; }
#vulnerable code int enable_load_extension(boolean enable) throws SQLException { return call("sqlite3_enable_load_extension", handle, enable ? 1 : 0); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void setMaxRows(int max) throws SQLException { //checkOpen(); if (max < 0) throw new SQLException("max row count must be >= 0"); rs.maxRows = max; }
#vulnerable code public void setMaxRows(int max) throws SQLException { checkOpen(); if (max < 0) throw new SQLException("max row count must be >= 0"); rs.maxRows = max; } #location 2 #vulne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; final String prefix = String.format("sql...
#vulnerable code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; final String prefix = "sqlite-3.6....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { osArch = resolveArmArchType(); } else { String lc = osArch.toLowerCase(Locale.US); if(archMap...
#vulnerable code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { // Java 1.8 introduces a system property to determine armel or armhf if(System.getProperty("sun.arch.abi") != null ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public int getMaxRows() throws SQLException { //checkOpen(); return rs.maxRows; }
#vulnerable code public int getMaxRows() throws SQLException { checkOpen(); return rs.maxRows; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { osArch = resolveArmArchType(); } else { String lc = osArch.toLowerCase(Locale.US); if(archMap...
#vulnerable code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { // Java 1.8 introduces a system property to determine armel or armhf if(System.getProperty("sun.arch.abi") != null ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; // ...
#vulnerable code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void basicBusyHandler() throws Exception { final int[] calls = {0}; BusyHandler.setHandler(conn, new BusyHandler() { @Override protected int callback(int nbPrevInvok) throws SQLException { assertEquals(n...
#vulnerable code @Test public void basicBusyHandler() throws Exception { final int[] calls = {0}; BusyHandler.setHandler(conn, new BusyHandler() { @Override protected int callback(int nbPrevInvok) throws SQLException { assertEq...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; // ...
#vulnerable code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Map<String,Class<?>> getTypeMap() throws SQLException { synchronized (this) { if (this.typeMap == null) { this.typeMap = new HashMap<String, Class<?>>(); } return this.typeMap; } }
#vulnerable code public Map<String,Class<?>> getTypeMap() throws SQLException { synchronized (typeMap) { if (this.typeMap == null) { this.typeMap = new HashMap<String, Class<?>>(); } return this.typeMap; } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testUnregister() throws Exception { final int[] calls = {0}; BusyHandler.setHandler(conn, new BusyHandler() { @Override protected int callback(int nbPrevInvok) throws SQLException { assertEquals(nbP...
#vulnerable code @Test public void testUnregister() throws Exception { final int[] calls = {0}; BusyHandler.setHandler(conn, new BusyHandler() { @Override protected int callback(int nbPrevInvok) throws SQLException { assertEqua...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { osArch = resolveArmArchType(); } else { String lc = osArch.toLowerCase(Locale.US); if(archMap...
#vulnerable code public static String getArchName() { String osArch = System.getProperty("os.arch"); if(osArch.startsWith("arm")) { // Java 1.8 introduces a system property to determine armel or armhf if(System.getProperty("sun.arch.abi") != null ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean execute(String sql) throws SQLException { internalClose(); SQLExtension ext = ExtendedCommand.parse(sql); if (ext != null) { ext.execute(db); return false; } this.sql = sql; db.prepare...
#vulnerable code public boolean execute(String sql) throws SQLException { internalClose(); SQLExtension ext = ExtendedCommand.parse(sql); if (ext != null) { ext.execute(db); return false; } this.sql = sql; bool...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void setTypeMap(Map map) throws SQLException { synchronized (this) { this.typeMap = map; } }
#vulnerable code public void setTypeMap(Map map) throws SQLException { synchronized (typeMap) { this.typeMap = map; } } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; // ...
#vulnerable code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; final String prefix = String.format("sql...
#vulnerable code private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName; final String prefix = "sqlite-3.6....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @GetMapping() public String profile(ModelMap mmap) { SysUser user = getSysUser(); user.setSex(dictDataService.selectDictLabel("sys_user_sex", user.getSex())); mmap.put("user", user); mmap.put("roleGroup", userService.selectUserRoleGroup...
#vulnerable code @GetMapping() public String profile(ModelMap mmap) { SysUser user = getUser(); user.setSex(dictDataService.selectDictLabel("sys_user_sex", user.getSex())); mmap.put("user", user); mmap.put("roleGroup", userService.selectUserRoleGr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @GetMapping("/checkPassword") @ResponseBody public boolean checkPassword(String password) { SysUser user = getSysUser(); String encrypt = new Md5Hash(user.getLoginName() + password + user.getSalt()).toHex().toString(); if (user.getPassword(...
#vulnerable code @GetMapping("/checkPassword") @ResponseBody public boolean checkPassword(String password) { SysUser user = getUser(); String encrypt = new Md5Hash(user.getLoginName() + password + user.getSalt()).toHex().toString(); if (user.getPasswo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Async protected void handleLog(final JoinPoint joinPoint, final Exception e) { try { // 获得注解 Log controllerLog = getAnnotationLog(joinPoint); if (controllerLog == null) { return; ...
#vulnerable code @Async protected void handleLog(final JoinPoint joinPoint, final Exception e) { try { // 获得注解 Log controllerLog = getAnnotationLog(joinPoint); if (controllerLog == null) { return; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @GetMapping("/checkPassword") @ResponseBody public boolean checkPassword(String password) { SysUser user = getSysUser(); String encrypt = new Md5Hash(user.getLoginName() + password + user.getSalt()).toHex().toString(); if (user.getPassword(...
#vulnerable code @GetMapping("/checkPassword") @ResponseBody public boolean checkPassword(String password) { SysUser user = getUser(); String encrypt = new Md5Hash(user.getLoginName() + password + user.getSalt()).toHex().toString(); if (user.getPasswo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getLoginName() { return getSysUser().getLoginName(); }
#vulnerable code public static String getLoginName() { return getUser().getLoginName(); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String getLoginName() { return getSysUser().getLoginName(); }
#vulnerable code public String getLoginName() { return getUser().getLoginName(); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Long getUserId() { return getSysUser().getUserId().longValue(); }
#vulnerable code public static Long getUserId() { return getUser().getUserId().longValue(); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Long getUserId() { return getSysUser().getUserId(); }
#vulnerable code public Long getUserId() { return getUser().getUserId(); } #location 3 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<T> importExcel(String sheetName, InputStream input) throws Exception { List<T> list = new ArrayList<T>(); Workbook workbook = WorkbookFactory.create(input); Sheet sheet = null; if (StringUtils.isNotEmpty(sheetName)) { ...
#vulnerable code public List<T> importExcel(String sheetName, InputStream input) throws Exception { List<T> list = new ArrayList<T>(); Workbook workbook = WorkbookFactory.create(input); Sheet sheet = null; if (StringUtils.isNotEmpty(sheetName)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void clearState() { setConnection(null); activeSenders.clear(); activeRequestResponseClients.clear(); failAllCreationRequests(); // make sure we make configured number of attempts to re-connect connectAttempts = new ...
#vulnerable code protected void clearState() { setConnection(null); offeredCapabilities = Collections.emptyList(); activeSenders.clear(); activeRequestResponseClients.clear(); failAllCreationRequests(); // make sure we make configured nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void onClose(final MqttEndpoint endpoint) { }
#vulnerable code protected void onClose(final MqttEndpoint endpoint) { metrics.decrementMqttConnections(getCredentials(endpoint.auth()).getTenantId()); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetOrCreateSenderFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that tries to create a telemetry sender for "tenant" final Async connected = ctx.async(); final HonoClientImpl client = new HonoClientImpl(v...
#vulnerable code @Test public void testGetOrCreateSenderFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that tries to create a telemetry sender for "tenant" ProtonConnection con = mock(ProtonConnection.class); DisconnectHandlerProvidingCo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void sendRegistrationData(final ProtonDelivery delivery, final Message msg) { vertx.runOnContext(run -> { final JsonObject registrationMsg = RegistrationConstants.getRegistrationMsg(msg); vertx.eventBus().send(EVENT_BUS_ADDRESS_REGISTRA...
#vulnerable code private void sendRegistrationData(final ProtonDelivery delivery, final Message msg) { final ResourceIdentifier messageAddress = ResourceIdentifier.fromString( MessageHelper.getAnnotation(msg, APP_PROPERTY_RESOURCE_ID)); checkPermission(me...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Optional<TimeUntilDisconnectNotification> fromMessage(final Message msg) { final Integer ttd = MessageHelper.getTimeUntilDisconnect(msg); if (ttd == null) { return Optional.empty(); } else if (ttd == 0 || MessageHelper.isDev...
#vulnerable code public static Optional<TimeUntilDisconnectNotification> fromMessage(final Message msg) { if (MessageHelper.isDeviceCurrentlyConnected(msg)) { final String tenantId = MessageHelper.getTenantIdAnnotation(msg); final String deviceId = Messa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetOrCreateRequestResponseClientFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that tries to create a registration client for "tenant" final Async connected = ctx.async(); final HonoClientImpl client = ne...
#vulnerable code @Test public void testGetOrCreateRequestResponseClientFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that tries to create a registration client for "tenant" ProtonConnection con = mock(ProtonConnection.class); Disconnect...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private R getRequestResponseResult(final Message message) { final Integer status = MessageHelper.getApplicationProperty( message.getApplicationProperties(), MessageHelper.APP_PROPERTY_STATUS, Integer.class); if ...
#vulnerable code private R getRequestResponseResult(final Message message) { final Integer status = MessageHelper.getApplicationProperty( message.getApplicationProperties(), MessageHelper.APP_PROPERTY_STATUS, Integer.class); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCreateEventConsumerFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that already tries to create a telemetry sender for "tenant" final Async connected = ctx.async(); final HonoClientImpl client = new HonoCl...
#vulnerable code @Test public void testCreateEventConsumerFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that already tries to create a telemetry sender for "tenant" ProtonConnection con = mock(ProtonConnection.class); DisconnectHandlerP...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testConnectTriesToReconnectOnFailedConnectAttempt(final TestContext ctx) { // GIVEN a client that cannot connect to the server // expect the connection factory to fail twice and succeed on third connect attempt connectionFactory ...
#vulnerable code @Test public void testConnectTriesToReconnectOnFailedConnectAttempt(final TestContext ctx) { // GIVEN a client that cannot connect to the server ProtonConnection con = mock(ProtonConnection.class); // expect the connection factory to fail tw...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCreateTelemetryConsumerFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that already tries to create a telemetry sender for "tenant" final Async connected = ctx.async(); final HonoClientImpl client = new Ho...
#vulnerable code @Test public void testCreateTelemetryConsumerFailsOnConnectionFailure(final TestContext ctx) { // GIVEN a client that already tries to create a telemetry sender for "tenant" ProtonConnection con = mock(ProtonConnection.class); DisconnectHand...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDownstreamDisconnectTriggersReconnect(final TestContext ctx) { // expect the connection factory to be invoked twice // first on initial connection // second on re-connect attempt connectionFactory = new DisconnectHand...
#vulnerable code @Test public void testDownstreamDisconnectTriggersReconnect(final TestContext ctx) { final ProtonConnection connectionToCreate = mock(ProtonConnection.class); when(connectionToCreate.getRemoteContainer()).thenReturn("server"); // expect the ...
Below is the vulnerable code, please generate the patch based on the following information.