input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public void testToBean() throws SQLException, ParseException { int rowCount = 0; TestBean b = null; while (this.rs.next()) { b = (TestBean) processor.toBean(this.rs, TestBean.class); assertNotNull(b); rowCount...
#fixed code public void testToBean() throws SQLException, ParseException { TestBean row = null; assertTrue(this.rs.next()); row = (TestBean) processor.toBean(this.rs, TestBean.class); assertEquals("1", row.getOne()); assertEquals("2", row.getTwo()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initAuthEnv() { String paramUserName = getInitParameter(InitServletData.PARAM_NAME_USERNAME); if (!StringUtils.isEmpty(paramUserName)) { this.initServletData.setUsername(paramUserName); } String paramPassword = g...
#fixed code private void initAuthEnv() { String paramUserName = getInitParameter(InitServletData.PARAM_NAME_USERNAME); if (!StringUtils.isEmpty(paramUserName)) { this.initServletData.setUsername(paramUserName); } String paramPassword = getInit...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() { MemoryIndex<String> mi = new MemoryIndex<String>(); FileIterator instanceFileIterator = IOUtil.instanceFileIterator("/home/ansj/workspace/ansj_seg/library/default.dic", IOUtil.UTF8); long start = System.currentTimeMillis(); System.ou...
#fixed code @Test public void test() { MemoryIndex<String> mi = new MemoryIndex<String>(); // FileIterator instanceFileIterator = IOUtil.instanceFileIterator("/home/ansj/workspace/ansj_seg/library/default.dic", IOUtil.UTF8); // long start = System.currentTimeMillis(); // System.ou...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void saveModel(String filePath) throws IOException { BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filePath))) ; writeMap(bw,idWordMap) ; writeMap(bw,word2Mc) ; writeMap(bw,ww2Mc.get()) ; } #location 5 ...
#fixed code public void saveModel(String filePath) throws IOException { ObjectOutput oot = new ObjectOutputStream(new FileOutputStream(filePath)); oot.writeObject(this); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int getIntValue(String value) { if (StringUtil.isBlank(value)) { return 0; } return castToInt(value); } #location 5 #vulnerability type NULL_DEREFERENCE
#fixed code public static int getIntValue(String value) { if (StringUtil.isBlank(value)) { return 0; } return castToInteger(value); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void saveModel(String filePath) throws IOException { BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filePath))) ; writeMap(bw,idWordMap) ; writeMap(bw,word2Mc) ; writeMap(bw,ww2Mc.get()) ; } #location 7 ...
#fixed code public void saveModel(String filePath) throws IOException { ObjectOutput oot = new ObjectOutputStream(new FileOutputStream(filePath)); oot.writeObject(this); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override @SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine") public synchronized void launch(SlaveComputer computer, TaskListener listener) { if (!(computer instanceof KubernetesComputer)) { throw new Ille...
#fixed code @Override @SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine") public synchronized void launch(SlaveComputer computer, TaskListener listener) { if (!(computer instanceof KubernetesComputer)) { throw new IllegalArg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public AbstractFolderProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException { if (form == null) { return null; } // ignore modifications silently and return the unmodified object if the user ...
#fixed code @Override public AbstractFolderProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException { if (form == null) { return null; } // ignore modifications silently and return the unmodified object if the user ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Pod getPodTemplate(KubernetesSlave slave, Label label) { final PodTemplate template = getTemplate(label); String id = getIdForLabel(label); Pod pod = new Pod(); KubernetesHelper.setName(pod, slave.getNodeName()); pod.get...
#fixed code private Pod getPodTemplate(KubernetesSlave slave, Label label) { final PodTemplate template = getTemplate(label); String id = getIdForLabel(label); List<EnvVar> env = new ArrayList<EnvVar>(3); // always add some env vars env.add(new Env...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE...
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE, "Bui...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Pod getPodTemplate(KubernetesSlave slave, Label label) { DockerTemplate template = getTemplate(label); String id = getIdForLabel(label); Pod podTemplate = new Pod(); podTemplate.setId(slave.getNodeName()); // labels ...
#fixed code private Pod getPodTemplate(KubernetesSlave slave, Label label) { DockerTemplate template = getTemplate(label); String id = getIdForLabel(label); Pod podTemplate = new Pod(); podTemplate.setId(slave.getNodeName()); // labels pod...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void validatePod(Pod pod) { assertEquals(ImmutableMap.of("some-label", "some-label-value"), pod.getMetadata().getLabels()); // check containers Map<String, Container> containers = new HashMap<>(); for (Container c : pod.getSpec()...
#fixed code private void validatePod(Pod pod) { assertEquals(ImmutableMap.of("some-label", "some-label-value"), pod.getMetadata().getLabels()); // check containers Map<String, Container> containers = pod.getSpec().getContainers().stream() .collect...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE...
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE, "Bui...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void validatePod(Pod pod) { assertEquals(ImmutableMap.of("some-label", "some-label-value"), pod.getMetadata().getLabels()); // check containers Map<String, Container> containers = new HashMap<>(); for (Container c : pod.getSpec()...
#fixed code private void validatePod(Pod pod) { assertEquals(ImmutableMap.of("some-label", "some-label-value"), pod.getMetadata().getLabels()); // check containers Map<String, Container> containers = pod.getSpec().getContainers().stream() .collect...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException, ExecutionException { L...
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException, ExecutionException { LOGGER....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static List<KubernetesCloud> getUsageRestrictedKubernetesClouds() { List<KubernetesCloud> clouds = new ArrayList<>(); for (Cloud cloud : Jenkins.getInstance().clouds) { if(cloud instanceof KubernetesCloud) { if (((Kub...
#fixed code private static List<KubernetesCloud> getUsageRestrictedKubernetesClouds() { List<KubernetesCloud> clouds = Jenkins.get().clouds .getAll(KubernetesCloud.class) .stream() .filter(KubernetesCloud::isUsageRestricted) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override @SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine") public synchronized void launch(SlaveComputer computer, TaskListener listener) { if (!(computer instanceof KubernetesComputer)) { throw new Ille...
#fixed code @Override @SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "This is fine") public synchronized void launch(SlaveComputer computer, TaskListener listener) { if (!(computer instanceof KubernetesComputer)) { throw new IllegalArg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Nonnull public KubernetesCloud getKubernetesCloud() { Cloud cloud = Jenkins.getInstance().getCloud(getCloudName()); if (cloud instanceof KubernetesCloud) { return (KubernetesCloud) cloud; } else { throw new IllegalSta...
#fixed code @Nonnull public KubernetesCloud getKubernetesCloud() { return getKubernetesCloud(getCloudName()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void push(String item) throws IOException { if (getRun() == null) { LOGGER.warning("run is null, cannot push"); return; } synchronized (getRun()) { BulkChange bc = new BulkChange(getRun()); t...
#fixed code public void push(String item) throws IOException { if (run == null) { LOGGER.warning("run is null, cannot push"); return; } synchronized (run) { BulkChange bc = new BulkChange(run); try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void onResume() { super.onResume(); Cloud cloud = Jenkins.getInstance().getCloud(cloudName); if (cloud == null) { throw new RuntimeException(String.format("Cloud does not exist: %s", cloudName)); } ...
#fixed code @Override public void onResume() { super.onResume(); Cloud cloud = Jenkins.get().getCloud(cloudName); if (cloud == null) { throw new RuntimeException(String.format("Cloud does not exist: %s", cloudName)); } if (!(cloud i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static boolean userHasAdministerPermission() { return Jenkins.getInstance().getACL().hasPermission(Jenkins.ADMINISTER); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private static boolean userHasAdministerPermission() { return Jenkins.get().hasPermission(Jenkins.ADMINISTER); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException, ExecutionException { L...
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException, ExecutionException { LOGGER....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Node call() throws Exception { RetentionStrategy retentionStrategy; if (t.getIdleMinutes() == 0) { retentionStrategy = new OnceRetentionStrategy(cloud.getRetentionTimeout()); } else { retentionStrategy = new CloudRe...
#fixed code public Node call() throws Exception { return KubernetesSlave .builder() .podTemplate(cloud.getUnwrappedTemplate(t)) .cloud(cloud) .build(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void runWithDeadlineSeconds() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "Deadline"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("runWithDeadlineSeconds.groovy") , true)); ...
#fixed code @Test public void runWithDeadlineSeconds() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "Deadline"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("runWithDeadlineSeconds.groovy") , true)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean start() throws Exception { Cloud cloud = Jenkins.getInstance().getCloud(cloudName); if (cloud == null) { throw new AbortException(String.format("Cloud does not exist: %s", cloudName)); } if (!(clo...
#fixed code @Override public boolean start() throws Exception { Cloud cloud = Jenkins.get().getCloud(cloudName); if (cloud == null) { throw new AbortException(String.format("Cloud does not exist: %s", cloudName)); } if (!(cloud instanceof ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull Label label) throws Exception { if (containerCap == 0) { return true; } KubernetesClient client = connect(); String templateNamespace = template...
#fixed code private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull Label label) throws Exception { if (containerCap == 0) { return true; } KubernetesClient client = connect(); String templateNamespace = template.getNa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String pop() throws IOException { if (getRun() == null) { LOGGER.warning("run is null, cannot pop"); return null; } synchronized (getRun()) { BulkChange bc = new BulkChange(getRun()); try { ...
#fixed code public String pop() throws IOException { if (run == null) { LOGGER.warning("run is null, cannot pop"); return null; } synchronized (getRun()) { BulkChange bc = new BulkChange(getRun()); try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void runInPod() throws Exception { List<PodTemplate> templates = null; while (b.isBuilding() && (templates = podTemplatesWithLabel(name.getMethodName(), cloud.getAllTemplates())).isEmpty()) { LOGGER.log(Level.INFO, "Waiting f...
#fixed code @Test public void runInPod() throws Exception { SemaphoreStep.waitForStart("podTemplate/1", b); List<PodTemplate> templates = podTemplatesWithLabel(name.getMethodName(), cloud.getAllTemplates()); assertThat(templates, hasSize(1)); Semaphore...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Pod getPodTemplate(KubernetesSlave slave, Label label) { DockerTemplate template = getTemplate(label); String id = getIdForLabel(label); Pod podTemplate = new Pod(); podTemplate.setId(slave.getNodeName()); // labels ...
#fixed code private Pod getPodTemplate(KubernetesSlave slave, Label label) { DockerTemplate template = getTemplate(label); String id = getIdForLabel(label); Pod podTemplate = new Pod(); /* podTemplate.setId(slave.getNodeName()); // labels...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public InputStream getData(String resourceId) throws IOException { LoadableResource load = this.resources.get(resourceId); if (Objects.nonNull(load)) { load.getDataStream(); } throw new IllegalArgumentException("...
#fixed code @Override public InputStream getData(String resourceId) throws IOException { LoadableResource load = this.resources.get(resourceId); if (Objects.nonNull(load)) { return load.getDataStream(); } throw new IllegalArgumentException(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { if (!isAvailable(conversionQuery)) { return null; } CurrencyUnit base = conversionQuery.getBaseCurrency(); CurrencyUnit term = conversionQuer...
#fixed code @Override public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { if (!isAvailable(conversionQuery)) { return null; } CurrencyUnit base = conversionQuery.getBaseCurrency(); CurrencyUnit term = conversionQuery.getC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected boolean load(URI itemToLoad, boolean fallbackLoad) { InputStream is = null; ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { URLConnection conn = itemToLoad.toURL().openConnection(); byte[] data ...
#fixed code protected boolean load(URI itemToLoad, boolean fallbackLoad) { InputStream is = null; ByteArrayOutputStream stream = new ByteArrayOutputStream(); try{ URLConnection conn; String proxyPort = this.properties.get("proxy.port"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { if (!isAvailable(conversionQuery)) { return null; } CurrencyUnit base = conversionQuery.getBaseCurrency(); CurrencyUnit term = conversionQuer...
#fixed code @Override public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { if (!isAvailable(conversionQuery)) { return null; } CurrencyUnit base = conversionQuery.getBaseCurrency(); CurrencyUnit term = conversionQuery.getC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void copy(InputStream source, File dest) throws IOException { FileOutputStream fos = new FileOutputStream(dest); copy(source, fos); fos.close(); } #location 5 #vulnerabil...
#fixed code public static void copy(InputStream source, File dest) throws IOException { FileOutputStream fos = null; try { fos = new FileOutputStream(dest); copy(source, fos); } finally { if (fos != null) try {fos.close();} catch (Exception e) {} ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void deleteNode(Handle handle) throws IOException { if (cachesize != 0) { Node n = (Node) cache.get(handle); if (n != null) { cacheScore.deleteScore(handle); cache.remove(handle); } ...
#fixed code protected void deleteNode(Handle handle) throws IOException { if (cachesize != 0) { Node n = (Node) cache.get(handle); if (n != null) synchronized (cache) { cacheScore.deleteScore(handle); cache.remove(handle); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { serverLog.logSystem("PLASMA INDEXING", "started word cache management"); int check; // permanently flush cache elements while (!(terminate)) { if (hashScore.size() < 100) try {Thread.currentThread().sleep(10000);} catch (InterruptedEx...
#fixed code public void run() { serverLog.logSystem("PLASMA INDEXING", "started word cache management"); int check; // permanently flush cache elements while (!(terminate)) { if (hashScore.size() < 100) try {Thread.currentThread().sleep(10000);} catch (InterruptedExceptio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String readLine() throws IOException { // with these functions, we consider a line as always terminated by CRLF serverByteBuffer sb = new serverByteBuffer(); int c; while (true) { c = read(); if (c < 0) { if (sb.length() == 0) return null; else re...
#fixed code public String readLine() throws IOException { // with these functions, we consider a line as always terminated by CRLF byte[] bb = new byte[80]; int bbsize = 0; int c; while (true) { c = read(); if (c < 0) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void respondError(OutputStream respond, String origerror, int errorcase, String url) { try { // set rewrite values serverObjects tp = new serverObjects(); tp.put("errormessage", errorcase); tp.put("httperro...
#fixed code private void respondError(OutputStream respond, String origerror, int errorcase, String url) { FileInputStream fis = null; try { // set rewrite values serverObjects tp = new serverObjects(); tp.put("errormessage", errorcase)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void run() { serverLog.logSystem("PLASMA INDEXING", "started word cache management"); int check; // permanently flush cache elements while (!(terminate)) { if (hashScore.size() < 100) try {Thread.currentThread().sleep(10000);} catch (InterruptedEx...
#fixed code public void run() { serverLog.logSystem("PLASMA INDEXING", "started word cache management"); int check; // permanently flush cache elements while (!(terminate)) { if (hashScore.size() < 100) try {Thread.currentThread().sleep(10000);} catch (InterruptedExceptio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static TreeMap loadMap(String mapname, String filename, String sep) { TreeMap map = new TreeMap(); try { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); String line; int pos; while ((line = br.r...
#fixed code private static TreeMap loadMap(String mapname, String filename, String sep) { TreeMap map = new TreeMap(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); String line; int pos; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private int flushFromMemToLimit() { if ((hashScore.size() == 0) && (cache.size() == 0)) { serverLog.logDebug("PLASMA INDEXING", "flushToLimit: called but cache is empty"); return 0; } if ((hashScore.size() == 0) && (cache.size() != 0)) { serverLog.logE...
#fixed code private int flushFromMemToLimit() { if ((hashScore.size() == 0) && (cache.size() == 0)) { serverLog.logDebug("PLASMA INDEXING", "flushToLimit: called but cache is empty"); return 0; } if ((hashScore.size() == 0) && (cache.size() != 0)) { serverLog.logError("...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void copy(File source, OutputStream dest) throws IOException { InputStream fis = new FileInputStream(source); copy(fis, dest); fis.close(); } #location 5 #vulnerability type RESOURCE_L...
#fixed code public static void copy(File source, OutputStream dest) throws IOException { InputStream fis = null; try { fis = new FileInputStream(source); copy(fis, dest); } finally { if (fis != null) try { fis.close(); } catch (Exception e) {} ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] read(File source) throws IOException { byte[] buffer = new byte[(int) source.length()]; InputStream fis = new FileInputStream(source); int p = 0; int c; while ((c = fis.read(buffer, p, buffer.length - p)) > 0) p += c...
#fixed code public static byte[] read(File source) throws IOException { byte[] buffer = new byte[(int) source.length()]; InputStream fis = null; try { fis = new FileInputStream(source); int p = 0, c; while ((c = fis.read(buffer, p, buffer.length - p)) > 0) p +=...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int addEntryToIndexMem(String wordHash, plasmaWordIndexEntry entry) throws IOException { // make space for new words int flushc = 0; //serverLog.logDebug("PLASMA INDEXING", "addEntryToIndexMem: cache.size=" + cache.size() + "; hashScore.size=" + hashScore.size...
#fixed code public int addEntryToIndexMem(String wordHash, plasmaWordIndexEntry entry) throws IOException { // make space for new words int flushc = 0; //serverLog.logDebug("PLASMA INDEXING", "addEntryToIndexMem: cache.size=" + cache.size() + "; hashScore.size=" + hashScore.size()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void copy(File source, File dest) throws IOException { FileInputStream fis = new FileInputStream(source); FileOutputStream fos = new FileOutputStream(dest); copy(fis, fos); fis.close(); fos.close(); } ...
#fixed code public static void copy(File source, File dest) throws IOException { FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(source); fos = new FileOutputStream(dest); copy(fis, fos); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { // return variable that accumulates replacements serverObjects prop = new serverObjects(); //if (post == null) System.out.println("POST: NULL"); else System.out.println("P...
#fixed code public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { // return variable that accumulates replacements serverObjects prop = new serverObjects(); //if (post == null) System.out.println("POST: NULL"); else System.out.println("POST: "...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static HashSet loadSet(String setname, String filename) { HashSet set = new HashSet(); try { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); String line; while ((line = br.readLine()) != null) { li...
#fixed code private static HashSet loadSet(String setname, String filename) { HashSet set = new HashSet(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); String line; while ((line = br.readLine(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean job() throws Exception { // prepare for new connection // idleThreadCheck(); this.switchboard.handleBusyState(this.theSessionPool.getNumActive() /*activeThreads.size() */); log.logDebug( "* waiting for connections,...
#fixed code public boolean job() throws Exception { // prepare for new connection // idleThreadCheck(); this.switchboard.handleBusyState(this.theSessionPool.getNumActive() /*activeThreads.size() */); log.logDebug( "* waiting for connections, " + t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int size() { return java.lang.Math.max(singletons.size(), java.lang.Math.max(backend.size(), cache.size())); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public int size() { return java.lang.Math.max(assortmentCluster.sizeTotal(), java.lang.Math.max(backend.size(), cache.size())); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void copy(File source, File dest) throws IOException { FileInputStream fis = new FileInputStream(source); FileOutputStream fos = new FileOutputStream(dest); copy(fis, fos); fis.close(); fos.close(); } ...
#fixed code public static void copy(File source, File dest) throws IOException { FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(source); fos = new FileOutputStream(dest); copy(fis, fos); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int addEntryToIndexMem(String wordHash, plasmaWordIndexEntry entry) throws IOException { // make space for new words int flushc = 0; //serverLog.logDebug("PLASMA INDEXING", "addEntryToIndexMem: cache.size=" + cache.size() + "; hashScore.size=" + hashScore.size...
#fixed code public int addEntryToIndexMem(String wordHash, plasmaWordIndexEntry entry) throws IOException { // make space for new words int flushc = 0; //serverLog.logDebug("PLASMA INDEXING", "addEntryToIndexMem: cache.size=" + cache.size() + "; hashScore.size=" + hashScore.size()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public serverObjects searchFromRemote(Set hashes, int count, boolean global, long duetime) { if (hashes == null) hashes = new HashSet(); serverObjects prop = new serverObjects(); try { log.logInfo("INIT HASH SEARCH: " + hashe...
#fixed code public serverObjects searchFromRemote(Set hashes, int count, boolean global, long duetime) { if (hashes == null) hashes = new HashSet(); serverObjects prop = new serverObjects(); try { log.logInfo("INIT HASH SEARCH: " + hashes + " ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String readLine() throws IOException { // with these functions, we consider a line as always terminated by CRLF serverByteBuffer sb = new serverByteBuffer(); int c; while (true) { c = read(); if (c < 0) { if (sb.length() == 0) return null; else re...
#fixed code public String readLine() throws IOException { // with these functions, we consider a line as always terminated by CRLF byte[] bb = new byte[80]; int bbsize = 0; int c; while (true) { c = read(); if (c < 0) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void initDataComposer(IDataComposer dataComposer, HttpServletRequest request) { String paramName = (String) request.getSession().getAttribute(Constants.MODIFY_STATE_HDIV_PARAMETER); String preState = paramName != null ? request.getParameter(paramName) : null...
#fixed code protected void initDataComposer(IDataComposer dataComposer, HttpServletRequest request) { String paramName = (String) request.getSession().getAttribute(Constants.MODIFY_STATE_HDIV_PARAMETER); String preState = paramName != null ? request.getParameter(paramName) : null; if...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public StatusEnum process(String optType, String optId, StatusEnum initStatus, long expireMs) { if (Dew.cluster.cache.setnx(CACHE_KEY + optType + ":" + optId, initStatus.toString(), expireMs / 1000)) { // 设置成功,表示之前不存在 return...
#fixed code @Override public StatusEnum process(String optType, String optId, StatusEnum initStatus, long expireMs) { if (Dew.cluster.cache.setnx(CACHE_KEY + optType + ":" + optId, initStatus.toString(), expireMs / 1000)) { // 设置成功,表示之前不存在 return Statu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void register(final DynamicConfig config) { final SlaveSyncClient slaveSyncClient = new SlaveSyncClient(config); final MasterSlaveSyncManager masterSlaveSyncManager = new MasterSlaveSyncManager(slaveSyncClient); StorageConfig storageConf...
#fixed code private void register(final DynamicConfig config) { BrokerRole role = BrokerConfig.getBrokerRole(); if(role != BrokerRole.BACKUP) throw new RuntimeException("Only support backup"); final SlaveSyncClient slaveSyncClient = new SlaveSyncClient(config); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void recover() { if (segments.isEmpty()) { return; } LOG.info("Recovering logs."); final List<Long> baseOffsets = new ArrayList<>(segments.navigableKeySet()); final int offsetCount = baseOffsets.size(); ...
#fixed code private void recover() { if (segments.isEmpty()) { return; } LOG.info("Recovering logs."); final List<Long> baseOffsets = new ArrayList<>(segments.navigableKeySet()); final int offsetCount = baseOffsets.size(); long...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void register(final DynamicConfig config) { final SlaveSyncClient slaveSyncClient = new SlaveSyncClient(config); final MasterSlaveSyncManager masterSlaveSyncManager = new MasterSlaveSyncManager(slaveSyncClient); StorageConfig storageConf...
#fixed code private void register(final DynamicConfig config) { BrokerRole role = BrokerConfig.getBrokerRole(); if(role != BrokerRole.BACKUP) throw new RuntimeException("Only support backup"); final SlaveSyncClient slaveSyncClient = new SlaveSyncClient(config); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static MemoryLayoutSpecification getEffectiveMemoryLayoutSpecification() { final String dataModel = System.getProperty("sun.arch.data.model"); if ("32".equals(dataModel)) { // Running with 32-bit data model return new Mem...
#fixed code private static MemoryLayoutSpecification getEffectiveMemoryLayoutSpecification() { final String dataModel = System.getProperty("sun.arch.data.model"); if ("32".equals(dataModel)) { // Running with 32-bit data model return new MemoryLay...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void putBlock(Block block) throws Exception { rocksDB.put((BLOCKS_BUCKET_PREFIX + block.getHash()).getBytes(), SerializeUtils.serialize(block)); } #location 2 #vulnerability type THREAD_SAFETY_...
#fixed code public void putBlock(Block block) throws Exception { byte[] key = SerializeUtils.serialize(BLOCKS_BUCKET_PREFIX + block.getHash()); rocksDB.put(key, SerializeUtils.serialize(block)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initRocksDB() { try { rocksDB = RocksDB.open(new Options().setCreateIfMissing(true), DB_FILE); } catch (RocksDBException e) { e.printStackTrace(); } } #location 3 ...
#fixed code private void initRocksDB() { try { Options options = new Options(); options.setCreateIfMissing(true); rocksDB = RocksDB.open(options, DB_FILE); } catch (RocksDBException e) { e.printStackTrace(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void putLastBlockHash(String tipBlockHash) throws Exception { rocksDB.put((BLOCKS_BUCKET_PREFIX + "l").getBytes(), tipBlockHash.getBytes()); } #location 2 #vulnerability type THREAD_SAFETY_VIOL...
#fixed code public void putLastBlockHash(String tipBlockHash) throws Exception { rocksDB.put(SerializeUtils.serialize(BLOCKS_BUCKET_PREFIX + "l"), SerializeUtils.serialize(tipBlockHash)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Block getBlock(String blockHash) throws Exception { return (Block) SerializeUtils.deserialize(rocksDB.get((BLOCKS_BUCKET_PREFIX + blockHash).getBytes())); } #location 2 #vulnerability type THRE...
#fixed code public Block getBlock(String blockHash) throws Exception { byte[] key = SerializeUtils.serialize(BLOCKS_BUCKET_PREFIX + blockHash); return (Block) SerializeUtils.deserialize(rocksDB.get(key)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String getLastBlockHash() throws Exception { byte[] lastBlockHashBytes = rocksDB.get((BLOCKS_BUCKET_PREFIX + "l").getBytes()); if (lastBlockHashBytes != null) { return new String(lastBlockHashBytes); } return ""; } ...
#fixed code public String getLastBlockHash() throws Exception { byte[] lastBlockHashBytes = rocksDB.get(SerializeUtils.serialize(BLOCKS_BUCKET_PREFIX + "l")); if (lastBlockHashBytes != null) { return (String) SerializeUtils.deserialize(lastBlockHashBytes); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void loadResource(Yaml yaml, InputStream yamlStream, String filename) { Node loadedYaml = yaml.compose(new UnicodeReader(yamlStream)); if (loadedYaml == null) { LOG.error("The file {} is empty", filename); return; ...
#fixed code private void loadResource(Yaml yaml, InputStream yamlStream, String filename) { Node loadedYaml = yaml.compose(new UnicodeReader(yamlStream)); if (loadedYaml == null) { throw new InvalidParserConfigurationException("The file " + filename + " is em...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void informSubstrings(ParserRuleContext ctx, String name, int maxSubStrings) { String text = getSourceText(ctx); inform(ctx, name, text, false); int startOffsetPrevious = 0; int count = 1; char[] chars = text.toCharArray(...
#fixed code private void informSubstrings(ParserRuleContext ctx, String name, int maxSubStrings) { String text = getSourceText(ctx); if (text==null) { return; } inform(ctx, name, text, false); int startOffsetPrevious = 0; int c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void informSubVersions(ParserRuleContext ctx, String name, int maxSubStrings) { String text = getSourceText(ctx); inform(ctx, name, text, false); int startOffsetPrevious = 0; int count = 1; char[] chars = text.toCharArray...
#fixed code private void informSubVersions(ParserRuleContext ctx, String name, int maxSubStrings) { String text = getSourceText(ctx); if (text==null) { return; } inform(ctx, name, text, false); int startOffsetPrevious = 0; int ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Health health() { boolean allPassed = true; Health.Builder builder = new Health.Builder(); for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) { if (!sofaRuntimeManager.isLivenessHealth()) ...
#fixed code @Override public Health health() { boolean allPassed = true; Health.Builder builder = new Health.Builder(); for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) { Biz biz = DynamicJvmServiceProxyFinder.getBiz(sofa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReadinessCheckFailedHttpCode() throws IOException { HttpURLConnection huc = (HttpURLConnection) (new URL( "http://localhost:8080/health/readiness").openConnection()); huc.setRequestMethod("HEAD"); huc.connect...
#fixed code @Test public void testReadinessCheckFailedHttpCode() { ResponseEntity<String> response = restTemplate.getForEntity("/health/readiness", String.class); Assert.assertEquals(HttpStatus.SERVICE_UNAVAILABLE, response.getStatusCode()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Health health() { boolean allPassed = true; Health.Builder builder = new Health.Builder(); for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) { if (!sofaRuntimeManager.isLivenessHealth()) ...
#fixed code @Override public Health health() { boolean allPassed = true; Health.Builder builder = new Health.Builder(); for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) { Biz biz = DynamicJvmServiceProxyFinder.getBiz(sofa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void initialize(ConfigurableApplicationContext applicationContext) { Environment environment = applicationContext.getEnvironment(); if (SOFABootEnvUtils.isSpringCloudBootstrapEnvironment(environment)) { return; } ...
#fixed code @Override public void initialize(ConfigurableApplicationContext applicationContext) { Environment environment = applicationContext.getEnvironment(); if (SOFABootEnvUtils.isSpringCloudBootstrapEnvironment(environment)) { return; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @GetMapping("/download/{key:.+}") public ResponseEntity<Resource> download(@PathVariable String key) { LitemallStorage litemallStorage = litemallStorageService.findByKey(key); if (key == null) { ResponseEntity.notFound(); } ...
#fixed code @GetMapping("/download/{key:.+}") public ResponseEntity<Resource> download(@PathVariable String key) { LitemallStorage litemallStorage = litemallStorageService.findByKey(key); if (key == null) { return ResponseEntity.notFound().build(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @PostMapping("refund") public Object refund(@LoginAdmin Integer adminId, @RequestBody String body) { if (adminId == null) { return ResponseUtil.unlogin(); } Integer orderId = JacksonUtil.parseInteger(body, "orderId"); Inte...
#fixed code @PostMapping("refund") public Object refund(@LoginAdmin Integer adminId, @RequestBody String body) { if (adminId == null) { return ResponseUtil.unlogin(); } Integer orderId = JacksonUtil.parseInteger(body, "orderId"); String ref...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @PostMapping("comment") public Object comment(@LoginUser Integer userId, @RequestBody String body) { if (userId == null) { return ResponseUtil.unlogin(); } Integer orderGoodsId = JacksonUtil.parseInteger(body, "orderGoodsId"); ...
#fixed code @PostMapping("comment") public Object comment(@LoginUser Integer userId, @RequestBody String body) { if (userId == null) { return ResponseUtil.unlogin(); } Integer orderGoodsId = JacksonUtil.parseInteger(body, "orderGoodsId"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @PostMapping("/update") public Object update(@LoginAdmin Integer adminId, @RequestBody GoodsAllinone goodsAllinone) { if (adminId == null) { return ResponseUtil.unlogin(); } LitemallGoods goods = goodsAllinone.getGoods(); ...
#fixed code @PostMapping("/update") public Object update(@LoginAdmin Integer adminId, @RequestBody GoodsAllinone goodsAllinone) { if (adminId == null) { return ResponseUtil.unlogin(); } LitemallGoods goods = goodsAllinone.getGoods(); Litem...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initCollapseAnimations(String state){ collapseAnim = new Timeline(this); switch (state){ case "expand":{ collapseAnim.addPropertyToInterpolate("width",this.getWidth(),250); break; } ...
#fixed code private void initCollapseAnimations(String state){ collapseAnim = new Timeline(this); switch (state){ case "expand":{ collapseAnim.addPropertyToInterpolate("width",this.getWidth(),MAX_WIDTH); break; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void loadConfigFile(){ JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject) parser.parse(new FileReader(CONFIG_FILE)); JSONArray buttons = (JSONArray) root.get("buttons"); cachedButtonsCo...
#fixed code private void loadConfigFile(){ JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject) parser.parse(new FileReader(CONFIG_FILE)); JSONArray buttons = (JSONArray) root.get("buttons"); cachedButtonsConfig =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private JPanel getFormattedMessagePanel(String message){ JPanel labelsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); labelsPanel.setBackground(AppThemeColor.TRANSPARENT); String itemName = StringUtils.substringBetween(message, "to buy your...
#fixed code private JPanel getFormattedMessagePanel(String message){ JPanel labelsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); labelsPanel.setBackground(AppThemeColor.TRANSPARENT); String itemName = StringUtils.substringBetween(message, "to buy your ", " ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void loadConfigFile(){ JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject) parser.parse(new FileReader(CONFIG_FILE)); JSONArray buttons = (JSONArray) root.get("buttons"); cachedButtonsCo...
#fixed code private void loadConfigFile(){ JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject) parser.parse(new FileReader(CONFIG_FILE)); JSONArray buttons = (JSONArray) root.get("buttons"); cachedButtonsConfig =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void load(){ File configFile = new File(HISTORY_FILE); if (configFile.exists()) { JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject)parser.parse(new FileReader(HISTORY_FILE)); ...
#fixed code public void load(){ File configFile = new File(HISTORY_FILE); if (configFile.exists()) { JSONParser parser = new JSONParser(); try { JSONObject root = (JSONObject)parser.parse(new FileReader(HISTORY_FILE)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void load() { File configFile = new File(CONFIG_FILE); if (!configFile.exists()) { try { new File(CONFIG_FILE_PATH).mkdir(); FileWriter fileWriter = new FileWriter(CONFIG_FILE); fileWrit...
#fixed code private void load() { File configFile = new File(CONFIG_FILE); if (!configFile.exists()) { try { new File(CONFIG_FILE_PATH).mkdir(); FileWriter fileWriter = new FileWriter(CONFIG_FILE); fileWriter.wri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] tryDecompress(byte[] raw) throws Exception { if (!isGzipStream(raw)) { return raw; } GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(raw)); ByteArrayOutputStream out ...
#fixed code public static byte[] tryDecompress(byte[] raw) throws Exception { if (!isGzipStream(raw)) { return raw; } GZIPInputStream gis = null; ByteArrayOutputStream out = null; try { gis = new GZIPInputStream(new ByteArr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void signalPublish(String key, String value) throws Exception { long start = System.currentTimeMillis(); final Datum datum = new Datum(); datum.key = key; datum.value = value; if (RaftCore.getDatum(key) == null) { ...
#fixed code public static void signalPublish(String key, String value) throws Exception { long start = System.currentTimeMillis(); final Datum datum = new Datum(); datum.key = key; datum.value = value; if (RaftCore.getDatum(key) == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping("/updateClusterConf") public JSONObject updateClusterConf(HttpServletRequest request) throws IOException { JSONObject result = new JSONObject(); String ipSpliter = ","; String ips = BaseServlet.optional(request, "ips", "");...
#fixed code @RequestMapping("/updateClusterConf") public JSONObject updateClusterConf(HttpServletRequest request) throws IOException { JSONObject result = new JSONObject(); String ipSpliter = ","; String ips = BaseServlet.optional(request, "ips", ""); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void refreshSrvIfNeed() { try { if (!CollectionUtils.isEmpty(serverList)) { LogUtils.LOG.debug("server list provided by user: " + serverList); return; } if (System.currentTimeMillis() ...
#fixed code private void refreshSrvIfNeed() { try { if (!CollectionUtils.isEmpty(serverList)) { LogUtils.LOG.debug("server list provided by user: " + serverList); return; } if (System.currentTimeMillis() - last...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] tryDecompress(InputStream raw) throws Exception { try { GZIPInputStream gis = new GZIPInputStream(raw); ByteArrayOutputStream out = new ByteArrayOutputStream(); I...
#fixed code public static byte[] tryDecompress(InputStream raw) throws Exception { try { GZIPInputStream gis = new GZIPInputStream(raw); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void contextPrepared(ConfigurableApplicationContext context) { System.out.printf("Log files: %s/logs/%n", NACOS_HOME); System.out.printf("Conf files: %s/conf/%n", NACOS_HOME); System.out.printf("Data files: %s/data/%n", NACOS...
#fixed code @Override public void contextPrepared(ConfigurableApplicationContext context) { }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping("/updateClusterConf") public JSONObject updateClusterConf(HttpServletRequest request) throws IOException { JSONObject result = new JSONObject(); String ipSpliter = ","; String ips = BaseServlet.optional(request, "ips", "");...
#fixed code @RequestMapping("/updateClusterConf") public JSONObject updateClusterConf(HttpServletRequest request) throws IOException { JSONObject result = new JSONObject(); String ipSpliter = ","; String ips = BaseServlet.optional(request, "ips", ""); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void contextPrepared(ConfigurableApplicationContext context) { System.out.printf("Log files: %s/logs/%n", NACOS_HOME); System.out.printf("Conf files: %s/conf/%n", NACOS_HOME); System.out.printf("Data files: %s/data/%n", NACOS...
#fixed code @Override public void contextPrepared(ConfigurableApplicationContext context) { }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Instance selectOneHealthyInstance(String serviceName, List<String> clusters, boolean subscribe) throws NacosException { if (subscribe) { return Balancer.RandomByWeight.selectHost( hostReactor.getServiceIn...
#fixed code @Override public Instance selectOneHealthyInstance(String serviceName, List<String> clusters, boolean subscribe) throws NacosException { return selectOneHealthyInstance(serviceName, Constants.DEFAULT_GROUP, clusters, subscribe); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping("/onAddIP4Dom") public String onAddIP4Dom(HttpServletRequest request) throws Exception { if (Switch.getDisableAddIP()) { throw new AccessControlException("Adding IP for dom is forbidden now."); } String clientIP =...
#fixed code @RequestMapping("/onAddIP4Dom") public String onAddIP4Dom(HttpServletRequest request) throws Exception { if (Switch.getDisableAddIP()) { throw new AccessControlException("Adding IP for dom is forbidden now."); } String clientIP = WebUt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException { Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral)); ...
#fixed code public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException { Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException { Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral)); ...
#fixed code public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException { Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void registerInstance(String namespaceId, String serviceName, String clusterName, Instance instance) throws Exception { Service service = getService(namespaceId, serviceName); boolean serviceUpdated = false; if (service == null) { ...
#fixed code public void registerInstance(String namespaceId, String serviceName, String clusterName, Instance instance) throws Exception { Service service = getService(namespaceId, serviceName); boolean serviceUpdated = false; if (service == null) { s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @RequestMapping("/updateClusterConf") public JSONObject updateClusterConf(HttpServletRequest request) throws IOException { JSONObject result = new JSONObject(); String ipSpliter = ","; String ips = BaseServlet.optional(request, "ips", "");...
#fixed code @RequestMapping("/updateClusterConf") public JSONObject updateClusterConf(HttpServletRequest request) throws IOException { JSONObject result = new JSONObject(); String ipSpliter = ","; String ips = BaseServlet.optional(request, "ips", ""); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException { Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral)); ...
#fixed code public List<Instance> updateIpAddresses(Service service, String action, boolean ephemeral, Instance... ips) throws NacosException { Datum datum = consistencyService.get(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), ephemeral)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<String> readClusterConf() throws IOException { List<String> instanceList = new ArrayList<String>(); List<String> lines = IoUtils.readLines( new InputStreamReader(new FileInputStream(new File(CLUSTER_CONF_FILE_PATH)), UT...
#fixed code public static List<String> readClusterConf() throws IOException { List<String> instanceList = new ArrayList<String>(); Reader reader = null; try { reader = new InputStreamReader(new FileInputStream(new File(CLUSTER_CONF_FILE_PATH)), UTF_8)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @NeedAuth @RequestMapping("/remvIP4Dom") public String remvIP4Dom(HttpServletRequest request) throws Exception { String dom = WebUtils.required(request, "dom"); String ipListString = WebUtils.required(request, "ipList"); Loggers.DEBUG_LO...
#fixed code @NeedAuth @RequestMapping("/remvIP4Dom") public String remvIP4Dom(HttpServletRequest request) throws Exception { String dom = WebUtils.required(request, "dom"); String ipListString = WebUtils.required(request, "ipList"); Map<String, String> pr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void checkLocalConfig(CacheData cacheData) { final String dataId = cacheData.dataId; final String group = cacheData.group; final String tenant = cacheData.tenant; File path = LocalConfigInfoProcessor.getFailoverFile(agent.getName(...
#fixed code private void checkLocalConfig(CacheData cacheData) { final String dataId = cacheData.dataId; final String group = cacheData.group; final String tenant = cacheData.tenant; File path = LocalConfigInfoProcessor.getFailoverFile(agent.getName(), dat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void registerInstance(String namespaceId, String serviceName, String clusterName, Instance instance) throws Exception { Service service = getService(namespaceId, serviceName); boolean serviceUpdated = false; if (service == null) { ...
#fixed code public void registerInstance(String namespaceId, String serviceName, String clusterName, Instance instance) throws Exception { Service service = getService(namespaceId, serviceName); boolean serviceUpdated = false; if (service == null) { s...
Below is the vulnerable code, please generate the patch based on the following information.