input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code protected void reset() { config().reset(); mirrorLog = false; listVersions = null; versionToDownload = null; downloadedVersion = null; driverManagerType = null; } #location 7 ...
#fixed code protected void reset() { config().reset(); mirrorLog = false; listVersions = null; versionToDownload = null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config().getTimeout()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(driverManagerType); urlFilter = new UrlFilter...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config().getTimeout()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(driverManagerType); urlFilter = new UrlFilter(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<URL> getDrivers() throws IOException { URL driverUrl = getDriverUrl(); String driverVersion = versionToDownload; BufferedReader reader = new BufferedReader( new InputStreamReader(openGitHubConnection(driverUrl))); GsonBuilder gsonBuilde...
#fixed code @Override public List<URL> getDrivers() throws IOException { URL driverUrl = getDriverUrl(); String driverVersion = versionToDownload; BufferedReader reader = new BufferedReader( new InputStreamReader(openGitHubConnection(driverUrl))); GsonBuilder gsonBuilder = ne...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new WdmHttpClient.Builder().proxy(proxyValue) .proxyUser(proxyUser).proxyPass(proxyPass).build(); try (WdmHttpClient wdmHttpClient = httpClient) { downloa...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(proxyValue, proxyUser, proxyPass); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(this, wdmHttpClient); urlFilter = new Ur...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<URL> filterCandidateUrls(Architecture arch, String version, boolean getLatest) throws IOException { List<URL> urls = getDrivers(); List<URL> candidateUrls; log.trace("All URLs: {}", urls); boolean continueSearchi...
#fixed code private List<URL> filterCandidateUrls(Architecture arch, String version, boolean getLatest) throws IOException { List<URL> urls = getDrivers(); List<URL> candidateUrls; log.trace("All URLs: {}", urls); boolean continueSearchingVers...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(String driverVersion) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); if (isUnknown(driverVersion)) { ...
#fixed code protected void manage(String driverVersion) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); if (isUnknown(driverVersion)) { dri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static final synchronized void download(URL url, String version, String export, List<String> driverName) throws IOException { File targetFile = new File(getTarget(version, url)); File binary = null; // Check if binary exists boolean download = !targetFil...
#fixed code public static final synchronized void download(URL url, String version, String export, List<String> driverName) throws IOException { File targetFile = new File(getTarget(version, url)); File binary = null; // Check if binary exists boolean download = !targetFile.getP...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config().getTimeout()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlF...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected String resolveDriverVersion(String driverVersion) { preferenceKey = getKeyForPreferences(); Optional<String> browserVersion = empty(); browserVersion = getValueFromPreferences(browserVersion); if (!browserVersion.isPresent()) { ...
#fixed code protected String resolveDriverVersion(String driverVersion) { String preferenceKey = getKeyForPreferences(); Optional<String> browserVersion = empty(); browserVersion = getValueFromPreferences(preferenceKey, browserVersion); if (!browserVersion...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void reset() { config().reset(); mirrorLog = false; versionToDownload = null; forcedArch = false; forcedOs = false; retryCount = 0; isLatest = true; isSnap = false; } ...
#fixed code protected void reset() { config().reset(); mirrorLog = false; versionToDownload = null; forcedArch = false; forcedOs = false; retryCount = 0; isSnap = false; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void reset() { config().reset(); mirrorLog = false; listVersions = null; versionToDownload = null; forcedArch = false; forcedOs = false; retry = true; isLatest = true; } ...
#fixed code protected void reset() { config().reset(); mirrorLog = false; listVersions = null; versionToDownload = null; forcedArch = false; forcedOs = false; retryCount = 0; isLatest = true; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected String download(String driverVersion) throws IOException { List<URL> candidateUrls = getCandidateUrls(driverVersion); if (candidateUrls.isEmpty()) { Architecture arch = config().getArchitecture(); String os = config().ge...
#fixed code protected String download(String driverVersion) throws IOException { List<URL> candidateUrls = getCandidateUrls(driverVersion); if (candidateUrls.isEmpty()) { Architecture arch = config().getArchitecture(); String os = config().getOs();...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void reset() { config().reset(); mirrorLog = false; listVersions = null; versionToDownload = null; forcedArch = false; useBeta = config().isUseBetaVersions(); } #location 7 ...
#fixed code protected void reset() { config().reset(); mirrorLog = false; listVersions = null; versionToDownload = null; forcedArch = false; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected List<File> getFilesInCache() { List<File> listFiles = (List<File>) listFiles( new File(downloader.getTargetPath()), null, true); sort(listFiles); return listFiles; } #location 3 ...
#fixed code protected List<File> getFilesInCache() { List<File> listFiles = (List<File>) listFiles( new File(config.getTargetPath()), null, true); sort(listFiles); return listFiles; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Optional<String> getDefaultBrowserVersion(String programFilesEnv, String winBrowserName, String linuxBrowserName, String macBrowserName, String versionFlag, String browserNameInOutput) { if (IS_OS_WINDOWS) { ...
#fixed code protected Optional<String> getDefaultBrowserVersion(String programFilesEnv, String winBrowserName, String linuxBrowserName, String macBrowserName, String versionFlag, String browserNameInOutput) { String browserBinaryPath = config()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void storeVersionToDownload(String driverVersion) { if (!isUnknown(driverVersion)) { if (driverVersion.startsWith(".")) { driverVersion = driverVersion.substring(1); } versionToDownload = driverVersio...
#fixed code protected void storeVersionToDownload(String driverVersion) { if (!isUnknown(driverVersion)) { if (driverVersion.startsWith(".")) { driverVersion = driverVersion.substring(1); } driverVersionToDownload = driverVersio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config()); try (HttpClient wdmHttpClient = httpClient) { downloader = new Downloader(getDriverManagerType()); urlFilter = new UrlFilter(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void reset() { useBetaVersions = getBoolean("wdm.useBetaVersions"); mirrorLog = false; isForcingCache = false; isForcingDownload = false; listVersions = null; architecture = null; driverUrl = null; ...
#fixed code protected void reset() { useBetaVersions = false; mirrorLog = false; isForcingCache = false; isForcingDownload = false; listVersions = null; architecture = null; driverUrl = null; version = null; proxyVal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config().getProxyValue(), config().getProxyUser(), config().getProxyPass()); httpClient.setTimeout(config().getTimeout()); try (HttpClient wdmH...
#fixed code protected void manage(Architecture arch, String version) { httpClient = new HttpClient(config().getProxyValue(), config().getProxyUser(), config().getProxyPass()); httpClient.setTimeout(config().getTimeout()); try (HttpClient wdmHttpCli...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void manage(Architecture arch, String version) { try { boolean getLatest = version == null || version.isEmpty() || version.equalsIgnoreCase(DriverVersion.LATEST.name()) || version.equalsIgnoreCase( DriverVersion.NOT_SPECIFIED.name()); Strin...
#fixed code public void manage(Architecture arch, String version) { try { boolean getLatest = version == null || version.isEmpty() || version.equalsIgnoreCase(DriverVersion.LATEST.name()) || version.equalsIgnoreCase( DriverVersion.NOT_SPECIFIED.name()); String driv...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void exportDriver(String variableValue) { driverPath = variableValue; Optional<String> exportParameter = getExportParameter(); if (!config.isAvoidExport() && exportParameter.isPresent()) { String variableName = exportParamet...
#fixed code protected void exportDriver(String variableValue) { downloadedDriverPath = variableValue; Optional<String> exportParameter = getExportParameter(); if (!config.isAvoidExport() && exportParameter.isPresent()) { String variableName = exportPar...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected String getTargetPath() { String path = (String) resolveConfigKey("wdm.targetPath", targetPath); if (path.contains(HOME)) { path = path.replace(HOME, System.getProperty("user.home")); } return path; } ...
#fixed code protected String getTargetPath() { String path = null; Object resolved = resolveConfigKey("wdm.targetPath", targetPath); if (resolved != null) { path = (String) resolved; if (path.contains(HOME)) { path = path.re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testServer() throws IOException { String serverUrl = String.format("http://localhost:%s/%s", serverPort, path); OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder().url(serverUrl)...
#fixed code @Test public void testServer() throws IOException { String serverUrl = String.format("http://localhost:%s/%s", serverPort, path); OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder().url(serverUrl).build...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void reset() { config().reset(); mirrorLog = false; versionToDownload = null; forcedArch = false; forcedOs = false; retryCount = 0; isSnap = false; } #location 4 ...
#fixed code protected void reset() { config().reset(); mirrorLog = false; driverVersionToDownload = null; forcedArch = false; forcedOs = false; retryCount = 0; isSnap = false; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void downloadAndExport(String driverVersion) throws IOException { Optional<String> driverInCache = searchDriverInCache(driverVersion); String versionStr = isUnknown(driverVersion) ? "(latest version)" : driverVersion; i...
#fixed code protected void downloadAndExport(String driverVersion) throws IOException { Optional<String> driverInCache = searchDriverInCache(driverVersion); String versionStr = isUnknown(driverVersion) ? "(latest version)" : driverVersion; if (dri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(final String[] args) throws Throwable { toInfinityAndBeyond(); logger.info("Starting ..."); final ScheduledExecutorService downloadExecutor = Executors .newSingleThreadScheduledExecutor(new NameThreadFac...
#fixed code public static void main(final String[] args) throws Throwable { toInfinityAndBeyond(); logger.info("Starting ..."); final ScheduledExecutorService downloadExecutor = Executors .newSingleThreadScheduledExecutor(new NameThreadFactory("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(final String... args) throws Throwable { toInfinityAndBeyond(); final Options opts = new Options(); opts.addOption("n", "basename", true, "The base name of the simulator instance"); opts.addOption(null, "name-fac...
#fixed code public static void main(final String... args) throws Throwable { toInfinityAndBeyond(); final Options opts = new Options(); opts.addOption( builder("n") .longOpt("basename") .hasArg().a...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String authCode = req.getParameter("code"); String uri = "http://localhost:9090/auth/realms/master/protocol/openid-conne...
#fixed code @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ConsoleSetting settings = ConsoleSetting.getInstance(); String authCode = req.getParameter("code"); String uri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(final String[] args) throws Throwable { toInfinityAndBeyond(); logger.info("Starting ..."); final ScheduledExecutorService downloadExecutor = Executors .newSingleThreadScheduledExecutor(new NameThreadFac...
#fixed code public static void main(final String[] args) throws Throwable { toInfinityAndBeyond(); logger.info("Starting ..."); final ScheduledExecutorService downloadExecutor = Executors .newSingleThreadScheduledExecutor(new NameThreadFactory("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("Duplicates") private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); String iconResource = icon.getResource(); // // Check if the resource is an HTTP URL or not ...
#fixed code @SuppressWarnings("Duplicates") private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); String iconResource = icon.getResource(); // // Check if the resource is an HTTP URL or not if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("Duplicates") private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); String iconResource = icon.getResource(); // // Check if the resource is an HTTP URL or not ...
#fixed code @SuppressWarnings("Duplicates") private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); String iconResource = icon.getResource(); // // Check if the resource is an HTTP URL or not if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("Duplicates") private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); String iconResource = icon.getResource(); // // Check if the resource is an HTTP URL or not ...
#fixed code @SuppressWarnings("Duplicates") private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); String iconResource = icon.getResource(); // // Check if the resource is an HTTP URL or not if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String authCode = req.getParameter("code"); String uri = "http://localhost:9090/auth/realms/master/protocol/openid-conne...
#fixed code @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ConsoleSetting settings = ConsoleSetting.getInstance(); String authCode = req.getParameter("code"); String uri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFil...
#fixed code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { int nblocks = blockIds.length; if (modifiesInedges) { int startStreamBlock = rangeStartEdgePtr / blocksize; for(int i=0; i < nblocks; i++) { String blockFilename =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadVertices(int windowStart, int windowEnd, ChiVertex[] vertices) throws FileNotFoundException, IOException { if (adjData == null) { loadAdj(); edataFilesize = (int) new File(edgeDataFilename).length(); ...
#fixed code public void loadVertices(int windowStart, int windowEnd, ChiVertex[] vertices) throws FileNotFoundException, IOException { if (adjData == null) { blocksize = ChiFilenames.getBlocksize(converter.sizeOf()); loadAdj(); loadEdata(); } System.out.println("Load memo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFil...
#fixed code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { int nblocks = blockIds.length; if (modifiesInedges) { int startStreamBlock = rangeStartEdgePtr / blocksize; for(int i=0; i < nblocks; i++) { String blockFilename =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadVertices(int windowStart, int windowEnd, ChiVertex[] vertices) throws FileNotFoundException, IOException { if (adjData == null) { loadAdj(); edataFilesize = (int) new File(edgeDataFilename).length(); ...
#fixed code public void loadVertices(int windowStart, int windowEnd, ChiVertex[] vertices) throws FileNotFoundException, IOException { if (adjData == null) { blocksize = ChiFilenames.getBlocksize(converter.sizeOf()); loadAdj(); loadEdata(); } System.out.println("Load memo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFil...
#fixed code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFilename)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFil...
#fixed code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFilename)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { byte[] data = dataBlockManager.getRawBlock(blockId); if (modifiesInedges) { FileOutputStream fos = new FileOutputStream(new File(edgeDataFil...
#fixed code public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException { int nblocks = blockIds.length; if (modifiesInedges) { int startStreamBlock = rangeStartEdgePtr / blocksize; for(int i=0; i < nblocks; i++) { String blockFilename =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void send() throws Exception { logger.debug("event=send_sync_http_request endpoint=" + endpoint + "\" message=\"" + message + "\""); if ((message == null) || (endpoint == null)) { logger.debug("event=send_http_request error_code=MissingParameters...
#fixed code @Override public void send() throws Exception { if ((message == null) || (endpoint == null)) { logger.debug("event=send_http_request error_code=MissingParameters endpoint=" + endpoint + "\" message=\"" + message + "\""); throw new Exception("Message and Endpoint must b...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (redirectUnauthenticatedUser(request, response)) { return; } CMBControllerServlet.valueAccumulator.initializeAllCounters(); res...
#fixed code @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (redirectUnauthenticatedUser(request, response)) { return; } CMBControllerServlet.valueAccumulator.initializeAllCounters(); response....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (redirectUnauthenticatedUser(request, response)) { return; } CMBControllerServlet.valueAccumulator.initializeAllCounters(); respo...
#fixed code @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (redirectUnauthenticatedUser(request, response)) { return; } CMBControllerServlet.valueAccumulator.initializeAllCounters(); response.se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void state4ENTITY_LENGTH() throws ProtocolException { // get content length int clen = Integer.parseInt(httpMessage.getFirstHeader(HttpHeaders.CONTENT_LENGTH.getName()).getValue()); if (clen < 0) { throw new ProtocolException(ProtocolExceptionType.UNEXPE...
#fixed code protected void state4ENTITY_LENGTH() throws ProtocolException { // get content length int clen = Integer.parseInt(httpMessage.getFirstHeader(HttpHeaderType.CONTENT_LENGTH.getName()).getValue()); if (clen < 0) { throw new ProtocolException(ProtocolExceptionType.UNEXPECTE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { long timeoutMillis = unit.toMillis(timeout); long endTime = System.currentTimeMillis() + timeoutMillis; synchronized (this) { if (ready) return ready; ...
#fixed code @Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { long timeoutMillis = unit.toMillis(timeout); long endTime = System.currentTimeMillis() + timeoutMillis; synchronized (this) { if (done) return done; if (tim...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String readFileAsString(String filePath) throws IOException { byte[] buffer = new byte[(int) getFile(filePath).length()]; BufferedInputStream inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath))); ...
#fixed code public static String readFileAsString(String filePath) throws IOException { byte[] buffer = new byte[(int) getFile(filePath).length()]; BufferedInputStream bis = null; try { bis = new BufferedInputStream(new FileInputStream(getFile(filePath))); bis.read(buffer); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void state4ENTITY() throws ProtocolException { boolean done = skip(CR, LF); if (!done) { return; } // content length if (httpMessage.getFirstHeader(HttpHeaders.CONTENT_LENGTH.getName()) != null) { entity = new HttpEntity(); entity.setChars...
#fixed code protected void state4ENTITY() throws ProtocolException { boolean done = skip(CR, LF); if (!done) { return; } // content length if (httpMessage.getFirstHeader(HttpHeaderType.CONTENT_LENGTH.getName()) != null) { entity = new HttpEntity(); entity.setContentT...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void writeStringToFile(String content, String filePath) throws Exception { BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(getFile(filePath))); outputStream.write(content.getBytes()); ...
#fixed code public static void writeStringToFile(String content, String filePath) throws Exception { BufferedOutputStream bos = null; try { bos = new BufferedOutputStream(new FileOutputStream(getFile(filePath))); bos.write(content.getBytes()); bos.flush(); } finally { i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void startElasticsearchRestClient() throws IOException { testClusterPort = Integer.parseInt(System.getProperty("tests.cluster.port", DEFAULT_TEST_CLUSTER_PORT.toString())); testClusterHost = System.getProperty("tests.cluste...
#fixed code @BeforeClass public static void startElasticsearchRestClient() throws IOException { testClusterPort = Integer.parseInt(System.getProperty("tests.cluster.port", DEFAULT_TEST_CLUSTER_PORT.toString())); testClusterHost = System.getProperty("tests.cluster.host...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Collection<FileAbstractModel> getFiles(String dir) { if (logger.isDebugEnabled()) logger.debug("Listing local files from {}", dir); File[] files = new File(dir).listFiles(); Collection<FileAbstractModel> result = new ArrayLi...
#fixed code @Override public Collection<FileAbstractModel> getFiles(String dir) { logger.debug("Listing local files from {}", dir); File[] files = new File(dir).listFiles(); Collection<FileAbstractModel> result; if (files != null) { result...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void start() throws Exception { logger.info("Starting FS crawler"); if (loop < 0) { logger.info("FS crawler started in watch mode. It will run unless you stop it with CTRL+C."); } if (loop == 0 && !rest) { ...
#fixed code public void start() throws Exception { logger.info("Starting FS crawler"); if (loop < 0) { logger.info("FS crawler started in watch mode. It will run unless you stop it with CTRL+C."); } if (loop == 0 && !rest) { closed...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected SuggestRefreshResponse newResponse(SuggestRefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shard...
#fixed code @Override protected SuggestRefreshResponse newResponse(SuggestRefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List<ShardOperationFailedException> shardFailur...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfigure() throws Exception { double epsilon = 0.000000000000001 ; Settings smsemoaSettings = new SMSEMOASettings("Fonseca"); Algorithm algorithm = smsemoaSettings.configure() ; Problem problem = new Fonseca("Real") ; SBXCrosso...
#fixed code @Test public void testConfigure() throws Exception { double epsilon = 0.000000000000001 ; Settings smsemoaSettings = new SMSEMOASettings("Fonseca"); SMSEMOA algorithm = (SMSEMOA) smsemoaSettings.configure() ; Problem problem = new Fonseca("Real") ; SBXCro...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator ...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indica...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadInstance() { try { File archivo = new File(fileName_); FileReader fr = null; BufferedReader br = null; fr = new FileReader(archivo); br = new BufferedReader(fr); // File reading String line; int lineCnt ...
#fixed code public void loadInstance() throws IOException { File archivo = new File(fileName_); FileReader fr = null; BufferedReader br = null; fr = new FileReader(archivo); br = new BufferedReader(fr); // File reading String line; int lineCnt = 0; line...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SolutionSet execute() throws JMException, ClassNotFoundException { initParams(); success_ = false; globalBest_ = null ; //->Step 1 (and 3) Create the initial population and evaluate for (int i = 0; i < swarmSize_; i++) { Solution particl...
#fixed code public SolutionSet execute() throws JMException, ClassNotFoundException { initParams(); success_ = false; // Step 1 Create the initial population and evaluate for (int i = 0; i < swarmSize_; i++) { Solution particle = new Solution(problem_); proble...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator ...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indica...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadInstance() { try { File archivo = new File(fileName_); FileReader fr = null; BufferedReader br = null; fr = new FileReader(archivo); br = new BufferedReader(fr); // File reading String line; int lineCnt ...
#fixed code public void loadInstance() throws IOException { File archivo = new File(fileName_); FileReader fr = null; BufferedReader br = null; fr = new FileReader(archivo); br = new BufferedReader(fr); // File reading String line; int lineCnt = 0; line...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator ...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indica...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { neighborhood_ = parentThread_.neighborhood_; problem_ = parentThread_.problem_; lambda_ = parentThread_.lambda_; population_ = parentThread_.population_; z_ = parentThread_.z_; indArray_ = parentThread_.indArray_; barrier_ =...
#fixed code public void run() { neighborhood_ = parentThread_.neighborhood_; problem_ = parentThread_.problem_; lambda_ = parentThread_.lambda_; population_ = parentThread_.population_; z_ = parentThread_.z_; indArray_ = parentThread_.indArray_; barrier_ = paren...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator ...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indica...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public void loadColumnVectorFromFile(String file, int rows, double[] column) throws JMetalException { try { BufferedReader brSrc = new BufferedReader(new FileReader(file)); loadColumnVector(brSrc, rows, column); brSrc.close(); } catch ...
#fixed code static public void loadColumnVectorFromFile(String file, int rows, double[] column) throws JMetalException { try { BufferedReader brSrc = new BufferedReader( new InputStreamReader(new FileInputStream(ClassLoader.getSystemResourc...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfigure2() throws Exception { double epsilon = 0.000000000000001 ; Settings smsemoaSettings = new SMSEMOASettings("Fonseca"); Algorithm algorithm = smsemoaSettings.configure(configuration_) ; Problem problem = new Fonseca("Real") ...
#fixed code @Test public void testConfigure2() throws Exception { double epsilon = 0.000000000000001 ; Settings smsemoaSettings = new SMSEMOASettings("Fonseca"); SMSEMOA algorithm = (SMSEMOA) smsemoaSettings.configure(configuration) ; Problem problem = new Fonseca("Real")...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfigure() throws Exception { double epsilon = 0.000000000000001 ; Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5"); Algorithm algorithm = nsgaIISettings.configure() ; Problem problem = new ZDT5("Binary") ; SinglePoi...
#fixed code @Test public void testConfigure() throws Exception { double epsilon = 0.000000000000001 ; Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5"); NSGAII algorithm = (NSGAII)nsgaIISettings.configure() ; Problem problem = new ZDT5("Binary") ; SinglePoin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator i...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indicat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public void loadMatrixFromFile(String file, int rows, int columns, double[][] matrix) throws JMetalException { try { BufferedReader brSrc = new BufferedReader(new FileReader(file)); loadMatrix(brSrc, rows, columns, matrix); brSrc.close(); ...
#fixed code static public void loadMatrixFromFile(String file, int rows, int columns, double[][] matrix) throws JMetalException { try { BufferedReader brSrc = new BufferedReader( new InputStreamReader(new FileInputStream(ClassLoader.getSyst...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfigure2() throws Exception { double epsilon = 0.000000000000001 ; Settings smsemoaSettings = new FastSMSEMOASettings("Fonseca"); Algorithm algorithm = smsemoaSettings.configure(configuration_) ; Problem problem = new Fonseca("Rea...
#fixed code @Test public void testConfigure2() throws Exception { double epsilon = 0.000000000000001 ; Settings fastSMEEMOASettings = new FastSMSEMOASettings("Fonseca"); FastSMSEMOA algorithm = (FastSMSEMOA) fastSMEEMOASettings.configure(configuration) ; Problem problem =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() throws JMException { double epsilon = 0.000000000000001; Settings GDE3Settings = new GDE3_Settings("Fonseca"); Algorithm algorithm = GDE3Settings.configure(); //Problem problem = new Fonseca("Real"); DifferentialEvolutionCro...
#fixed code @Test public void test() throws JMException { double epsilon = 0.000000000000001; GDE3_Settings GDE3Settings = new GDE3_Settings("Fonseca"); GDE3 algorithm = (GDE3) GDE3Settings.configure(); DifferentialEvolutionCrossover crossover = (DifferentialEvolut...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int compare(Solution o1, Solution o2) { if (o1 == null) { return 1; } else if (o2 == null) { return -1; } int flagComparatorRank = RANK_COMPARATOR.compare(o1, o2); if (flagComparatorRank != 0) { return flagComparat...
#fixed code @Override public int compare(Solution o1, Solution o2) { if (o1 == null) { return 1; } else if (o2 == null) { return -1; } int flagComparatorRank = RANK_COMPARATOR.compare(o1, o2); if (flagComparatorRank != 0) { return flagComparatorRank...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfigure2() throws Exception { double epsilon = 0.000000000000001 ; Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5"); Algorithm algorithm = nsgaIISettings.configure(configuration_) ; Problem problem = new ZDT5("Binary") ;...
#fixed code @Test public void testConfigure2() throws Exception { double epsilon = 0.000000000000001 ; Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5"); NSGAII algorithm = (NSGAII)nsgaIISettings.configure(configuration_) ; Problem problem = new ZDT5("Binary") ; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator ...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indica...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int compare(Solution solution1, Solution solution2) { if (solution1 == null) { return 1; } else if (solution2 == null) { return -1; } if ((int)solution1.getAlgorithmAttributes().getAttribute("Rank") < (int)solution2.getAlgor...
#fixed code @Override public int compare(Solution solution1, Solution solution2) { if (solution1 == null) { return 1; } else if (solution2 == null) { return -1; } if (NSGAIIAttr.getAttributes(solution1).getRank() < NSGAIIAttr.getAttributes(solution2).getRank(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public void loadNMatrixFromFile(String file, int N, int rows, int columns, double[][][] matrix) throws JMetalException { try { BufferedReader brSrc = new BufferedReader(new FileReader(file)); for (int i = 0; i < N; i++) { loadMatrix(brSr...
#fixed code static public void loadNMatrixFromFile(String file, int N, int rows, int columns, double[][][] matrix) throws JMetalException { try { BufferedReader brSrc = new BufferedReader( new InputStreamReader(new FileInputStream(ClassLoad...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator i...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator indicat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConfigure() throws Exception { double epsilon = 0.000000000000001 ; Settings smsemoaSettings = new FastSMSEMOASettings("Fonseca"); Algorithm algorithm = smsemoaSettings.configure() ; Problem problem = new Fonseca("Real") ; SBXCr...
#fixed code @Test public void testConfigure() throws Exception { double epsilon = 0.000000000000001 ; Settings fastSMEEMOASettings = new FastSMSEMOASettings("Fonseca"); FastSMSEMOA algorithm = (FastSMSEMOA) fastSMEEMOASettings.configure() ; Problem problem = new Fonseca("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test2() throws JMException { double epsilon = 0.000000000000001; Settings GDE3Settings = new GDE3_Settings("Fonseca"); Algorithm algorithm = GDE3Settings.configure(configuration_); //Problem problem = new Fonseca("Real"); Different...
#fixed code @Test public void test2() throws JMException { double epsilon = 0.000000000000001; Settings GDE3Settings = new GDE3_Settings("Fonseca"); GDE3 algorithm = (GDE3) GDE3Settings.configure(configuration_); DifferentialEvolutionCrossover crossover = (Differen...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndica...
#fixed code public static void main(String[] args) throws JMException, SecurityException, IOException, ClassNotFoundException { Problem problem; Algorithm algorithm; Operator crossover; Operator mutation; Operator selection; QualityIndicator in...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws JMetalException, IOException { ExperimentData experimentData = new ExperimentData.Builder("Experiment2") .algorithmNameList(new String[]{"NSGAII", "SMPSO", "MOCell"}) .problemList(new String[]{"ZDT1", "ZDT2", "...
#fixed code public static void main(String[] args) throws JMetalException, IOException { ExperimentData experimentData = new ExperimentData.Builder("Experiment2") .algorithmNameList(new String[]{"NSGAII", "SMPSO", "MOCell"}) .problemList(new String[]{"ZDT1", "ZDT2", "ZDT3",...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static public void loadRowVectorFromFile(String file, int columns, double[] row) throws JMetalException { try { BufferedReader brSrc = new BufferedReader(new FileReader(file)); loadRowVector(brSrc, columns, row); brSrc.close(); } catch (Excep...
#fixed code static public void loadRowVectorFromFile(String file, int columns, double[] row) throws JMetalException { try { BufferedReader brSrc = new BufferedReader( new InputStreamReader(new FileInputStream(ClassLoader.getSystemResource(f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void updateOfSolutions(Solution indiv, int id, int type) { // indiv: child solution // id: the id of current subproblem // type: update solutions in - neighborhood (1) or whole population (otherwise) int size; int time; time = 0; if (type == 1) { size ...
#fixed code void initIdealPoint() throws JMException, ClassNotFoundException { for (int i = 0; i < problem_.getNumberOfObjectives(); i++) { z_[i] = 1.0e+30; indArray_[i] = new Solution(problem_); problem_.evaluate(indArray_[i]); evaluations_++; } // for for (int i = 0; i ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int compare(Solution o1, Solution o2) { if (o1 == null) { return 1; } else if (o2 == null) { return -1; } int flagComparatorRank = RANK_COMPARATOR.compare(o1, o2); if (flagComparatorRank != 0) { return flagComparat...
#fixed code @Override public int compare(Solution o1, Solution o2) { if (o1 == null) { return 1; } else if (o2 == null) { return -1; } int flagComparatorRank = RANK_COMPARATOR.compare(o1, o2); if (flagComparatorRank != 0) { return flagComparatorRank...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static LoggedInStatus webappLogin(HttpServletRequest request, HttpServletResponse response, boolean requiresAdminRights) throws IOException { // check if there a session and a login information attached to it HttpSession session = request.getSession(true); Lo...
#fixed code public static LoggedInStatus webappLogin(HttpServletRequest request, HttpServletResponse response, boolean requiresAdminRights) throws IOException { // check if there a session and a login information attached to it //HttpSession session = request.getSession(true); //Logg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printLine(SearchResult result){ StringBuilder builder = new StringBuilder(); HashMap<String, Object> extraFields = result.getExtraData(); for (String tag : tagsOrder) { Object temp1 = extraFields.get(tag); String temp1String = temp1.toString(...
#fixed code private void printLine(SearchResult result){ StringBuilder builder = new StringBuilder(); HashMap<String, Object> extraFields = result.getExtraData(); for (String tag : tagsOrder) { Object temp1 = extraFields.get(tag); final String s = (temp1 != null) ? te...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void printLine(SearchResult result){ StringBuilder builder = new StringBuilder(); HashMap<String, Object> extraFields = result.getExtraData(); for (String tag : tagsOrder) { Object temp1 = extraFields.get(tag); String s = StringUtils.trimToEmpty(te...
#fixed code private void printLine(SearchResult result){ StringBuilder builder = new StringBuilder(); HashMap<String, Object> extraFields = result.getExtraData(); for (String tag : tagsOrder) { Object temp1 = extraFields.get(tag); String s = (temp1 != null) ? StringUtils.tr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void doGetExportCvs(HttpServletRequest req, HttpServletResponse resp) throws IOException{ resp.setHeader("Content-disposition","attachment; filename=QueryResultsExport.csv"); String queryString = req.getParameter("query"); String[] fields = req.getParameterVa...
#fixed code private void doGetExportCvs(HttpServletRequest req, HttpServletResponse resp) throws IOException{ resp.setHeader("Content-disposition","attachment; filename=QueryResultsExport.csv"); String queryString = req.getParameter("query"); String[] fields = req.getParameterValues("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void printFile(byte[] bytes) throws Exception { InputStream in; if(encrypt){ cipher.init(Cipher.ENCRYPT_MODE, key); byte[] encryptedBytes = cipher.doFinal(bytes); in = new ByteArrayInputStream(encryptedBytes);...
#fixed code public void printFile(byte[] bytes) throws IOException { if (encrypt) { byte[] encryptedBytes = new byte[0]; try { cipher.init(Cipher.ENCRYPT_MODE, key); encryptedBytes = cipher.doFinal(bytes); } ca...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //resp.addHeader("Access-Control-Allow-Origin", "*"); HttpSession session = req.getSession(false); LoggedIn mLoggedIn = Session.getUse...
#fixed code @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String token = req.getHeader("Authorization"); User user = Authentication.getInstance().getUsername(token); if(user == null) { resp.sendError(40...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //resp.addHeader("Access-Control-Allow-Origin", "*"); //Try login // Does not require admini rights. LoggedIn mLogge...
#fixed code @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //resp.addHeader("Access-Control-Allow-Origin", "*"); //Try login // Does not require admini rights. LoggedIn mLoggedIn = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public JSONResource json(URI anUri) throws IOException, MalformedURLException { JSONObject json = JSONObject.class.cast(anUri.toURL().openConnection().getContent()); return new JSONResource(json); } #location 2 ...
#fixed code public JSONResource json(URI anUri) throws IOException { return doGET(anUri, new JSONResource()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public JSONResource json(URI anUri) throws IOException, MalformedURLException { JSONObject json = JSONObject.class.cast(anUri.toURL().openConnection().getContent()); return new JSONResource(json); } #location 2 ...
#fixed code public JSONResource json(URI anUri) throws IOException { return doGET(anUri, new JSONResource()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive", "Name,Manufacturer,Model,SerialNumber,Size"...
#fixed code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); readMap.clear(); writeMap.clear(); populateReadWriteMaps(); Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Display[] getDisplays() { List<Display> displays = new ArrayList<Display>(); ArrayList<String> xrandr = ExecutingCommand.runNative("xrandr --verbose"); boolean foundEdid = false; StringBuilder sb = new StringBuilder(); ...
#fixed code public static Display[] getDisplays() { List<Display> displays = new ArrayList<Display>(); ArrayList<String> xrandr = ExecutingCommand.runNative("xrandr --verbose"); if (xrandr != null) { boolean foundEdid = false; StringBuilder...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Map<Integer, PerfCounterBlock> buildProcessMapFromPerfCounters(Collection<Integer> pids) { Map<Integer, PerfCounterBlock> processMap = new HashMap<>(); Pair<List<String>, Map<ProcessPerformanceProperty, List<Long>>> instanceValues = Process...
#fixed code public static Map<Integer, PerfCounterBlock> buildProcessMapFromPerfCounters(Collection<Integer> pids) { Map<Integer, PerfCounterBlock> processMap = new HashMap<>(); Pair<List<String>, Map<ProcessPerformanceProperty, List<Long>>> instanceValues = ProcessInform...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partition...
#fixed code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partitions ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public float getProcessorLoad() { // should be same as on Mac. Not tested. ArrayList<String> topResult = ExecutingCommand.runNative("top -l 1 -R -F -n1"); // cpu load is in [3] String[] idle = topResult.get(3).split(" "); // idle value is in [6] return 100 - Float...
#fixed code public float getProcessorLoad() { Scanner in = null; try { in = new Scanner(new FileReader("/proc/stat")); } catch (FileNotFoundException e) { System.err.println("Problem with: /proc/stat"); System.err.println(e.getMessage()); return -1; } in.useDelimiter("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getAvailable() { long returnCurrentUsageMemory = 0; Scanner in = null; try { in = new Scanner(new FileReader("/proc/meminfo")); } catch (FileNotFoundException e) { return returnCurrentUsageMemory; } in.useDelimiter("\n"); while (in.hasNext()...
#fixed code public long getAvailable() { long availableMemory = 0; List<String> memInfo = null; try { memInfo = FileUtil.readFile("/proc/meminfo"); } catch (IOException e) { System.err.println("Problem with: /proc/meminfo"); System.err.println(e.getMessage()); return ava...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) { Map<T, Long> valueMap = queryValuesFromPDH(propertyEnum, perfObject); if (valueMap.isEmpty()) { return que...
#fixed code public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) { // Check without locking for performance if (!failedQueryCache.contains(perfObject)) { failedQueryCacheLock.lock...
Below is the vulnerable code, please generate the patch based on the following information.