output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static ThreadId start(final ReplicatorOptions opts, final RaftOptions raftOptions) { if (opts.getLogManager() == null || opts.getBallotBox() == null || opts.getNode() == null) { throw new IllegalArgumentException("Invalid ReplicatorOptions."); ...
#vulnerable code public static ThreadId start(final ReplicatorOptions opts, final RaftOptions raftOptions) { if (opts.getLogManager() == null || opts.getBallotBox() == null || opts.getNode() == null) { throw new IllegalArgumentException("Invalid ReplicatorOptions.");...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <T extends Message> Future<Message> invokeWithDone(final Endpoint endpoint, final Message request, final InvokeContext ctx, final RpcResponseClos...
#vulnerable code public <T extends Message> Future<Message> invokeWithDone(final Endpoint endpoint, final Message request, final InvokeContext ctx, final RpcRespon...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void shutdown(final Closure done) { List<RepeatedTimer> timers = null; this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state...
#vulnerable code @Override public void shutdown(final Closure done) { this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state.compareTo(State.STATE_SHUTTING) < 0)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void destroy() { final ThreadId savedId = this.id; LOG.info("Replicator {} is going to quit", savedId); this.id = null; releaseReader(); // Unregister replicator metric set if (this.options.getNode().getNodeMetrics().isEna...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void shutdown(final Closure done) { List<RepeatedTimer> timers = null; this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state...
#vulnerable code @Override public void shutdown(final Closure done) { this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state.compareTo(State.STATE_SHUTTING) < 0)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void destroy() { final ThreadId savedId = this.id; LOG.info("Replicator {} is going to quit", savedId); this.id = null; releaseReader(); // Unregister replicator metric set if (this.options.getNode().getNodeMetrics().isEna...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testOnRpcReturnedRpcError() { testRpcReturnedError(); }
#vulnerable code @Test public void testOnRpcReturnedRpcError() { final Replicator r = getReplicator(); assertNull(r.getBlockTimer()); final RpcRequests.AppendEntriesRequest request = createEmptyEntriesRequest(); final RpcRequests.AppendEntriesResponse...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unused") static void onTimeoutNowReturned(final ThreadId id, final Status status, final TimeoutNowRequest request, final TimeoutNowResponse response, final boolean stopAfterFinish) { final Replicator r = (Rep...
#vulnerable code @SuppressWarnings("unused") static void onTimeoutNowReturned(final ThreadId id, final Status status, final TimeoutNowRequest request, final TimeoutNowResponse response, final boolean stopAfterFinish) { final Replicator r ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean commitAt(long firstLogIndex, long lastLogIndex, PeerId peer) { //TODO use lock-free algorithm here? final long stamp = stampedLock.writeLock(); long lastCommittedIndex = 0; try { if (pendingIndex == 0) { ...
#vulnerable code public boolean commitAt(long firstLogIndex, long lastLogIndex, PeerId peer) { //TODO use lock-free algorithm here? final long stamp = stampedLock.writeLock(); long lastCommittedIndex = 0; try { if (pendingIndex == 0) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void sendNextRpc() { this.timer = null; final long offset = requestBuilder.getOffset() + requestBuilder.getCount(); final long maxCount = this.destBuf == null ? raftOptions.getMaxByteCountPerRpc() : Integer.MAX_VALUE; this.requestBuilder ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void destroy() { final ThreadId savedId = this.id; LOG.info("Replicator {} is going to quit", savedId); this.id = null; releaseReader(); // Unregister replicator metric set if (this.options.getNode().getNodeMetrics().isEna...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void destroy() { final ThreadId savedId = this.id; LOG.info("Replicator {} is going to quit", savedId); this.id = null; releaseReader(); // Unregister replicator metric set if (this.options.getNode().getNodeMetrics().isEna...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void sendEntries() { boolean doUnlock = true; try { long prevSendIndex = -1; while (true) { final long nextSendingIndex = getNextSendIndex(); if (nextSendingIndex > prevSendIndex) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void destroy() { final ThreadId savedId = this.id; LOG.info("Replicator {} is going to quit", savedId); this.id = null; releaseReader(); // Unregister replicator metric set if (this.options.getNode().getNodeMetrics().isEna...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Session startCopyToFile(String source, String destPath, CopyOptions opts) throws IOException { final File file = new File(destPath); // delete exists file. if (file.exists()) { if (!file.delete()) { LOG.error("Fail t...
#vulnerable code public Session startCopyToFile(String source, String destPath, CopyOptions opts) throws IOException { final File file = new File(destPath); // delete exists file. if (file.exists()) { if (!file.delete()) { LOG.error("...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static void onHeartbeatReturned(final ThreadId id, final Status status, final AppendEntriesRequest request, final AppendEntriesResponse response, final long rpcSendTime) { if (id == null) { // replicator already was dest...
#vulnerable code static void onHeartbeatReturned(final ThreadId id, final Status status, final AppendEntriesRequest request, final AppendEntriesResponse response, final long rpcSendTime) { if (id == null) { // replicator already wa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void onRpcReturned(Status status, GetFileResponse response) { this.lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous on...
#vulnerable code void onRpcReturned(Status status, GetFileResponse response) { lock.lock(); try { if (this.finished) { return; } if (!status.isOk()) { // Reset count to make next rpc retry the previous o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void shutdown(final Closure done) { List<RepeatedTimer> timers = null; this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state...
#vulnerable code @Override public void shutdown(final Closure done) { this.writeLock.lock(); try { LOG.info("Node {} shutdown, currTerm={} state={}.", getNodeId(), this.currTerm, this.state); if (this.state.compareTo(State.STATE_SHUTTING) < 0)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code long getNextSendIndex() { // Fast path if (this.inflights.isEmpty()) { return this.nextIndex; } // Too many in-flight requests. if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { retur...
#vulnerable code void installSnapshot() { if (this.state == State.Snapshot) { LOG.warn("Replicator {} is installing snapshot, ignore the new request.", this.options.getPeerId()); this.id.unlock(); return; } boolean doUnlock = t...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRead() throws IOException { //noinspection UnstableApiUsage BufferedReader in = new BufferedReader(new InputStreamReader(Resources.getResource("event.txt").openStream(), Charsets.UTF_8)); Event ev = Event.read(in); ass...
#vulnerable code @Test public void testRead() throws IOException, ParseException, Event.EventFormatException { BufferedReader in = new BufferedReader(new InputStreamReader(Resources.getResource("event.txt").openStream(), Charsets.UTF_8)); Event ev = Event.read(in); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void writeKryo(String fileName, GraphDatabaseService db, SubGraph graph, ProgressReporter reporter, Config config) throws Exception { OutputStream outputStream = new BufferedOutputStream(new DeflaterOutputStream(new FileOutputStream(fileName, true), false), Fi...
#vulnerable code private void writeKryo(String fileName, GraphDatabaseService db, SubGraph graph, ProgressReporter reporter, Config config) throws Exception { OutputStream outputStream = new DeflaterOutputStream(new FileOutputStream(fileName, true)); com.esotericsoftware...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String getIpAddress() { HttpServletRequest request = getRequest(); String ip = request.getHeader("x-forwarded-for"); if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("Proxy-Client-IP"); ...
#vulnerable code public String getIpAddress() { HttpServletRequest request = getRequest(); String ip = request.getHeader("x-forwarded-for"); if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("Proxy-Client-I...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader, DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) { if (option == null) { option = new DatabaseOperation...
#vulnerable code public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader, DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) { if (option == null) { option = new DatabaseOpe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private ClassLoader getDriverClassLoader() { File localDriverPath = getCustomDriverPath(); if (driverClassLoader != null) { return driverClassLoader; } else if (localDriverPath.exists()) { try { List<URL> urlList = new ArrayList<>(); File...
#vulnerable code private ClassLoader getDriverClassLoader() { File localDriverPath = getCustomDriverPath(); if (driverClassLoader != null) { return driverClassLoader; } else if (localDriverPath.exists()) { try { List<URL> urlList = new ArrayList<URL>(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetConfiguredTemplate() { String templateName = ""; try { FileWriter fileWriter = new FileWriter(tempFile); try { fileWriter.append("new_command.template=templates/col_new_template_migration.sql"); fileWriter.flush(); ...
#vulnerable code @Test public void testGetConfiguredTemplate() { String templateName = ""; try { FileWriter fileWriter = new FileWriter(tempFile); fileWriter.append("new_command.template=templates/col_new_template_migration.sql"); fileWriter.flush(); tem...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader, DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) { if (option == null) { option = new DatabaseOperation...
#vulnerable code public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader, DatabaseOperationOption option, PrintStream printStream, MigrationHook upHook, MigrationHook downHook) { if (option == null) { option = new DatabaseOpe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void save(MethodNode methodNode) { try { MethodNodeService methodNodeService = ApplicationContextHelper.popBean(MethodNodeService.class); assert methodNodeService != null; methodNodeService.saveNotRedo(methodNode); ...
#vulnerable code private static void save(MethodNode methodNode) { try { MethodNodeService methodNodeService = ApplicationContextHelper.popBean(MethodNodeService.class); methodNodeService.saveNotRedo(methodNode); } catch (Exception e) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code InplaceFileConverter(RuleSet ruleSet) { this.lineConverter = new LineConverter(ruleSet); lineTerminator = System.getProperty("line.separator"); }
#vulnerable code byte[] readFile(File file) throws IOException { FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int n = 0; byte[] buffer = new byte[BUFFER_LEN]; while ((n = fis.read(buffer)) != -1) { // ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code InplaceFileConverter(RuleSet ruleSet) { this.lineConverter = new LineConverter(ruleSet); lineTerminator = System.getProperty("line.separator"); }
#vulnerable code void convert(File file, byte[] input) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(input); Reader reader = new InputStreamReader(bais); BufferedReader breader = new BufferedReader(reader); FileWriter fileWriter = new FileWriter...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean contains(String name) { throw new UnsupportedOperationException("This method has been deprecated."); }
#vulnerable code public boolean contains(String name) { if(name == null) { return false; } if(factory.exists(name)) { Marker other = factory.getMarker(name); return contains(other); } else { return false; } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Iterator<Marker> iterator() { return referenceList.iterator(); }
#vulnerable code public Iterator<Marker> iterator() { if (referenceList != null) { return referenceList.iterator(); } else { List<Marker> emptyList = Collections.emptyList(); return emptyList.iterator(); } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code InplaceFileConverter(RuleSet ruleSet) { this.lineConverter = new LineConverter(ruleSet); lineTerminator = System.getProperty("line.separator"); }
#vulnerable code void convert(File file, byte[] input) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(input); Reader reader = new InputStreamReader(bais); BufferedReader breader = new BufferedReader(reader); FileWriter fileWriter = new FileWriter...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static ILoggerFactory getILoggerFactory() { if (INITIALIZATION_STATE == UNINITIALIZED) { synchronized (LoggerFactory.class) { if (INITIALIZATION_STATE == UNINITIALIZED) { INITIALIZATION_STATE = ONGOING_INITIALIZAT...
#vulnerable code public static ILoggerFactory getILoggerFactory() { if (INITIALIZATION_STATE == UNINITIALIZED) { synchronized (LoggerFactory.class) { if (INITIALIZATION_STATE == UNINITIALIZED) { INITIALIZATION_STATE = ONGOING_INITI...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean contains(String name) { if (name == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.name.equals(name)) { return true; } if (hasReferences()) { for (int i = 0; i < refereceList.size(); i++) { ...
#vulnerable code public boolean contains(String name) { if (name == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.name.equals(name)) { return true; } if (hasChildren()) { for (int i = 0; i < children.size(); i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean contains(String name) { if (name == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.name.equals(name)) { return true; } if (hasReferences()) { for (int i = 0; i < referenceList.size(); i++) { ...
#vulnerable code public boolean contains(String name) { if (name == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.name.equals(name)) { return true; } if (hasReferences()) { for (int i = 0; i < refereceList.size(); i+...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean contains(Marker other) { if (other == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.equals(other)) { return true; } if (hasReferences()) { for (int i = 0; i < refereceList.size(); i++) { ...
#vulnerable code public boolean contains(Marker other) { if (other == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.equals(other)) { return true; } if (hasChildren()) { for (int i = 0; i < children.size(); i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean contains(Marker other) { if (other == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.equals(other)) { return true; } if (hasReferences()) { for (int i = 0; i < referenceList.size(); i++) { ...
#vulnerable code public boolean contains(Marker other) { if (other == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.equals(other)) { return true; } if (hasReferences()) { for (int i = 0; i < refereceList.size(); i++)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean contains(String name) { if(name == null) { throw new IllegalArgumentException("Other cannot be null"); } if (this.name.equals(name)) { return true; } if (hasChildren()) { for(int i = 0; i < children.size(); i++) { ...
#vulnerable code public boolean contains(String name) { if(name == null) { return false; } if(factory.exists(name)) { Marker other = factory.getMarker(name); return contains(other); } else { return false; } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean deleteFileOrDirectory(File path) throws MojoFailureException { if (path.isDirectory()) { File[] files = path.listFiles(); if (null != files) { for (File file : files) { if (file.isDirectory()) { if (!deleteFileOrDirectory(file)) { ...
#vulnerable code private static boolean deleteFileOrDirectory(File path) throws MojoFailureException { if (path.isDirectory()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void verifyNode(Node node) { if (node == null) return; // Pre-order traversal. verifyNodes(node.children()); if (node instanceof Call) { Call call = (Call) node; // Skip resolving property derefs. if (call.isJavaStatic() || cal...
#vulnerable code private void verifyNode(Node node) { if (node == null) return; // Pre-order traversal. verifyNodes(node.children()); if (node instanceof Call) { Call call = (Call) node; // Skip resolving property derefs. if (call.isJavaStatic() ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public final void evalLispFile() { // Loop.evalLisp("default", new InputStreamReader(LispEvaluatorTest.class.getResourceAsStream("funcs.lisp"))); }
#vulnerable code @Test public final void evalLispFile() { Loop.evalLisp("default", new InputStreamReader(LispEvaluatorTest.class.getResourceAsStream("funcs.lisp"))); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String processVForValue(String vForValue) { VForDefinition vForDef = new VForDefinition(vForValue, context); // Set return of the "in" expression currentExpressionReturnType = vForDef.getInExpressionType(); String inExpression = t...
#vulnerable code private String processVForValue(String vForValue) { VForDefinition vForDef = new VForDefinition(vForValue, context); // Set return of the "in" expression currentExpressionReturnType = vForDef.getInExpressionType(); String inExpressi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Property(trials = 10) public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long expected...
#vulnerable code @Property(trials = 10) public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long ex...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Property(trials = TRIALS) public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long exp...
#vulnerable code @Property(trials = TRIALS) public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); lo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Property(trials = 10) public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long e...
#vulnerable code @Property(trials = 10) public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Property(trials = TRIALS) public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); lo...
#vulnerable code @Property(trials = TRIALS) public void shouldCollectToCollectionWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Property(trials = TRIALS) public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long expe...
#vulnerable code @Property(trials = TRIALS) public void shouldCollectToSetWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); lon...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Property(trials = 10) public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long expecte...
#vulnerable code @Property(trials = 10) public void shouldCollectToListWithThrottledParallelism(@InRange(minInt = 2, maxInt = 20) int unitsOfWork, @InRange(minInt = 1, maxInt = 40) int parallelism) { // given executor = threadPoolExecutor(unitsOfWork); long e...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testToMap() throws SQLException { assertTrue(this.rs.next()); Map m = processor.toMap(this.rs); assertEquals(COLS, m.keySet().size()); assertEquals("1", m.get("one")); assertEquals("2", m.get("TWO")); assertEquals("...
#vulnerable code public void testToMap() throws SQLException { int rowCount = 0; Map m = null; while (this.rs.next()) { m = processor.toMap(this.rs); assertNotNull(m); assertEquals(COLS, m.keySet().size()); rowCoun...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testToArray() throws SQLException { Object[] a = null; assertTrue(this.rs.next()); a = processor.toArray(this.rs); assertEquals(COLS, a.length); assertEquals("1", a[0]); assertEquals("2", a[1]); assertEquals...
#vulnerable code public void testToArray() throws SQLException { int rowCount = 0; Object[] a = null; while (this.rs.next()) { a = processor.toArray(this.rs); assertEquals(COLS, a.length); rowCount++; } assert...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testHandle() throws SQLException { ResultSetHandler h = new BeanListHandler(TestBean.class); List results = (List) h.handle(this.rs); assertNotNull(results); assertEquals(ROWS, results.size()); Iterator iter = results.iterator(); TestBean row = null; ...
#vulnerable code public void testHandle() throws SQLException { ResultSetHandler h = new BeanListHandler(TestBean.class); List results = (List) h.handle(this.rs); assertNotNull(results); assertEquals(ROWS, results.size()); Iterator iter = results.iterator(); TestBean row = nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testColumnNameHandle() throws SQLException { ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<Integer>("intTest"); Map<Integer,Map<String,Object>> results = h.handle(this.rs); assertNotNull(results); assertEqu...
#vulnerable code public void testColumnNameHandle() throws SQLException { ResultSetHandler<Map<Object,Map<String,Object>>> h = new KeyedHandler("three"); Map<Object,Map<String,Object>> results = h.handle(this.rs); assertNotNull(results); assertEquals(ROW...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testHandle() throws SQLException { ResultSetHandler h = new ArrayListHandler(); List results = (List) h.handle(this.rs); assertNotNull(results); assertEquals(ROWS, results.size()); Iterator iter = results.iterator(); Object[] row = null; assertT...
#vulnerable code public void testHandle() throws SQLException { ResultSetHandler h = new ArrayListHandler(); List results = (List) h.handle(this.rs); assertNotNull(results); assertEquals(ROWS, results.size()); Iterator iter = results.iterator(); Object[] row = null; while (...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testHandle() throws SQLException { ResultSetHandler h = new MapListHandler(); List results = (List) h.handle(this.rs); assertNotNull(results); assertEquals(ROWS, results.size()); Iterator iter = results.iterator(); Map row = null; assertTr...
#vulnerable code public void testHandle() throws SQLException { ResultSetHandler h = new MapListHandler(); List results = (List) h.handle(this.rs); assertNotNull(results); assertEquals(ROWS, results.size()); Iterator iter = results.iterator(); Map row = null; while (i...
Below is the vulnerable code, please generate the patch based on the following information.
#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()...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void initAuthEnv() { String paramUserName = getInitParameter(InitServletData.PARAM_NAME_USERNAME); if (!StringUtils.isEmpty(paramUserName)) { this.initServletData.setUsername(paramUserName); } String paramPassword = getInit...
#vulnerable code private void initAuthEnv() { String paramUserName = getInitParameter(InitServletData.PARAM_NAME_USERNAME); if (!StringUtils.isEmpty(paramUserName)) { this.initServletData.setUsername(paramUserName); } String paramPassword = g...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void saveModel(String filePath) throws IOException { ObjectOutput oot = new ObjectOutputStream(new FileOutputStream(filePath)); oot.writeObject(this); }
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static int getIntValue(String value) { if (StringUtil.isBlank(value)) { return 0; } return castToInteger(value); }
#vulnerable code public static int getIntValue(String value) { if (StringUtil.isBlank(value)) { return 0; } return castToInt(value); } #location 5 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void saveModel(String filePath) throws IOException { ObjectOutput oot = new ObjectOutputStream(new FileOutputStream(filePath)); oot.writeObject(this); }
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE, "Bui...
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE, "Bui...
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException { LOGGER.log(Level.FINE...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static List<KubernetesCloud> getUsageRestrictedKubernetesClouds() { List<KubernetesCloud> clouds = Jenkins.get().clouds .getAll(KubernetesCloud.class) .stream() .filter(KubernetesCloud::isUsageRestricted) ...
#vulnerable code private static List<KubernetesCloud> getUsageRestrictedKubernetesClouds() { List<KubernetesCloud> clouds = new ArrayList<>(); for (Cloud cloud : Jenkins.getInstance().clouds) { if(cloud instanceof KubernetesCloud) { if (((Kub...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Nonnull public KubernetesCloud getKubernetesCloud() { return getKubernetesCloud(getCloudName()); }
#vulnerable code @Nonnull public KubernetesCloud getKubernetesCloud() { Cloud cloud = Jenkins.getInstance().getCloud(getCloudName()); if (cloud instanceof KubernetesCloud) { return (KubernetesCloud) cloud; } else { throw new IllegalSta...
Below is the vulnerable code, please generate the patch based on the following information.
#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 { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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)); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean userHasAdministerPermission() { return Jenkins.get().hasPermission(Jenkins.ADMINISTER); }
#vulnerable code private static boolean userHasAdministerPermission() { return Jenkins.getInstance().getACL().hasPermission(Jenkins.ADMINISTER); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException, ExecutionException { LOGGER....
#vulnerable code @SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" }) public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, IOException, CertificateEncodingException, ExecutionException { L...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Node call() throws Exception { return KubernetesSlave .builder() .podTemplate(cloud.getUnwrappedTemplate(t)) .cloud(cloud) .build(); }
#vulnerable code public Node call() throws Exception { RetentionStrategy retentionStrategy; if (t.getIdleMinutes() == 0) { retentionStrategy = new OnceRetentionStrategy(cloud.getRetentionTimeout()); } else { retentionStrategy = new CloudRe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void runWithDeadlineSeconds() throws Exception { WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "Deadline"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("runWithDeadlineSeconds.groovy") , true)); ...
#vulnerable 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.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#vulnerable code private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull Label label) throws Exception { if (containerCap == 0) { return true; } KubernetesClient client = connect(); String templateNamespace = template...
Below is the vulnerable code, please generate the patch based on the following information.
#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 { ...
#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 { ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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(...
#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("...
Below is the vulnerable code, please generate the patch based on the following information.
#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"); ...
#vulnerable code protected boolean load(URI itemToLoad, boolean fallbackLoad) { InputStream is = null; ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { URLConnection conn = itemToLoad.toURL().openConnection(); byte[] data ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { if (!isAvailable(conversionQuery)) { return null; } CurrencyUnit base = conversionQuery.getBaseCurrency(); CurrencyUnit term = conversionQuery.getC...
#vulnerable code @Override public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) { if (!isAvailable(conversionQuery)) { return null; } CurrencyUnit base = conversionQuery.getBaseCurrency(); CurrencyUnit term = conversionQuer...
Below is the vulnerable code, please generate the patch based on the following information.
#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) {} ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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) { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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)...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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; ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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("...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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) {} ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 +=...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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()); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.