input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Test public void testCreatePool() throws SQLException, ClassNotFoundException { BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class); expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes(); expect(mockConfig.getMaxConnectionsPerPartition()).andRet...
#fixed code @Test public void testCreatePool() throws SQLException, ClassNotFoundException, CloneNotSupportedException { BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class); expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes(); expect(mockConfig.getMaxConnections...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void initializer_same_key() { App app = new App(); final AtomicBoolean called = new AtomicBoolean(false); assertThat(called.get(), is(false)); app.initializer("foo", (theApp) -> { called.set(true); })...
#fixed code @Test public void initializer_same_key() { App app = new App(AppConfig.builder().signingSecret("secret").build()); final AtomicBoolean called = new AtomicBoolean(false); assertThat(called.get(), is(false)); app.initializer("foo", (theApp) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Request<?> toSlackRequest(HttpRequest<?> req, LinkedHashMap<String, String> body) { String requestBody = body.entrySet().stream().map(e -> { try { String k = URLEncoder.encode(e.getKey(), "UTF-8"); String v = UR...
#fixed code public Request<?> toSlackRequest(HttpRequest<?> req, LinkedHashMap<String, String> body) { String requestBody = body.entrySet().stream().map(e -> { try { String k = URLEncoder.encode(e.getKey(), "UTF-8"); String v = URLEncod...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void rtmStart() throws Exception { // TODO: "prefs" support SlackConfig config = new SlackConfig(); config.setLibraryMaintainerMode(false); config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener()); ...
#fixed code @Test public void rtmStart() throws Exception { // TODO: "prefs" support SlackConfig config = new SlackConfig(); config.setLibraryMaintainerMode(false); config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener()); Sl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Bot findBot(String enterpriseId, String teamId) { AmazonS3 s3 = this.createS3Client(); String fullKey = getBotKey(enterpriseId, teamId); if (isHistoricalDataEnabled()) { fullKey = fullKey + "-latest"; } ...
#fixed code @Override public Bot findBot(String enterpriseId, String teamId) { AmazonS3 s3 = this.createS3Client(); String fullKey = getBotKey(enterpriseId, teamId); if (isHistoricalDataEnabled()) { fullKey = fullKey + "-latest"; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void initializer_start() { App app = new App(); final AtomicBoolean called = new AtomicBoolean(false); assertThat(called.get(), is(false)); app.initializer("foo", (theApp) -> { called.set(true); }); ...
#fixed code @Test public void initializer_start() { App app = new App(AppConfig.builder().signingSecret("secret").build()); final AtomicBoolean called = new AtomicBoolean(false); assertThat(called.get(), is(false)); app.initializer("foo", (theApp) -> ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void rtmStart() throws Exception { // TODO: "prefs" support SlackConfig config = new SlackConfig(); config.setLibraryMaintainerMode(false); config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener()); ...
#fixed code @Test public void rtmStart() throws Exception { // TODO: "prefs" support SlackConfig config = new SlackConfig(); config.setLibraryMaintainerMode(false); config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener()); Sl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void initializer_called() { App app = new App(); final AtomicBoolean called = new AtomicBoolean(false); assertThat(called.get(), is(false)); app.initializer("foo", (theApp) -> { called.set(true); }); ...
#fixed code @Test public void initializer_called() { App app = new App(AppConfig.builder().signingSecret("secret").build()); final AtomicBoolean called = new AtomicBoolean(false); assertThat(called.get(), is(false)); app.initializer("foo", (theApp) ->...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() throws Exception { String channelName = "test" + System.currentTimeMillis(); TestChannelGenerator channelGenerator = new TestChannelGenerator(testConfig, channelCreationToken); Conversation channel = channelGenerator....
#fixed code @Test public void test() throws Exception { String channelName = "test" + System.currentTimeMillis(); TestChannelGenerator channelGenerator = new TestChannelGenerator(testConfig, channelCreationToken); Conversation channel = channelGenerator.create...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void status() { App app = new App(); assertThat(app.status(), is(App.Status.Stopped)); app.start(); assertThat(app.status(), is(App.Status.Running)); app.stop(); assertThat(app.status(), is(App.Status.Stop...
#fixed code @Test public void status() { App app = new App(AppConfig.builder().signingSecret("secret").build()); assertThat(app.status(), is(App.Status.Stopped)); app.start(); assertThat(app.status(), is(App.Status.Running)); app.stop(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void builder_config() { App app = new App(); assertNotNull(app.config()); app = app.toBuilder().build(); assertNotNull(app.config()); app = app.toOAuthCallbackApp(); assertNotNull(app.config()); ...
#fixed code @Test public void builder_config() { App app = new App(AppConfig.builder().signingSecret("secret").build()); assertNotNull(app.config()); app = app.toBuilder().build(); assertNotNull(app.config()); app = app.toOAuthCallbackApp(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Request<?> toSlackRequest(ApiGatewayRequest awsReq) { if (log.isDebugEnabled()) { log.debug("AWS API Gateway Request: {}", awsReq); } SlackRequestParser.HttpRequest rawRequest = SlackRequestParser.HttpRequest.builder() ...
#fixed code protected Request<?> toSlackRequest(ApiGatewayRequest awsReq) { if (log.isDebugEnabled()) { log.debug("AWS API Gateway Request: {}", awsReq); } RequestContext context = awsReq.getRequestContext(); SlackRequestParser.HttpRequest rawR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void builder_status() { App app = new App(); assertNotNull(app.status()); assertThat(app.status(), is(App.Status.Stopped)); app = app.toBuilder().build(); assertThat(app.status(), is(App.Status.Stopped)); ...
#fixed code @Test public void builder_status() { App app = new App(AppConfig.builder().signingSecret("secret").build()); assertNotNull(app.status()); assertThat(app.status(), is(App.Status.Stopped)); app = app.toBuilder().build(); assertThat(a...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Installer findInstaller(String enterpriseId, String teamId, String userId) { AmazonS3 s3 = this.createS3Client(); String fullKey = getInstallerKey(enterpriseId, teamId, userId); if (isHistoricalDataEnabled()) { fu...
#fixed code @Override public Installer findInstaller(String enterpriseId, String teamId, String userId) { AmazonS3 s3 = this.createS3Client(); String fullKey = getInstallerKey(enterpriseId, teamId, userId); if (isHistoricalDataEnabled()) { fullKey ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { DebugProtocol protocol = new DebugProtocol(new EventListener() { @Override public void onPageLoad() { //To change body of implemented methods use File | Settings | File Templates. } ...
#fixed code public static void main(String[] args) throws Exception { test(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(expectedExceptions = UnexpectedAlertOpen.class) public void cannotInteractWithAppWhenAlertOpen() throws Exception { RemoteUIADriver driver = null; try { driver = getDriver(); RemoteUIATarget target = driver.getLocalTarget(); RemoteUIAApp...
#fixed code @Test(expectedExceptions = UnexpectedAlertOpen.class) public void cannotInteractWithAppWhenAlertOpen() throws Exception { RemoteUIADriver driver = null; try { driver = getDriver(); RemoteUIATarget target = driver.getLocalTarget(); RemoteUIAApplicati...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void canSwitchToTheWebViewAndFindByCSS() throws Exception { IOSCapabilities safari = IOSCapabilities.iphone("UICatalog"); safari.setCapability(IOSCapabilities.TIME_HACK, false); RemoteUIADriver driver = null; try { driver = new Remote...
#fixed code @Test public void canSwitchToTheWebViewAndFindByCSS() throws Exception { IOSCapabilities safari = IOSCapabilities.iphone("UICatalog"); safari.setCapability(IOSCapabilities.TIME_HACK, false); RemoteUIADriver driver = null; try { driver = new RemoteUIADri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public View handle(HttpServletRequest req) throws IOSAutomationException { String path = req.getPathInfo(); String pattern = "/resources/"; int end = path.indexOf(pattern) + pattern.length(); String resource = path.substring(end); InputStream is = nu...
#fixed code public View handle(HttpServletRequest req) throws IOSAutomationException { String path = req.getPathInfo(); String pattern = "/resources/"; int end = path.indexOf(pattern) + pattern.length(); String resource = path.substring(end); InputStream is = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Response handle() throws Exception { JSONObject payload = getRequest().getPayload(); String type = payload.getString("using"); String value = payload.getString("value"); RemoteWebElement element = null; if (getRequest().hasVariable...
#fixed code @Override public Response handle() throws Exception { waitForPageToLoad(); int implicitWait = (Integer) getConf("implicit_wait", 0); long deadline = System.currentTimeMillis() + implicitWait; List<RemoteWebElement> elements = null; do { try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Set<String> getWindowHandles() { try { JSONObject payload = new JSONObject(); WebDriverLikeCommand command = WebDriverLikeCommand.WINDOW_HANDLES; Path p = new Path(command).withSession(getSessionId()); WebDriverLikeRequest ...
#fixed code @Override public Set<String> getWindowHandles() { WebDriverLikeRequest request = buildRequest(WebDriverLikeCommand.WINDOW_HANDLES); List<String> all = execute(request); Set<String> res = new HashSet<String>(); res.addAll(all); return res; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Response handle() throws Exception { JSONObject payload = getRequest().getPayload(); String type = payload.getString("using"); String value = payload.getString("value"); RemoteWebElement element = null; if (getRequest().hasVariable...
#fixed code @Override public Response handle() throws Exception { waitForPageToLoad(); int implicitWait = (Integer) getConf("implicit_wait", 0); long deadline = System.currentTimeMillis() + implicitWait; RemoteWebElement rwe = null; do { try { rwe = fin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onPageLoad() { System.err.println("new page loaded"); pageLoaded = true; reset(); } #location 5 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public void onPageLoad() { System.err.println("new page loaded"); pageLoaded = true; reset(); try { Thread.sleep(5000); System.out.println( "on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocument())...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onPageLoad() { System.err.println("new page loaded"); pageLoaded = true; reset(); try { Thread.sleep(5000); System.out.println( "on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum...
#fixed code @Override public void onPageLoad() { pageLoaded = true; reset(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setValueNative(String value) throws Exception { UIAElement el = getNativeElement(); WorkingMode origin = session.getMode(); try { session.setMode(WorkingMode.Native); UIARect rect = el.getRect(); int x = rect.getX() + rect.getWidt...
#fixed code public void setValueNative(String value) throws Exception { /*WebElement el = getNativeElement(); WorkingMode origin = session.getMode(); try { session.setMode(WorkingMode.Native); el.click(); RemoteUIAKeyboard keyboard = (RemoteUIAKeyboard) sessio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onPageLoad() { System.err.println("new page loaded"); pageLoaded = true; reset(); try { Thread.sleep(5000); System.out.println( "on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum...
#fixed code @Override public void onPageLoad() { pageLoaded = true; reset(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onPageLoad() { System.err.println("new page loaded"); pageLoaded = true; reset(); try { Thread.sleep(5000); System.out.println( "on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum...
#fixed code @Override public void onPageLoad() { pageLoaded = true; reset(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void typeURLNative(String url) { WorkingMode base = getSession().getMode(); try { getSession().setMode(WorkingMode.Native); getAddressBar().tap(); RemoteUIAKeyboard keyboard = (RemoteUIAKeyboard)getSession().getNativeDriver().getKeyboar...
#fixed code private void typeURLNative(String url) { WorkingMode base = getSession().getMode(); try { getSession().setMode(WorkingMode.Native); getAddressBar().tap(); RemoteUIAKeyboard keyboard = (RemoteUIAKeyboard) getSession().getNativeDriver().getKeyboard(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void persist(File screenshot, JSONObject tree, File dest) throws FileNotFoundException, IOException, JSONException { System.out.println(screenshot.getAbsolutePath()); FileWriter write = new FileWriter(dest); IOUtils.copy(new StringReader(tr...
#fixed code public static void persist(File screenshot, JSONObject tree, File dest) throws FileNotFoundException, IOException, JSONException { IOUtils.copy(new StringReader(tree.toString(2)), new FileOutputStream(dest), "UTF-8"); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onPageLoad() { System.err.println("new page loaded"); pageLoaded = true; reset(); try { Thread.sleep(5000); System.out.println( "on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum...
#fixed code @Override public void onPageLoad() { pageLoaded = true; reset(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setValueNative(String value) throws Exception { UIAElement el = getNativeElement(); WorkingMode origin = session.getMode(); try { session.setMode(WorkingMode.Native); UIARect rect = el.getRect(); int x = rect.getX() + rect.getWidt...
#fixed code public void setValueNative(String value) throws Exception { /*WebElement el = getNativeElement(); WorkingMode origin = session.getMode(); try { session.setMode(WorkingMode.Native); el.click(); RemoteUIAKeyboard keyboard = (RemoteUIAKeyboard) sessio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private File createTmpScript(String content) throws IOException { File res = File.createTempFile(FILE_NAME, ".js"); BufferedWriter out = new BufferedWriter(new FileWriter(res)); out.write(content); out.close(); return res; } ...
#fixed code private File createTmpScript(String content) throws IOException { File res=null; if (DEBUG){ res = new File("/Users/freynaud/Documents/debug.js"); }else { res = File.createTempFile(FILE_NAME, ".js"); } Writer writer = new FileWriter(res); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testTrivialMethod() throws Exception { lib.simple("com.jitlogic.zorka.spy.unittest.SomeClass", "someMethod", "zorka:type=ZorkaStats,name=SomeClass", "stats"); Object obj = TestUtil.instrumentAndInstantiate(spy, "com.jitlogic.zorka.spy....
#fixed code @Test public void testTrivialMethod() throws Exception { Object obj = makeCall("someMethod"); assertEquals(1, obj.getClass().getField("runCounter").get(obj)); checkStats("someMethod", 1, 0, 1); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean onActivate(Item item, Player player) { int[] faces = new int[]{3, 0, 1, 2}; this.meta = (faces[(player != null) ? player.getDirection() : 0] & 0x03) | ((~this.meta) & 0x04); this.getLevel().setBlock(this, this, true);...
#fixed code @Override public boolean onActivate(Item item, Player player) { if (player == null) { return false; } double rotation = (player.yaw - 90) % 360; if (rotation < 0) { rotation += 360.0; } int[][] face...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void openSession(String identifier, String address, int port, long clientID) { PlayerCreationEvent ev = new PlayerCreationEvent(this, Player.class, Player.class, null, address, port); this.server.getPluginManager().callEvent(ev); ...
#fixed code @Override public void openSession(String identifier, String address, int port, long clientID) { PlayerCreationEvent ev = new PlayerCreationEvent(this, Player.class, Player.class, null, address, port); this.server.getPluginManager().callEvent(ev); C...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean getDataFlag(int propertyId, int id) { return ((this.getDataPropertyByte(propertyId) == null ? 0 : this.getDataPropertyByte(propertyId).data & 0xff) & (1 << id)) > 0; } #location 2 #vuln...
#fixed code public boolean getDataFlag(int propertyId, int id) { return ((this.getDataPropertyByte(propertyId).data & 0xff) & (1 << id)) > 0; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(StreamingReader reader = StreamingReader.builder().read(f)) { for(Row row : r...
#fixed code @Test public void testSpecialStyles() throws Exception { File f = new File("src/test/resources/special_types.xlsx"); Map<Integer, List<Cell>> contents = new HashMap<>(); try(Workbook wb = StreamingReader.builder().open(f)) { for(Row row : wb.getSheetAt(0)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void install() throws InstallationException { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROOT; } if(npmDownloadRoot == null || npmDownloadRoot.isEmpty()){ ...
#fixed code public void install() throws InstallationException { // use static lock object for a synchronized block synchronized (LOCK) { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static List<String> buildArguments(ProxyConfig proxyConfig, String npmRegistryURL) { List<String> arguments = new ArrayList<String>(); if(npmRegistryURL != null && !npmRegistryURL.isEmpty()){ arguments.add ("--registry=" + npm...
#fixed code static List<String> buildArguments(ProxyConfig proxyConfig, String npmRegistryURL) { List<String> arguments = new ArrayList<String>(); if(npmRegistryURL != null && !npmRegistryURL.isEmpty()){ arguments.add ("--registry=" + npmRegist...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void install() throws InstallationException { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROOT; } if(npmDownloadRoot == null || npmDownloadRoot.isEmpty()){ ...
#fixed code public void install() throws InstallationException { // use static lock object for a synchronized block synchronized (LOCK) { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void install() throws InstallationException { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROOT; } if(npmDownloadRoot == null || npmDownloadRoot.isEmpty()){ ...
#fixed code public void install() throws InstallationException { // use static lock object for a synchronized block synchronized (LOCK) { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void install() throws InstallationException { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROOT; } if(npmDownloadRoot == null || npmDownloadRoot.isEmpty()){ ...
#fixed code public void install() throws InstallationException { // use static lock object for a synchronized block synchronized (LOCK) { if(nodeDownloadRoot == null || nodeDownloadRoot.isEmpty()){ nodeDownloadRoot = DEFAULT_NODEJS_DOWNLOAD_ROO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initialize( final String methodName, final AtomicReference<OperationArguments> operationArgumentsRef, final AtomicReference<IAuthentication> authenticationRef ) throws IOException, URISyntaxException { // parse the op...
#fixed code private void initialize( final String methodName, final AtomicReference<OperationArguments> operationArgumentsRef, final AtomicReference<IAuthentication> authenticationRef ) throws IOException, URISyntaxException { // parse the operatio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void save() { if (backingFile != null) { // TODO: consider creating a backup of the file, if it exists, before overwriting it FileOutputStream fos = null; try { fos = new FileOutputStrea...
#fixed code void reload() { if (backingFile != null) { FileInputStream fis = null; try { fis = new FileInputStream(backingFile); final InsecureStore clone = fromXml(fis); if (clone != ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static InsecureStore clone(InsecureStore inputStore) { ByteArrayOutputStream baos = null; ByteArrayInputStream bais = null; try { baos = new ByteArrayOutputStream(); final PrintStream ps = new PrintStream(baos)...
#fixed code static InsecureStore clone(InsecureStore inputStore) { ByteArrayOutputStream baos = null; ByteArrayInputStream bais = null; try { baos = new ByteArrayOutputStream(); inputStore.toXml(baos); final String...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String doHttpGet(URL url) throws IOException, RestApiException { System.out.println("GET " + url.toString()); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanceFollowRedirect...
#fixed code private String doHttpGet(URL url) throws IOException, RestApiException { System.out.println("GET " + url.toString()); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanceFollowRedirects(true...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String doHttpGet(URL url) throws IOException, RestApiException { System.out.println("GET " + url.toString()); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanceFollowRedirect...
#fixed code private String doHttpGet(URL url) throws IOException, RestApiException { System.out.println("GET " + url.toString()); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanceFollowRedirects(true...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String doHttpPost(URL url, String body) throws IOException { System.out.println("POST " + url.toString() + " " + body); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanc...
#fixed code private String doHttpPost(URL url, String body) throws IOException { System.out.println("POST " + url.toString() + " " + body); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanceFollo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String doHttpPost(URL url, String body) throws IOException { System.out.println("POST " + url.toString() + " " + body); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanc...
#fixed code private String doHttpPost(URL url, String body) throws IOException { System.out.println("POST " + url.toString() + " " + body); HttpURLConnection connection = JdkHttpTransport.createConnection(config, url, headers, false); connection.setInstanceFollo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public DataFrame<R, String> read(Consumer<DbSourceOptions<R>> configurator) throws DataFrameException { final DbSourceOptions<R> options = initOptions(new DbSourceOptions<>(), configurator); try (Connection conn = options.getConnection()) {...
#fixed code @Override public DataFrame<R, String> read(Consumer<DbSourceOptions<R>> configurator) throws DataFrameException { final DbSourceOptions<R> options = initOptions(new DbSourceOptions<>(), configurator); try (Connection conn = options.getConnection()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testParse() throws ParseException, IOException, Exception { // JSONObject parsed = iseParser.parse(getRawMessage().getBytes()); // assertNotNull(parsed); URL log_url = getClass().getClassLoader().getResource("IseSample.log"); BufferedReader br = new B...
#fixed code public void testParse() throws ParseException, IOException, Exception { for (String inputString : getInputStrings()) { JSONObject parsed = parser.parse(inputString.getBytes()); assertNotNull(parsed); System.out.println(parsed)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Map<String, JSONObject> alert(JSONObject raw_message) { Map<String, JSONObject> alerts = new HashMap<String, JSONObject>(); JSONObject content = (JSONObject) raw_message.get("message"); JSONObject enrichment = null; if (raw_message.containsKey...
#fixed code @Override public Map<String, JSONObject> alert(JSONObject raw_message) { Map<String, JSONObject> alerts = new HashMap<String, JSONObject>(); JSONObject content = (JSONObject) raw_message.get("message"); JSONObject enrichment = null; if (raw_message.containsKey("enri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean initializeAdapter() { _LOG.info("Initializing MysqlAdapter...."); try { boolean reachable = (java.lang.Runtime.getRuntime() .exec("ping -n 1 " + _ip).waitFor() == 0); if (!reachable) throw new Exception("Unable to reach IP.....
#fixed code @Override public boolean initializeAdapter() { _LOG.info("Initializing MysqlAdapter...."); try { Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://" + _ip + "/" + _tablename + "?user=" + _username + "&password=...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testParse() throws IOException, Exception { URL log_url = getClass().getClassLoader().getResource("LancopeSample.log"); BufferedReader br; try { br = new BufferedReader(new FileReader(log_url.getFile())); Stri...
#fixed code public void testParse() throws IOException, Exception { for (String inputString : getInputStrings()) { JSONObject parsed = parser.parse(inputString.getBytes()); assertNotNull(parsed); System.out.println(parsed); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public JSONObject parse(byte[] raw_message) { String toParse = ""; JSONObject toReturn; try { toParse = new String(raw_message, "UTF-8"); //System.out.println("Received message: " + toParse); OpenSOCMatch gm = grok.match(toParse); gm.captur...
#fixed code @Override public JSONObject parse(byte[] raw_message) { String toParse = ""; JSONObject toReturn; try { toParse = new String(raw_message, "UTF-8"); //System.out.println("Received message: " + toParse); //OpenSOCMatch gm = grok.match(toParse); //gm.captures...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public JSONObject parse(byte[] raw_message) { String toParse = ""; JSONObject toReturn; try { toParse = new String(raw_message, "UTF-8"); //System.out.println("Received message: " + toParse); Match gm = grok.match(toParse); gm.captures(); ...
#fixed code @Override public JSONObject parse(byte[] raw_message) { String toParse = ""; JSONObject toReturn; try { toParse = new String(raw_message, "UTF-8"); //System.out.println("Received message: " + toParse); Match gm = grok.match(toParse); gm.captures(); toR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Object createTest() throws Exception { ensureHierarchicalFixturesAreValid(); return instances.getLast(); } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override protected Object createTest() throws Exception { instances = createHierarchicalFixtures(); return instances.getLast(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Statement withBefores(final FrameworkMethod method, final Object target, final Statement next) { Statement statement = next; for (int i = instances.size() - 1; i >= 0; i--) { final Object instance = instances.get(i); ...
#fixed code @Override protected Statement withBefores(final FrameworkMethod method, final Object target, final Statement next) { Statement statement = next; for (int i = instances.size() - 1; i >= 0; i--) { final Object instance = instances.get(i); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Statement withAfters(final FrameworkMethod method, final Object target, final Statement next) { Statement statement = next; for (int i = instances.size() - 1; i >= 0; i--) { final Object instance = instances.get(i); ...
#fixed code @Override protected Statement withAfters(final FrameworkMethod method, final Object target, final Statement next) { Statement statement = next; for (int i = instances.size() - 1; i >= 0; i--) { final Object instance = instances.get(i); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void registerResources(final PluginAnnotation<T> pluginAnnotation, final ClassLoader classLoader) throws IOException { final T annot = pluginAnnotation.getAnnotation(); WatchEventDTO watchEventDTO = WatchEventDTO.parse(annot); String pa...
#fixed code private void registerResources(final PluginAnnotation<T> pluginAnnotation, final ClassLoader classLoader) throws IOException { final T annot = pluginAnnotation.getAnnotation(); WatchEventDTO watchEventDTO = WatchEventDTO.parse(annot); String path = w...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void register(Object generatorStrategy, Object classGenerator, byte[] bytes) { try { ClassPool classPool = ProxyTransformationUtils.getClassPool(generatorStrategy.getClass().getClassLoader()); CtClass cc = classPool.makeClass(new ByteArrayInputStream(...
#fixed code public static void register(Object generatorStrategy, Object classGenerator, byte[] bytes) { try { generatorParams.put(getClassName(bytes), new GeneratorParams(generatorStrategy, classGenerator)); } catch (Exception e) { LOGGER.error("Error saving parameters of a creat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Object callPluginMethod(Class pluginClass, ClassLoader appClassLoader, String method, Class[] paramTypes, Object[] params) { Object pluginInstance = PluginManager.getInstance().getPlugin(pluginClass.getName(), appClassLoader); try { ...
#fixed code public static Object callPluginMethod(Class pluginClass, ClassLoader appClassLoader, String method, Class[] paramTypes, Object[] params) { Object pluginInstance = PluginManager.getInstance().getPlugin(pluginClass.getName(), appClassLoader); try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @OnClassLoadEvent(classNameRegexp = ".*", events = LoadEvent.REDEFINE, skipSynthetic = false) public static byte[] transformRedefinitions(final Class<?> classBeingRedefined, final byte[] classfileBuffer, final ClassLoader loader) throws IllegalClassFormatException, IOE...
#fixed code @OnClassLoadEvent(classNameRegexp = ".*", events = LoadEvent.REDEFINE, skipSynthetic = false) public static byte[] transformRedefinitions(final Class<?> classBeingRedefined, final byte[] classfileBuffer, final ClassLoader loader) throws IllegalClassFormatException, IOExcepti...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void scanJar(String urlFile, ScannerVisitor visitor) throws IOException { LOGGER.trace("Scanning JAR file '{}'", urlFile); int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR); JarFile jarFile; String rootEntryPath; i...
#fixed code private void scanJar(String urlFile, ScannerVisitor visitor) throws IOException { LOGGER.trace("Scanning JAR file '{}'", urlFile); int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR); JarFile jarFile = null; String rootEntryPath; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void defineBean(BeanDefinition candidate) { synchronized (getClass()) { // TODO sychronize on DefaultListableFactory.beanDefinitionMap? ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate); candi...
#fixed code public void defineBean(BeanDefinition candidate) { synchronized (getClass()) { // TODO sychronize on DefaultListableFactory.beanDefinitionMap? ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate); candidate.s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void configureLog(Properties properties) { for (String property : properties.stringPropertyNames()) { if (property.startsWith(LOGGER_PREFIX)) { String classPrefix = getClassPrefix(property); AgentLogger.L...
#fixed code public static void configureLog(Properties properties) { for (String property : properties.stringPropertyNames()) { if (property.startsWith(LOGGER_PREFIX)) { String classPrefix = getClassPrefix(property); AgentLogger.Level l...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void scanJar(String urlFile, ScannerVisitor visitor) throws IOException { LOGGER.trace("Scanning JAR file '{}'", urlFile); int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR); JarFile jarFile; String rootEntryPath; i...
#fixed code private void scanJar(String urlFile, ScannerVisitor visitor) throws IOException { LOGGER.trace("Scanning JAR file '{}'", urlFile); int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR); JarFile jarFile = null; String rootEntryPath; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void refreshProxiedFactory() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException { // refresh registry EntityManagerFactoryRegistry.INSTANCE.removeEntityManagerFactory(persistenceUnitName, currentI...
#fixed code public void refreshProxiedFactory() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException { // refresh registry try { Class entityManagerFactoryRegistryClazz = loadClass("org.hibernate.ejb.internal.En...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void savePolicyFile(String text) { try { FileOutputStream fos = new FileOutputStream(filePath); fos.write(text.getBytes()); fos.close(); } catch (IOException e) { e.printStackTrace(); th...
#fixed code private void savePolicyFile(String text) { try (FileOutputStream fos = new FileOutputStream(filePath)) { IOUtils.write(text, fos, Charset.forName("UTF-8")); } catch (IOException e) { e.printStackTrace(); throw new Error("Pol...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSpliter() throws IOException { String testS = "test data only for "; SharedBufferPool sharedPool = new SharedBufferPool(1024 * 1024 * 100, testS.length() + 4); ReactorBufferPool reactBufferPool = new ReactorBufferPool(sharedPool, Thread.current...
#fixed code @Test public void testSpliter() throws IOException { SharedBufferPool sharedPool = new SharedBufferPool(1024 * 1024 * 100, 10240); ReactorBufferPool reactBufferPool = new ReactorBufferPool(sharedPool, Thread.currentThread(), 1000); ByteBufferArray bufArray = reactBufferPo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPostWithMultipartFormFieldsAndFile() throws IOException { String fileName = "GrandCanyon.txt"; String fileContent = HttpPostRequestTest.VALUE; String divider = UUID.randomUUID().toString(); String header = "POST...
#fixed code @Test public void testPostWithMultipartFormFieldsAndFile() throws IOException { String fileName = "GrandCanyon.txt"; String fileContent = HttpPostRequestTest.VALUE; String divider = UUID.randomUUID().toString(); String header = "POST " + H...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void sendBodyWithCorrectTransferAndEncoding(OutputStream outputStream, long pending) throws IOException { if (this.requestMethod != Method.HEAD && this.chunkedTransfer) { ChunkedOutputStream chunkedOutputStream = new ChunkedOutputStream(outpu...
#fixed code private void sendBodyWithCorrectTransferAndEncoding(OutputStream outputStream, long pending) throws IOException { if (this.requestMethod != Method.HEAD && this.chunkedTransfer) { ChunkedOutputStream chunkedOutputStream = new ChunkedOutputStream(outputStrea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shutdown() throws Exception { Client client = TestGraphUtil.instance.createClient(); client.delegate().shutdown(); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Test public void shutdown() throws Exception { Client client = TestGraphUtil.instance.createClient(); client.getDelegate().shutdown(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void load(final JanusGraph graph, final int rowsToLoad, final boolean report) throws IOException, InterruptedException { final JanusGraphManagement mgmt = graph.openManagement(); if (mgmt.getGraphIndex(CHARACTER) == null) { ...
#fixed code public static void load(final JanusGraph graph, final int rowsToLoad, final boolean report) throws IOException, InterruptedException { final JanusGraphManagement mgmt = graph.openManagement(); if (mgmt.getGraphIndex(CHARACTER) == null) { f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Category> getFriendList() { LOGGER.info("开始获取好友列表"); HttpPost post = defaultHttpPost( "http://s.web2.qq.com/api/get_user_friends2", "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1"); JSON...
#fixed code public List<Category> getFriendList() { LOGGER.info("开始获取好友列表"); JSONObject r = new JSONObject(); r.put("vfwebqq", vfwebqq); r.put("hash", hash()); try { HttpPost post = defaultHttpPost(ApiUrl.GET_FRIEND_LIST, new BasicNameV...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldCreateConversationThenJoinAndSendOfferRequest() throws Exception { // given MessageMatcher s1Matcher = new MessageMatcher(); MessageMatcher s2Matcher = new MessageMatcher(); Session s1 = mockSession("s1", s1Matcher); Session s2 = mockSess...
#fixed code @Test public void shouldCreateConversationThenJoinAndSendOfferRequest() throws Exception { // given MessageMatcher s1Matcher = new MessageMatcher(); MessageMatcher s2Matcher = new MessageMatcher(); Session s1 = mockSession("s1", s1Matcher); Session s2 = mockSession("s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void handleError(Session s, Throwable exception) { doSaveExecution(new SessionWrapper(s), session -> { members.unregister(session.getId()); eventBus.post(UNEXPECTED_SITUATION.occurFor(session, exception.getMessage()...
#fixed code public void handleError(Session s, Throwable exception) { doSaveExecution(s, session -> { members.unregister(session.getId()); eventBus.post(UNEXPECTED_SITUATION.occurFor(session, exception.getMessage())); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldCreateConversation() throws Exception { // given MessageMatcher matcher = new MessageMatcher(); InternalMessage message = InternalMessage.create()// .from(Member.builder()// .session(mockSession("sessionId", matcher))// .build...
#fixed code @Test public void shouldCreateConversation() throws Exception { // given MessageMatcher matcher = new MessageMatcher(); InternalMessage message = InternalMessage.create()// .from(Member.create()// .session(mockSession("sessionId", matcher))// .build())// ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldCreateConversationThenJoinAndSendOfferRequest() throws Exception { // given MessageMatcher s1Matcher = new MessageMatcher(); MessageMatcher s2Matcher = new MessageMatcher(); Session s1 = mockSession("s1", s1Matcher); Session s2 = mockSess...
#fixed code @Test public void shouldCreateConversationThenJoinAndSendOfferRequest() throws Exception { // given MessageMatcher s1Matcher = new MessageMatcher(); MessageMatcher s2Matcher = new MessageMatcher(); Session s1 = mockSession("s1", s1Matcher); Session s2 = mockSession("s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void send(InternalMessage message, int retry) { Message messageToSend = message.transformToExternalMessage(); if (message.getSignal() != Signal.PING) { log.info("Outgoing: " + toString()); } Session destSession = messa...
#fixed code private void send(InternalMessage message, int retry) { if (message.getSignal() != Signal.PING) { log.debug("Outgoing: " + message.transformToExternalMessage()); } if (message.getSignal() == Signal.ERROR) { tryToSendErrorMessage...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldCreateConversationThenJoinAndSendOfferRequest() throws Exception { // given MessageMatcher s1Matcher = new MessageMatcher(); MessageMatcher s2Matcher = new MessageMatcher(); Session s1 = mockSession("s1", s1Matcher); Session s2 = mockSess...
#fixed code @Test public void shouldCreateConversationThenJoinAndSendOfferRequest() throws Exception { // given MessageMatcher s1Matcher = new MessageMatcher(); MessageMatcher s2Matcher = new MessageMatcher(); Session s1 = mockSession("s1", s1Matcher); Session s2 = mockSession("s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private Object getListArg(ManagedList<XmlManagedNode> values, Class<?> setterParamType) { Collection<Object> collection = null; if (VerifyUtils.isNotEmpty(values.getTypeName())) { try { coll...
#fixed code @SuppressWarnings("unchecked") private Object getListArg(ManagedList<XmlManagedNode> values, Class<?> setterParamType) { Collection<Object> collection = null; if (VerifyUtils.isNotEmpty(values.getTypeName())) { try { collection...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void parseProperties(Properties properties) { for (Entry<Object, Object> entry : properties.entrySet()) { String name = (String) entry.getKey(); String value = (String) entry.getValue(); // System.out.println(name + "|" + value); String[] strs = Strin...
#fixed code private void parseProperties(Properties properties) { for (Entry<Object, Object> entry : properties.entrySet()) { String name = (String) entry.getKey(); String value = (String) entry.getValue(); String[] strs = StringUtils.split(value, ','); switch (strs.length) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { String json = "{ \"key1\":333, \"arrayKey\":[444, \"array\"], \"key2\" : {\"key3\" : \"hello\", \"key4\":\"world\" }, \"booleanKey\" : true } "; JsonObject jsonObject = Json.toJsonObject(json); System.out.println(jsonObjec...
#fixed code public static void main(String[] args) { Calendar cal = Calendar.getInstance(); cal.set(2015, Calendar.JANUARY, 25, 14, 53, 12); System.out.println(cal.get(Calendar.HOUR_OF_DAY)); DateFormatObject obj = new DateFormatObject(); System.out.println(obj); obj.init(cal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static long copy(File src, File dest, long position, long count) throws IOException { FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest); FileChannel inChannel = in.getChannel(); FileChannel outChannel = out.getC...
#fixed code public static long copy(File src, File dest, long position, long count) throws IOException { try(FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest); FileChannel inChannel = in.getChannel(); FileChannel outChannel = out.get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void flush() { if (fileOutput && buffer.size() > 0) { BufferedWriter bufferedWriter = null; try { String date = LogFactory.dayDateFormat.format(new Date()); bufferedWriter = getBufferedWriter(date); for (LogItem logItem = null; (logItem = bu...
#fixed code public void flush() { if (fileOutput && buffer.size() > 0) { try { for (LogItem logItem = null; (logItem = buffer.poll()) != null;) { Date d = new Date(); bufferedWriter = getBufferedWriter(LogFactory.dayDateFormat.format(d)); logItem.setDate(SafeSimpleDa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testHeaders() throws Throwable { final HTTP2ServerDecoder decoder = new HTTP2ServerDecoder(); final HTTP2MockSession session = new HTTP2MockSession(); final HTTP2Configuration http2Configuration = new HTTP2Configuration(); final HTTP2ServerConnec...
#fixed code @Test public void testHeaders() throws Throwable { final HTTP2ServerDecoder decoder = new HTTP2ServerDecoder(); final HTTP2MockSession session = new HTTP2MockSession(); final HTTP2Configuration http2Configuration = new HTTP2Configuration(); final HTTP2ServerConnection h...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void render(RoutingContext ctx, int status, Throwable t) { HttpStatus.Code code = HttpStatus.getCode(status); String title = status + " " + (code != null ? code.getMessage() : "error"); String content; switch (code) { c...
#fixed code public void render(RoutingContext ctx, int status, Throwable t) { HttpStatus.Code code = Optional.ofNullable(HttpStatus.getCode(status)).orElse(HttpStatus.Code.INTERNAL_SERVER_ERROR); String title = status + " " + code.getMessage(); String content; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMethodType() { Map<String, MethodGenericTypeBind> getterMap = ReflectUtils.getGenericBeanGetterMethods( new GenericTypeReference<Request<Map<String, Foo>, String, Map<String, List<Foo>>>>() { }, null); ...
#fixed code @Test public void testMethodType() { Map<String, MethodGenericTypeBind> getterMap = ReflectUtils.getGenericBeanGetterMethods(reqRef); MethodGenericTypeBind extInfo = getterMap.get("extInfo"); ParameterizedType parameterizedType = (ParameterizedType...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static long copy(File src, File dest, long position, long count) throws IOException { FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest); FileChannel inChannel = in.getChannel(); FileChannel outChannel = out.getC...
#fixed code public static long copy(File src, File dest, long position, long count) throws IOException { try(FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest); FileChannel inChannel = in.getChannel(); FileChannel outChannel = out.get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testHeaders() throws Throwable { final HTTP2Decoder decoder = new HTTP2Decoder(); final HTTP2MockSession session = new HTTP2MockSession(); final HTTP2Configuration http2Configuration = new HTTP2Configuration(); final HTTP2SessionAttachment attach...
#fixed code @Test public void testHeaders() throws Throwable { final HTTP2Decoder decoder = new HTTP2Decoder(); final HTTP2MockSession session = new HTTP2MockSession(); final HTTP2Configuration http2Configuration = new HTTP2Configuration(); final HTTP2SessionAttachment attachment =...
Below is the vulnerable code, please generate the patch based on the following information.